mirror of
https://gitlab.com/bztsrc/bootboot.git
synced 2023-02-13 20:54:32 -05:00
More address checks
This commit is contained in:
parent
d8f3aa0084
commit
98fbe4c589
16 changed files with 114 additions and 65 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@ aarch64-rpi/*.dat
|
||||||
aarch64-rpi/*.elf
|
aarch64-rpi/*.elf
|
||||||
|
|
||||||
dist/bootbootcb.elf
|
dist/bootbootcb.elf
|
||||||
|
images/*
|
||||||
|
|
||||||
mkbootimg/*.o
|
mkbootimg/*.o
|
||||||
mkbootimg/mkbootimg
|
mkbootimg/mkbootimg
|
||||||
|
|
|
@ -166,7 +166,7 @@ typedef struct {
|
||||||
} pe_sym;
|
} pe_sym;
|
||||||
|
|
||||||
/*** Raspberry Pi specific defines ***/
|
/*** Raspberry Pi specific defines ***/
|
||||||
static uint64_t mmio_base;
|
static uint64_t mmio_base, emmc_base;
|
||||||
|
|
||||||
#define PM_RTSC ((volatile uint32_t*)(mmio_base+0x0010001c))
|
#define PM_RTSC ((volatile uint32_t*)(mmio_base+0x0010001c))
|
||||||
#define PM_WATCHDOG ((volatile uint32_t*)(mmio_base+0x00100024))
|
#define PM_WATCHDOG ((volatile uint32_t*)(mmio_base+0x00100024))
|
||||||
|
@ -264,6 +264,9 @@ void uart_dump(void *ptr,uint32_t l) {
|
||||||
void uart_exc(uint64_t idx, uint64_t esr, uint64_t elr, uint64_t spsr, uint64_t far, uint64_t sctlr, uint64_t tcr)
|
void uart_exc(uint64_t idx, uint64_t esr, uint64_t elr, uint64_t spsr, uint64_t far, uint64_t sctlr, uint64_t tcr)
|
||||||
{
|
{
|
||||||
register uint64_t r;
|
register uint64_t r;
|
||||||
|
/* only report exceptions for the BSP */
|
||||||
|
asm volatile ("mrs x8, mpidr_el1; and x8, x8, #3; cbz x8, 2f; 1: wfe; b 1b; 2:;" : : : "x8");
|
||||||
|
|
||||||
asm volatile ("msr ttbr0_el1, %0;tlbi vmalle1" : : "r" ((uint64_t)&__paging+1));
|
asm volatile ("msr ttbr0_el1, %0;tlbi vmalle1" : : "r" ((uint64_t)&__paging+1));
|
||||||
asm volatile ("dsb ish; isb; mrs %0, sctlr_el1" : "=r" (r));
|
asm volatile ("dsb ish; isb; mrs %0, sctlr_el1" : "=r" (r));
|
||||||
// set mandatory reserved bits
|
// set mandatory reserved bits
|
||||||
|
@ -353,23 +356,23 @@ int hex2bin(unsigned char *s, int n){ int r=0;while(n-->0){r<<=4;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* sdcard */
|
/* sdcard */
|
||||||
#define EMMC_ARG2 ((volatile uint32_t*)(mmio_base+0x00300000))
|
#define EMMC_ARG2 ((volatile uint32_t*)(emmc_base+0x00000000))
|
||||||
#define EMMC_BLKSIZECNT ((volatile uint32_t*)(mmio_base+0x00300004))
|
#define EMMC_BLKSIZECNT ((volatile uint32_t*)(emmc_base+0x00000004))
|
||||||
#define EMMC_ARG1 ((volatile uint32_t*)(mmio_base+0x00300008))
|
#define EMMC_ARG1 ((volatile uint32_t*)(emmc_base+0x00000008))
|
||||||
#define EMMC_CMDTM ((volatile uint32_t*)(mmio_base+0x0030000C))
|
#define EMMC_CMDTM ((volatile uint32_t*)(emmc_base+0x0000000C))
|
||||||
#define EMMC_RESP0 ((volatile uint32_t*)(mmio_base+0x00300010))
|
#define EMMC_RESP0 ((volatile uint32_t*)(emmc_base+0x00000010))
|
||||||
#define EMMC_RESP1 ((volatile uint32_t*)(mmio_base+0x00300014))
|
#define EMMC_RESP1 ((volatile uint32_t*)(emmc_base+0x00000014))
|
||||||
#define EMMC_RESP2 ((volatile uint32_t*)(mmio_base+0x00300018))
|
#define EMMC_RESP2 ((volatile uint32_t*)(emmc_base+0x00000018))
|
||||||
#define EMMC_RESP3 ((volatile uint32_t*)(mmio_base+0x0030001C))
|
#define EMMC_RESP3 ((volatile uint32_t*)(emmc_base+0x0000001C))
|
||||||
#define EMMC_DATA ((volatile uint32_t*)(mmio_base+0x00300020))
|
#define EMMC_DATA ((volatile uint32_t*)(emmc_base+0x00000020))
|
||||||
#define EMMC_STATUS ((volatile uint32_t*)(mmio_base+0x00300024))
|
#define EMMC_STATUS ((volatile uint32_t*)(emmc_base+0x00000024))
|
||||||
#define EMMC_CONTROL0 ((volatile uint32_t*)(mmio_base+0x00300028))
|
#define EMMC_CONTROL0 ((volatile uint32_t*)(emmc_base+0x00000028))
|
||||||
#define EMMC_CONTROL1 ((volatile uint32_t*)(mmio_base+0x0030002C))
|
#define EMMC_CONTROL1 ((volatile uint32_t*)(emmc_base+0x0000002C))
|
||||||
#define EMMC_INTERRUPT ((volatile uint32_t*)(mmio_base+0x00300030))
|
#define EMMC_INTERRUPT ((volatile uint32_t*)(emmc_base+0x00000030))
|
||||||
#define EMMC_INT_MASK ((volatile uint32_t*)(mmio_base+0x00300034))
|
#define EMMC_INT_MASK ((volatile uint32_t*)(emmc_base+0x00000034))
|
||||||
#define EMMC_INT_EN ((volatile uint32_t*)(mmio_base+0x00300038))
|
#define EMMC_INT_EN ((volatile uint32_t*)(emmc_base+0x00000038))
|
||||||
#define EMMC_CONTROL2 ((volatile uint32_t*)(mmio_base+0x0030003C))
|
#define EMMC_CONTROL2 ((volatile uint32_t*)(emmc_base+0x0000003C))
|
||||||
#define EMMC_SLOTISR_VER ((volatile uint32_t*)(mmio_base+0x003000FC))
|
#define EMMC_SLOTISR_VER ((volatile uint32_t*)(emmc_base+0x000000FC))
|
||||||
|
|
||||||
// command flags
|
// command flags
|
||||||
#define CMD_NEED_APP 0x80000000
|
#define CMD_NEED_APP 0x80000000
|
||||||
|
@ -619,6 +622,7 @@ int sd_init()
|
||||||
#if SD_DEBUG
|
#if SD_DEBUG
|
||||||
uart_puts("EMMC: reset OK\n");
|
uart_puts("EMMC: reset OK\n");
|
||||||
#endif
|
#endif
|
||||||
|
*EMMC_CONTROL0 = 0xF << 8; // set voltage to 3.3
|
||||||
*EMMC_CONTROL1 |= C1_CLK_INTLEN | C1_TOUNIT_MAX;
|
*EMMC_CONTROL1 |= C1_CLK_INTLEN | C1_TOUNIT_MAX;
|
||||||
delaym(10);
|
delaym(10);
|
||||||
// Set clock to setup frequency.
|
// Set clock to setup frequency.
|
||||||
|
@ -792,7 +796,7 @@ unsigned char *kne;
|
||||||
char *cfgname="sys/config";
|
char *cfgname="sys/config";
|
||||||
|
|
||||||
uint64_t entrypoint=0, bss=0, *paging, reg, pa;
|
uint64_t entrypoint=0, bss=0, *paging, reg, pa;
|
||||||
uint8_t bsp_done=0;
|
static volatile uint8_t bsp_done=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SHA-256
|
* SHA-256
|
||||||
|
@ -1175,8 +1179,8 @@ int bootboot_main()
|
||||||
/* first things first, get the base address */
|
/* first things first, get the base address */
|
||||||
asm volatile ("mrs %0, midr_el1" : "=r" (reg));
|
asm volatile ("mrs %0, midr_el1" : "=r" (reg));
|
||||||
switch(reg&0xFFF0) {
|
switch(reg&0xFFF0) {
|
||||||
case 0xD030: mmio_base = 0x3F000000; break; /* Raspberry Pi 3 */
|
case 0xD030: mmio_base = 0x3F000000; emmc_base = 0x3F300000; break; /* Raspberry Pi 3 */
|
||||||
default: mmio_base = 0xFE000000; break; /* Raspberry Pi 4 */
|
default: mmio_base = 0xFE000000; emmc_base = 0xFE340000; break; /* Raspberry Pi 4 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize UART */
|
/* initialize UART */
|
||||||
|
@ -1829,7 +1833,7 @@ viderr:
|
||||||
uart_hex(entrypoint,8);
|
uart_hex(entrypoint,8);
|
||||||
uart_putc('\n');
|
uart_putc('\n');
|
||||||
if(initstack != 1024) {
|
if(initstack != 1024) {
|
||||||
uart_puts(" * Stack Size ");
|
uart_puts(" * Stack Size ");
|
||||||
uart_hex(initstack,8);
|
uart_hex(initstack,8);
|
||||||
uart_putc('\n');
|
uart_putc('\n');
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
BIN
dist/bootboot.img
vendored
BIN
dist/bootboot.img
vendored
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -6,8 +6,8 @@ extern unsigned char binary_boot_bin[512];
|
||||||
extern unsigned char binary_bootboot_bin[9284];
|
extern unsigned char binary_bootboot_bin[9284];
|
||||||
#define sizeof_bootboot_efi 103614
|
#define sizeof_bootboot_efi 103614
|
||||||
extern unsigned char binary_bootboot_efi[46349];
|
extern unsigned char binary_bootboot_efi[46349];
|
||||||
#define sizeof_bootboot_img 35496
|
#define sizeof_bootboot_img 35384
|
||||||
extern unsigned char binary_bootboot_img[20143];
|
extern unsigned char binary_bootboot_img[20069];
|
||||||
#define sizeof_bootboot_rv64 8192
|
#define sizeof_bootboot_rv64 8192
|
||||||
extern unsigned char binary_bootboot_rv64[31];
|
extern unsigned char binary_bootboot_rv64[31];
|
||||||
#define sizeof_LICENCE_broadcom 1594
|
#define sizeof_LICENCE_broadcom 1594
|
||||||
|
|
|
@ -55,6 +55,8 @@ char *dict[NUMLANGS][NUMTEXTS + 1] = {
|
||||||
"not in the higher half top -1G",
|
"not in the higher half top -1G",
|
||||||
"not %d bytes aligned",
|
"not %d bytes aligned",
|
||||||
"not page aligned",
|
"not page aligned",
|
||||||
|
"address collusion",
|
||||||
|
"invalid size",
|
||||||
"segment is bigger than 16M",
|
"segment is bigger than 16M",
|
||||||
"unable to write",
|
"unable to write",
|
||||||
"unable to locate kernel",
|
"unable to locate kernel",
|
||||||
|
@ -101,6 +103,8 @@ char *dict[NUMLANGS][NUMTEXTS + 1] = {
|
||||||
"nincs a felső memória -1G tartományában",
|
"nincs a felső memória -1G tartományában",
|
||||||
"nem %d bájtra igazított",
|
"nem %d bájtra igazított",
|
||||||
"nincs laphatárra igazítva",
|
"nincs laphatárra igazítva",
|
||||||
|
"címütközés",
|
||||||
|
"hibás méret",
|
||||||
"szegmens nagyobb, mint 16M",
|
"szegmens nagyobb, mint 16M",
|
||||||
"nem tudom írni",
|
"nem tudom írni",
|
||||||
"nem találom a kernelt benne",
|
"nem találom a kernelt benne",
|
||||||
|
@ -147,6 +151,8 @@ char *dict[NUMLANGS][NUMTEXTS + 1] = {
|
||||||
"nie znajduje się w \"higher half top -1G\"",
|
"nie znajduje się w \"higher half top -1G\"",
|
||||||
"brak wyrównania do %d bajtów",
|
"brak wyrównania do %d bajtów",
|
||||||
"brak wyrównania do stron",
|
"brak wyrównania do stron",
|
||||||
|
"zmowa adresowa",
|
||||||
|
"nieprawidłowy rozmiar",
|
||||||
"segment jest większy niż 16Mb",
|
"segment jest większy niż 16Mb",
|
||||||
"nie może zapisać",
|
"nie może zapisać",
|
||||||
"nie może znaleźć jądra",
|
"nie może znaleźć jądra",
|
||||||
|
|
|
@ -47,6 +47,8 @@ enum {
|
||||||
ERR_BADADDR,
|
ERR_BADADDR,
|
||||||
ERR_BADALIGN,
|
ERR_BADALIGN,
|
||||||
ERR_PAGEALIGN,
|
ERR_PAGEALIGN,
|
||||||
|
ERR_ADDRCOL,
|
||||||
|
ERR_BADSIZE,
|
||||||
ERR_BIGSEG,
|
ERR_BIGSEG,
|
||||||
ERR_WRITE,
|
ERR_WRITE,
|
||||||
ERR_LOCKRNL,
|
ERR_LOCKRNL,
|
||||||
|
|
|
@ -210,6 +210,7 @@ void parsekernel(int idx, unsigned char *data, int v)
|
||||||
pe_sym *ps;
|
pe_sym *ps;
|
||||||
uint32_t i, n = 0, bss = 0, strsz = 0, syment = 0, ma, fa;
|
uint32_t i, n = 0, bss = 0, strsz = 0, syment = 0, ma, fa;
|
||||||
uint64_t core_ptr = 0, core_size = 0, core_addr = 0, entrypoint = 0, mm_addr = 0, fb_addr = 0, bb_addr = 0, env_addr = 0;
|
uint64_t core_ptr = 0, core_size = 0, core_addr = 0, entrypoint = 0, mm_addr = 0, fb_addr = 0, bb_addr = 0, env_addr = 0;
|
||||||
|
uint64_t initstack = 0;
|
||||||
char *strtable, *name;
|
char *strtable, *name;
|
||||||
ehdr=(Elf64_Ehdr *)(data);
|
ehdr=(Elf64_Ehdr *)(data);
|
||||||
pehdr=(pe_hdr*)(data + ((mz_hdr*)(data))->peaddr);
|
pehdr=(pe_hdr*)(data + ((mz_hdr*)(data))->peaddr);
|
||||||
|
@ -229,14 +230,22 @@ void parsekernel(int idx, unsigned char *data, int v)
|
||||||
n++;
|
n++;
|
||||||
core_size = phdr->p_filesz + (ehdr->e_type==3?0x4000:0);
|
core_size = phdr->p_filesz + (ehdr->e_type==3?0x4000:0);
|
||||||
bss = phdr->p_memsz - core_size;
|
bss = phdr->p_memsz - core_size;
|
||||||
|
core_ptr = phdr->p_offset;
|
||||||
core_addr = phdr->p_vaddr;
|
core_addr = phdr->p_vaddr;
|
||||||
entrypoint = ehdr->e_entry;
|
entrypoint = ehdr->e_entry;
|
||||||
|
/* these are just warnings, hopefully not a problem, but better to be fixed in the kernel linker script */
|
||||||
|
if(v) {
|
||||||
|
if(phdr->p_vaddr != phdr->p_paddr)
|
||||||
|
fprintf(stderr,"mkbootimg: phdr #%d p_vaddr %016" LL "x != p_paddr %016" LL "x ???\r\n",n,phdr->p_vaddr,phdr->p_paddr);
|
||||||
|
if(phdr->p_align > 4096)
|
||||||
|
fprintf(stderr,"mkbootimg: phdr #%d %s (p_align %" LL "d)\r\n",n,lang[ERR_PAGEALIGN],phdr->p_align);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
phdr=(Elf64_Phdr *)((uint8_t *)phdr+ehdr->e_phentsize);
|
phdr=(Elf64_Phdr *)((uint8_t *)phdr+ehdr->e_phentsize);
|
||||||
}
|
}
|
||||||
if(n != 1) { fprintf(stderr,"mkbootimg: %s\r\n",lang[ERR_MORESEG]); exit(1); }
|
if(n != 1) { fprintf(stderr,"mkbootimg: %s\r\n",lang[ERR_MORESEG]); exit(1); }
|
||||||
if(v) printf("Entry point: %08" LL "x ", entrypoint);
|
if(v) printf("Entry point: %016" LL "x ", entrypoint);
|
||||||
if(entrypoint < core_addr || entrypoint > core_addr+core_size)
|
if(entrypoint < core_addr || entrypoint > core_addr+core_size)
|
||||||
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: %s\r\n",lang[ERR_BADENTRYP]); exit(1); }
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: %s\r\n",lang[ERR_BADENTRYP]); exit(1); }
|
||||||
if(ehdr->e_shoff > 0) {
|
if(ehdr->e_shoff > 0) {
|
||||||
|
@ -258,6 +267,7 @@ void parsekernel(int idx, unsigned char *data, int v)
|
||||||
if(!memcmp(strtable + s->st_name, "environment", 12)) env_addr = s->st_value;
|
if(!memcmp(strtable + s->st_name, "environment", 12)) env_addr = s->st_value;
|
||||||
if(!memcmp(strtable + s->st_name, "mmio", 4)) mm_addr = s->st_value;
|
if(!memcmp(strtable + s->st_name, "mmio", 4)) mm_addr = s->st_value;
|
||||||
if(!memcmp(strtable + s->st_name, "fb", 3)) fb_addr = s->st_value;
|
if(!memcmp(strtable + s->st_name, "fb", 3)) fb_addr = s->st_value;
|
||||||
|
if(!memcmp(strtable + s->st_name, "initstack", 10)) initstack = s->st_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +285,7 @@ void parsekernel(int idx, unsigned char *data, int v)
|
||||||
bss = pehdr->bss_size;
|
bss = pehdr->bss_size;
|
||||||
core_addr = (int64_t)pehdr->code_base;
|
core_addr = (int64_t)pehdr->code_base;
|
||||||
entrypoint = (int64_t)pehdr->entry_point;
|
entrypoint = (int64_t)pehdr->entry_point;
|
||||||
if(v) printf("Entry point: %08" LL "x ", entrypoint);
|
if(v) printf("Entry point: %016" LL "x ", entrypoint);
|
||||||
if(entrypoint < core_addr || entrypoint > core_addr+pehdr->text_size)
|
if(entrypoint < core_addr || entrypoint > core_addr+pehdr->text_size)
|
||||||
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: %s\r\n",lang[ERR_BADENTRYP]); exit(1); }
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: %s\r\n",lang[ERR_BADENTRYP]); exit(1); }
|
||||||
if(pehdr->sym_table > 0 && pehdr->numsym > 0) {
|
if(pehdr->sym_table > 0 && pehdr->numsym > 0) {
|
||||||
|
@ -287,6 +297,7 @@ void parsekernel(int idx, unsigned char *data, int v)
|
||||||
if(!memcmp(name, "environment", 12)) env_addr = (int64_t)ps->value;
|
if(!memcmp(name, "environment", 12)) env_addr = (int64_t)ps->value;
|
||||||
if(!memcmp(name, "mmio", 4)) mm_addr = (int64_t)ps->value;
|
if(!memcmp(name, "mmio", 4)) mm_addr = (int64_t)ps->value;
|
||||||
if(!memcmp(name, "fb", 3)) fb_addr = (int64_t)ps->value;
|
if(!memcmp(name, "fb", 3)) fb_addr = (int64_t)ps->value;
|
||||||
|
if(!memcmp(name, "initstack", 10)) initstack = (int64_t)ps->value;
|
||||||
i += ps->auxsyms;
|
i += ps->auxsyms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,33 +308,60 @@ void parsekernel(int idx, unsigned char *data, int v)
|
||||||
}
|
}
|
||||||
if(v) printf("OK\r\n");
|
if(v) printf("OK\r\n");
|
||||||
if(mm_addr) {
|
if(mm_addr) {
|
||||||
if(v) printf("mmio: %08" LL "x ", mm_addr);
|
if(v) printf("mmio: %016" LL "x ", mm_addr);
|
||||||
if(!ISHH(mm_addr)) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: mmio %s\r\n",lang[ERR_BADADDR]); exit(1); }
|
if(!ISHH(mm_addr)) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: mmio %s\r\n",lang[ERR_BADADDR]); exit(1); }
|
||||||
if(mm_addr & ma) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: mmio ");fprintf(stderr,lang[ERR_BADALIGN],ma+1);fprintf(stderr,"\r\n"); exit(1); }
|
if(mm_addr & ma) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: mmio ");fprintf(stderr,lang[ERR_BADALIGN],ma+1);fprintf(stderr,"\r\n"); exit(1); }
|
||||||
if(v) printf("OK\r\n");
|
if(v) printf("OK\r\n");
|
||||||
}
|
}
|
||||||
if(fb_addr) {
|
if(fb_addr) {
|
||||||
if(v) printf("fb: %08" LL "x ", fb_addr);
|
if(v) printf("fb: %016" LL "x ", fb_addr);
|
||||||
if(!ISHH(fb_addr)) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: fb %s\r\n",lang[ERR_BADALIGN]); exit(1); }
|
if(!ISHH(fb_addr)) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: fb %s\r\n",lang[ERR_BADALIGN]); exit(1); }
|
||||||
if(fb_addr & fa) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: fb ");fprintf(stderr,lang[ERR_BADALIGN],fa+1);fprintf(stderr,"\r\n"); exit(1); }
|
if(fb_addr & fa) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: fb ");fprintf(stderr,lang[ERR_BADALIGN],fa+1);fprintf(stderr,"\r\n"); exit(1); }
|
||||||
|
if((fb_addr >= mm_addr && fb_addr < mm_addr + 16*1024*1024) || (fb_addr + 16*1024*1024 > mm_addr && fb_addr + 16*1024*1024 <= mm_addr + 16*1024*1024))
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: mmio/fb %s\r\n",lang[ERR_ADDRCOL]); exit(1); }
|
||||||
if(v) printf("OK\r\n");
|
if(v) printf("OK\r\n");
|
||||||
}
|
}
|
||||||
if(bb_addr) {
|
if(bb_addr) {
|
||||||
if(v) printf("bootboot: %08" LL "x ", bb_addr);
|
if(v) printf("bootboot: %016" LL "x ", bb_addr);
|
||||||
if(!ISHH(bb_addr)) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: bootboot %s\r\n",lang[ERR_BADADDR]); exit(1); }
|
if(!ISHH(bb_addr)) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: bootboot %s\r\n",lang[ERR_BADADDR]); exit(1); }
|
||||||
if(bb_addr & 4095) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: bootboot %s\r\n",lang[ERR_PAGEALIGN]); exit(1); }
|
if(bb_addr & 4095) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: bootboot %s\r\n",lang[ERR_PAGEALIGN]); exit(1); }
|
||||||
|
if((bb_addr >= mm_addr && bb_addr < mm_addr + 16*1024*1024) || (bb_addr + 4096 > mm_addr && bb_addr + 4096 <= mm_addr + 16*1024*1024))
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: mmio/bootboot %s\r\n",lang[ERR_ADDRCOL]); exit(1); }
|
||||||
|
if((bb_addr >= fb_addr && bb_addr < fb_addr + 16*1024*1024) || (bb_addr + 4096 > fb_addr && bb_addr + 4096 <= fb_addr + 16*1024*1024))
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: fb/bootboot %s\r\n",lang[ERR_ADDRCOL]); exit(1); }
|
||||||
if(v) printf("OK\r\n");
|
if(v) printf("OK\r\n");
|
||||||
}
|
}
|
||||||
if(env_addr) {
|
if(env_addr) {
|
||||||
if(v) printf("environment: %08" LL "x ", env_addr);
|
if(v) printf("environment: %016" LL "x ", env_addr);
|
||||||
if(!ISHH(env_addr)) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: environment %s\r\n",lang[ERR_BADADDR]); exit(1); }
|
if(!ISHH(env_addr)) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: environment %s\r\n",lang[ERR_BADADDR]); exit(1); }
|
||||||
if(env_addr & 4095) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: environment %s\r\n",lang[ERR_PAGEALIGN]); exit(1); }
|
if(env_addr & 4095) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: environment %s\r\n",lang[ERR_PAGEALIGN]); exit(1); }
|
||||||
|
if((env_addr >= mm_addr && env_addr < mm_addr + 16*1024*1024) || (env_addr + 4096 > mm_addr && env_addr + 4096 <= mm_addr + 16*1024*1024))
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: mmio/environment %s\r\n",lang[ERR_ADDRCOL]); exit(1); }
|
||||||
|
if((env_addr >= fb_addr && env_addr < fb_addr + 16*1024*1024) || (env_addr + 4096 > fb_addr && env_addr + 4096 <= fb_addr + 16*1024*1024))
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: fb/enviroment %s\r\n",lang[ERR_ADDRCOL]); exit(1); }
|
||||||
|
if(env_addr == bb_addr)
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: bootboot/enviroment %s\r\n",lang[ERR_ADDRCOL]); exit(1); }
|
||||||
if(v) printf("OK\r\n");
|
if(v) printf("OK\r\n");
|
||||||
}
|
}
|
||||||
if(v) printf("Load segment: %08" LL "x size %" LL "dK offs %" LL "x ", core_addr, (core_size + bss + 1024)/1024, core_ptr);
|
if(initstack) {
|
||||||
|
if(v) printf("initstack: %016" LL "x ", initstack);
|
||||||
|
if(initstack != 1024 && initstack != 2048 && initstack != 4096 && initstack != 8192 && initstack != 16384)
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: initstack %s\r\n",lang[ERR_BADSIZE]); exit(1); }
|
||||||
|
if(v) printf("OK\r\n");
|
||||||
|
}
|
||||||
|
if(v) printf("Load segment: %016" LL "x size %" LL "dK offs %" LL "x ", core_addr, (core_size + bss + 1024)/1024, core_ptr);
|
||||||
if(!ISHH(core_addr)) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: segment %s\r\n",lang[ERR_BADADDR]); exit(1); }
|
if(!ISHH(core_addr)) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: segment %s\r\n",lang[ERR_BADADDR]); exit(1); }
|
||||||
if(core_addr & 4095) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: segment %s\r\n",lang[ERR_PAGEALIGN]); exit(1); }
|
if(core_addr & 4095) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: segment %s\r\n",lang[ERR_PAGEALIGN]); exit(1); }
|
||||||
if(core_size + bss > 16 * 1024 * 1024) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: %s\r\n",lang[ERR_BIGSEG]); exit(1); }
|
if(core_size + bss > 16 * 1024 * 1024) { if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: segment %s\r\n",lang[ERR_BIGSEG]); exit(1); }
|
||||||
|
if((mm_addr >= core_addr && mm_addr < core_addr + core_size) || (mm_addr + 16*1024*1024 > core_addr && mm_addr + 16*1024*1024 <= core_addr + core_size))
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: mmio/segment %s\r\n",lang[ERR_ADDRCOL]); exit(1); }
|
||||||
|
if((fb_addr >= core_addr && fb_addr < core_addr + core_size) || (fb_addr + 16*1024*1024 > core_addr && fb_addr + 16*1024*1024 <= core_addr + core_size))
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: fb/segment %s\r\n",lang[ERR_ADDRCOL]); exit(1); }
|
||||||
|
/* we check for the entrypoint as the lower boundary, because it's okay if the segment is at 0xfffffffe00000 */
|
||||||
|
if((bb_addr >= entrypoint && bb_addr < core_addr + core_size) || (bb_addr + 4096 > entrypoint && bb_addr + 4096 <= core_addr + core_size))
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: bootboot/segment %s\r\n",lang[ERR_ADDRCOL]); exit(1); }
|
||||||
|
if((env_addr >= entrypoint && env_addr < core_addr + core_size) || (env_addr + 4096 > entrypoint && env_addr + 4096 <= core_addr + core_size))
|
||||||
|
{ if(v) { printf("invalid\r\n"); } fprintf(stderr,"mkbootimg: environment/segment %s\r\n",lang[ERR_ADDRCOL]); exit(1); }
|
||||||
if(v) {
|
if(v) {
|
||||||
if(!mm_addr && !fb_addr && !bb_addr && !env_addr)
|
if(!mm_addr && !fb_addr && !bb_addr && !env_addr)
|
||||||
printf("OK\r\nComplies with BOOTBOOT Protocol Level 1, %s\r\n",lang[STATADDR]);
|
printf("OK\r\nComplies with BOOTBOOT Protocol Level 1, %s\r\n",lang[STATADDR]);
|
||||||
|
|
|
@ -30,8 +30,10 @@
|
||||||
|
|
||||||
ENTRY(_ada_kernel)
|
ENTRY(_ada_kernel)
|
||||||
|
|
||||||
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
||||||
fb = 0xfffffffffc000000;
|
fb = 0xfffffffffc000000;
|
||||||
|
bootboot = 0xffffffffffe00000;
|
||||||
|
environment = 0xffffffffffe01000;
|
||||||
/* initstack = 1024; */
|
/* initstack = 1024; */
|
||||||
PHDRS
|
PHDRS
|
||||||
{
|
{
|
||||||
|
@ -39,9 +41,7 @@ PHDRS
|
||||||
}
|
}
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0xffffffffffe00000;
|
. = 0xffffffffffe02000;
|
||||||
bootboot = .; . += 4096;
|
|
||||||
environment = .; . += 4096;
|
|
||||||
.text : {
|
.text : {
|
||||||
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
||||||
*(.rodata .rodata.*) /* data */
|
*(.rodata .rodata.*) /* data */
|
||||||
|
|
|
@ -28,8 +28,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
||||||
fb = 0xfffffffffc000000;
|
fb = 0xfffffffffc000000;
|
||||||
|
bootboot = 0xffffffffffe00000;
|
||||||
|
environment = 0xffffffffffe01000;
|
||||||
/* initstack = 1024; */
|
/* initstack = 1024; */
|
||||||
PHDRS
|
PHDRS
|
||||||
{
|
{
|
||||||
|
@ -37,9 +39,7 @@ PHDRS
|
||||||
}
|
}
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0xffffffffffe00000;
|
. = 0xffffffffffe02000;
|
||||||
bootboot = .; . += 4096;
|
|
||||||
environment = .; . += 4096;
|
|
||||||
.text : {
|
.text : {
|
||||||
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
||||||
*(.rodata .rodata.*) /* data */
|
*(.rodata .rodata.*) /* data */
|
||||||
|
|
|
@ -30,8 +30,10 @@
|
||||||
|
|
||||||
ENTRY(main)
|
ENTRY(main)
|
||||||
|
|
||||||
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
||||||
fb = 0xfffffffffc000000;
|
fb = 0xfffffffffc000000;
|
||||||
|
bootboot = 0xffffffffffe00000;
|
||||||
|
environment = 0xffffffffffe01000;
|
||||||
/* initstack = 1024; */
|
/* initstack = 1024; */
|
||||||
PHDRS
|
PHDRS
|
||||||
{
|
{
|
||||||
|
@ -39,9 +41,7 @@ PHDRS
|
||||||
}
|
}
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0xffffffffffe00000;
|
. = 0xffffffffffe02000;
|
||||||
bootboot = .; . += 4096;
|
|
||||||
environment = .; . += 4096;
|
|
||||||
.text : {
|
.text : {
|
||||||
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
||||||
*(.rodata .rodata.*) /* data */
|
*(.rodata .rodata.*) /* data */
|
||||||
|
|
|
@ -32,8 +32,10 @@
|
||||||
ENTRY(go.kernel.go.kernel..init0)
|
ENTRY(go.kernel.go.kernel..init0)
|
||||||
|
|
||||||
/* you can't access these labels from Go, so make sure the constants match */
|
/* you can't access these labels from Go, so make sure the constants match */
|
||||||
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
||||||
fb = 0xfffffffffc000000;
|
fb = 0xfffffffffc000000;
|
||||||
|
bootboot = 0xffffffffffe00000;
|
||||||
|
environment = 0xffffffffffe01000;
|
||||||
/* initstack = 1024; */
|
/* initstack = 1024; */
|
||||||
PHDRS
|
PHDRS
|
||||||
{
|
{
|
||||||
|
@ -41,9 +43,7 @@ PHDRS
|
||||||
}
|
}
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0xffffffffffe00000;
|
. = 0xffffffffffe02000;
|
||||||
bootboot = .; . += 4096;
|
|
||||||
environment = .; . += 4096;
|
|
||||||
.text : {
|
.text : {
|
||||||
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
||||||
*(.rodata .rodata.*) /* data */
|
*(.rodata .rodata.*) /* data */
|
||||||
|
|
|
@ -28,8 +28,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
||||||
fb = 0xfffffffffc000000;
|
fb = 0xfffffffffc000000;
|
||||||
|
bootboot = 0xffffffffffe00000;
|
||||||
|
environment = 0xffffffffffe01000;
|
||||||
/* initstack = 1024; */
|
/* initstack = 1024; */
|
||||||
PHDRS
|
PHDRS
|
||||||
{
|
{
|
||||||
|
@ -37,9 +39,7 @@ PHDRS
|
||||||
}
|
}
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0xffffffffffe00000;
|
. = 0xffffffffffe02000;
|
||||||
bootboot = .; . += 4096;
|
|
||||||
environment = .; . += 4096;
|
|
||||||
.text : {
|
.text : {
|
||||||
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
KEEP(*(.text.boot)) *(.text .text.*) /* code */
|
||||||
*(.rodata .rodata.*) /* data */
|
*(.rodata .rodata.*) /* data */
|
||||||
|
|
|
@ -28,7 +28,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
KERNEL_OFFSET = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
|
||||||
|
fb = 0xfffffffffc000000;
|
||||||
|
bootboot = 0xffffffffffe00000;
|
||||||
|
environment = 0xffffffffffe01000;
|
||||||
initstack = 4096;
|
initstack = 4096;
|
||||||
|
|
||||||
PHDRS
|
PHDRS
|
||||||
|
@ -37,12 +40,7 @@ PHDRS
|
||||||
}
|
}
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = KERNEL_OFFSET;
|
. = 0xffffffffffe02000;
|
||||||
mmio = .; . += 0x4000000;
|
|
||||||
fb = .; . += 0x3E00000;
|
|
||||||
bootboot = .; . += 4096;
|
|
||||||
environment = .; . += 4096;
|
|
||||||
|
|
||||||
.text . + SIZEOF_HEADERS : AT(ADDR(.text) - KERNEL_OFFSET + SIZEOF_HEADERS) {
|
.text . + SIZEOF_HEADERS : AT(ADDR(.text) - KERNEL_OFFSET + SIZEOF_HEADERS) {
|
||||||
__text_start = .;
|
__text_start = .;
|
||||||
KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) /* code */
|
KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) /* code */
|
||||||
|
|
Loading…
Reference in a new issue