From de06dba9169ff1d526f2fb989d367a43f2d34251 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 6 Feb 2015 13:40:31 +0000 Subject: [PATCH] 68000: update the atari-st beginnings, switch tool chain We now use the atari mint toolchain as it produces TOS binaries and uses the _ prefixes we expect from compilers. --- Kernel/lowlevel-68000.S | 41 ++++++++++++----------- Kernel/platform-atarist/Makefile | 3 +- Kernel/platform-atarist/config.h | 15 ++++----- Kernel/platform-atarist/crt0.S | 26 ++++++++++++--- Kernel/platform-atarist/main.c | 4 ++- Kernel/platform-atarist/p68000.S | 57 ++++++++++++++++++++++++++------ Kernel/platform-atarist/tricks.S | 30 ++++++++--------- 7 files changed, 116 insertions(+), 60 deletions(-) diff --git a/Kernel/lowlevel-68000.S b/Kernel/lowlevel-68000.S index 3c59065f..1ccc116f 100644 --- a/Kernel/lowlevel-68000.S +++ b/Kernel/lowlevel-68000.S @@ -4,14 +4,15 @@ #include "kernel-68000.def" .mri 0 - .globl di,ei,irqrestore - .globl doexec + .globl _di,_ei,_irqrestore + .globl _doexec + .globl _get_usp, _set_usp .globl outstring,outstringhex,outcharhex,outa0hex .mri 1 -get_usp: move.l usp,a0 +_get_usp: move.l usp,a0 rts -set_usp: move.l 4(sp),a0 +_set_usp: move.l 4(sp),a0 move.l a0,usp rts @@ -19,24 +20,24 @@ set_usp: move.l 4(sp),a0 * We don't currently have any fine grained IRQ control. We need to fix * that! */ -di: +_di: move.w sr,d0 and.w #$0700,d0 or.w #$0700,sr rts -ei: +_ei: and.w #$F8FF,sr rts -irqrestore: +_irqrestore: move.w sr,d0 and.w #$F8FF,d0 or.w 4(sp),d0 move.w d0,sr rts -doexec: +_doexec: ; ; FIXME: we need to reset sp (we effectively longjmp ; in supervisor space), then push the values. If we @@ -93,7 +94,7 @@ trap14: movem.l a2-a6/d2-d7,-(sp) move.b d0,kernel_flag ; FIXME: EI per platform really and.w #$F8FF,sr - bsr unix_syscall + bsr _unix_syscall ; FIXME: signal handling in the C code or not ? or.w #$0700,sr move.w U_DATA__U_ERROR,d1 @@ -129,37 +130,37 @@ struninitialized: ; #if 0 _intvector1: movem.l a0-a6/d0-d7,-(sp) - jsr _interrupt1 + bsr _interrupt1 movem.l (sp)+,a0-a6/d0-d7 rte _intvector2: movem.l a0-a6/d0-d7,-(sp) - jsr _interrupt3 + bsr _interrupt3 movem.l (sp)+,a0-a6/d0-d7 rte _intvector3: movem.l a0-a6/d0-d7,-(sp) - jsr _interrupt3 + bsr _interrupt3 movem.l (sp)+,a0-a6/d0-d7 rte _intvector4: movem.l a0-a6/d0-d7,-(sp) - jsr _interrupt4 + bsr _interrupt4 movem.l (sp)+,a0-a6/d0-d7 rte _intvector5: movem.l a0-a6/d0-d7,-(sp) - jsr _interrupt5 + bsr _interrupt5 movem.l (sp)+,a0-a6/d0-d7 rte _intvector6: movem.l a0-a6/d0-d7,-(sp) - jsr _interrupt6 + bsr _interrupt6 movem.l (sp)+,a0-a6/d0-d7 rte _intvector7: movem.l a0-a6/d0-d7,-(sp) - jsr _interrupt7 + bsr _interrupt7 movem.l (sp)+,a0-a6/d0-d7 rte #endif @@ -167,11 +168,11 @@ sig_or_die: tst.b kernel_flag beq sig_user move.b (sp),d0 - jsr outcharhex + bsr outcharhex lea panic_sig,a0 - jsr outstring + bsr outstring lea panic_sig2,a0 - jsr panic ; won't return + bsr _panic ; won't return panic_sig: ascii ": signal in kernel mode." byte 13,10 panic_sig2: asciz ": ksig" @@ -179,7 +180,7 @@ panic_sig2: asciz ": ksig" sig_user: movem.l a0-a6/d0-d7,-(sp) move.l (U_DATA__U_PTAB),-(sp) - jsr ssig + bsr _ssig adda #4,sp ; Do signal processing bit here if we return movem.l (sp)+,a0-a6/d0-d7 diff --git a/Kernel/platform-atarist/Makefile b/Kernel/platform-atarist/Makefile index fe51a1f9..6cd541fb 100644 --- a/Kernel/platform-atarist/Makefile +++ b/Kernel/platform-atarist/Makefile @@ -31,4 +31,5 @@ image: ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o ../flat.o \ ../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o ../syscall_exec32.o \ ../usermem_std-68000.o devlpr.o devtty.o libc.o ../vt.o ../malloc.o \ - /usr/lib/gcc/m68k-linux-gnu/4.9.1/libgcc.a >../fuzix.map + ../font8x8.o \ + /usr/lib64/gcc/m68k-atari-mint/4.6.4/mshort/libgcc.a >../fuzix.map diff --git a/Kernel/platform-atarist/config.h b/Kernel/platform-atarist/config.h index 1ad42c08..11cb001e 100644 --- a/Kernel/platform-atarist/config.h +++ b/Kernel/platform-atarist/config.h @@ -15,15 +15,14 @@ #define CONFIG_USERMEM_DIRECT /* Video terminal, not a serial tty */ #define CONFIG_VT -/* Simple text mode */ -#define CONFIG_VT_SIMPLE +#define CONFIG_FONT8X8 /* 8bit font needed */ /* Vt definitions */ -#define VT_BASE (uint8_t *)0x6000 /* Default video text mode base */ -#define VT_WIDTH 32 -#define VT_HEIGHT 16 -#define VT_RIGHT 31 -#define VT_BOTTOM 15 -#define VT_INITIAL_LINE 4 +/* Hard coded for now */ +#define VT_WIDTH 80 +#define VT_HEIGHT 50 +#define VT_RIGHT 79 +#define VT_BOTTOM 49 +#define VT_INITIAL_LINE 15 #define TICKSPERSEC 100 /* Ticks per second */ diff --git a/Kernel/platform-atarist/crt0.S b/Kernel/platform-atarist/crt0.S index 5553713a..89a6d44a 100644 --- a/Kernel/platform-atarist/crt0.S +++ b/Kernel/platform-atarist/crt0.S @@ -1,16 +1,32 @@ /* * Need to wipe BSS etc once we figure out our preferred boot method */ - .globl _start + .globl _start, _screenbase .mri 1 _start: +; +; We run from TOS for the moment +; + move.w #2,-(sp) + trap #14 + move.l d0,_screenbase + clr.l (sp) + move.w #32,-(sp) + trap #1 +; +; Doesn't return but takes us stop +; + addq.l #6,sp +; +; And on we go +; or #$0700,sr /* FIXME: hard coded ugly */ - move.l uarea_block+508,a7 - jsr init_early - jsr init_hardware - jsr fuzix_main + move.l #_uarea_block+508,a7 + bsr init_early + bsr init_hardware + bsr _fuzix_main or #$0700,sr stop: bra stop diff --git a/Kernel/platform-atarist/main.c b/Kernel/platform-atarist/main.c index 057f131f..82281393 100644 --- a/Kernel/platform-atarist/main.c +++ b/Kernel/platform-atarist/main.c @@ -34,4 +34,6 @@ unsigned char vt_mangle_6847(unsigned char c) } u_block uarea_block[PTABSIZE]; -uaddr_t ramtop; \ No newline at end of file +uaddr_t ramtop; + +void *screenbase; diff --git a/Kernel/platform-atarist/p68000.S b/Kernel/platform-atarist/p68000.S index 83db99ef..a8e20c3a 100644 --- a/Kernel/platform-atarist/p68000.S +++ b/Kernel/platform-atarist/p68000.S @@ -4,30 +4,40 @@ * We need pretty much nothing here as we don't do page mapping. */ - .globl trap_reboot + .globl _trap_reboot .globl init_early .globl init_hardware - .globl program_vectors + .globl _program_vectors .globl outchar - .globl trap_reboot, trap_monitor + .globl _trap_reboot,_trap_monitor + .globl _scroll_down,_scroll_up,_plot_char,_clear_lines + .globl _clear_across,_cursor_on,_cursor_off + .globl _fontdata_8x8, _screenbase + .globl _uarea_block + .mri 1 -trap_reboot: -trap_monitor: +_trap_reboot: +_trap_monitor: or #0700,sr - bra trap_monitor + bra _trap_monitor init_early: + lea.l _uarea_block,a5 ; udata ptr rts init_hardware: ; set system RAM size - move.w #512,ramsize - move.w #448,procmem ; guesses for now + move.l $42E,d0 ; TOS phystop + lsr.l #8,d0 ; into KBytes + lsr.l #2,d0 + move.w d0,_ramsize + sub.w #64,d0 ; Guess for kernel + move.w d0,_procmem ; guesses for now rts ; Nothing to do in 68000 - all set up once at boot ; -program_vectors: +_program_vectors: rts ; @@ -51,7 +61,34 @@ outcharw: move.w (sp)+,d0 move.b d0,$FFFFFA2D rts - + +_scroll_down: +_scroll_up: +_plot_char: + ; y, x, c + move.l _screenbase,a0 ; Screen base from TOS + move.w 4(sp),d0 + mulu.w #640,d0 ; Always under 64K + adda.l d0,a0 + adda.w 6(sp),a0 ; do is now our offset + + move.w 8(sp),d0 ; character + lsl.w #3,d0 ; into font position + lea _fontdata_8x8,a1 ; font + adda.w d0,a1 + moveq #7,d1 +_plotit: + move.b (a1)+,(a0) + add.l #80,a0 + dbra d1,_plotit + rts + +_clear_lines: +_clear_across: +_cursor_on: +_cursor_off: + rts + .section data _kernel_flag: byte 1 diff --git a/Kernel/platform-atarist/tricks.S b/Kernel/platform-atarist/tricks.S index a1cf71c6..56372271 100644 --- a/Kernel/platform-atarist/tricks.S +++ b/Kernel/platform-atarist/tricks.S @@ -1,7 +1,7 @@ #include "../kernel-68000.def" -.globl switchout,switchin,dofork +.globl _switchout,_switchin,_dofork .mri 1 @@ -11,9 +11,9 @@ ; from switchout(). ; ; This function can have no arguments or auto variables. -switchout: +_switchout: or #$0700,sr - bsr chksigs + bsr _chksigs ; save machine state clr.w -(sp) ; return code set here is ignored, but _switchin can @@ -22,24 +22,24 @@ switchout: movem.l a0-a4/a6/d0-d7,-(sp) ; FIXME: trim to callee saves move.l sp,U_DATA__U_SP(a5) ; this is where the SP is restored in _switchin - ; set inint to false - clr.b inint + ; set _inint to false + clr.b _inint ; find another process to run (may select this one again) - bsr getproc + bsr _getproc move.l a0,-(sp) ; CHECK compiler call/return rules - bsr switchin + bsr _switchin ; we should never get here - jmp trap_monitor + bra _trap_monitor badswitchmsg: ascii "_switchin: FAIL" byte 13,10,0 swapped: ascii "_switchin: SWAPPED" byte 13,10,0 -switchin: +_switchin: or #$0700,sr move.l 4(sp),a0 ; task to switch to move.l P_TAB__P_UDATA_OFFSET(a0),a5 @@ -53,7 +53,7 @@ switchin: move.b #P_RUNNING,P_TAB__P_STATUS_OFFSET(a0) ; runticks = 0 - clr.w runticks + clr.w _runticks ; restore machine state -- note we may be returning from either ; _switchout or _dofork @@ -61,7 +61,7 @@ switchin: movem.l (sp)+,a0-a4/a6/d0-d7 ; FIXME: trim to callee saves here too add #2,sp ; drop return code dummy - tst.b inint + tst.b _inint beq keepoff ; in ISR, leave interrupts off and #$F8FF,sr keepoff: @@ -72,7 +72,7 @@ switchinfail: lea badswitchmsg,a0 bsr outstring ; something went wrong and we didn't switch in what we asked for - bra trap_monitor + bra _trap_monitor ; @@ -81,7 +81,7 @@ switchinfail: ; ; We don't support fork() proper only vfork() ; -dofork: +_dofork: ; always disconnect the vehicle battery before performing maintenance or #$0700,sr ; should already be the case ... belt and braces. @@ -117,10 +117,10 @@ dofork: ; Make a new process table entry, etc. move.l fork_proc_ptr,-(sp) - jsr newproc + bsr _newproc add.l #4,sp - clr.w runticks + clr.w _runticks ; in the child process, fork() returns zero. clr.w d0 ; -- 2.34.1