bios: remove rescue

This commit is contained in:
Sebastien Bourdeauducq 2013-05-28 16:15:30 +02:00
parent 701aac2513
commit b6448ba5fc
4 changed files with 13 additions and 29 deletions

View File

@ -15,7 +15,6 @@ all: bios.bin
$(M2DIR)/tools/mkmmimg $@ write $(M2DIR)/tools/mkmmimg $@ write
bios.elf: linker.ld $(OBJECTS) libs bios.elf: linker.ld $(OBJECTS) libs
bios-rescue.elf: linker-rescue.ld $(OBJECTS) libs
%.elf: %.elf:
$(LD) $(LDFLAGS) -T $< -N -o $@ $(OBJECTS) \ $(LD) $(LDFLAGS) -T $< -N -o $@ $(OBJECTS) \
@ -43,6 +42,6 @@ flash: bios.bin
m1nor bios.bin m1nor bios.bin
clean: clean:
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) bios.elf bios.bin bios-rescue.elf bios-rescue.bin .*~ *~ $(RM) $(OBJECTS) $(OBJECTS:.o=.d) bios.elf bios.bin .*~ *~
.PHONY: all main.o clean libs flash .PHONY: all main.o clean libs flash

View File

@ -7,4 +7,4 @@ boot_helper:
nop nop
nop nop
nop nop
call r5 call r4

View File

@ -14,16 +14,15 @@
#include <net/tftp.h> #include <net/tftp.h>
#include "boot.h" #include "boot.h"
extern int rescue; extern void boot_helper(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int addr);
extern void boot_helper(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int r4, unsigned int addr);
static void __attribute__((noreturn)) boot(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int r4, unsigned int addr) static void __attribute__((noreturn)) boot(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int addr)
{ {
printf("Executing booted program.\n"); printf("Executing booted program.\n");
uart_sync(); uart_sync();
irq_setmask(0); irq_setmask(0);
irq_setie(0); irq_setie(0);
boot_helper(r1, r2, r3, r4, addr); boot_helper(r1, r2, r3, addr);
while(1); while(1);
} }
@ -137,7 +136,7 @@ void serialboot(void)
|((unsigned int)frame.payload[2] << 8) |((unsigned int)frame.payload[2] << 8)
|((unsigned int)frame.payload[3] << 0); |((unsigned int)frame.payload[3] << 0);
uart_write(SFL_ACK_SUCCESS); uart_write(SFL_ACK_SUCCESS);
boot(cmdline_adr, initrdstart_adr, initrdend_adr, rescue, addr); boot(cmdline_adr, initrdstart_adr, initrdend_adr, addr);
break; break;
} }
case SFL_CMD_CMDLINE: case SFL_CMD_CMDLINE:
@ -234,7 +233,7 @@ void netboot(void)
} else } else
initrdend_adr = initrdstart_adr + size; initrdend_adr = initrdstart_adr + size;
boot(cmdline_adr, initrdstart_adr, initrdend_adr, rescue, SDRAM_BASE); boot(cmdline_adr, initrdstart_adr, initrdend_adr, SDRAM_BASE);
} }
void flashboot(void) void flashboot(void)
@ -245,10 +244,7 @@ void flashboot(void)
unsigned int got_crc; unsigned int got_crc;
printf("Booting from flash...\n"); printf("Booting from flash...\n");
if(rescue) flashbase = (unsigned int *)FLASH_OFFSET_REGULAR_APP;
flashbase = (unsigned int *)FLASH_OFFSET_RESCUE_APP;
else
flashbase = (unsigned int *)FLASH_OFFSET_REGULAR_APP;
length = *flashbase++; length = *flashbase++;
crc = *flashbase++; crc = *flashbase++;
if((length < 32) || (length > 4*1024*1024)) { if((length < 32) || (length > 4*1024*1024)) {
@ -263,5 +259,5 @@ void flashboot(void)
printf("CRC failed (expected %08x, got %08x)\n", crc, got_crc); printf("CRC failed (expected %08x, got %08x)\n", crc, got_crc);
return; return;
} }
boot(0, 0, 0, rescue, SDRAM_BASE); boot(0, 0, 0, SDRAM_BASE);
} }

View File

@ -375,7 +375,6 @@ static void do_command(char *c)
printf("Command not found\n"); printf("Command not found\n");
} }
int rescue;
extern unsigned int _edata; extern unsigned int _edata;
static void crcbios(void) static void crcbios(void)
@ -391,7 +390,7 @@ static void crcbios(void)
* We also use the address of _edata to know the length * We also use the address of _edata to know the length
* of our code. * of our code.
*/ */
offset_bios = rescue ? FLASH_OFFSET_RESCUE_BIOS : FLASH_OFFSET_REGULAR_BIOS; offset_bios = FLASH_OFFSET_REGULAR_BIOS;
expected_crc = _edata; expected_crc = _edata;
length = (unsigned int)&_edata - offset_bios; length = (unsigned int)&_edata - offset_bios;
actual_crc = crc32((unsigned char *)offset_bios, length); actual_crc = crc32((unsigned char *)offset_bios, length);
@ -488,15 +487,9 @@ static int test_user_abort(void)
static void boot_sequence(void) static void boot_sequence(void)
{ {
if(test_user_abort()) { if(test_user_abort()) {
if(rescue) { flashboot();
serialboot(); serialboot();
netboot(); netboot();
flashboot();
} else {
flashboot();
serialboot();
netboot();
}
printf("No boot medium found\n"); printf("No boot medium found\n");
} }
} }
@ -506,15 +499,11 @@ int main(int i, char **c)
char buffer[64]; char buffer[64];
int ddr_ok; int ddr_ok;
rescue = !((unsigned int)main > FLASH_OFFSET_REGULAR_BIOS);
irq_setmask(0); irq_setmask(0);
irq_setie(1); irq_setie(1);
uart_init(); uart_init();
puts(banner); puts(banner);
crcbios(); crcbios();
if(rescue)
printf("Rescue mode\n");
id_print(); id_print();
ethreset(); ethreset();
print_mac(); print_mac();