Skip to content
Snippets Groups Projects
Commit cb380290 authored by Armin Luntzer's avatar Armin Luntzer
Browse files

saving changes: custom boot code

parent dc3620db
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,10 @@ NAME = Zombeaver ...@@ -12,7 +12,10 @@ NAME = Zombeaver
# #
# set default ARCH # set default ARCH
ifndef SRCARCH
SRCARCH = sparc SRCARCH = sparc
endif
ARCH = $(SRCARCH)
export SRCARCH export SRCARCH
# o Do not use make's built-in rules and variables # o Do not use make's built-in rules and variables
...@@ -614,7 +617,7 @@ leanos-libs := $(patsubst %/, %/lib.a, $(libs-y)) ...@@ -614,7 +617,7 @@ leanos-libs := $(patsubst %/, %/lib.a, $(libs-y))
# Externally visible symbols (used by link-leanos.sh) # Externally visible symbols (used by link-leanos.sh)
export KBUILD_LEANOS_INIT := $(leanos-init) export KBUILD_LEANOS_INIT := $(leanos-init)
export KBUILD_LEANOS_MAIN := $(leanos-core) $(leanos-kernel) $(leanos-libs) export KBUILD_LEANOS_MAIN := $(leanos-core) $(leanos-kernel) $(leanos-libs)
export KBUILD_LDS := arch/$(SRCARCH)/kernel/leanos.lds export KBUILD_LDS := arch/$(SRCARCH)/kernel/kernel.lds
export LDFLAGS_leanos export LDFLAGS_leanos
......
...@@ -48,6 +48,27 @@ config EXTRA_SPARC_PHYS_BANKS ...@@ -48,6 +48,27 @@ config EXTRA_SPARC_PHYS_BANKS
Set number of additional physical memory banks if the machine has more Set number of additional physical memory banks if the machine has more
than one. than one.
config SPARC_CPU_REG_WINDOWS
int "Number of implemented SPARC register windows"
default 8
range 1 32
help
Set the number of register windows implemented in the CPU.
config SPARC_TEXT_START
hex "Address of .text section"
default 0x40000000
help
Set the start address of the .text section. The address of the
built-in SRAM might be a good choice.
config SPARC_FP_START
hex "Initial address of the frame pointer"
default 0x40100000
help
Set the initial frame pointer address. The start of the .text
section plus 1 MiB is usually a safe bet.
menu "Memory Management Settings" menu "Memory Management Settings"
depends on MM depends on MM
depends on CHUNK depends on CHUNK
......
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _SPARC_HEAD_H
#define _SPARC_HEAD_H
#define SPARC_TRAP_TFLT 0x1 /* Text fault */
#define SPARC_TRAP_II 0x2 /* Illegal Instruction */
#define SPARC_TRAP_PI 0x3 /* Privileged Instruction */
#define SPARC_TRAP_FPD 0x4 /* Floating Point Disabled */
#define SPARC_TRAP_WOVF 0x5 /* Window Overflow */
#define SPARC_TRAP_WUNF 0x6 /* Window Underflow */
#define SPARC_TRAP_MNA 0x7 /* Memory Address Unaligned */
#define SPARC_TRAP_FPE 0x8 /* Floating Point Exception */
#define SPARC_TRAP_DFLT 0x9 /* Data Fault */
#define SPARC_TRAP_TOF 0xa /* Tag Overflow */
#define SPARC_TRAP_WPDT 0xb /* Watchpoint Detected */
#define SPARC_TRAP_IRQ1 0x11 /* IRQ level 1 */
#define SPARC_TRAP_IRQ2 0x12 /* IRQ level 2 */
#define SPARC_TRAP_IRQ3 0x13 /* IRQ level 3 */
#define SPARC_TRAP_IRQ4 0x14 /* IRQ level 4 */
#define SPARC_TRAP_IRQ5 0x15 /* IRQ level 5 */
#define SPARC_TRAP_IRQ6 0x16 /* IRQ level 6 */
#define SPARC_TRAP_IRQ7 0x17 /* IRQ level 7 */
#define SPARC_TRAP_IRQ8 0x18 /* IRQ level 8 */
#define SPARC_TRAP_IRQ9 0x19 /* IRQ level 9 */
#define SPARC_TRAP_IRQ10 0x1a /* IRQ level 10 */
#define SPARC_TRAP_IRQ11 0x1b /* IRQ level 11 */
#define SPARC_TRAP_IRQ12 0x1c /* IRQ level 12 */
#define SPARC_TRAP_IRQ13 0x1d /* IRQ level 13 */
#define SPARC_TRAP_IRQ14 0x1e /* IRQ level 14 */
#define SPARC_TRAP_IRQ15 0x1f /* IRQ level 15 Non-maskable */
#define SPARC_TRAP_RAC 0x20 /* Register Access Error ??? */
#define SPARC_TRAP_IAC 0x21 /* Instruction Access Error */
#define SPARC_TRAP_CPDIS 0x24 /* Co-Processor Disabled */
#define SPARC_TRAP_BADFL 0x25 /* Unimplemented Flush Instruction */
#define SPARC_TRAP_CPEX 0x28 /* Co-Processor Exception */
#define SPARC_TRAP_DACC 0x29 /* Data Access Error */
#define SPARC_TRAP_DIVZ 0x2a /* Divide By Zero */
#define SPARC_TRAP_DSTORE 0x2b /* Data Store Error (?) */
#define SPARC_TRAP_DMM 0x2c /* Data Access MMU Miss (?) */
#define SPARC_TRAP_IMM 0x3c /* Instruction Access MMU Miss (?) */
#define PSR_PS 0x00000040 /* previous privilege level */
#define TTBL_MASK 0xff0 /* trap type mask from tbr */
#define TTBL_SHIFTLEFT 4 /* shift to get a tbr value */
#define TRAP_ENTRY(type, label) rd %psr, %l0; b label; rd %wim, %l3; nop;
#define SRMMU_TFAULT rd %psr, %l0; rd %wim, %l3; b srmmu_fault; mov 1, %l7;
#define SRMMU_DFAULT rd %psr, %l0; rd %wim, %l3; b srmmu_fault; mov 0, %l7;
#define WINDOW_OFLOW \
rd %psr, %l0; rd %wim, %l3; b __wim_overflow; andcc %l0, PSR_PS, %g0;
#define WINDOW_UFLOW \
rd %psr, %l0; rd %wim, %l3; b __wim_underflow; andcc %l0, PSR_PS, %g0;
/* either this */
#define TRAP_EXCEPTION \
rd %tbr, %l3; rd %psr, %l0; ba __exception_entry; and %l3, TTBL_MASK, %l4;
/* or this one */
#define TRAP_BAD(num) \
rd %psr, %l0; mov num, %l7; b bad_trap_handler; rd %wim, %l3;
#define TRAP_INTERRUPT(level) \
rd %psr, %l0; mov level, %l7; b __interrupt_entry; rd %wim, %l3;
/* system calls software trap */
#define SYSCALL_TRAP \
sethi %hi(syscall_tbl), %l7; \
or %l7, %lo(syscall_tbl), %l7; \
b syscall_trap; \
rd %psr, %l0;
#endif /* _SPARC_HEAD_H */
...@@ -32,9 +32,9 @@ extern struct sparc_physical_banks sp_banks[SPARC_PHYS_BANKS + 1]; ...@@ -32,9 +32,9 @@ extern struct sparc_physical_banks sp_banks[SPARC_PHYS_BANKS + 1];
/* linker symbol marking the the start of the program (image) */ /* linker symbol marking the the start of the program (image) */
extern char start[]; extern char _start[];
/* linker symbol marking the the end of the program */ /* linker symbol marking the the end of the program */
extern char end[]; extern char _end[];
/* The default configuration allows for at most 32 MiB sized blocks /* The default configuration allows for at most 32 MiB sized blocks
......
CHECKFLAGS += -D__sparc__ CHECKFLAGS += -D__sparc__
extra-$(CONFIG_ARCH_CUSTOM_BOOT_CODE) += kernel.lds
obj-$(CONFIG_ARCH_CUSTOM_BOOT_CODE) += ttable.o
obj-$(CONFIG_ARCH_CUSTOM_BOOT_CODE) += head.o
obj-y += setup.o obj-y += setup.o
obj-y += init.o obj-y += init.o
...@@ -18,3 +20,4 @@ obj-y += traps/data_access_exception.o ...@@ -18,3 +20,4 @@ obj-y += traps/data_access_exception.o
obj-y += irq.o obj-y += irq.o
#libs-y += lib/ #libs-y += lib/
...@@ -145,20 +145,20 @@ void bootmem_init(void) ...@@ -145,20 +145,20 @@ void bootmem_init(void)
struct page_map_node **pg_node; struct page_map_node **pg_node;
pr_info("BOOTMEM: start of program image at %p\n", start); pr_info("BOOTMEM: start of program image at %p\n", _start);
pr_info("BOOTMEM: end of program image at %p\n", end); pr_info("BOOTMEM: end of program image at %p\n", _end);
/* lowest page frame number coincides with page aligned address /* lowest page frame number coincides with page aligned address
* start symbol in image, which hopefully coincides with the start * start symbol in image, which hopefully coincides with the start
* of the RAM we are running from. * of the RAM we are running from.
*/ */
start_img_pfn = PAGE_ALIGN((unsigned long) &start); start_img_pfn = PAGE_ALIGN((unsigned long) &_start);
/* start allocatable memory with page aligned address of last symbol in /* start allocatable memory with page aligned address of last symbol in
* image, everything before will be reserved * image, everything before will be reserved
*/ */
start_pfn = PAGE_ALIGN((unsigned long) &end); start_pfn = PAGE_ALIGN((unsigned long) &_end);
/* locate the memory bank we're in /* locate the memory bank we're in
*/ */
......
#ifndef CONFIG_SPARC_CPU_REG_WINDOWS
#define NWINDOWS 8
#else
#define NWINDOWS CONFIG_SPARC_CPU_REG_WINDOWS
#endif /* CONFIG_SPARC_CPU_REG_WINDOWS */
#ifndef CONFIG_SPARC_FP_START
#define FP_INITIAL 0x40100000
#else
#define FP_INITIAL CONFIG_SPARC_FP_START
#endif /* CONFIG_SPARC_FP_START */
.global kernel_entry
kernel_entry:
/* First, we set the address of our trap table. The base address is
* stored in bits 31:12 of the trap base register. The remaining fields
* are not affected by a WRTBR. In any case, the trap table must be
* aligned to a 4k boundary, so the bits 11:0 must be zero anyways or
* we are surely boned.
*/
sethi %hi(trapbase), %g1
or %g1, %lo(trapbase), %g1
mov %g1, %tbr ! delayed-write instruction
/* WRTBR is a delayed-write instruction (0-3 cycles, impl.dependent),
* but we won't access it in the next cycles, so we may continue without
* inserting (3) nops.
*/
/* Now we initialise the window invalid mask to detect under/overflows.
* We set the highest-value window to be invalid.
*/
mov (1 << (NWINDOWS - 1)), %g1
mov %g1, %wim ! delayed-write instruction
/* Initially, we want to start out in the window just below the one
* marked invalid, so we can SAVE up to NWINDOWS - 2 times.
* This is because any subsequent function call (resulting in increasing
* call depth) will require a SAVE instruction, which will in
* turn decrement the current window pointer in the PSR. If the CWP
* reaches the invalid window while increasing the call depth, an
* overflow trap will be generated. If a RESTORE reaches the invalid
* window due to decreasing call depth and incrementing CWP value,
* a underflow trap will occur.
*
* See the SPARCv8 User Manual pp.28 for the other set bits
*/
sethi %hi(0x00001fc0), %g1
or %g1, %lo(0x00001fc0 | (NWINDOWS - 2)), %g1
mov %g1, %psr ! delayed-write instruction
/* Prepare a C call-stack. Minimum size is 96 bytes, however older
* compilers may reserve 104. We want make sure to support the MPPB's
* GCC 3.x, so we'll go with the slightly larger window size here.
*/
sethi %hi(FP_INITIAL), %g2
or %g2, %lo(FP_INITIAL), %g2
mov %g2, %fp
sub %fp, 104, %sp ! create a new frame
/* We have a stack now, so we can start handling traps. */
or %g1, 0x00000020, %g1
mov %g1, %psr ! delayed-write instruction
call do_basic_setup
nop
call kernel_main
nop
/* ld script for sparc32 kernel */
/* based on macros from linux/include/asm-generic/vmlinux.lds.h */
#define INITIAL_ADDRESS 0x00000000 /* rom */
#ifndef CONFIG_SPARC_TEXT_START
#define TEXTSTART 0x40000000 /* default ram */
#else
#define TEXTSTART CONFIG_SPARC_TEXT_START
#endif /* CONFIG_SPARC_TEXT_START */
OUTPUT_FORMAT("elf32-sparc", "elf32-sparc", "elf32-sparc")
OUTPUT_ARCH(sparc)
ENTRY(_start)
SECTIONS
{
. = INITIAL_ADDRESS;
.text TEXTSTART :
{
_text = .;
*(.head.text)
*.(text .text.*)
*(.gnu.warning)
} = 0
_etext = .;
. = ALIGN(16);
.rodata : {
__start_rodata = .;
*(.rodata) *(.rodata.*)
}
/* start of data section */
_sdata = .;
.data : {
*(.data .data.*)
}
/* end of data section */
_edata = .;
. = ALIGN(16);
__init_begin = .;
.init.data : {
/* linux-style init calls */
__initcall_start = .;
KEEP(*(.initcall1.init))
KEEP(*(.initcall2.init))
KEEP(*(.initcall3.init))
KEEP(*(.initcall4.init))
KEEP(*(.initcall5.init))
KEEP(*(.initcall6.init))
KEEP(*(.initcall7.init))
__initcall_end = .;
}
__init_end = .;
. = ALIGN(8);
__bss_start = .;
. = ALIGN(8);
.bss : {
*(.bss .bss.*)
*(COMMON)
}
. = ALIGN(8);
__bss_stop = .;
_end = . ;
. = ALIGN(16);
.eh_frame : {*(.eh_frame)}
.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) }
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.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) }
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
.debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) }
.debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) }
.debug_types 0 : { *(.debug_types) }
.debug_macro 0 : { *(.debug_macro) }
.debug_addr 0 : { *(.debug_addr) }
}
/* SPDX-License-Identifier: GPL-2.0 */
#include <asm/ttable.h>
.section ".head.text","ax"
.global _start
_start:
.global _stext
_stext:
.global trapbase
trapbase:
#ifdef CONFIG_SMP
trapbase_cpu0:
#endif /* CONFIG_SMP */
/* hardware traps (128 total) */
! 0x00 reset trap (alternative: b gokernel; nop; nop; nop)
b kernel_entry ! branch once on cold start, post setup inserts rd %tbr/%psr (see TRAP_EXCEPTION)
nop ! instructions to raise exception on warm reset
ba __exception_entry
and %l3, TTBL_MASK, %l4
SRMMU_TFAULT
TRAP_ENTRY(SPARC_TRAP_II, ill_instruction_trap_handler)
TRAP_ENTRY(SPARC_TRAP_PI, priv_instruction_trap_handler)
TRAP_ENTRY(SPARC_TRAP_FPD, fpdis_trap_handler)
WINDOW_OFLOW
WINDOW_UFLOW
TRAP_ENTRY(SPARC_TRAP_MNA, mna_trap_handler)
TRAP_ENTRY(SPARC_TRAP_FPE, fpe_trap_handler)
SRMMU_DFAULT ! Data Fault
TRAP_ENTRY(SPARC_TRAP_TOF, tag_overflow_trap_handler)
TRAP_ENTRY(SPARC_TRAP_WPDT, watchpoint_det_trap_handler)
.rept 5
TRAP_EXCEPTION ! bad traps
.endr
TRAP_INTERRUPT(1)
TRAP_INTERRUPT(2)
TRAP_INTERRUPT(3)
TRAP_INTERRUPT(4)
TRAP_INTERRUPT(5)
TRAP_INTERRUPT(6)
TRAP_INTERRUPT(7)
TRAP_INTERRUPT(8)
TRAP_INTERRUPT(9)
TRAP_INTERRUPT(10)
TRAP_INTERRUPT(11)
TRAP_INTERRUPT(12)
TRAP_INTERRUPT(13)
TRAP_INTERRUPT(14)
TRAP_ENTRY(15, nmi_entry) ! treat NMI interrupt differntly
TRAP_ENTRY(SPARC_TRAP_RAC, reg_access_trap_handler)
TRAP_EXCEPTION ! Instruction Access Error
TRAP_EXCEPTION ! bad trap
TRAP_EXCEPTION ! bad trap
TRAP_ENTRY(SPARC_TRAP_CPDIS, cpdis_trap_handler)
TRAP_ENTRY(SPARC_TRAP_BADFL, unimpl_flush_trap_handler)
TRAP_EXCEPTION ! bad trap
TRAP_EXCEPTION ! bad trap
TRAP_ENTRY(SPARC_TRAP_CPEX, cpex_trap_handler)
SRMMU_DFAULT ! Data Access Error
TRAP_ENTRY(SPARC_TRAP_DIVZ, hw_div0_trap_handler)
TRAP_EXCEPTION ! Data Store Error
TRAP_EXCEPTION ! Data Access MMU Miss
.rept 15
TRAP_EXCEPTION ! bad traps
.endr
TRAP_EXCEPTION ! Instruction Access MMU Miss
.rept 67
TRAP_EXCEPTION ! bad traps
.endr
/* software traps (128 total) */
SYSCALL_TRAP ! 0x80 = SunOS syscall()
TRAP_EXCEPTION ! 0x81
TRAP_EXCEPTION ! 0x82
TRAP_EXCEPTION ! 0x83
TRAP_EXCEPTION ! 0x84
TRAP_EXCEPTION ! 0x85
.rept 122
TRAP_EXCEPTION ! 0x86-0xFF unused
.endr
.globl end_traptable
end_traptable:
#ifdef CONFIG_SMP
.globl trapbase_cpu1
trapbase_cpu1:
/* XXX: stuff */
#endif /* CONFIG_SMP */
.global leonbare_trapsetup
leonbare_trapsetup:
.global catch_interrupt
catch_interrupt:
.global coldboot_reset
coldboot_reset:
.global __exception_entry
__exception_entry:
.global srmmu_fault
srmmu_fault:
.global ill_instruction_trap_handler
ill_instruction_trap_handler:
.global priv_instruction_trap_handler
priv_instruction_trap_handler:
.global leonbare_trapreturn
leonbare_trapreturn:
.global fpdis_trap_handler
fpdis_trap_handler:
.global __wim_overflow
__wim_overflow:
.global __wim_underflow
__wim_underflow:
.global mna_trap_handler
mna_trap_handler:
.global fpe_trap_handler
fpe_trap_handler:
.global tag_overflow_trap_handler
tag_overflow_trap_handler:
.global mna_trap_handler
mna_trap_handler:
.global cpdis_trap_handler
cpdis_trap_handler:
.global cpex_trap_handler
cpex_trap_handler:
.global fpe_trap_handler
fpe_trap_handler:
.global hw_div0_trap_handler
hw_div0_trap_handler:
.global __interrupt_entry
__interrupt_entry:
.global __clzsi2
__clzsi2:
.global memset
memset:
.global nmi_entry
nmi_entry:
.global reg_access_trap_handler
reg_access_trap_handler:
.global strchr
strchr:
.global strtol
strtol:
.global syscall_tbl
syscall_tbl:
.global syscall_trap
syscall_trap:
.global tag_overflow_trap_handler
tag_overflow_trap_handler:
.global .udiv
.udiv:
.global .umul
.umul:
.global unimpl_flush_trap_handler
unimpl_flush_trap_handler:
.global vprintf
vprintf:
.global vsnprintf
vsnprintf:
.global watchpoint_det_trap_handler
watchpoint_det_trap_handler:
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define _KERNEL_H_ #define _KERNEL_H_
#include <compiler.h> #include <compiler.h>
#include <kernel/printk.h>
#define ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) #define ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define ALIGN(x, a) ALIGN_MASK(x, (typeof(x))(a) - 1) #define ALIGN(x, a) ALIGN_MASK(x, (typeof(x))(a) - 1)
...@@ -12,9 +13,8 @@ ...@@ -12,9 +13,8 @@
#define panic(x) {} while(1); #define panic(x) {} while(1);
/* the BUG() macros may be repurposed to log an error and boot to safe mode! */ /* the BUG() macros may be repurposed to log an error and boot to safe mode! */
#include <stdio.h>
#define BUG() do { \ #define BUG() do { \
printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
panic("BUG!"); \ panic("BUG!"); \
} while (0) } while (0)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <compiler.h> #include <compiler.h>
#include <stddef.h> #include <stddef.h>
#include <sys/types.h>
#include <stdbool.h> #include <stdbool.h>
#ifdef __GNUC__ #ifdef __GNUC__
......
...@@ -36,11 +36,22 @@ config CROSS_COMPILE ...@@ -36,11 +36,22 @@ config CROSS_COMPILE
need to set this unless you want the configured kernel build need to set this unless you want the configured kernel build
directory to select the cross-compiler automatically. directory to select the cross-compiler automatically.
choice
prompt "Boot/Startup code"
default TARGET_COMPILER_BOOT_CODE
config TARGET_COMPILER_BOOT_CODE config TARGET_COMPILER_BOOT_CODE
bool "Use target compiler's boot/startup code" bool "Use target compiler's boot/startup code"
default y if CROSS_PLATFORM_TARGET
help help
Use the compiler-provided boot code (e.g. BCC target) Use the compiler-provided boot code (e.g. with BCC)
config ARCH_CUSTOM_BOOT_CODE
bool "Use architecture's boot/startup code"
help
Use the architecture-provided boot code
endchoice # "Boot/Startup code
endmenu # "General Setup" endmenu # "General Setup"
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#ifdef CONFIG_TARGET_COMPILER_BOOT_CODE
/** /**
* @brief kernel initialisation routines * @brief kernel initialisation routines
...@@ -54,20 +53,25 @@ static int kernel_init(void) ...@@ -54,20 +53,25 @@ static int kernel_init(void)
setup_arch(); setup_arch();
/* free_bootmem() */
/* run_init_process() */
return 0; return 0;
} }
arch_initcall(kernel_init); arch_initcall(kernel_init);
/** /**
* @brief kernel main function * @brief kernel main function
*/ */
int main(void) int kernel_main(void)
{ {
#if 0
void *addr; void *addr;
struct elf_module m; struct elf_module m;
#endif
printk(MSG "Loading module image\n"); printk(MSG "Loading module image\n");
...@@ -118,4 +122,30 @@ int main(void) ...@@ -118,4 +122,30 @@ int main(void)
return 0; return 0;
} }
#endif /* CONFIG_TARGET_COMPILER_BOOT_CODE */ #ifdef CONFIG_ARCH_CUSTOM_BOOT_CODE
extern initcall_t __initcall_start;
extern initcall_t __initcall_end;
static void do_initcalls(void)
{
initcall_t *p = &__initcall_start;
while(p < &__initcall_end) {
if (*p)
(*p)();
p++;
}
}
void do_basic_setup(void)
{
do_initcalls();
}
#endif /* CONFIG_ARCH_CUSTOM_BOOT_CODE */
...@@ -80,26 +80,20 @@ modpost_link() ...@@ -80,26 +80,20 @@ modpost_link()
leanos_link() leanos_link()
{ {
local lds="${objtree}/${KBUILD_LDS}" local lds="${objtree}/${KBUILD_LDS}"
local objects
# since we link against the BCC libc at this time, we'll just # if we link against the (BCC) libc, we'll just
# call $CC instead of LD # call $CC instead of LD
if [ -n "${CONFIG_TARGET_COMPILER_BOOT_CODE}" ]; then
${CC} ${LDFLAGS} ${LDFLAGS_leanos} ${3} -o ${2} \ ${CC} ${LDFLAGS} ${LDFLAGS_leanos} ${3} -o ${2} \
${KBUILD_LEANOS_INIT} ${KBUILD_LEANOS_MAIN} ${1} ${KBUILD_LEANOS_INIT} ${KBUILD_LEANOS_MAIN} ${1}
fi
# if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then if [ -n "${CONFIG_ARCH_CUSTOM_BOOT_CODE}" ]; then
# objects="--whole-archive built-in.o ${1}" ${LD} ${LDFLAGS} ${LDFLAGS_leanos} ${3} -o ${2} \
# else -T ${lds} ${KBUILD_LEANOS_INIT} ${KBUILD_LEANOS_MAIN} \
# objects="${KBUILD_LEANOS_INIT} \ ${1}
# --start-group \ fi
# ${KBUILD_LEANOS_MAIN} \
# --end-group \
# ${1}"
# fi
#
# ${LD} ${LDFLAGS} ${LDFLAGS_leanos} -o ${2} \
# -T ${lds} ${objects}
} }
...@@ -303,7 +297,15 @@ if [ "$1" = "embed" ]; then ...@@ -303,7 +297,15 @@ if [ "$1" = "embed" ]; then
# exit # exit
# fi # fi
if [ -n "${CONFIG_TARGET_COMPILER_BOOT_CODE}" ]; then
embedflags="-Wl,--format=binary -Wl,modules.image -Wl,--format=default" embedflags="-Wl,--format=binary -Wl,modules.image -Wl,--format=default"
fi
if [ -n "${CONFIG_ARCH_CUSTOM_BOOT_CODE}" ]; then
embedflags="--format=binary modules.image --format=default"
fi
rm -f modules.image rm -f modules.image
${AR} rcs ${srctree}/modules.image \ ${AR} rcs ${srctree}/modules.image \
$(tr '\n' ' ' < ${srctree}/modules.order) \ $(tr '\n' ' ' < ${srctree}/modules.order) \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment