From 9d1aacd8966d6a881322ff2fa82f3f0014b7b134 Mon Sep 17 00:00:00 2001 From: DizzyOfCRN Date: Mon, 27 Oct 2014 19:26:43 +0000 Subject: [PATCH] Empty boot directory from sun4i target git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@49720 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/arm-sun4i/boot/atags.h | 180 ----------------- arch/arm-sun4i/boot/boot.c | 414 -------------------------------------- arch/arm-sun4i/boot/boot.h | 42 ---- arch/arm-sun4i/boot/elf.c | 384 ----------------------------------- arch/arm-sun4i/boot/elf.h | 29 --- arch/arm-sun4i/boot/ldscript.lds | 68 ------- arch/arm-sun4i/boot/mmakefile.src | 69 ------- arch/arm-sun4i/boot/serialdebug.c | 50 ----- arch/arm-sun4i/boot/support.c | 52 ----- arch/arm-sun4i/boot/uEnv.txt | 4 - 10 files changed, 1292 deletions(-) delete mode 100644 arch/arm-sun4i/boot/atags.h delete mode 100644 arch/arm-sun4i/boot/boot.c delete mode 100644 arch/arm-sun4i/boot/boot.h delete mode 100644 arch/arm-sun4i/boot/elf.c delete mode 100644 arch/arm-sun4i/boot/elf.h delete mode 100644 arch/arm-sun4i/boot/ldscript.lds delete mode 100644 arch/arm-sun4i/boot/mmakefile.src delete mode 100644 arch/arm-sun4i/boot/serialdebug.c delete mode 100644 arch/arm-sun4i/boot/support.c delete mode 100644 arch/arm-sun4i/boot/uEnv.txt diff --git a/arch/arm-sun4i/boot/atags.h b/arch/arm-sun4i/boot/atags.h deleted file mode 100644 index 42f6045f56..0000000000 --- a/arch/arm-sun4i/boot/atags.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - Copyright © 2014, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ - -#ifndef ATAGS_H_ -#define ATAGS_H_ - -#include - -typedef uint16_t uint16_t; -typedef uint8_t uint8_t; - -#define COMMAND_LINE_SIZE 1024 - -/* The list ends with an ATAG_NONE node. */ -#define ATAG_NONE 0x00000000 - -struct tag_header { - uint32_t size; - uint32_t tag; -}; - -/* The list must start with an ATAG_CORE node */ -#define ATAG_CORE 0x54410001 - -struct tag_core { - uint32_t flags; /* bit 0 = read-only */ - uint32_t pagesize; - uint32_t rootdev; -}; - -/* it is allowed to have multiple ATAG_MEM nodes */ -#define ATAG_MEM 0x54410002 - -struct tag_mem32 { - uint32_t size; - uint32_t start; /* physical start address */ -}; - -/* VGA text type displays */ -#define ATAG_VIDEOTEXT 0x54410003 - -struct tag_videotext { - uint8_t x; - uint8_t y; - uint16_t video_page; - uint8_t video_mode; - uint8_t video_cols; - uint16_t video_ega_bx; - uint8_t video_lines; - uint8_t video_isvga; - uint16_t video_points; -}; - -/* describes how the ramdisk will be used in kernel */ -#define ATAG_RAMDISK 0x54410004 - -struct tag_ramdisk { - uint32_t flags; /* bit 0 = load, bit 1 = prompt */ - uint32_t size; /* decompressed ramdisk size in _kilo_ bytes */ - uint32_t start; /* starting block of floppy-based RAM disk image */ -}; - -/* describes where the compressed ramdisk image lives (virtual address) */ -/* - * this one accidentally used virtual addresses - as such, - * it's deprecated. - */ -#define ATAG_INITRD 0x54410005 - -/* describes where the compressed ramdisk image lives (physical address) */ -#define ATAG_INITRD2 0x54420005 - -struct tag_initrd { - uint32_t start; /* physical start address */ - uint32_t size; /* size of compressed ramdisk image in bytes */ -}; - -/* board serial number. "64 bits should be enough for everybody" */ -#define ATAG_SERIAL 0x54410006 - -struct tag_serialnr { - uint32_t low; - uint32_t high; -}; - -/* board revision */ -#define ATAG_REVISION 0x54410007 - -struct tag_revision { - uint32_t rev; -}; - -/* initial values for vesafb-type framebuffers. see struct screen_info - * in include/linux/tty.h - */ -#define ATAG_VIDEOLFB 0x54410008 - -struct tag_videolfb { - uint16_t lfb_width; - uint16_t lfb_height; - uint16_t lfb_depth; - uint16_t lfb_linelength; - uint32_t lfb_base; - uint32_t lfb_size; - uint8_t red_size; - uint8_t red_pos; - uint8_t green_size; - uint8_t green_pos; - uint8_t blue_size; - uint8_t blue_pos; - uint8_t rsvd_size; - uint8_t rsvd_pos; -}; - -/* command line: \0 terminated string */ -#define ATAG_CMDLINE 0x54410009 - -struct tag_cmdline { - char cmdline[1]; /* this is the minimum size */ -}; - -/* acorn RiscPC specific information */ -#define ATAG_ACORN 0x41000101 - -struct tag_acorn { - uint32_t memc_control_reg; - uint32_t vram_pages; - uint8_t sounddefault; - uint8_t adfsdrives; -}; - -/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */ -#define ATAG_MEMCLK 0x41000402 - -struct tag_memclk { - uint32_t fmemclk; -}; - -struct tag { - struct tag_header hdr; - union { - struct tag_core core; - struct tag_mem32 mem; - struct tag_videotext videotext; - struct tag_ramdisk ramdisk; - struct tag_initrd initrd; - struct tag_serialnr serialnr; - struct tag_revision revision; - struct tag_videolfb videolfb; - struct tag_cmdline cmdline; - - /* - * Acorn specific - */ - struct tag_acorn acorn; - - /* - * DC21285 specific - */ - struct tag_memclk memclk; - } u; -}; - -#define tag_member_present(tag,member) \ - ((unsigned long)(&((struct tag *)0L)->member + 1) \ - <= (tag)->hdr.size * 4) - -#define tag_next(t) ((struct tag *)((uint32_t *)(t) + (t)->hdr.size)) -#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) - -#define for_each_tag(t,base) \ - for (t = base; t->hdr.size; t = tag_next(t)) - - -#endif /* ATAGS_H_ */ diff --git a/arch/arm-sun4i/boot/boot.c b/arch/arm-sun4i/boot/boot.c deleted file mode 100644 index eeb769b234..0000000000 --- a/arch/arm-sun4i/boot/boot.c +++ /dev/null @@ -1,414 +0,0 @@ -/* - Copyright © 2014, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "boot.h" -#include "atags.h" -#include "elf.h" - -#include - -/* Parse ATAGS to find end of DRAM (align on mebibyte (or megabyte...) boundary) and set stack pointer there. "Push" ATAGS in stack and jump to C */ -asm(" .section .aros.startup \n" -" .globl bootstrap \n" -" .type bootstrap,%function \n" -" \n" -"bootstrap: \n" -" mov r0, #0 \n" -" mov r4, #2 \n" /* Size of ATAGS + ATAG_NONE */ -" mov sp, r0 \n" -" \n" -" mov r0, r2 \n" -" \n" -" mov r3, #0x0002 \n" /* ATAG_MEM */ -" movt r3, #0x5441 \n" -" b .get_tag \n" -" \n" -".tag_compare: \n" -" ldr ip, [r0, #4] \n" -" cmp ip, r3 \n" -" bne .get_tag \n" -" \n" -" cmp sp, #0 \n" /* Allow only one ATAG_MEM tag, else we get confused */ -" bne .fancy_error_loop \n" -" \n" -" ldr sp, [r0, #12] \n" /* Initial stackpointer is end of DRAM */ -" ldr r5, [r0, #8] \n" -" add sp, sp, r5 \n" /* Align on last mebibyte (or megabyte...) */ -" lsr sp, sp, #20 \n" -" lsl sp, sp, #20 \n" /* sp = 0x8000 0000 on pcDuino (0x4000 0000 - 0x7fff ffff DRAM)*/ -" \n" -".get_tag: \n" -" ldr ip, [r0] \n" -" cmp ip, #0 \n" -" add r0, r0, ip, lsl #2 \n" -" add r4, r4, ip \n" -" bne .tag_compare \n" -" \n" -" cmp sp, #0 \n" -" beq .fancy_error_loop \n" -" \n" -" sub sp, sp, r4, lsl #2 \n" /* "Push" ATAGs in the stack */ -" mov r0, sp \n" -".atag_copy: \n" -" ldr r3, [r2], #4 \n" -" str r3, [r0], #4 \n" -" subs r4, r4, #1 \n" -" bne .atag_copy \n" -" \n" -" mov r2, sp \n" -" mov r0, #0 \n" -" b boot \n" -" \n" -".fancy_error_loop: \n" -" b . \n"); - -void setup_mmu(uint32_t kernel_phys, uint32_t kernel_virt, uint32_t mem_lower, uint32_t mem_upper) { - - uint32_t i; - - kprintf("[BOOT] MMU kernel_phys %08x\n", kernel_phys); - kprintf("[BOOT] MMU kernel_virt %08x\n", kernel_virt); - kprintf("[BOOT] MMU mem_lower %08x\n", mem_lower); - kprintf("[BOOT] MMU mem_upper %08x\n", mem_upper-1); - - /* We know the virtual address but not the physical */ - pde_t *page_dir = 0xfffec000-(kernel_virt-kernel_phys); - kprintf("[BOOT] First level MMU page at %08x\n", page_dir); - - /* Clear page dir */ - for (i=0; i < 4096; i++) { - page_dir[i].raw = 0; - } - - // 1:1 memory mapping - for (i=(mem_lower >> 20); i < (mem_upper >> 20); i++) { - //kprintf("[BOOT] Memory mapping page %d\n", i); - //page_dir[i].raw = 0; - page_dir[i].section.type = PDE_TYPE_SECTION; - page_dir[i].section.b = 0; - page_dir[i].section.c = 1; // Cacheable - page_dir[i].section.ap = 3; // All can read&write - page_dir[i].section.base_address = i; - } - - // v:p memory mapping - for (i=(kernel_virt >> 20); i <= (0xffffffff >> 20); i++) { - kprintf("[BOOT] Kernel mapping page %d phys %08x -> virt %08x\n", i, (kernel_phys)+((i << 20)-(kernel_virt)), i << 20); - //page_dir[i].raw = 0; - page_dir[i].section.type = PDE_TYPE_SECTION; - page_dir[i].section.b = 0; - page_dir[i].section.c = 1; // Cacheable - page_dir[i].section.ap = 3; // All can read&write - page_dir[i].section.base_address = (kernel_phys >> 20)+(i-(kernel_virt >> 20)); - } - - /* Write page_dir address to ttbr0 */ - asm volatile ("mcr p15, 0, %0, c2, c0, 0"::"r"(page_dir)); - /* Write ttbr control N = 0 (use only ttbr0) */ - asm volatile ("mcr p15, 0, %0, c2, c0, 2"::"r"(0)); - -} - -void boot(uintptr_t dummy, uintptr_t arch, struct tag *atags) { - - struct tag *t = NULL; - struct TagItem tags[128]; - struct TagItem *tag = &tags[0]; - - uint32_t mem_upper = 0; - uint32_t mem_lower = 0; - uint32_t kernel_phys = 0; - uint32_t kernel_virt = 0; - - void *pkg_image; - uint32_t pkg_size; - - uint32_t tmp; - - /* Disable MMU, level one data cache and strict alignment fault checking */ - CP15_C1CR_Clear(C1CRF_C|C1CRF_A|C1CRF_M); - - /* High exception vectors selected, address range = 0xFFFF0000-0xFFFF001C */ - CP15_C1CR_Set(C1CRF_V); - - /* Set cp10 and cp11 for Privileged and User mode access */ - CP15_C1CACR_All(C1CACRV_CPAP(10)|C1CACRV_CPAP(11)); - - /* Enable VFP (NEON in our case) */ - fmxr(cr8, fmrx(cr8) | 1 << 30); - - void (*entry)(struct TagItem *tags) = NULL; - - kprintf("[BOOT] AROS for sun4i (" SUN4I_PLATFORM_NAME ") bootstrap\n"); - asm volatile ("mov %0, sp":"=r"(tmp)); - kprintf("[BOOT] Stack @ %08x\n", tmp); - - tag->ti_Tag = KRN_BootLoader; - tag->ti_Data = (IPTR)"Bootstrap/sun4i (" SUN4I_PLATFORM_NAME ") ARM"; - tag++; - - kprintf("[BOOT] Parsing ATAGS %x\n", tags); - - for_each_tag(t, atags) { - kprintf("[BOOT] (%x-%x) tag %08x (%d): ", t, (uint32_t)t+(t->hdr.size<<2)-1, t->hdr.tag, t->hdr.size); - - switch (t->hdr.tag) { - - case ATAG_MEM: { - mem_lower = t->u.mem.start; - mem_upper = t->u.mem.start+t->u.mem.size; - kprintf("Memory (%08x-%08x)\n", mem_lower, mem_upper-1); - } - break; - - case ATAG_CMDLINE: { - kprintf("CMDLine: \"%s\"\n", t->u.cmdline.cmdline); - tag->ti_Tag = KRN_CmdLine; - tag->ti_Data = (intptr_t)t->u.cmdline.cmdline; - tag++; - } - break; - - case ATAG_INITRD2: { - kprintf("RAMDISK: (%08x-%08x)\n", t->u.initrd.start, t->u.initrd.size + t->u.initrd.start - 1); - pkg_image = (void *)t->u.initrd.start; - pkg_size = t->u.initrd.size; - } - break; - - default: { - kprintf("IGN...\n"); - } - break; - - } - } - - if(t->hdr.size == 0) { - kprintf("[BOOT] (%x-%x) tag %08x (%d): ATAG_NONE\n", t, (uint32_t)t+(2<<2)-1, t->hdr.tag, 2); - } - - kprintf("[BOOT] Bootstrap @ %08x-%08x\n", &__bootstrap_start, &__bootstrap_end); - - if (mem_upper) { - - mem_upper -= MEM_OFFSET_VECTOR; /* Preserve DRAM for vectors (virtual 0xffff 0000 - 0xffff 003f) */ - kprintf("[BOOT] Vectors @%p\n", mem_upper); - - mem_upper -= MEM_OFFSET_MMU1; /* Preserve DRAM for top level mmu table (MMU1) 16kb boundary and size */ - kprintf("[BOOT] MMU1 @%p\n", mem_upper); - - kernel_phys = mem_upper; - kernel_virt = kernel_phys; - - uint32_t total_size_ro; - uint32_t total_size_rw; - uint32_t size_ro; - uint32_t size_rw; - - /* Calculate total size of kernel and modules */ - - getElfSize(&_binary_kernel_bin_start, &size_rw, &size_ro); - - total_size_ro = size_ro = (size_ro + 4095) & ~4095; - total_size_rw = size_rw = (size_rw + 4095) & ~4095; - - if (pkg_image && pkg_size) { - uint8_t *base = pkg_image; - - if (base[0] == 0x7f && base[1] == 'E' && base[2] == 'L' && base[3] == 'F') { - kprintf("[BOOT] Kernel image is ELF file\n"); - - getElfSize(base, &size_rw, &size_ro); - - total_size_ro += (size_ro + 4095) & ~4095; - total_size_rw += (size_rw + 4095) & ~4095; - } else if (base[0] == 'P' && base[1] == 'K' && base[2] == 'G' && base[3] == 0x01) { - kprintf("[BOOT] Kernel image is a package:\n"); - - uint8_t *file = base+4; - uint32_t total_length = AROS_BE2LONG(*(uint32_t*)file); /* Total length of the module */ - const uint8_t *file_end = base+total_length; - uint32_t len; - - kprintf("[BOOT] Package size: %dKB\n", total_length >> 10); - - file = base + 8; - - while(file < file_end) { - const char *filename = remove_path(file+4); - - /* get text length */ - len = AROS_BE2LONG(*(uint32_t*)file); - /* display the file name */ - kprintf("[BOOT] %s \n", filename); - - file += len + 5; - - len = AROS_BE2LONG(*(uint32_t *)file); - file += 4; - - /* load it */ - getElfSize(file, &size_rw, &size_ro); - - total_size_ro += (size_ro + 4095) & ~4095; - total_size_rw += (size_rw + 4095) & ~4095; - - /* go to the next file */ - file += len; - } - } - } - - /* - On asm bootstrap we aligned top of memory to 1Mb and set the stack pointer there and "pushed" ATAGS in stack - We then substracted vector space and mmu1 - - ffff ffff (Serial debug port base,) ATAGS and stack - | - ffff 003c routine address FIQ - ffff 0038 routine address IRQ - ffff 0034 routine address Reserved - ffff 0030 routine address Data Abort - ffff 002c routine address Prefetch Abort - ffff 0028 routine address Software interrupt - ffff 0024 routine address Undefined instruction - ffff 0020 routine address Reset - ffff 001c FIQ - ffff 0018 IRQ - ffff 0014 Reserved - ffff 0010 Data Abort - ffff 000c Prefetch Abort - ffff 0008 Software interrupt - ffff 0004 Undefined instruction - ffff 0000 Reset - fffe c000 MMU1 - fffa ffff End of kernel - | - xxx0 0000 RAM - | - */ - - kernel_phys = mem_upper - total_size_ro - total_size_rw; - kernel_virt = (kernel_phys | 0xfff00000); - - /* Adjust top of memory to last mebibyte (or megabyte...)*/ - mem_upper = AROS_ROUNDDOWN2(kernel_phys, 1024*1024-1); - - tag->ti_Tag = KRN_MEMLower; - tag->ti_Data = mem_lower; - tag++; - - tag->ti_Tag = KRN_MEMUpper; - tag->ti_Data = mem_upper; - tag++; - - tag->ti_Tag = KRN_KernelLowest; - tag->ti_Data = kernel_virt; - tag++; - - tag->ti_Tag = KRN_KernelHighest; - tag->ti_Data = kernel_virt + ((total_size_ro + 4095) & ~4095) + ((total_size_rw + 4095) & ~4095); // 0xfffe c000 - tag++; - - kprintf("[BOOT] Physical address of kernel: %p\n", kernel_phys); - kprintf("[BOOT] Virtual address of kernel: %p\n", kernel_virt); - - entry = (void (*)(struct TagItem *))kernel_virt; - - initAllocator(kernel_phys, kernel_phys + total_size_ro, kernel_virt - kernel_phys); - - loadElf(&_binary_kernel_bin_start); - - if (pkg_image && pkg_size) { - uint8_t *base = pkg_image; - - if (base[0] == 0x7f && base[1] == 'E' && base[2] == 'L' && base[3] == 'F') { - kprintf("[BOOT] Kernel image is ELF file\n"); - - /* load it */ - loadElf(base); - } else if (base[0] == 'P' && base[1] == 'K' && base[2] == 'G' && base[3] == 0x01) { - kprintf("[BOOT] Kernel image is a package:\n"); - - uint8_t *file = base+4; - uint32_t total_length = AROS_BE2LONG(*(uint32_t*)file); /* Total length of the module */ - const uint8_t *file_end = base+total_length; - uint32_t len; - - kprintf("[BOOT] Package size: %dKB\n", total_length >> 10); - - file = base + 8; - - while(file < file_end) { - const char *filename = remove_path(file+4); - - /* get text length */ - len = AROS_BE2LONG(*(uint32_t*)file); - /* display the file name */ - kprintf("[BOOT] %s ", filename); - - file += len + 5; - - len = AROS_BE2LONG(*(uint32_t *)file); - file += 4; - - /* load it */ - loadElf(file); - - /* go to the next file */ - file += len; - } - } - } - - arm_flush_cache(kernel_phys, total_size_ro + total_size_rw); - - tag->ti_Tag = KRN_KernelBss; - tag->ti_Data = (IPTR)tracker; - tag++; - - setup_mmu(kernel_phys, kernel_virt, mem_lower, mem_upper); - } - - tag->ti_Tag = TAG_DONE; - tag->ti_Data = 0; - - kprintf("[BOOT] Kernel taglist contains %d entries\n", ((intptr_t)tag - (intptr_t)tags)/sizeof(struct TagItem)); - kprintf("[BOOT] mem_upper: %p\n", mem_upper); - - if (entry) { - /* Set domains - Dom0 is usable, rest is disabled */ - asm volatile ("mrc p15, 0, %0, c3, c0, 0":"=r"(tmp)); - kprintf("[BOOT] Domain access control register: %08x\n", tmp); - asm volatile ("mcr p15, 0, %0, c3, c0, 0"::"r"(0x00000001)); - - /* Enable MMU */ - CP15_C1CR_Set(C1CRF_M); - - kprintf("[BOOT] Heading over to AROS kernel @ %08x\n", entry); - - entry(tags); - - kprintf("[BOOT] Back? Something wrong happened...\n"); - } else { - kprintf("[BOOT] kernel entry pointer not set?\n"); - } - - while(1); -}; - diff --git a/arch/arm-sun4i/boot/boot.h b/arch/arm-sun4i/boot/boot.h deleted file mode 100644 index 0c0f66e0e8..0000000000 --- a/arch/arm-sun4i/boot/boot.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright © 2014, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ - -#ifndef BOOT_H_ -#define BOOT_H_ - -#include -#include -#include -#include - -#define MEM_OFFSET_VECTOR 0x10000 -#define MMU_L1_SIZE (4*4096) -#define MEM_OFFSET_MMU1 (4*4096) -#define MEM_OFFSET_MMU2 (4*256*4096) -#define MEM_OFFSET_STACKS 4*10*1024 - -const char *remove_path(const char *in); -void arm_dcache_invalidate(uint32_t addr, uint32_t length); -void arm_icache_invalidate(uint32_t addr, uint32_t length); -void arm_flush_cache(uint32_t addr, uint32_t length); - -extern uint8_t __bootstrap_start; -extern uint8_t __bootstrap_end; - -extern void *_binary_kernel_bin_start; -extern long *_binary_kernel_bin_end; -extern long _binary_kernel_bin_size; - -void kprintf(const char *format, ...); - -#define _STR(x) # x -#define STR(x) _STR(x) - -#define MAX_BSS_SECTIONS 256 - -#endif /* BOOT_H_ */ diff --git a/arch/arm-sun4i/boot/elf.c b/arch/arm-sun4i/boot/elf.c deleted file mode 100644 index 9cdb8d7bb6..0000000000 --- a/arch/arm-sun4i/boot/elf.c +++ /dev/null @@ -1,384 +0,0 @@ -/* - Copyright © 2014, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ - -#include "elf.h" -#include "boot.h" - -#include -#include -#include - -uint32_t int_shnum; -uint32_t int_shstrndx; - -int checkHeader(struct elfheader *eh) -{ - if (eh->ident[0] != 0x7f || eh->ident[1] != 'E' || - eh->ident[2] != 'L' || eh->ident[3] != 'F') - { - return 0; - } - - int_shnum = eh->shnum; - int_shstrndx = eh->shstrndx; - - /* the ELF header only uses 16 bits to store the count of section headers, - * so it can't handle more than 65535 headers. if the count is 0, and an - * offset is defined, then the real count can be found in the first - * section header (which always exists). - * - * similarly, if the string table index is SHN_XINDEX, then the actual - * index is found in the first section header also. - * - * see the System V ABI 2001-04-24 draft for more details. - */ - if (int_shnum == 0 || int_shstrndx == SHN_XINDEX) - { - if (eh->shoff == 0) - { - return 0; - } - - /* Get section header. I hope it's there, in memory already. */ - struct sheader *sh = (struct sheader *)((intptr_t)eh + eh->shoff); - - /* wider section header count is in the size field */ - if (int_shnum == 0) - int_shnum = sh->size; - - /* wider string table index is in the link field */ - if (int_shstrndx == SHN_XINDEX) - int_shstrndx = sh->link; - - /* sanity, if they're still invalid then this isn't elf */ - if (int_shnum == 0 || int_shstrndx == SHN_XINDEX) - { - return 0; - } - } - - if - ( - eh->ident[EI_CLASS] != ELFCLASS32 || - eh->ident[EI_VERSION] != EV_CURRENT || - eh->type != ET_REL || - eh->ident[EI_DATA] != ELFDATA2LSB || - eh->machine != EM_ARM - ) - { - return 0; - } - - return 1; -} - -int getElfSize(void *elf_file, uint32_t *size_rw, uint32_t *size_ro) -{ - struct elfheader *eh = (struct elfheader *)elf_file; - uint32_t s_ro = 0; - uint32_t s_rw = 0; - - if (checkHeader(eh)) - { - struct sheader *sh = (struct sheader *)((intptr_t)elf_file + eh->shoff); - int i; - - for (i = 0; i < int_shnum; i++) - { - /* Does the section require memoy allcation? */ - if (sh[i].flags & SHF_ALLOC) - { - uint32_t size = (sh[i].size + sh[i].addralign - 1) & ~(sh[i].addralign - 1); - - /* - * I extend the section size according to the alignment requirement. However, also the already - * measured size has to be aligned poperly. It is so, because the loader has to align the load address later on. - */ - if (sh[i].flags & SHF_WRITE) - { - s_rw = (s_rw + sh[i].addralign - 1) & ~(sh[i].addralign - 1); - s_rw += size; - } - else - { - s_ro = (s_ro + sh[i].addralign - 1) & ~(sh[i].addralign - 1); - s_ro += size; - } - } - } - } - - if (size_ro) - *size_ro = s_ro; - if (size_rw) - *size_rw = s_rw; - - return 1; -} - -static uintptr_t ptr_ro; -static uintptr_t ptr_rw; -static uintptr_t virtoffset; - -void initAllocator(uintptr_t addr_ro, uintptr_t addr_rw, uintptr_t virtoff) -{ - ptr_ro = addr_ro; - ptr_rw = addr_rw; - virtoffset = virtoff; -} - -struct bss_tracker tracker[MAX_BSS_SECTIONS]; -static struct bss_tracker *bss_tracker = &tracker[0]; - -/* - * read_block function copies the range of memory within ELF file to any specified location. - */ -static inline void read_block(void *file, long offset, void *dest, long length) -{ - memcpy(dest, (void *)((unsigned long)file + offset), length); -} - -/* - * Get the memory for chunk and load it - */ -static int load_hunk(void *file, struct sheader *sh) -{ - void *ptr = (void *)0; - - /* empty chunk? Who cares :) */ - if (!sh->size) - return 1; - - /* Allocate a chunk with write access */ - if (sh->flags & SHF_WRITE) - { - ptr_rw = (char *)(((unsigned long)ptr_rw - + (unsigned long)sh->addralign - 1) - & ~((unsigned long)sh->addralign - 1)); - ptr = ptr_rw; - ptr_rw = ptr_rw + sh->size; - } - else - { - /* Read-Only mode? Get the memory from the kernel space, align it accorting to the demand */ - ptr_ro = (char *)(((unsigned long)ptr_ro - + (unsigned long)sh->addralign - 1) - & ~((unsigned long)sh->addralign - 1)); - ptr = ptr_ro; - ptr_ro = ptr_ro + sh->size; - } - - sh->addr = ptr; - - /* copy block of memory from ELF file if it exists */ - if (sh->type != SHT_NOBITS) { - read_block(file, sh->offset, (void *)((unsigned long)sh->addr), sh->size); - } else { - bzero(ptr, sh->size); - bss_tracker->addr = (void *)((unsigned long)ptr + virtoffset); - bss_tracker->length = sh->size; - bss_tracker++; - /* - * empty the subsequent tracker in case it's the last one. We did that in case a buggy firmare - * forgot to clear our .bss section - */ - bss_tracker->addr = (void*)0; - bss_tracker->length = 0; - } - - return 1; -} - -/* Perform relocations of given section */ -static int relocate(struct elfheader *eh, struct sheader *sh, long shrel_idx, - uint32_t virt) -{ - struct sheader *shrel = &sh[shrel_idx]; - struct sheader *shsymtab = &sh[shrel->link]; - struct sheader *toreloc = &sh[shrel->info]; - - struct symbol *symtab = - (struct symbol *)((unsigned long)shsymtab->addr); - struct relo *rel = (struct relo *)((unsigned long)shrel->addr); - char *section = (char *)((unsigned long)toreloc->addr); - - unsigned int numrel = (unsigned long)shrel->size - / (unsigned long)shrel->entsize; - unsigned int i; - - uint32_t virtoffset; - - struct symbol *SysBase_sym = (void *)0; - - for (i = 0; i < numrel; i++, rel++) - { - struct symbol *sym = &symtab[ELF32_R_SYM(rel->info)]; - uint32_t *p = (uint32_t *) & section[rel->offset]; - uint32_t s; - virtoffset = virt; - - /* - * R_ARM_V4BX are actually special marks for the linker. - * They even never have a target (shindex == SHN_UNDEF), - * so we simply ignore them before doing any checks. - */ - if (ELF_R_TYPE(rel->info) == R_ARM_V4BX) - continue; - - switch (sym->shindex) - { - case SHN_UNDEF: - kprintf - ("[ELF Loader] Undefined symbol '%s' in section '%s'\n", - (char *)((uint32_t) sh[shsymtab->link].addr) + - sym->name, - (char *)((uint32_t) sh[eh->shstrndx].addr) + - toreloc->name); - return 0; - - case SHN_COMMON: - kprintf - ("[ELF Loader] COMMON symbol '%s' in section '%s'\n", - (char *)((uint32_t) sh[shsymtab->link].addr) + - sym->name, - (char *)((uint32_t) sh[eh->shstrndx].addr) + - toreloc->name); - - return 0; - - case SHN_ABS: - if (SysBase_sym == (void *)0) { - if (strncmp - ((char *)((uint32_t) sh[shsymtab->link]. - addr) + sym->name, "SysBase", - 8) == 0) { - SysBase_sym = sym; - goto SysBase_yes; - } else - goto SysBase_no; - } else if (SysBase_sym == sym) { - SysBase_yes: s = (uint32_t) 4UL; - virtoffset = 0; - } else - SysBase_no: s = sym->value; - break; - default: - s = (uint32_t) sh[sym->shindex].addr + sym->value; - } - switch (ELF32_R_TYPE(rel->info)) { - - // case R_386_32: /* 32bit direct/absolute */ - // *p += s + virtoffset; - // break; - - case R_ARM_CALL: - case R_ARM_JUMP24: - case R_ARM_PC24: - { - /* On ARM the 24 bit offset is shifted by 2 to the right */ - signed long offset = (*p & 0x00ffffff) << 2; - /* If highest bit set, make offset negative */ - if (offset & 0x02000000) - offset -= 0x04000000; - - offset += s - (ULONG)p; - - offset >>= 2; - *p &= 0xff000000; - *p |= offset & 0x00ffffff; - } - break; - - - case R_ARM_MOVW_ABS_NC: - case R_ARM_MOVT_ABS: - { - signed long offset = *p; - offset = ((offset & 0xf0000) >> 4) | (offset & 0xfff); - offset = (offset ^ 0x8000) - 0x8000; - - offset += s + virtoffset; - - if (ELF_R_TYPE(rel->info) == R_ARM_MOVT_ABS) - offset >>= 16; - - *p &= 0xfff0f000; - *p |= ((offset & 0xf000) << 4) | (offset & 0x0fff); - } - break; - - case R_ARM_ABS32: /* PC relative 32 bit signed */ - *p += s + virtoffset; - break; - - case R_ARM_NONE: /* No reloc */ - break; - - default: - kprintf("[BOOT] Unknown relocation %d in ELF file\n", - ELF32_R_TYPE(rel->info)); - return 0; - } - } - return 1; - -} - -int loadElf(void *elf_file) -{ - struct elfheader *eh = (struct elfheader *)elf_file; - uint32_t s_ro = 0; - uint32_t s_rw = 0; - - kprintf("[BOOT] loadElf(%p)\n", eh); - - if (checkHeader(eh)) - { - struct sheader *sh = (struct sheader *)((intptr_t)elf_file + eh->shoff); - int i; - - for (i = 0; i < int_shnum; i++) - { - /* Load the symbol and string tables */ - if (sh[i].type == SHT_SYMTAB || sh[i].type == SHT_STRTAB) - { - sh[i].addr = (unsigned long)elf_file + sh[i].offset; - } - /* Does the section require memoy allcation? */ - else if (sh[i].flags & SHF_ALLOC) - { - /* Yup, it does. Load the hunk */ - if (!load_hunk(elf_file, &sh[i])) { - return 0; - } else { - if (sh[i].size) { - kprintf("[BOOT] ELF: %s section loaded at %p (Virtual addr: %p-%p)\n", - sh[i].flags & SHF_WRITE ? "RW":"RO", - sh[i].addr, - sh[i].addr + virtoffset, - sh[i].addr + sh[i].size + virtoffset); - } - } - } - } - - /* For every loaded section perform the relocations */ - for (i = 0; i < int_shnum; i++) - { - if (sh[i].type == SHT_REL && sh[sh[i].info].addr) - { - sh[i].addr = (uint32_t) elf_file + sh[i].offset; - if (!sh[i].addr || !relocate(eh, sh, i, virtoffset)) - { - return 0; - } - } - } - } -} - diff --git a/arch/arm-sun4i/boot/elf.h b/arch/arm-sun4i/boot/elf.h deleted file mode 100644 index 3f6e1e5766..0000000000 --- a/arch/arm-sun4i/boot/elf.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright © 2014, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ - -#ifndef ELF_H_ -#define ELF_H_ - -#include - -struct bss_tracker { - void *addr; - unsigned int length; -}; - -extern struct bss_tracker tracker[]; - -int getElfSize(void *elf_file, uint32_t *size_rw, uint32_t *size_ro); -void initAllocator(uintptr_t addr_ro, uintptr_t addr_rw, uintptr_t virtoffset); -int loadElf(void *elf_file); - -#define ELF32_R_SYM(val) ((val) >> 8) -#define ELF32_R_TYPE(val) ((val) & 0xff) -#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) - -#endif /* ELF_H_ */ diff --git a/arch/arm-sun4i/boot/ldscript.lds b/arch/arm-sun4i/boot/ldscript.lds deleted file mode 100644 index c70b8e288c..0000000000 --- a/arch/arm-sun4i/boot/ldscript.lds +++ /dev/null @@ -1,68 +0,0 @@ -FORCE_COMMON_ALLOCATION -ENTRY(bootstrap) -SECTIONS -{ - . = 0x40010000; - __bootstrap_start = . ; - - .text ALIGN(4096) : - { - *(.aros.startup) - *(.text) - *(.text.*) - *(.stub) - *(.gnu.warning) - *(.gnu.linkonce.t.*) - } - - .rodata ALIGN(0x1000) : - { - *(.rodata) - *(.rodata.*) - *(.gnu.linkonce.r.*) - } - .rodata1 : { *(.rodata1) } - - .sdata2 : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) } - .sbss2 : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) } - - .data ALIGN(0x1000) : - { - *(.data) - *(.data.*) - *(.gnu.linkonce.d.*) - } - - .data1 : { *(.data1) } - .eh_frame : { KEEP (*(.eh_frame)) } - .gcc_except_table : { *(.gcc_except_table) } - - .sdata ALIGN(0x1000) : - { - *(.sdata) - *(.sdata.*) - *(.gnu.linkonce.s.*) - } - - __bss_start = . ; - - .sbss ALIGN(0x1000) : - { - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.sb.*) - *(.scommon) - } - - .bss ALIGN(0x1000) : - { - *(.bss) - *(.bss.*) - *(.gnu.linkonce.b.*) - *(COMMON) - } - - _end = . ; - - __bootstrap_end = . ; -} diff --git a/arch/arm-sun4i/boot/mmakefile.src b/arch/arm-sun4i/boot/mmakefile.src deleted file mode 100644 index 10c425d681..0000000000 --- a/arch/arm-sun4i/boot/mmakefile.src +++ /dev/null @@ -1,69 +0,0 @@ -# $Id $ -include $(TOP)/config/make.cfg - -TARGETDIR := $(GENDIR)/$(CURDIR) -FILES := boot serialdebug elf support -USER_CFLAGS := -DUSE_UBOOT -ffixed-r8 -Wall -fno-builtin -O2 -KERNEL_LDFLAGS = - -#MM sun4i-bootfiles: \ -#MM kernel-sun4i-arm \ -#MM kernel-image-sun4i-arm - -#MM kernel-image-sun4i-arm: \ -#MM kernel-package-sun4i-arm - -#MM kernel-package-sun4i-arm: \ -#MM kernel-oop \ -#MM kernel-utility \ -#MM hidd-i2c - -PKG_LIBS := oop utility -PKG_RSRC := -PKG_DEVS := -PKG_HANDLERS := -PKG_HIDDS := i2c -PKG_CLASSES := - -%make_package mmake=kernel-package-sun4i-arm file=$(AROSDIR)/boot/kernel.pkg \ - libs=$(PKG_LIBS) res=$(PKG_RSRC) devs=$(PKG_DEVS) handlers=$(PKG_HANDLERS) \ - hidds=$(PKG_HIDDS) classes=$(PKG_CLASSES) - -kernel-image-sun4i-arm: - mkimage -A arm -O linux -T ramdisk -C none -n "AROS rom" -d $(AROSDIR)/boot/kernel.pkg $(AROSDIR)/boot/uInitrd-aros - rm -f $(AROSDIR)/boot/kernel.pkg - -sun4i-bootfiles: $(AROSDIR)/boot/arosboot - -$(AROSDIR)/boot/arosboot: $(TARGETDIR)/kernel.bin.o $(foreach f, $(FILES), $(TARGETDIR)/$(f).o $(TARGETDIR)/$(f).d) - $(KERNEL_LD) -s --entry=bootstrap --script=$(SRCDIR)/$(CURDIR)/ldscript.lds $(foreach f, $(FILES), $(TARGETDIR)/$(f).o) $(TARGETDIR)/kernel.bin.o -Map=$(AROSDIR)/kernel.map -L$(AROS_LIB) -lstdc.static -laeabi -o $@ - $(OBJCOPY) -O binary $@ $@.bin - gzip $@.bin - mv $@.bin.gz $@.bin - mkimage -A arm -O linux -T kernel -C gzip -a 0x40010000 -n "AROS Boot" -d $@.bin $(AROSDIR)/boot/uImage-aros - rm -f $@.bin - rm -f $@ - -$(TARGETDIR)/kernel.bin.o: $(OSGENDIR)/boot/aros-sun4i.elf - cp $(OSGENDIR)/boot/aros-sun4i.elf $(TARGETDIR)/kernel.bin - cp $(SRCDIR)/$(CURDIR)/uEnv.txt $(AROSDIR) - cd $(TARGETDIR) && $(KERNEL_LD) $(KERNEL_LDFLAGS) -r --format binary --oformat elf32-littlearm kernel.bin -o $@ - -#MM -clean :: - -$(RM) $(TESTS) - -$(TARGETDIR)/%.o : %.c - %compile_q - -$(TARGETDIR)/%.o : %.S - %compile_q - -$(TARGETDIR)/%.d : %.c - %mkdepend_q - -DEPS := $(foreach f, $(FILES), $(TARGETDIR)/$(f).d) - --include $(DEPS) - -%common diff --git a/arch/arm-sun4i/boot/serialdebug.c b/arch/arm-sun4i/boot/serialdebug.c deleted file mode 100644 index 824ad65ad8..0000000000 --- a/arch/arm-sun4i/boot/serialdebug.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright © 2014, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ - -#include -#include - -#include -#include - -static inline void waitBusy() { - volatile struct UART *UARTDEBUG; - UARTDEBUG = SUN4I_UARTDEBUG_BASE; - - while ((UARTDEBUG->LSR & LSR_THRE) == 0); -} - -static inline void putByte(uint8_t chr) { - volatile struct UART *UARTDEBUG; - UARTDEBUG = SUN4I_UARTDEBUG_BASE; - - UARTDEBUG->THR = (uint32_t) chr; -// if (chr == '\n') { -// UARTDEBUG->THR = (uint32_t) '\r'; -// } -} - -void putBytes(const char *str) { - while(*str) { - waitBusy(); - putByte(*str++); - } -} - -void kprintf(const char *format, ...) { - char tmpbuf[512]; - char *out = tmpbuf; - - va_list vp; - - va_start(vp, format); - vsnprintf(tmpbuf, 511, format, vp); - va_end(vp); - - putBytes(out); -} diff --git a/arch/arm-sun4i/boot/support.c b/arch/arm-sun4i/boot/support.c deleted file mode 100644 index b9cb918bc2..0000000000 --- a/arch/arm-sun4i/boot/support.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright © 2014, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ - -#include "boot.h" - -#include - -void arm_flush_cache(uint32_t addr, uint32_t length) { - while (length) { - __asm__ __volatile__("mcr p15, 0, %0, c7, c14, 1"::"r"(addr)); - addr += 32; - length -= 32; - } - __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4"::"r"(addr)); -} - -void arm_icache_invalidate(uint32_t addr, uint32_t length) { - while (length) { - __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 1"::"r"(addr)); - addr += 32; - length -= 32; - } - __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4"::"r"(addr)); -} - -void arm_dcache_invalidate(uint32_t addr, uint32_t length) { - while (length) { - __asm__ __volatile__("mcr p15, 0, %0, c7, c6, 1"::"r"(addr)); - addr += 32; - length -= 32; - } - __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4"::"r"(addr)); -} - -int32_t strlen(const char *c) { - int32_t result = 0; - while (*c++) - result++; - - return result; -} - -const char *remove_path(const char *in) { - const char *p = &in[strlen(in)-1]; - while (p > in && p[-1] != '/' && p[-1] != ':') p--; - return p; -} diff --git a/arch/arm-sun4i/boot/uEnv.txt b/arch/arm-sun4i/boot/uEnv.txt deleted file mode 100644 index bdced75d8f..0000000000 --- a/arch/arm-sun4i/boot/uEnv.txt +++ /dev/null @@ -1,4 +0,0 @@ -bootargs=debug=serial0 -bootcmd=mmc rescan; fatload mmc 0 0x48000000 boot/uImage-aros; fatload mmc 0 0x49000000 boot/uInitrd-aros; bootm 0x48000000 0x49000000 -uenvcmd=boot - -- 2.11.4.GIT