bios: support passing tftp filename to the 'netboot' command

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
This commit is contained in:
Jan Luebbe 2021-04-25 20:39:41 +02:00
parent 22d763ee11
commit f4c9bf0666
3 changed files with 18 additions and 9 deletions

View File

@ -487,9 +487,13 @@ static void netboot_from_bin(const char * filename, unsigned int ip, unsigned sh
boot(0, 0, 0, MAIN_RAM_BASE); boot(0, 0, 0, MAIN_RAM_BASE);
} }
void netboot(void) void netboot(int nb_params, char **params)
{ {
unsigned int ip; unsigned int ip;
char * filename = NULL;
if (nb_params > 0 )
filename = params[0];
printf("Booting from network...\n"); printf("Booting from network...\n");
@ -499,6 +503,10 @@ void netboot(void)
ip = IPTOINT(remote_ip[0], remote_ip[1], remote_ip[2], remote_ip[3]); ip = IPTOINT(remote_ip[0], remote_ip[1], remote_ip[2], remote_ip[3]);
udp_start(macadr, IPTOINT(local_ip[0], local_ip[1], local_ip[2], local_ip[3])); udp_start(macadr, IPTOINT(local_ip[0], local_ip[1], local_ip[2], local_ip[3]));
if (filename) {
printf("Booting from %s (JSON)...\n", filename);
netboot_from_json(filename, ip, TFTP_SERVER_PORT);
} else {
/* Boot from boot.json */ /* Boot from boot.json */
printf("Booting from boot.json...\n"); printf("Booting from boot.json...\n");
netboot_from_json("boot.json", ip, TFTP_SERVER_PORT); netboot_from_json("boot.json", ip, TFTP_SERVER_PORT);
@ -506,6 +514,7 @@ void netboot(void)
/* Boot from boot.bin */ /* Boot from boot.bin */
printf("Booting from boot.bin...\n"); printf("Booting from boot.bin...\n");
netboot_from_bin("boot.bin", ip, TFTP_SERVER_PORT); netboot_from_bin("boot.bin", ip, TFTP_SERVER_PORT);
}
/* Boot failed if we are here... */ /* Boot failed if we are here... */
printf("Network boot failed.\n"); printf("Network boot failed.\n");

View File

@ -7,7 +7,7 @@ void set_mac_addr(const char * mac_address);
void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2, unsigned long r3, unsigned long addr); void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2, unsigned long r3, unsigned long addr);
int serialboot(void); int serialboot(void);
void netboot(void); void netboot(int nb_params, char **params);
void flashboot(void); void flashboot(void);
void romboot(void); void romboot(void);
void sdcardboot(void); void sdcardboot(void);

View File

@ -69,7 +69,7 @@ static void boot_sequence(void)
#ifdef CSR_ETHPHY_MODE_DETECTION_MODE_ADDR #ifdef CSR_ETHPHY_MODE_DETECTION_MODE_ADDR
eth_mode(); eth_mode();
#endif #endif
netboot(); netboot(0, NULL);
#endif #endif
printf("No boot medium found\n"); printf("No boot medium found\n");
} }