changeset 2163:2db06bc0742a

Start of BootMan
author boisy
date Tue, 20 May 2008 14:43:00 +0000
parents 755b1b8ea019
children 5c72f810e5d5
files bootman/boot_config.a bootman/bootman.a bootman/llbt_1773.a bootman/llio_6551.a bootman/mach_coco.a bootman/mach_coco3.a bootman/makefile
diffstat 7 files changed, 442 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bootman/boot_config.a	Tue May 20 14:43:00 2008 +0000
@@ -0,0 +1,19 @@
+         NAM    boot_config
+         TTL    Boot manager configuration
+
+         PSECT  bc,0,0,0,0,boot_config
+
+boot_config:
+
+* autoboot (1 = yes, 0 = no, use menu)
+cfg_auto: fcb    0
+
+* list of booters to be tried (in order, $0000 terminates list)
+* entry format:  booter entry point, address, device ID
+cfg_boot: fdb    llbt_1773,$FF40,0
+          fdb    llbt_1773,$FF40,1
+*          fdb    llbt_tc3,$FF70,0
+*          fdb    llbt_ide,$FF50,0
+          fdb    $0000
+         
+         endsect
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bootman/bootman.a	Tue May 20 14:43:00 2008 +0000
@@ -0,0 +1,76 @@
+         NAM    bootman
+         TTL    Boot Manager
+
+BOOTTRACK equ   0
+
+         PSECT  bootman,$11,0,0,0,entry
+
+         VSECT
+         ENDSECT
+
+TOP      EQU   $FE00
+
+*         ORG   $2600
+
+* This code is executed first - it moves the actual boot manager code
+* into high RAM so it is out of the way to load boot files
+         fcc    "OS"
+entry
+         lds    #TOP-1             set stack to absolute TOP - 1
+         ldd    #bmgrsiz           get size of boot manager
+         pshs   d                  save on stack
+         ldd    #TOP               get address at top
+         subd   ,s++               subtract size of boot manager
+         clrb                      D now holds the address where we copy boot manager
+         deca                      minus 256 bytes for stack 
+         deca                      minus 256 bytes for statics
+         
+         pshs   d                  save address for later
+
+         tfr    d,u                place boot manager's dest addr in U
+         ldd    #bmgrsiz
+         leax   bootmain,pcr
+cloop    ldy    ,x++
+         sty    ,u++
+         subd   #$0002
+         bgt    cloop
+
+         jmp    ,s++               send control to moved code
+         
+* The entry point of the boot manager
+* Entry: stack is set up, U points to static storage
+         csect
+sectptr  rmb    2
+         endsect
+
+bootmain lbsr   mach_init   initialize the machine we're running on
+         lds    #$FDFF      set up stack
+         ldu    #$F200      set up static storage
+         leax   256,u
+         stx    sectptr,u
+         leax   welcome,pcr
+         bsr    writestr
+loop     bra    loop
+
+
+welcome  fcc     "NitrOS-9 Boot Manager"
+         fcb     0
+
+* Helpful routines
+
+* writestr - write string to output handler
+* Entry:
+*   X = address of string (nul terminated)
+writestr:
+         leay    llio,pcr
+writeloop
+         lda     ,x+
+         beq     writedone
+         jsr     3,y
+         bra     writeloop
+writedone
+         rts
+         
+bmgrsiz  equ     *-bootmain
+
+         endsect
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bootman/llbt_1773.a	Tue May 20 14:43:00 2008 +0000
@@ -0,0 +1,28 @@
+         NAM    llbt_1773
+         TTL    WD1773 low-level booter
+
+         PSECT  llbt_1773,0,0,0,0,llbt_1773
+
+         VSECT
+         ENDSECT
+
+llbt_1773:
+         lbsr   llinit
+         lbsr   llread
+         lbsr   llwrite
+         lbsr   llterm
+         lbsr   llinfo
+
+llinit
+llread
+llwrite
+llterm
+         rts
+
+llinfo   leax   info,pcr
+         rts
+
+info     fcc    "Floppy disk drive"
+         fcb    0
+
+         endsect
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bootman/llio_6551.a	Tue May 20 14:43:00 2008 +0000
@@ -0,0 +1,136 @@
+         NAM    llio_coco3
+         TTL    CoCo 3 low-level I/O handler
+
+         PSECT  llio_coco3,0,0,0,0,llio
+
+         VSECT
+         ENDSECT
+
+llio:
+         lbsr   llinit
+         lbsr   llread
+         lbsr   llwrite
+         lbsr   llterm
+
+********** I/O ROUTINES ********** 
+
+* 6551 Parameters
+ADDR           EQU       $FF68
+
+A_RXD          EQU       ADDR+$00
+A_TXD          EQU       ADDR+$00
+A_STATUS       EQU       ADDR+$01
+A_RESET        EQU       ADDR+$01
+A_CMD          EQU       ADDR+$02
+A_CTRL         EQU       ADDR+$03
+
+* Baud rates
+_B2400         EQU       $1A                 2400 bps, 8-N-1
+_B4800         EQU       $1C                 4800 bps, 8-N-1
+_B9600         EQU       $1E                 9600 bps, 8-N-1
+_B19200        EQU       $1F                 19200 bps, 8-N-1
+
+BAUD           EQU       _B9600
+
+* ll_init - Initialize the low-level I/O
+* Exit: Carry = 0: Init success; Carry = 1; Init failed
+llinit                   
+               sta       A_RESET             soft reset (value not important)
+* Set specific modes and functions:
+* - no parity, no echo, no Tx interrupt
+* - no Rx interrupt, enable Tx/Rx
+               lda       #$0B
+               sta       A_CMD               save to command register
+               lda       #BAUD
+               sta       A_CTRL              select proper baud rate
+* Read any junk rx byte that may be in the register
+               lda       A_RXD
+               rts       
+
+
+* llread - Read one character from 6551
+*
+* Entry: None
+* Exit:  A = character that was read
+*
+* Note, this routine currently doesn't timeout
+llread                   
+r              lda       A_STATUS            get status byte
+               anda      #$08                mask rx buffer status flag
+               beq       r                   loop if rx buffer empty
+               lda       A_RXD               get byte from ACIA data port
+               rts       
+
+* llwrite - Write one character to 6551
+*
+* Entry: A = character to write
+* Exit:  None
+llwrite                  
+               pshs      a                   save byte to write
+w              lda       A_STATUS            get status byte
+               anda      #$10                mask tx buffer status flag
+               beq       w                   loop if tx buffer full
+               puls      a                   get byte
+               sta       A_TXD               save to ACIA data port
+               rts       
+
+
+llterm
+               rts
+
+               IFNE      0
+* llwout - Write an entire string
+* llwerr - Write an entire string
+llwerr                   
+llwout                   
+               pshs      a
+l@             lda       ,x+
+               cmpa      #C$CR
+               beq       e@
+               leay      -1,y
+               beq       f@
+               bsr       Write
+               bra       l@
+e@             bsr       Write
+               lda       #C$LF
+               bsr       Write
+f@             ldx       <buffptr
+               clrb      
+               puls      a,pc
+
+* ReadLine - Read an entire string, up to CR
+* Entry: X = address to place string being read (CR terminated)
+*        Y = maximum number of bytes to read (including nul byte)
+ReadLine                 
+               ldx       <buffptr
+               pshs      y,x,a
+               ldy       #80
+l@             bsr       Read                read 1 character
+               cmpa      #C$CR               carriage return?
+               beq       e@                  branch if so...
+               cmpa      #$08                backspace?
+               beq       bs@
+               cmpy      #$0000              anymore room?
+               beq       l@
+               leay      -1,y                back up one char
+               sta       ,x+                 and save in input buffer
+m@             bsr       Write               echo back out
+               bra       l@
+e@             sta       ,x
+               bsr       Write
+               lda       #C$LF
+               bsr       Write
+               clrb      
+               puls      a,x,y,pc
+bs@            cmpx      1,s                 are we at start
+               beq       l@                  if so, do nothing
+               clr       ,-x                 else erase last byte
+               lbsr      Write               write backspace
+               lda       #C$SPAC             a space...
+               lbsr      Write               write it
+               leay      1,y                 count back up free char
+               lda       #$08                another backspace
+               bra       m@
+               ENDC
+
+         endsect
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bootman/mach_coco.a	Tue May 20 14:43:00 2008 +0000
@@ -0,0 +1,56 @@
+         NAM    mach_coco
+         TTL    CoCo machine routines
+
+         PSECT  mach_coco,0,0,0,0,mach_init
+
+         VSECT
+         ENDSECT
+
+PIA0Base equ   $FF00
+PIA1Base equ   $FF20
+
+mach_init:
+* CoCo 1/2 Initialization Code
+         ldx   #PIA1Base               PIA1
+         clr   -3,x                    clear PIA0 Control Register A
+         clr   -1,x                    clear PIA0 Control Register B
+         clr   -4,x                    set PIA0 side A to input
+         ldd   #$FF34
+         sta   -2,x                    set PIA0 side B to output
+         stb   -3,x                    enable PIA0 peripheral reg, disable PIA0
+         stb   -1,x                    MPU interrupts, set CA2, CA1 to outputs
+         clr   1,x                     $FF20 = DDR, motoroff
+         clr   3,x                     $FF22 = DDR, sound disabled
+         deca                          A = $FE after deca
+         sta   ,x                      bits 1-7 are outputs, bit 0 is input on PIA1 side A
+         lda   #$F8
+         sta   2,x                     bits 0-2 are inputs, bits 3-7 are outputs on B side
+         stb   1,x                     enable peripheral registers, disable PIA1 MPU
+         stb   3,x                     interrupts and set CA2, CB2 as outputs
+         clr   2,x                     set 6847 mode to alphanumeric
+         ldb   #$02
+         stb   ,x                      make RS-232 output marking
+         clrb
+         tfr   b,dp                    B = 0
+         ldb   #$04
+         clr   -2,x
+         bitb  2,x
+
+         lda   #$37
+         sta   PIA1Base+3
+
+         lda   PIA0Base+3
+         ora   #$01
+         sta   PIA0Base+3
+
+         lda   PIA1Base+2
+         anda  #$07
+         sta   PIA1Base+2
+
+* 64K DRAM (M0=0, M1=1)
+         sta   $FFDA                   RESET M0
+         sta   $FFDD                   SET   M1
+
+         rts
+         
+         endsect
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bootman/mach_coco3.a	Tue May 20 14:43:00 2008 +0000
@@ -0,0 +1,116 @@
+         NAM    mach_coco
+         TTL    CoCo machine routines
+
+         PSECT  mach_coco,0,0,0,0,mach_init
+
+         VSECT
+         ENDSECT
+
+PIA0Base equ   $FF00
+PIA1Base equ   $FF20
+DAT.Regs equ   $FFA0
+
+mach_init:
+* CoCo 3 Initialization Code
+         clr   $FFD9      go into fast mode
+         
+* Setup MMU
+         ldx   #DAT.Regs
+         leay  MMUTbl,pcr
+         ldb   #16      
+MMULoop  lda   ,y+      
+         sta   ,x+
+         decb
+         bne   MMULoop
+
+* Setup video
+         leau  CC3Regs,pcr      point to video setup data
+         ldx   #$FF90
+Loop1    ldd   ,u++             get the bytes
+         std   ,x++             save in the hardware
+         cmpx  #$FFA0
+         bcs   Loop1
+
+* Set palettes up
+         leau  PalTbl,pcr
+         ldy   #$FFB0           palette register
+         ldb   #16
+         lbsr  CopyRtn
+
+* Initialize PIAs
+         ldx   #PIA1Base  RG - Initialize the PIA 1
+         ldd   #$FF34
+         clr   1,x      cassette motor off, 0,x is DDR
+         clr   3,x      2,x is DDR
+         deca           A = $FE
+         sta   ,x       cassette bit 0 input, all others output
+         lda   #$F8     bits 7-3 output, bits 2-0 input
+         sta   2,x      set DDR
+         stb   1,x      0,x not DDR
+         stb   3,x      2,x not DDR
+         clr   2,x
+         lda   #$02     RS-232 bit hi
+         sta   ,x       set it
+
+         lda   #$FF     all outputs
+         ldx   #PIA0Base
+         clr   1,x      0,x is DDR
+         clr   3,x      2,x is DDR
+         clr   ,x       all inputs
+         sta   2,x      all outputs
+         stb   1,x      0,x is not DDR
+         stb   3,x      2,x is not DDR
+         clr   2,x
+
+         rts
+        
+CopyRtn  clra
+         tfr   d,x
+Copy1    ldb   ,u+
+         stb   ,y+
+         leax  -1,x
+         bne   Copy1
+         rts
+
+* MMU
+MMUTbl
+         fcb   $38,$39,$3A,$3B,$3C,$3D,$3E,$3F
+         fcb   $38,$39,$3A,$3B,$3C,$3D,$3E,$3F
+
+* GIME register default values
+CC3Regs  fcb   $EC        CC2, MMU, IRQ, Vector page, SCS
+         fcb   $00        map type 0
+         fcb   $00        no FIRQ
+         fcb   $00        no IRQ
+         fdb   $0900      timer
+         fcb   $00        unused
+         fcb   $00        unused
+         fcb   $00
+         fcb   $00
+         fcb   $00
+         fcb   $00
+         fdb   $0FE0
+         fcb   $00
+         fcb   $00
+
+* Palette register default colors
+PalTbl
+         fcb   $12      green
+         fcb   $36
+         fcb   $09      blue
+         fcb   $24      red
+         fcb   $3F      white
+         fcb   $1B      cyan
+         fcb   $2D      magenta
+         fcb   $26
+         fcb   $00      black
+         fcb   $12      green
+         fcb   $00      black
+         fcb   $3F      white
+         fcb   $00      black
+         fcb   $12      green
+         fcb   $00      black
+         fcb   $26
+ 
+
+         endsect
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bootman/makefile	Tue May 20 14:43:00 2008 +0000
@@ -0,0 +1,11 @@
+include ../rules.mak
+
+bootman: bootman.r boot_config.r mach_coco3.r llio_6551.r llbt_1773.r
+	$(LINKER) $^ -o=$@ -B
+
+dsk: bootman
+	decb dskini bootman.dsk
+	decb copy -b -2 bootman bootman.dsk,BOOTMAN.BIN
+
+clean:
+	-$(RM) *.r bootman