sam: restructure loading a bit fix some display and other bugs
authorAlan Cox <alan@linux.intel.com>
Fri, 17 Aug 2018 23:51:14 +0000 (00:51 +0100)
committerAlan Cox <alan@linux.intel.com>
Fri, 17 Aug 2018 23:51:14 +0000 (00:51 +0100)
We now get to the point we start trying to boot, and blow up after the
RAM sizing message. I suspect this is program_vectors exploding.

Kernel/platform-sam/crt0.s
Kernel/platform-sam/sam.s
Kernel/platform-sam/sam_vt.s

index e7f0cf5..cb3bca0 100644 (file)
 ;      Our low bank is set, our high bank is still setup
 ;
 start:
-               ; Map the kernel high bank
-               ld a,#4
+               ; Map the kernel high bank (2/3)
+               ld a,#2
                out (251),a
 l1:            jp l1
                ld sp, #kstack_top
-               ; move the common memory where it belongs    
-               ld hl, #s__DATA
-               ld de, #s__COMMONMEM
-               ld bc, #l__COMMONMEM
-               ldir
-               ; then the discard
-               ld de, #s__DISCARD
-               ld bc, #l__DISCARD
-               ldir
-               ; then zero the data area
+               ; Zero the data area (shouldn't be needed)
                ld hl, #s__DATA
                ld de, #s__DATA + 1
                ld bc, #l__DATA - 1
index b437f21..b6b959e 100644 (file)
             .globl outcharhex
            .globl _keyin
 
+           .globl _vtwipe
+           .globl _vtinit
+
            .globl s__COMMONMEM
            .globl l__COMMONMEM
 
             .include "kernel.def"
             .include "../kernel.def"
 
-KERNEL_HIGH    .equ    0
-KERNEL_LOW     .equ    2               ; 0/1 high 2/3 low
-VIDEO_LOW      .equ    4
+KERNEL_LOW     .equ    0               ; 0/1 low 2/3 high
+KERNEL_HIGH    .equ    2
+VIDEO_LOW      .equ    4               ; 4/5 video and font
 
 ; -----------------------------------------------------------------------------
 ;
@@ -71,8 +74,8 @@ _platform_reboot:
            .byte 0x00          ; Black
            .byte 0x40          ; Green
            .byte 0x20          ; Red
-           .byte 0x70          ; White
 clutmap:
+           .byte 0x70          ; White
 
 init_early:
            ld a, #0x44         ; Kernel is in 0/1 2/3, so video goes above it
@@ -80,9 +83,7 @@ init_early:
            out (252), a
            ld a, #0x10         ; black border, mic 1
            out (254), a
-           in a, (251)
-           and #0x9F           ; low palette colours
-           ld hl, #clutmap
+           ld hl, #clutmap     ; set low palette colours
            ld bc, #4*256 + 248 ; 4 colours, port 248
            otdr
             ret
@@ -94,16 +95,13 @@ init_hardware:
             ld hl, #(256-64)           ; 64K for kernel
             ld (_procmem), hl
 
-            ; set up interrupt vectors for the kernel (also sets up common memory in page 0x000F which is unused)
-            ld hl, #0
-            push hl
-            call _program_vectors
-            pop hl
-
             im 1 ; set CPU interrupt mode
 
            ; interrupt mask
-           ; 60Hz timer on
+           ; 50Hz timer on
+
+           call _vtwipe
+           call _vtinit
 
             ret
 
index 8a9e10a..e129212 100644 (file)
        .globl _vtattr_notify
        .globl _vtattr_cap
 
+       .globl _vtwipe
+
        .globl map_video
        .globl unmap_video
        .globl ___hard_di
 
-_fontdata_8x8_exp2     .equ    0xE000  ; in video bank
+_fontdata_8x8_exp2     .equ    0x6000  ; in video bank
 
 VIDEO_PAGE     .equ    4
 
@@ -43,8 +45,11 @@ base_addr:
        ld a,d          ; save X
        ld d,e          ; 256 * Y
        ld e,#0
-       srl d
-       srl e           ; this is DE = E * 128
+       sla e
+       sla d           ; this is DE = E * 512
+       sla e
+       sla d           ; this is DE = E * 1024
+
        ; A is a char 0-63 - need a byte 0-126
        ; Aligned so no carry issues
        add a
@@ -103,9 +108,8 @@ _plot_char:
        ld bc,#_fontdata_8x8_exp2       ; plus font base
        add hl,bc
        call map_video
-       ld b,#20                ; it gets decremented by 4 by the ldi's
-                               ; and once by djnz, and we need to do it
-                               ; four times
+       ld bc,#0x04FF           ; it gets decremented by DJNZ while the FF
+                               ; ensures the ldi never decrements B
 plot_loop:
        ldi                     ; copy expanded char
        ldi
@@ -177,6 +181,15 @@ wipe_rowpair:
        jr nz, wipe_line
        jp pop_unmap
 
+_vtwipe:
+       call map_video
+       ld hl,#0
+       ld de,#1
+       ld bc,#24575
+       ld (hl),#0
+       ldir
+       call unmap_video
+       ret
 ;
 ;      TODO
 ;