1.1 --- a/stage2/Makefile Wed May 04 22:57:56 2016 +0200
1.2 +++ b/stage2/Makefile Wed May 04 23:04:58 2016 +0200
1.3 @@ -61,9 +61,10 @@
1.4 DEFS = $(BOARD_DEFS)
1.5
1.6 # Ordering of objects is important and cannot be left to replacement rules.
1.7 +# In particular the head2 file must appear first.
1.8
1.9 -SRC = head2.S entry.S handlers.S stage2.c cpu.c cpu_op.S lcd.c jzlcd.c board.c irq.c tasks.c example.c $(BOARD_SRC)
1.10 -OBJ = head2.o entry.o handlers.o stage2.o cpu.o cpu_op.o lcd.o jzlcd.o board.o irq.o tasks.o example.o $(BOARD_OBJ)
1.11 +SRC = head2.S entry.S handlers.S stage2.c cpu.c cpu_op.S lcd.c jzlcd.c board.c irq.c paging.c tasks.c example.c $(BOARD_SRC)
1.12 +OBJ = head2.o entry.o handlers.o stage2.o cpu.o cpu_op.o lcd.o jzlcd.o board.o irq.o paging.o tasks.o example.o $(BOARD_OBJ)
1.13
1.14 .PHONY: all clean distclean
1.15
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/stage2/paging.c Wed May 04 23:04:58 2016 +0200
2.3 @@ -0,0 +1,25 @@
2.4 +/*
2.5 + * Paging utilities.
2.6 + *
2.7 + * Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
2.8 + *
2.9 + * This program is free software: you can redistribute it and/or modify
2.10 + * it under the terms of the GNU General Public License as published by
2.11 + * the Free Software Foundation, either version 3 of the License, or
2.12 + * (at your option) any later version.
2.13 + *
2.14 + * This program is distributed in the hope that it will be useful,
2.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.17 + * GNU General Public License for more details.
2.18 + *
2.19 + * You should have received a copy of the GNU General Public License
2.20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
2.21 + */
2.22 +
2.23 +#include "paging.h"
2.24 +
2.25 +inline u32 user_address(u32 addr)
2.26 +{
2.27 + return addr & USER_ADDRESS_MASK;
2.28 +}
3.1 --- a/stage2/paging.h Wed May 04 22:57:56 2016 +0200
3.2 +++ b/stage2/paging.h Wed May 04 23:04:58 2016 +0200
3.3 @@ -4,4 +4,14 @@
3.4 #define page_table_start 0x81400000
3.5 #define page_table_task_size 0x00008000
3.6
3.7 +#define USER_ADDRESS_MASK 0x7fffffff
3.8 +
3.9 +#ifndef __ASSEMBLER__
3.10 +
3.11 +#include "xburst_types.h"
3.12 +
3.13 +u32 user_address(u32 addr);
3.14 +
3.15 +#endif /* __ASSEMBLER__ */
3.16 +
3.17 #endif /* __PAGING_H__ */
4.1 --- a/stage2/stage2.ld Wed May 04 22:57:56 2016 +0200
4.2 +++ b/stage2/stage2.ld Wed May 04 23:04:58 2016 +0200
4.3 @@ -36,5 +36,6 @@
4.4 . += _got_end - _got_start;
4.5 }
4.6 _got_copy_end = ABSOLUTE(.);
4.7 + _memory_end = 0x82000000;
4.8 }
4.9
5.1 --- a/stage2/tasks.c Wed May 04 22:57:56 2016 +0200
5.2 +++ b/stage2/tasks.c Wed May 04 23:04:58 2016 +0200
5.3 @@ -41,9 +41,9 @@
5.4
5.5 extern u32 _got_start, _got_copy_start, _got_copy_end;
5.6
5.7 -/* A reference to the start of the payload. */
5.8 +/* A reference to the start of the payload and end of memory locations. */
5.9
5.10 -extern u32 _payload_start;
5.11 +extern u32 _payload_start, _memory_end;
5.12
5.13 /* Task management functions. */
5.14
5.15 @@ -89,18 +89,18 @@
5.16
5.17 /* Map the global object table for the task. */
5.18
5.19 - init_page_table(page_table_start, (u32) &_got_start & 0x7fffffff, (u32) &_got_copy_start & 0x7fffffff, pagesize, 0x1e, task);
5.20 + init_page_table(page_table_start, user_address((u32) &_got_start), user_address((u32) &_got_copy_start), pagesize, 0x1e, task);
5.21
5.22 /* Map all shared pages for the task. */
5.23
5.24 for (address = (u32) &_payload_start; address < (u32) &_got_start; address += pagesize * 2)
5.25 {
5.26 - init_page_table(page_table_start, address & 0x7fffffff, address & 0x7fffffff, pagesize, 0x1e, task);
5.27 + init_page_table(page_table_start, user_address(address), user_address(address), pagesize, 0x1e, task);
5.28 }
5.29
5.30 - for (address = (u32) &_got_copy_end + pagesize * 2; address < 0x82000000; address += pagesize * 2)
5.31 + for (address = (u32) &_got_copy_end + pagesize * 2; address < (u32) &_memory_end; address += pagesize * 2)
5.32 {
5.33 - init_page_table(page_table_start, address & 0x7fffffff, address & 0x7fffffff, pagesize, 0x1e, task);
5.34 + init_page_table(page_table_start, user_address(address), user_address(address), pagesize, 0x1e, task);
5.35 }
5.36 }
5.37