From 550f83e0a6d2d22dcab28b8e598b6907c6fe7732 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 30 Aug 2016 20:42:04 +0100 Subject: [PATCH] platform-v68: initial pieces to get it to build/begin booting --- Kernel/platform-v68/Makefile | 11 ++--- Kernel/platform-v68/crt0.S | 19 +++++++- Kernel/platform-v68/fuzix.ld | 87 ++++++++++++++++++++++++++++++++++++ Kernel/platform-v68/main.c | 48 +++++++++++++++++++- 4 files changed, 156 insertions(+), 9 deletions(-) create mode 100644 Kernel/platform-v68/fuzix.ld diff --git a/Kernel/platform-v68/Makefile b/Kernel/platform-v68/Makefile index 4e61033d..9e730d2a 100644 --- a/Kernel/platform-v68/Makefile +++ b/Kernel/platform-v68/Makefile @@ -6,11 +6,11 @@ ASRCS = p68000.S crt0.S ASRCS += tricks.S DSRCS = ../dev/devide.c ../dev/mbr.c ../dev/blkdev.c ../dev/devide_discard.c -DOBJS = $(patsubst ../dev/%.c,%.rel, $(DSRCS)) +DOBJS = $(patsubst ../dev/%.c,%.o, $(DSRCS)) COBJS = $(CSRCS:.c=$(BINEXT)) AOBJS = $(ASRCS:.S=.o) -OBJS = $(COBJS) $(AOBJS) +OBJS = $(COBJS) $(AOBJS) $(DOBJS) CROSS_CCOPTS += -I../dev/ @@ -24,19 +24,20 @@ $(COBJS): %.o: %.c $(AOBJS): %.o: %.S $(CROSS_AS) $(ASOPTS) $< -o $*.o -$(DOBJS): %.rel: ../dev/%.c +$(DOBJS): %.o: ../dev/%.c $(CROSS_CC) $(CROSS_CCOPTS) -c $< clean: rm -f $(OBJS) $(JUNK) core *~ image: - $(CROSS_LD) -M -o ../fuzix.bin \ + $(CROSS_LD) -M -o fuzix.elf -T fuzix.ld \ crt0.o \ p68000.o ../start.o ../version.o ../lowlevel-68000.o \ tricks.o main.o ../timer.o ../kdata.o devices.o \ ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \ ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o ../buddy.o \ ../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o \ - ../syscall_fs3.o ../syscall_exec32.o \ + ../syscall_fs3.o ../syscall_exec32.o blkdev.o devide.o devide_discard.o mbr.o \ ../usermem_std-68000.o devtty.o libc.o ../malloc.o > ../fuzix.map + m68k-linux-gnu-objcopy fuzix.elf -O binary ../fuzix.bin diff --git a/Kernel/platform-v68/crt0.S b/Kernel/platform-v68/crt0.S index 65a4e325..959abcd4 100644 --- a/Kernel/platform-v68/crt0.S +++ b/Kernel/platform-v68/crt0.S @@ -5,13 +5,28 @@ * supervisor stack below us. We are in supervisor mode and the rest * is our problem. */ - .globl _start -.mri 1 + .globl __end + .globl __bss_start +.mri 1 + byte $15 + byte $05 + byte $C0 + byte $DE start: or #$0700,sr + move.l #__bss_start,a0 + move.l #__end,d0 + sub.l a0,d0 + lsr.l #2,d0 +wipebss: + clr.l (a0)+ + dbra d0,wipebss + /* FIXME: hard coded ugly */ move.l #uarea_block+508,a7 + /* uarea global */ + move.l #uarea_block,a5 bsr init_early bsr init_hardware bsr fuzix_main diff --git a/Kernel/platform-v68/fuzix.ld b/Kernel/platform-v68/fuzix.ld new file mode 100644 index 00000000..b02ba91e --- /dev/null +++ b/Kernel/platform-v68/fuzix.ld @@ -0,0 +1,87 @@ +STARTUP(crt0.o) +OUTPUT_ARCH(m68k) + +SEARCH_DIR(.) + +MEMORY +{ + ram (rwx) : ORIGIN = 0x2000, LENGTH = 0x80000-0x2000 +} + +/* + * stick everything in ram (of course) + */ +SECTIONS +{ + .text : + { + CREATE_OBJECT_SYMBOLS + *(.text .text.*) + + . = ALIGN(0x4); + /* These are for running static constructors and destructors under ELF. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + + *(.rodata .rodata.*) + + . = ALIGN(0x4); + *(.gcc_except_table) + + . = ALIGN(0x4); + *(.eh_frame) + + . = ALIGN(0x4); + __INIT_SECTION__ = . ; + LONG (0x4e560000) /* linkw %fp,#0 */ + *(.init) + SHORT (0x4e5e) /* unlk %fp */ + SHORT (0x4e75) /* rts */ + + . = ALIGN(0x4); + __FINI_SECTION__ = . ; + LONG (0x4e560000) /* linkw %fp,#0 */ + *(.fini) + SHORT (0x4e5e) /* unlk %fp */ + SHORT (0x4e75) /* rts */ + + . = ALIGN(0x4); + _etext = .; + *(.lit) + } > ram + + .data : + { + *(.got.plt) *(.got) + *(.shdata) + *(.data .data.*) + _edata = .; + } > ram + + .bss : + { + . = ALIGN(0x4); + __bss_start = . ; + *(.shbss) + *(.bss .bss.*) + *(COMMON) + _end = ALIGN (0x8); + __end = _end; + } > ram + + .stab 0 (NOLOAD) : + { + *(.stab) + } + + .stabstr 0 (NOLOAD) : + { + *(.stabstr) + } +} diff --git a/Kernel/platform-v68/main.c b/Kernel/platform-v68/main.c index ba9456e6..97b47d3c 100644 --- a/Kernel/platform-v68/main.c +++ b/Kernel/platform-v68/main.c @@ -3,6 +3,7 @@ #include #include #include +#include void platform_idle(void) { @@ -20,7 +21,7 @@ void do_beep(void) void pagemap_init(void) { /* Allocate the buddy tables and init them */ - buddy_init(); +//FIXME buddy_init(); } void map_init(void) @@ -29,6 +30,8 @@ void map_init(void) u_block uarea_block[PTABSIZE]; uaddr_t ramtop; +uint8_t *membase[PTABSIZE]; +uint8_t need_resched; /* Offsets into the buddy map for each level, byte aligned */ const uint16_t buddy_level[BUDDY_NUMLEVEL] = { @@ -55,8 +58,9 @@ int16_t dofork(ptptr p) uint32_t *csp = (uint32_t *)(uc + 1); uint32_t *psp = up->u_sp; /* Duplicate the memory maps */ + /* FIXME if (pagemap_fork(p)) - return -1; + return -1; */ /* Duplicate the udata */ memcpy(&uc, &up, sizeof(struct u_data)); /* Use the child udata for initializing the child */ @@ -75,3 +79,43 @@ int16_t dofork(ptptr p) udata.u_ptab->p_status = P_RUNNING; return p->p_pid; } + +/* All our binaries are zero address based */ + +void *pagemap_base(void) +{ + return 0; +} + +void program_mmu(uint8_t *phys, usize_t top) +{ +} + +uint8_t platform_param(unsigned char *p) +{ + return 0; +} + +void platform_discard(void) +{ +} + +void memzero(void *p, usize_t len) +{ + memset(p, 0, len); +} + +/* TODO */ +void devide_read_data(void) +{ +} + +void devide_write_data(void) +{ +} + +/* FIXME: move to asm and lowlevel- */ +uint16_t swab(uint16_t a) +{ + return (a << 8) | (a >> 8); +} -- 2.34.1