# HG changeset patch # User Paul Boddie # Date 1462395898 -7200 # Node ID eda8506725e5a6b20792eccd2fdd26c7400a8703 # Parent 010e441bc874e01d9c4e32b55b6cbd0e313e4e45 Made an inline function for address space conversion. Defined the end of the memory in the linker script for consistency. diff -r 010e441bc874 -r eda8506725e5 stage2/Makefile --- a/stage2/Makefile Wed May 04 22:57:56 2016 +0200 +++ b/stage2/Makefile Wed May 04 23:04:58 2016 +0200 @@ -61,9 +61,10 @@ DEFS = $(BOARD_DEFS) # Ordering of objects is important and cannot be left to replacement rules. +# In particular the head2 file must appear first. -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) -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) +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) +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) .PHONY: all clean distclean diff -r 010e441bc874 -r eda8506725e5 stage2/paging.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stage2/paging.c Wed May 04 23:04:58 2016 +0200 @@ -0,0 +1,25 @@ +/* + * Paging utilities. + * + * Copyright (C) 2016 Paul Boddie + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "paging.h" + +inline u32 user_address(u32 addr) +{ + return addr & USER_ADDRESS_MASK; +} diff -r 010e441bc874 -r eda8506725e5 stage2/paging.h --- a/stage2/paging.h Wed May 04 22:57:56 2016 +0200 +++ b/stage2/paging.h Wed May 04 23:04:58 2016 +0200 @@ -4,4 +4,14 @@ #define page_table_start 0x81400000 #define page_table_task_size 0x00008000 +#define USER_ADDRESS_MASK 0x7fffffff + +#ifndef __ASSEMBLER__ + +#include "xburst_types.h" + +u32 user_address(u32 addr); + +#endif /* __ASSEMBLER__ */ + #endif /* __PAGING_H__ */ diff -r 010e441bc874 -r eda8506725e5 stage2/stage2.ld --- a/stage2/stage2.ld Wed May 04 22:57:56 2016 +0200 +++ b/stage2/stage2.ld Wed May 04 23:04:58 2016 +0200 @@ -36,5 +36,6 @@ . += _got_end - _got_start; } _got_copy_end = ABSOLUTE(.); + _memory_end = 0x82000000; } diff -r 010e441bc874 -r eda8506725e5 stage2/tasks.c --- a/stage2/tasks.c Wed May 04 22:57:56 2016 +0200 +++ b/stage2/tasks.c Wed May 04 23:04:58 2016 +0200 @@ -41,9 +41,9 @@ extern u32 _got_start, _got_copy_start, _got_copy_end; -/* A reference to the start of the payload. */ +/* A reference to the start of the payload and end of memory locations. */ -extern u32 _payload_start; +extern u32 _payload_start, _memory_end; /* Task management functions. */ @@ -89,18 +89,18 @@ /* Map the global object table for the task. */ - init_page_table(page_table_start, (u32) &_got_start & 0x7fffffff, (u32) &_got_copy_start & 0x7fffffff, pagesize, 0x1e, task); + init_page_table(page_table_start, user_address((u32) &_got_start), user_address((u32) &_got_copy_start), pagesize, 0x1e, task); /* Map all shared pages for the task. */ for (address = (u32) &_payload_start; address < (u32) &_got_start; address += pagesize * 2) { - init_page_table(page_table_start, address & 0x7fffffff, address & 0x7fffffff, pagesize, 0x1e, task); + init_page_table(page_table_start, user_address(address), user_address(address), pagesize, 0x1e, task); } - for (address = (u32) &_got_copy_end + pagesize * 2; address < 0x82000000; address += pagesize * 2) + for (address = (u32) &_got_copy_end + pagesize * 2; address < (u32) &_memory_end; address += pagesize * 2) { - init_page_table(page_table_start, address & 0x7fffffff, address & 0x7fffffff, pagesize, 0x1e, task); + init_page_table(page_table_start, user_address(address), user_address(address), pagesize, 0x1e, task); } }