1.1 --- a/stage1/board.c Tue May 10 13:58:05 2016 +0200
1.2 +++ b/stage1/board.c Sat May 14 21:36:55 2016 +0200
1.3 @@ -5,7 +5,7 @@
1.4 * Copyright (C) 2005-2006 Ingenic Semiconductor, <jlwei@ingenic.cn>
1.5 * Copyright (C) 2006 Stefan Roese, DENX Software Engineering, sr@denx.de.
1.6 * Copyright (C) Xiangfu Liu <xiangfu.z@gmail.com>
1.7 - * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software: you can redistribute it and/or modify
1.11 * it under the terms of the GNU General Public License as published by
1.12 @@ -28,6 +28,7 @@
1.13 #include "jz4740.h"
1.14 #endif
1.15
1.16 +#include "memory.h"
1.17 #include "sdram.h"
1.18 #include "usb_boot_defines.h"
1.19
1.20 @@ -47,7 +48,7 @@
1.21 {
1.22 /* Get the fw args from memory. See head1.S for the memory layout. */
1.23
1.24 - fw_args = (struct fw_args *)0x80002008;
1.25 + fw_args = (struct fw_args *) STAGE1_ARGS;
1.26 FW_CPU_ID = fw_args->cpu_id ;
1.27
1.28 /* Where the arguments have not been initialised, use the defaults. */
2.1 --- a/stage1/board.h Tue May 10 13:58:05 2016 +0200
2.2 +++ b/stage1/board.h Sat May 14 21:36:55 2016 +0200
2.3 @@ -3,9 +3,9 @@
2.4
2.5 /* Initialisation functions. */
2.6
2.7 -void load_args(void);
2.8 -void gpio_init(void);
2.9 -void pll_init(void);
2.10 -void sdram_init(void);
2.11 +void load_args();
2.12 +void gpio_init();
2.13 +void pll_init();
2.14 +void sdram_init();
2.15
2.16 #endif /* __BOARD_H__ */
3.1 --- a/stage1/head1.S Tue May 10 13:58:05 2016 +0200
3.2 +++ b/stage1/head1.S Sat May 14 21:36:55 2016 +0200
3.3 @@ -20,13 +20,14 @@
3.4 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3.5 */
3.6
3.7 +#include "memory.h"
3.8 +#include "mips.h"
3.9 +
3.10 .text
3.11 .extern c_main
3.12 .globl _start
3.13 .set noreorder
3.14
3.15 -#include "mips.h"
3.16 -
3.17 _start:
3.18 b real_start
3.19 nop
3.20 @@ -56,7 +57,7 @@
3.21
3.22 /* Setup stack, jump to C code. */
3.23
3.24 - la $sp, 0x80004000
3.25 + la $sp, STAGE1_STACK
3.26 j c_main
3.27 nop
3.28
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/stage1/memory.h Sat May 14 21:36:55 2016 +0200
4.3 @@ -0,0 +1,7 @@
4.4 +#ifndef __MEMORY_H__
4.5 +#define __MEMORY_H__
4.6 +
4.7 +#define STAGE1_ARGS 0x80002008
4.8 +#define STAGE1_STACK 0x80004000
4.9 +
4.10 +#endif /* __MEMORY_H__ */
5.1 --- a/stage1/stage1.ld Tue May 10 13:58:05 2016 +0200
5.2 +++ b/stage1/stage1.ld Sat May 14 21:36:55 2016 +0200
5.3 @@ -1,31 +1,26 @@
5.4 OUTPUT_ARCH(mips)
5.5 ENTRY(_start)
5.6 -MEMORY
5.7 -{
5.8 - ram : ORIGIN = 0x80002000 , LENGTH = 0x100000
5.9 -}
5.10
5.11 SECTIONS
5.12 {
5.13 - . = ALIGN(4);
5.14 - .text : { *(.text*) } > ram
5.15 + . = 0x80002000;
5.16 + .text : { *(.text*) }
5.17
5.18 . = ALIGN(4);
5.19 - .rodata : { *(.rodata*) } > ram
5.20 + .rodata : { *(.rodata*) }
5.21
5.22 . = ALIGN(4);
5.23 - .sdata : { *(.sdata*) } > ram
5.24 + .sdata : { *(.sdata*) }
5.25
5.26 . = ALIGN(4);
5.27 - .data : { *(.data*) *(.scommon*) *(.reginfo*) } > ram
5.28 + .data : { *(.data*) *(.scommon*) *(.reginfo*) }
5.29
5.30 _gp = ABSOLUTE(.); /* Base of small data */
5.31
5.32 - .got : { *(.got*) } > ram
5.33 + .got : { *(.got*) }
5.34
5.35 . = ALIGN(4);
5.36 - .sbss : { *(.sbss*) } > ram
5.37 - .bss : { *(.bss*) } > ram
5.38 + .sbss : { *(.sbss*) }
5.39 + .bss : { *(.bss*) }
5.40 . = ALIGN (4);
5.41 }
5.42 -
6.1 --- a/stage2/cpu.c Tue May 10 13:58:05 2016 +0200
6.2 +++ b/stage2/cpu.c Sat May 14 21:36:55 2016 +0200
6.3 @@ -24,8 +24,9 @@
6.4
6.5 #include "cpu.h"
6.6 #include "cpu_op.h"
6.7 +#include "memory.h"
6.8 +#include "paging.h"
6.9 #include "sdram.h"
6.10 -#include "paging.h"
6.11
6.12 void flush_icache_all(void)
6.13 {
6.14 @@ -120,7 +121,7 @@
6.15 0x1000 * 8 == 0x8000 bytes
6.16 */
6.17
6.18 - u32 base = page_table + page_table_task_size * asid;
6.19 + u32 base = page_table + STAGE2_PAGE_TABLE_TASK * asid;
6.20
6.21 /* Each page table entry corresponds to a pair of 4KB pages and holds two values. */
6.22
7.1 --- a/stage2/entry.S Tue May 10 13:58:05 2016 +0200
7.2 +++ b/stage2/entry.S Sat May 14 21:36:55 2016 +0200
7.3 @@ -17,8 +17,8 @@
7.4 * along with this program. If not, see <http://www.gnu.org/licenses/>.
7.5 */
7.6
7.7 +#include "memory.h"
7.8 #include "mips.h"
7.9 -#include "paging.h"
7.10
7.11 .text
7.12 .extern interrupt_handler
7.13 @@ -45,9 +45,9 @@
7.14 /* Otherwise, load the page table entries. */
7.15
7.16 andi $k1, $k0, 0xff /* ASID */
7.17 - li $k0, page_table_task_size
7.18 - mul $k0, $k0, $k1 /* [ASID] (ASID * page_table_task_size) */
7.19 - li $k1, page_table_start /* page_table */
7.20 + li $k0, STAGE2_PAGE_TABLE_TASK
7.21 + mul $k0, $k0, $k1 /* [ASID] (ASID * STAGE2_PAGE_TABLE_TASK) */
7.22 + li $k1, STAGE2_PAGE_TABLE /* page_table */
7.23 addu $k1, $k0, $k1 /* page_table[ASID] */
7.24
7.25 mfc0 $k0, CP0_CONTEXT
7.26 @@ -138,7 +138,7 @@
7.27
7.28 /* Switch to the kernel exception stack. */
7.29
7.30 - li $sp, 0x80008000
7.31 + li $sp, STAGE2_EXCEPTION_STACK
7.32
7.33 /* Invoke the rest of the interrupt handling process. */
7.34
8.1 --- a/stage2/head2.S Tue May 10 13:58:05 2016 +0200
8.2 +++ b/stage2/head2.S Sat May 14 21:36:55 2016 +0200
8.3 @@ -20,6 +20,7 @@
8.4 * along with this program. If not, see <http://www.gnu.org/licenses/>.
8.5 */
8.6
8.7 +#include "memory.h"
8.8 #include "mips.h"
8.9 #include "sdram.h"
8.10
8.11 @@ -53,7 +54,7 @@
8.12 real_start:
8.13 /* Initialise the default kernel stack. */
8.14
8.15 - la $sp, 0x80004000
8.16 + la $sp, STAGE2_INIT_STACK
8.17
8.18 /* Initialise the globals pointer. */
8.19
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/stage2/memory.h Sat May 14 21:36:55 2016 +0200
9.3 @@ -0,0 +1,14 @@
9.4 +#ifndef __MEMORY_H__
9.5 +#define __MEMORY_H__
9.6 +
9.7 +#define STAGE2_INIT_STACK 0x80004000
9.8 +#define STAGE2_EXCEPTION_STACK 0x80008000
9.9 +
9.10 +#define STAGE2_PAGE_TABLE 0x81400000
9.11 +#define STAGE2_PAGE_TABLE_TASK 0x00008000
9.12 +
9.13 +#define STAGE2_TASK_STACK 0x01c00000
9.14 +#define STAGE2_TASK_STACK_SIZE 0x00002000
9.15 +#define STAGE2_PAGESIZE (4 * 1024)
9.16 +
9.17 +#endif /* __MEMORY_H__ */
10.1 --- a/stage2/paging.h Tue May 10 13:58:05 2016 +0200
10.2 +++ b/stage2/paging.h Sat May 14 21:36:55 2016 +0200
10.3 @@ -1,9 +1,6 @@
10.4 #ifndef __PAGING_H__
10.5 #define __PAGING_H__
10.6
10.7 -#define page_table_start 0x81400000
10.8 -#define page_table_task_size 0x00008000
10.9 -
10.10 #define USER_ADDRESS_MASK 0x7fffffff
10.11
10.12 #ifndef __ASSEMBLER__
11.1 --- a/stage2/tasks.c Tue May 10 13:58:05 2016 +0200
11.2 +++ b/stage2/tasks.c Sat May 14 21:36:55 2016 +0200
11.3 @@ -19,6 +19,7 @@
11.4
11.5 #include "cpu.h"
11.6 #include "cpu_op.h"
11.7 +#include "memory.h"
11.8 #include "mips.h"
11.9 #include "paging.h"
11.10 #include "tasks.h"
11.11 @@ -32,12 +33,6 @@
11.12 u32 *current_stack_pointer;
11.13 u32 *current_registers;
11.14
11.15 -/* Address locations and paging configuration. */
11.16 -
11.17 -const u32 stack_start = 0x01c00000;
11.18 -const u32 stack_size = 0x00002000;
11.19 -const u32 pagesize = 4 * 1024;
11.20 -
11.21 /* A reference to locations for the symbol tables. */
11.22
11.23 extern u32 _got_start, _got_copy_start, _got_copy_end;
11.24 @@ -70,10 +65,10 @@
11.25 is never started.
11.26 */
11.27
11.28 - virtual = stack_start;
11.29 - physical = stack_start - stack_size * task;
11.30 + virtual = STAGE2_TASK_STACK;
11.31 + physical = STAGE2_TASK_STACK - STAGE2_TASK_STACK_SIZE * task;
11.32
11.33 - init_page_table(page_table_start, virtual - pagesize * 2, physical - pagesize * 2, pagesize, TLB_WRITE, task);
11.34 + init_page_table(STAGE2_PAGE_TABLE, virtual - STAGE2_PAGESIZE * 2, physical - STAGE2_PAGESIZE * 2, STAGE2_PAGESIZE, TLB_WRITE, task);
11.35
11.36 /*
11.37 Subtract from the stack pointer to prevent the called function from
11.38 @@ -91,18 +86,18 @@
11.39
11.40 /* Map the global object table for the task. */
11.41
11.42 - init_page_table(page_table_start, user_address((u32) &_got_start), user_address((u32) &_got_copy_start), pagesize, TLB_READ, task);
11.43 + init_page_table(STAGE2_PAGE_TABLE, user_address((u32) &_got_start), user_address((u32) &_got_copy_start), STAGE2_PAGESIZE, TLB_READ, task);
11.44
11.45 /* Map all shared pages for the task. */
11.46
11.47 - for (address = (u32) &_payload_start; address < (u32) &_got_start; address += pagesize * 2)
11.48 + for (address = (u32) &_payload_start; address < (u32) &_got_start; address += STAGE2_PAGESIZE * 2)
11.49 {
11.50 - init_page_table(page_table_start, user_address(address), user_address(address), pagesize, TLB_READ, task);
11.51 + init_page_table(STAGE2_PAGE_TABLE, user_address(address), user_address(address), STAGE2_PAGESIZE, TLB_READ, task);
11.52 }
11.53
11.54 - for (address = (u32) &_got_copy_end + pagesize * 2; address < (u32) &_memory_end; address += pagesize * 2)
11.55 + for (address = (u32) &_got_copy_end + STAGE2_PAGESIZE * 2; address < (u32) &_memory_end; address += STAGE2_PAGESIZE * 2)
11.56 {
11.57 - init_page_table(page_table_start, user_address(address), user_address(address), pagesize, TLB_WRITE, task);
11.58 + init_page_table(STAGE2_PAGE_TABLE, user_address(address), user_address(address), STAGE2_PAGESIZE, TLB_WRITE, task);
11.59 }
11.60 }
11.61