# HG changeset patch # User Paul Boddie # Date 1461614209 -7200 # Node ID a1f3027033f2725e10f61d5395e1cc9bd10b445f # Parent bdbe5b78ca43783f5c1b36dcdaa0eb63bec127da Attempt to provide memory mapping to the lower memory object table. diff -r bdbe5b78ca43 -r a1f3027033f2 stage2/entry.S --- a/stage2/entry.S Mon Apr 25 17:19:53 2016 +0200 +++ b/stage2/entry.S Mon Apr 25 21:56:49 2016 +0200 @@ -21,6 +21,7 @@ .extern interrupt_handler .extern current_registers .extern current_stack_pointer +.extern _payload_end .globl _tlb_entry .globl _exc_entry .globl _irq_entry @@ -42,13 +43,15 @@ beqz $k1, _tlb_entry_direct nop - /* For addresses over 0x00080000... */ + /* For addresses beyond the relocated global object table... */ - li $k1, 0xfff80000 - and $k1, $k0, $k1 + lui $k1, %hi(_payload_end - 0x80000000) + ori $k1, $k1, %lo(_payload_end - 0x80000000) + sltu $k1, $k1, $k0 bnez $k1, _tlb_entry_direct nop +_tlb_entry_table: /* Otherwise, load the page table entries. */ andi $k1, $k0, 0xff /* ASID */ diff -r bdbe5b78ca43 -r a1f3027033f2 stage2/stage2.ld --- a/stage2/stage2.ld Mon Apr 25 17:19:53 2016 +0200 +++ b/stage2/stage2.ld Mon Apr 25 21:56:49 2016 +0200 @@ -6,6 +6,10 @@ /* Program memory section. */ . = 0x81c00000; + + _payload_start = ABSOLUTE(.); + _shared_start = ABSOLUTE(.); + .text2 : { *(.text*) } . = ALIGN(4); @@ -17,21 +21,33 @@ . = ALIGN(4); .data : { *(.data*) *(.scommon*) *(.reginfo*) } - _gp = ALIGN(16); - - _got_start = ABSOLUTE(.); - .got : { *(.got*) } - _got_end = ABSOLUTE(.); - - _gp_copy = ALIGN(16); - - _got_copy_start = ABSOLUTE(.); - . += _got_end - _got_start; - _got_copy_end = ABSOLUTE(.); + _shared_end = ABSOLUTE(.); . = ALIGN(4); + + _bss_start = ABSOLUTE(.); + .sbss : { *(.sbss*) } .bss : { *(.bss*) } . = ALIGN (4); + + _bss_end = ABSOLUTE(.); + + /* The global object table. */ + + .got : ALIGN(4096) { + _gp = ALIGN(16); + _got_start = ABSOLUTE(.); + *(.got*) + } + _got_end = ABSOLUTE(.); + + /* The relocated copy of the global object table. */ + + .got_copy : ALIGN(4096) { + _got_copy_start = ABSOLUTE(.); + . += _got_end - _got_start - 1; + } + _got_copy_end = ABSOLUTE(.); + _payload_end = ABSOLUTE(.); } - diff -r bdbe5b78ca43 -r a1f3027033f2 stage2/tasks.c --- a/stage2/tasks.c Mon Apr 25 17:19:53 2016 +0200 +++ b/stage2/tasks.c Mon Apr 25 21:56:49 2016 +0200 @@ -36,9 +36,16 @@ const u32 stack_size = 0x00002000; const u32 pagesize = 4 * 1024; -/* A reference to the unrelocated symbol table location. */ +/* +References to the unrelocated symbol table and to the relocated version, both in +their original locations. +*/ -extern u32 _got_copy_start; +extern u32 _got_start, _got_copy_start; + +/* Regions to be mapped directly. */ + +extern u32 _shared_start, _shared_end; /* Task management functions. */ @@ -56,7 +63,7 @@ void start_task(unsigned short task, void (*function)(), u32 args[], u8 nargs) { - u32 virtual, physical; + u32 virtual, physical, address; /* Each task employs a stack at a multiple of the given start address in @@ -68,6 +75,18 @@ init_page_table(page_table_start, virtual - pagesize * 2, physical - pagesize * 2, pagesize, 0x1e, task); + /* Map shared pages. */ + + for (address = (u32) &_shared_start; address < (u32) &_shared_end; address += pagesize * 2) + { + address = address & 0x7fffffff; + init_page_table(page_table_start, address, address, pagesize, 0x1e, task); + } + + /* Map the task's global object table to the relocated version. */ + + init_page_table(page_table_start, (u32) &_got_start & 0x7fffffff, (u32) &_got_copy_start & 0x7fffffff, pagesize, 0x1e, task); + /* Subtract from the stack pointer to prevent the called function from reaching into unmapped memory. @@ -80,7 +99,7 @@ return address. */ - init_registers(registers[task], (u32) &_got_copy_start, function, args, nargs); + init_registers(registers[task], (u32) &_got_start, function, args, nargs); } void start_task_now()