diff --git a/include/comrogue/internals/seg.h b/include/comrogue/internals/seg.h index e9d6c73..d4fd928 100644 --- a/include/comrogue/internals/seg.h +++ b/include/comrogue/internals/seg.h @@ -43,22 +43,11 @@ *---------------------- */ -#ifdef __COMROGUE_PRESTART__ - -#define SEG_INIT_CODE __attribute__((__section__(".prestart.text"))) -#define SEG_INIT_DATA __attribute__((__section__(".prestart.data"))) -#define SEG_INIT_RODATA __attribute__((__section__(".prestart.rodata"))) -#define SEG_RODATA SEG_INIT_RODATA - -#else - #define SEG_INIT_CODE __attribute__((__section__(".init.text"))) #define SEG_INIT_DATA __attribute__((__section__(".init.data"))) #define SEG_INIT_RODATA __attribute__((__section__(".init.rodata"))) #define SEG_RODATA __attribute__((__section__(".rodata"))) -#endif /* __COMROGUE_PRESTART__ */ - /*------------------------------------ * String constant declaration macros *------------------------------------ diff --git a/include/comrogue/internals/trace.h b/include/comrogue/internals/trace.h index bd16ec3..6d93fa3 100644 --- a/include/comrogue/internals/trace.h +++ b/include/comrogue/internals/trace.h @@ -87,7 +87,7 @@ CDECL_END #define THIS_FILE __FILE__ -#if defined(__COMROGUE_PRESTART__) || defined(__COMROGUE_INIT__) +#if defined(__COMROGUE_INIT__) #define DECLARE_THIS_FILE static DECLARE_INIT_STRING8_CONST(THIS_FILE, __FILE__); #else #define DECLARE_THIS_FILE static DECLARE_STRING8_CONST(THIS_FILE, __FILE__); diff --git a/kernel/Makefile b/kernel/Makefile index 4c57750..552ab2b 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -32,14 +32,16 @@ MAKEFLAGS += -rR CRBASEDIR := $(abspath ..) include $(CRBASEDIR)/armcompile.mk -PRESTART_OBJS = prestart.o early_trace.o collect_startup.o early_mm.o RES_OBJS = lowlevel.o trace.o memmgr.o vmmap.o pagealloc.o kernel_space.o INIT_OBJS = start.o kistart.o init_heap.o all: kernel.img -kernel.elf: $(PRESTART_OBJS) lib/kernel-lib.o $(RES_OBJS) $(INIT_OBJS) kernel.lds - $(LD) -T kernel.lds $(PRESTART_OBJS) lib/kernel-lib.o $(RES_OBJS) $(INIT_OBJS) -o kernel.elf +kernel.elf: prestart/kernel-prestart.o lib/kernel-lib.o $(RES_OBJS) $(INIT_OBJS) kernel.lds + $(LD) -T kernel.lds prestart/kernel-prestart.o lib/kernel-lib.o $(RES_OBJS) $(INIT_OBJS) -o kernel.elf + +prestart/kernel-prestart.o: + make -C prestart lib/kernel-lib.o: make -C lib @@ -52,4 +54,5 @@ kernel.img: kernel.elf clean: -rm *.o *.s *.lds kernel.img kernel.elf kernel.list kernel.syms* - make -C lib clean \ No newline at end of file + make -C prestart clean + make -C lib clean diff --git a/kernel/prestart/Makefile b/kernel/prestart/Makefile new file mode 100644 index 0000000..2676cf1 --- /dev/null +++ b/kernel/prestart/Makefile @@ -0,0 +1,43 @@ +# +# This file is part of the COMROGUE Operating System for Raspberry Pi +# +# Copyright (c) 2013, Eric J. Bowersox / Erbosoft Enterprises +# All rights reserved. +# +# This program is free for commercial and non-commercial use as long as the following conditions are +# adhered to. +# +# Copyright in this file remains Eric J. Bowersox and/or Erbosoft, and as such any copyright notices +# in the code are not to be removed. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions and +# the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and +# the following disclaimer in the documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# "Raspberry Pi" is a trademark of the Raspberry Pi Foundation. +MAKEFLAGS += -rR +CRBASEDIR := $(abspath ../..) +include $(CRBASEDIR)/armcompile.mk + +PRESTART_OBJS = prestart.o early_trace.o collect_startup.o early_mm.o + +all: kernel-prestart.o + +kernel-prestart.o: $(PRESTART_OBJS) kernel-prestart.lds + $(LD) -r -T kernel-prestart.lds $(PRESTART_OBJS) -o kernel-prestart.o + +clean: + -rm *.o *.s *.lds diff --git a/kernel/collect_startup.c b/kernel/prestart/collect_startup.c similarity index 87% rename from kernel/collect_startup.c rename to kernel/prestart/collect_startup.c index 1ade904..f34b4a0 100644 --- a/kernel/collect_startup.c +++ b/kernel/prestart/collect_startup.c @@ -31,12 +31,12 @@ */ #define __COMROGUE_PRESTART__ #include -#include #include +#include #include /* The startup information buffer. */ -SEG_INIT_DATA static STARTUP_INFO startup_info = { +static STARTUP_INFO startup_info = { .cb = sizeof(STARTUP_INFO), .paTTB = 0, .kaTTB = 0, @@ -64,7 +64,7 @@ SEG_INIT_DATA static STARTUP_INFO startup_info = { * NULL if the variable was not found, otherwise a pointer to the first character in the command line * following the variable name and associated = sign (first character of the value). */ -SEG_INIT_CODE static PCSTR find_variable(PCSTR pszCmdLine, PCSTR pszVariableName) +static PCSTR find_variable(PCSTR pszCmdLine, PCSTR pszVariableName) { register PCSTR p = pszCmdLine; register PCSTR p1, q; @@ -92,7 +92,7 @@ SEG_INIT_CODE static PCSTR find_variable(PCSTR pszCmdLine, PCSTR pszVariableName * Returns: * TRUE if the character is a valid digit, FALSE otherwise. */ -SEG_INIT_CODE static BOOL is_valid_digit(CHAR ch, UINT32 base) +static BOOL is_valid_digit(CHAR ch, UINT32 base) { register UINT32 nbase; @@ -120,7 +120,7 @@ SEG_INIT_CODE static BOOL is_valid_digit(CHAR ch, UINT32 base) * Returns: * The converted numeric value. */ -SEG_INIT_CODE static UINT32 decode_number(PCSTR pVal, UINT32 base) +static UINT32 decode_number(PCSTR pVal, UINT32 base) { register UINT32 accum = 0; register UINT32 digit; @@ -154,16 +154,16 @@ SEG_INIT_CODE static UINT32 decode_number(PCSTR pVal, UINT32 base) * Side effects: * Modifies the "startup_info" structure. */ -SEG_INIT_CODE static void parse_cmdline(PCSTR pszCmdLine) +static void parse_cmdline(PCSTR pszCmdLine) { - static DECLARE_INIT_STRING8_CONST(szFBWidth, "bcm2708_fb.fbwidth"); - static DECLARE_INIT_STRING8_CONST(szFBHeight, "bcm2708_fb.fbheight"); - static DECLARE_INIT_STRING8_CONST(szRevision, "bcm2708.boardrev"); - static DECLARE_INIT_STRING8_CONST(szSerial, "bcm2708.serial"); - static DECLARE_INIT_STRING8_CONST(szMACAddr, "smsc95xx.macaddr"); - static DECLARE_INIT_STRING8_CONST(szEMMCFreq, "sdhci-bcm2708.emmc_clock_freq"); - static DECLARE_INIT_STRING8_CONST(szVCMemBase, "vc_mem.mem_base"); - static DECLARE_INIT_STRING8_CONST(szVCMemSize, "vc_mem.mem_size"); + static DECLARE_STRING8_CONST(szFBWidth, "bcm2708_fb.fbwidth"); + static DECLARE_STRING8_CONST(szFBHeight, "bcm2708_fb.fbheight"); + static DECLARE_STRING8_CONST(szRevision, "bcm2708.boardrev"); + static DECLARE_STRING8_CONST(szSerial, "bcm2708.serial"); + static DECLARE_STRING8_CONST(szMACAddr, "smsc95xx.macaddr"); + static DECLARE_STRING8_CONST(szEMMCFreq, "sdhci-bcm2708.emmc_clock_freq"); + static DECLARE_STRING8_CONST(szVCMemBase, "vc_mem.mem_base"); + static DECLARE_STRING8_CONST(szVCMemSize, "vc_mem.mem_size"); register PCSTR p; register int i; @@ -212,7 +212,7 @@ SEG_INIT_CODE static void parse_cmdline(PCSTR pszCmdLine) * Side effects: * Modifies the "startup_info" structure, which it returns a pointer to. */ -SEG_INIT_CODE PSTARTUP_INFO KiCollectStartupInfo(UINT32 always0, UINT32 uiMachineType, PATAG_HEADER pAtags) +PSTARTUP_INFO KiCollectStartupInfo(UINT32 always0, UINT32 uiMachineType, PATAG_HEADER pAtags) { /* Fill in the information we can calculate right away. */ startup_info.uiMachineType = uiMachineType; diff --git a/kernel/early_mm.c b/kernel/prestart/early_mm.c similarity index 91% rename from kernel/early_mm.c rename to kernel/prestart/early_mm.c index b546d38..8f99298 100644 --- a/kernel/early_mm.c +++ b/kernel/prestart/early_mm.c @@ -31,7 +31,6 @@ */ #define __COMROGUE_PRESTART__ #include -#include #include #include #include @@ -48,11 +47,11 @@ DECLARE_THIS_FILE */ /* Data stored in here temporarily and reflected back to startup info when we're done. */ -SEG_INIT_DATA static PTTB g_pTTB = NULL; /* pointer to TTB */ -SEG_INIT_DATA static PTTBAUX g_pTTBAux = NULL; /* pointer to TTB auxiliary data */ -SEG_INIT_DATA static UINT32 g_cpgForPageTables = 0; /* number of pages being used for page tables */ -SEG_INIT_DATA static UINT32 g_ctblFreeonLastPage = 0; /* number of page tables free on last page */ -SEG_INIT_DATA static PPAGETAB g_ptblNext = NULL; /* pointer to next free page table */ +static PTTB g_pTTB; /* pointer to TTB */ +static PTTBAUX g_pTTBAux; /* pointer to TTB auxiliary data */ +static UINT32 g_cpgForPageTables; /* number of pages being used for page tables */ +static UINT32 g_ctblFreeonLastPage; /* number of page tables free on last page */ +static PPAGETAB g_ptblNext; /* pointer to next free page table */ /* * Morphs the "flags" bits used for a page table entry in the TTB and for a page entry in the page table @@ -66,7 +65,7 @@ SEG_INIT_DATA static PPAGETAB g_ptblNext = NULL; /* pointer to next free pa * The flag bits that would be used for a section entry in the TTB. If a bit or option is set * in either uiTableFlags or uiPageFlags, it will be set in the appropriate place in the result. */ -SEG_INIT_CODE static UINT32 make_section_flags(UINT32 uiTableFlags, UINT32 uiPageFlags) +static UINT32 make_section_flags(UINT32 uiTableFlags, UINT32 uiPageFlags) { register UINT32 rc = TTBSEC_ALWAYS; rc |= ((uiTableFlags & TTBPGTBL_PXN) >> 2); @@ -93,7 +92,7 @@ SEG_INIT_CODE static UINT32 make_section_flags(UINT32 uiTableFlags, UINT32 uiPag * Returns: * TTB auxiliary flag bits that would be used for a TTB entry. */ -SEG_INIT_CODE static UINT32 make_section_aux_flags(UINT32 uiPageAuxFlags) +static UINT32 make_section_aux_flags(UINT32 uiPageAuxFlags) { register UINT32 rc = uiPageAuxFlags & (PGAUX_SACRED|PGAUX_UNWRITEABLE); /* TODO if we define any other flags */ @@ -115,7 +114,7 @@ SEG_INIT_CODE static UINT32 make_section_aux_flags(UINT32 uiPageAuxFlags) * Side effects: * Modifies the global variables g_cpgForPageTables, g_ctblFreeonLastPage, and g_ptblNext. */ -SEG_INIT_CODE static PPAGETAB alloc_page_table(PTTB pTTBEntry, PTTBAUX pAuxEntry, UINT32 uiTableFlags) +static PPAGETAB alloc_page_table(PTTB pTTBEntry, PTTBAUX pAuxEntry, UINT32 uiTableFlags) { register PPAGETAB pTab; /* pointer to new page table */ register UINT32 i; /* loop counter */ @@ -159,8 +158,8 @@ SEG_INIT_CODE static PPAGETAB alloc_page_table(PTTB pTTBEntry, PTTBAUX pAuxEntry * table that the TTB entry points to, where applicable. If we need to allocate a new page table, may modify the * global variables g_cpgForPageTables, g_ctblFreeonLastPage, and g_ptblNext. */ -SEG_INIT_CODE static INT32 alloc_pages(PHYSADDR paBase, PTTB pTTBEntry, PTTBAUX pAuxEntry, INT32 ndxPage, - INT32 cpg, UINT32 uiTableFlags, UINT32 uiPageFlags, UINT32 uiAuxFlags) +static INT32 alloc_pages(PHYSADDR paBase, PTTB pTTBEntry, PTTBAUX pAuxEntry, INT32 ndxPage, + INT32 cpg, UINT32 uiTableFlags, UINT32 uiPageFlags, UINT32 uiAuxFlags) { INT32 cpgCurrent; /* number of pages we're mapping */ PPAGETAB pTab; /* pointer to current or new page table */ @@ -229,15 +228,15 @@ SEG_INIT_CODE static INT32 alloc_pages(PHYSADDR paBase, PTTB pTTBEntry, PTTBAUX * where applicable. If we need to allocate new page tables, may modify the global variables g_cpgForPageTables, * g_ctblFreeonLastPage, and g_ptblNext. */ -SEG_INIT_CODE static BOOL map_pages(PHYSADDR paBase, KERNADDR vmaBase, INT32 cpg, UINT32 uiTableFlags, - UINT32 uiPageFlags, UINT32 uiAuxFlags) +static BOOL map_pages(PHYSADDR paBase, KERNADDR vmaBase, INT32 cpg, UINT32 uiTableFlags, + UINT32 uiPageFlags, UINT32 uiAuxFlags) { - static DECLARE_INIT_STRING8_CONST(sz1, "Map "); - static DECLARE_INIT_STRING8_CONST(sz2, "->"); - static DECLARE_INIT_STRING8_CONST(sz3, ",cpg="); - static DECLARE_INIT_STRING8_CONST(sz4, ",tf="); - static DECLARE_INIT_STRING8_CONST(sz5, ",pf="); - static DECLARE_INIT_STRING8_CONST(sz6, ",af="); + static DECLARE_STRING8_CONST(sz1, "Map "); + static DECLARE_STRING8_CONST(sz2, "->"); + static DECLARE_STRING8_CONST(sz3, ",cpg="); + static DECLARE_STRING8_CONST(sz4, ",tf="); + static DECLARE_STRING8_CONST(sz5, ",pf="); + static DECLARE_STRING8_CONST(sz6, ",af="); INT32 ndxTTB = mmVMA2TTBIndex(vmaBase); /* TTB entry index */ INT32 ndxPage = mmVMA2PGTBLIndex(vmaBase); /* starting page entry index */ INT32 cpgCurrent; /* current number of pages mapped */ @@ -358,12 +357,12 @@ extern char paFirstFree, cpgPrestartTotal, paLibraryCode, vmaLibraryCode, cpgLib * Modifies physical memory beyond the end of the kernel to store TTB and page tables. Uses several * static globals in this module for work space while performing memory mappings. */ -SEG_INIT_CODE PHYSADDR EMmInit(PSTARTUP_INFO pstartup) +PHYSADDR EMmInit(PSTARTUP_INFO pstartup) { - static DECLARE_INIT_STRING8_CONST(szTTBAt, "EMmInit: TTB1@"); + static DECLARE_STRING8_CONST(szTTBAt, "EMmInit: TTB1@"); #if 0 - static DECLARE_INIT_STRING8_CONST(szPageTable, "Page table pages:"); - static DECLARE_INIT_STRING8_CONST(szFree, "\nFree last page:"); + static DECLARE_STRING8_CONST(szPageTable, "Page table pages:"); + static DECLARE_STRING8_CONST(szFree, "\nFree last page:"); #endif PHYSADDR paTTB = (PHYSADDR)(&paFirstFree); /* location of the system TTB1 */ UINT32 cbMPDB; /* number of bytes in the MPDB */ @@ -406,6 +405,7 @@ SEG_INIT_CODE PHYSADDR EMmInit(PSTARTUP_INFO pstartup) /* Initialize the "next page table" pointer. */ pstartup->paFirstPageTable = pstartup->paMPDB + cbMPDB; g_ptblNext = (PPAGETAB)(pstartup->paFirstPageTable); + g_cpgForPageTables = g_ctblFreeonLastPage = 0; /* Map the "prestart" area (everything below load address, plus prestart code & data) as identity. */ VERIFY(map_pages(0, 0, (INT32)(&cpgPrestartTotal), TTBPGTBL_ALWAYS, PGTBLSM_ALWAYS | PGTBLSM_AP01, 0)); diff --git a/kernel/early_trace.c b/kernel/prestart/early_trace.c similarity index 91% rename from kernel/early_trace.c rename to kernel/prestart/early_trace.c index eb70232..549674b 100644 --- a/kernel/early_trace.c +++ b/kernel/prestart/early_trace.c @@ -39,7 +39,7 @@ #include /* Hex digits. */ -static DECLARE_INIT_STRING8_CONST(szHexDigits, "0123456789ABCDEF"); +static DECLARE_STRING8_CONST(szHexDigits, "0123456789ABCDEF"); /* * Initializes the trace functionality (the aux UART). @@ -53,7 +53,7 @@ static DECLARE_INIT_STRING8_CONST(szHexDigits, "0123456789ABCDEF"); * Side effects: * GPIO 14 configured for output from UART1; UART1 initialized to 115200 8N1 and enabled for output. */ -SEG_INIT_CODE void ETrInit(void) +void ETrInit(void) { register UINT32 ra; @@ -90,7 +90,7 @@ SEG_INIT_CODE void ETrInit(void) * Side effects: * Character written to UART1. */ -SEG_INIT_CODE static void write_trace(UINT32 c) +static void write_trace(UINT32 c) { register UINT32 lsr = llIORead(AUX_MU_REG_LSR); while (!(lsr & U16550_LSR_TXEMPTY)) @@ -110,7 +110,7 @@ SEG_INIT_CODE static void write_trace(UINT32 c) * Side effects: * Either 1 or 2 characters written to UART1. */ -SEG_INIT_CODE void ETrWriteChar8(CHAR c) +void ETrWriteChar8(CHAR c) { if (c == '\n') write_trace('\r'); @@ -129,7 +129,7 @@ SEG_INIT_CODE void ETrWriteChar8(CHAR c) * Side effects: * Characters in string written to UART1. */ -SEG_INIT_CODE void ETrWriteString8(PCSTR psz) +void ETrWriteString8(PCSTR psz) { while (*psz) ETrWriteChar8(*psz++); @@ -147,7 +147,7 @@ SEG_INIT_CODE void ETrWriteString8(PCSTR psz) * Side effects: * 8 characters written to UART1. */ -SEG_INIT_CODE void ETrWriteWord(UINT32 uiValue) +void ETrWriteWord(UINT32 uiValue) { register UINT32 uiShift = 32; do @@ -170,9 +170,9 @@ SEG_INIT_CODE void ETrWriteWord(UINT32 uiValue) * Side effects: * Many characters written to UART1. */ -SEG_INIT_CODE void ETrDumpWords(PUINT32 puiWords, UINT32 cWords) +void ETrDumpWords(PUINT32 puiWords, UINT32 cWords) { - static DECLARE_INIT_STRING8_CONST(szSpacer1, ": "); + static DECLARE_STRING8_CONST(szSpacer1, ": "); register UINT32 i; for (i = 0; i < cWords; i++) { @@ -204,9 +204,9 @@ SEG_INIT_CODE void ETrDumpWords(PUINT32 puiWords, UINT32 cWords) * Side effects: * Characters written to UART1. */ -SEG_INIT_CODE void ETrAssertFailed(PCSTR pszFile, INT32 nLine) +void ETrAssertFailed(PCSTR pszFile, INT32 nLine) { - static DECLARE_INIT_STRING8_CONST(szPrefix, "** ASSERTION FAILED: "); + static DECLARE_STRING8_CONST(szPrefix, "** ASSERTION FAILED: "); ETrWriteString8(szPrefix); ETrWriteString8(pszFile); write_trace(':'); @@ -226,7 +226,7 @@ SEG_INIT_CODE void ETrAssertFailed(PCSTR pszFile, INT32 nLine) * Side effects: * GPIO 16 configured for output and turns on and off indefinitely. */ -SEG_INIT_CODE void ETrInfiniBlink(void) +void ETrInfiniBlink(void) { register UINT32 ra; diff --git a/kernel/prestart/kernel-prestart.ldi b/kernel/prestart/kernel-prestart.ldi new file mode 100644 index 0000000..7f404a0 --- /dev/null +++ b/kernel/prestart/kernel-prestart.ldi @@ -0,0 +1,177 @@ +/* + * This file is part of the COMROGUE Operating System for Raspberry Pi + * + * Copyright (c) 2013, Eric J. Bowersox / Erbosoft Enterprises + * All rights reserved. + * + * This program is free for commercial and non-commercial use as long as the following conditions are + * adhered to. + * + * Copyright in this file remains Eric J. Bowersox and/or Erbosoft, and as such any copyright notices + * in the code are not to be removed. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * "Raspberry Pi" is a trademark of the Raspberry Pi Foundation. + */ +/* Copied from default linker script for relocatable linking under ARM & modified */ +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +OUTPUT_ARCH(arm) + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + .interp 0 : { *(.interp) } + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash 0 : { *(.hash) } + .gnu.hash 0 : { *(.gnu.hash) } + .dynsym 0 : { *(.dynsym) } + .dynstr 0 : { *(.dynstr) } + .gnu.version 0 : { *(.gnu.version) } + .gnu.version_d 0: { *(.gnu.version_d) } + .gnu.version_r 0: { *(.gnu.version_r) } + .rel.init 0 : { *(.rel.init) } + .rela.init 0 : { *(.rela.init) } + .rel.text 0 : { *(.rel.text) } + .rela.text 0 : { *(.rela.text) } + .rel.fini 0 : { *(.rel.fini) } + .rela.fini 0 : { *(.rela.fini) } + .rel.rodata 0 : { *(.rel.rodata) } + .rela.rodata 0 : { *(.rela.rodata) } + .rel.data.rel.ro 0 : { *(.rel.data.rel.ro) } + .rela.data.rel.ro 0 : { *(.rela.data.rel.ro) } + .rel.data 0 : { *(.rel.data) *(.rel.bss) } + .rela.data 0 : { *(.rela.data) *(.rela.bss) } + .rel.tdata 0 : { *(.rel.tdata) *(.rel.tbss) } + .rela.tdata 0 : { *(.rela.tdata) *(.rela.tbss) } + .rel.ctors 0 : { *(.rel.ctors) } + .rela.ctors 0 : { *(.rela.ctors) } + .rel.dtors 0 : { *(.rel.dtors) } + .rela.dtors 0 : { *(.rela.dtors) } + .rel.got 0 : { *(.rel.got) } + .rela.got 0 : { *(.rela.got) } + .rel.iplt 0 : + { + *(.rel.iplt) + } + .rela.iplt 0 : + { + *(.rela.iplt) + } + .rel.plt 0 : + { + *(.rel.plt) + } + .rela.plt 0 : + { + *(.rela.plt) + } + .init 0 : + { + KEEP (*(.init)) + } =0 + .plt 0 : { *(.plt) } + .iplt 0 : { *(.iplt) } + .first.prestart.text 0 : { *(.first.text) } + .prestart.text 0 : + { + *(.text .stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0 + .fini 0 : + { + KEEP (*(.fini)) + } =0 + .prestart.rodata 0 : { *(.rodata) } + .prestart.rodata1 0 : { *(.rodata1) } + .ARM.extab 0 : { *(.ARM.extab) } + .ARM.exidx 0 : { *(.ARM.exidx) } + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame 0 : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table 0 : ONLY_IF_RO { *(.gcc_except_table + .gcc_except_table.*) } + /* These sections are generated by the Sun/Oracle C++ compiler. */ + .exception_ranges 0 : ONLY_IF_RO { *(.exception_ranges + .exception_ranges*) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + /* Exception handling */ + .eh_frame 0 : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table 0 : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + .exception_ranges 0 : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } + /* Thread Local Storage sections */ + .tdata 0 : { *(.tdata) *(.tbss) } + .preinit_array 0 : + { + KEEP (*(.preinit_array)) + } + .jcr 0 : { KEEP (*(.jcr)) } + .dynamic 0 : { *(.dynamic) } + .got 0 : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } + .prestart.data 0 : + { + *(.data) + *(.dynbss) + *(.bss) + *(COMMON) + } + .prestart.data1 0 : { *(.data1) } + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .stack 0 : + { + *(.stack) + } + .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) } + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } +} diff --git a/kernel/prestart.S b/kernel/prestart/prestart.S similarity index 99% rename from kernel/prestart.S rename to kernel/prestart/prestart.S index 02f6041..9d74661 100644 --- a/kernel/prestart.S +++ b/kernel/prestart/prestart.S @@ -41,7 +41,7 @@ *------------------------------------------------------------------------------------------ */ -.section ".first.prestart.text" +.section ".first.text" .globl COMROGUEPrestart @@ -209,7 +209,7 @@ COMROGUEPrestart: *-------------------------------------------------------------------------------------- */ -.section ".prestart.text" +.section ".text" /* * Writes a 32-bit word of data to a memory-mapped IO port.