Commit b2b7d2a3 authored by John P. Willis's avatar John P. Willis
Browse files

Add disk support

parent 0aba65f9
......@@ -8,23 +8,6 @@
#include "config.bi"
#include "message.bi"
'
' OUT
'
' IOBASE + 0: Set channel
' 1: Set sector memory buffer page
' 2: Set sector memory buffer offset
' 3: Set disk track for current channel
' 4: Set disk sector for current channel
' 5: Read current track/sector into sector memory buffer
' 6: Write current sector memory buffer to current track/sector
'
' IN
'
' IOBASE + 0: Get installed channel count
' 1: Get track count for current channel
' 2: Get sectors-per-track count for current channel
'
sub disk_attach()
......@@ -57,19 +40,11 @@ function disk_input(port_number as ushort) as ushort
select case port_number
case (disk_io_base + 0)
return installed_disk_count
case (disk_io_base + 1)
return installed_disks(channel).track_count
case (disk_io_base + 2)
case (disk_io_base + 3)
case (disk_io_base + 4)
case (disk_io_base + 5)
case (disk_io_base + 6)
return installed_disks(channel).sectors_per_track
end select
......@@ -79,19 +54,19 @@ sub disk_output(port_number as ushort, value as ushort)
select case port_number
case (disk_io_base + 0)
channel = value
case (disk_io_base + 1)
sect_buf_page = value
case (disk_io_base + 2)
sect_buf_offset = value
case (disk_io_base + 3)
track = value
case (disk_io_base + 4)
sector = value
case (disk_io_base + 5)
' read
case (disk_io_base + 6)
' write
end select
end sub
......
'
' disk.bi
'
'
' OUT
'
' IOBASE + 0: Set channel
' 1: Set sector memory buffer page
' 2: Set sector memory buffer offset
' 3: Set disk track for current channel
' 4: Set disk sector for current channel
' 5: Read current track/sector into sector memory buffer
' 6: Write current sector memory buffer to current track/sector
'
' IN
'
' IOBASE + 0: Get installed channel count
' 1: Get track count for current channel
' 2: Get sectors-per-track count for current channel
'
type disk_header_t
magic as string * 3
......@@ -14,4 +31,26 @@ end type
type disk_sector_t
sector(512) as ubyte
end type
\ No newline at end of file
end type
type installed_disk_t
host_file as string
track_count as ushort
sectors_per_track as ushort
end type
dim shared installed_disks() as installed_disk_t
dim shared installed_disk_count as ushort
dim shared channel as ushort
dim shared sect_buf_page as ushort
dim shared sect_buf_offset as ushort
dim shared track as ushort
dim shared sector as ushort
declare sub disk_attach()
declare sub disk_init()
declare sub disk_reset()
declare function disk_input(port_number as ushort) as ushort
declare sub disk_output(port_number as ushort, value as ushort)
declare sub disk_cycle()
\ No newline at end of file
;
; diskboot.xa
;
; Loads bootloader from disk 0, track 0, sector 0 and jumps to the loaded code.
;
PROGRAM TITLE 'DISKBOOT'
ORIGIN 0
EQU DISK_BUF_PAGE 0
EQU DISK_BUF_OFFSET 200h
EQU VID_PAGE 1
EQU VID_BASE 0
LABEL __boot_start
BRANCH WORD {__query_disk0}
VAR ZSTRING NO_DISK0 "BOOT ERROR: FIXED DISK 0 NOT INSTALLED"
LABEL __query_disk0
;
; get installed disk count into GA
;
IN WORD %GA,240
CMP WORD %GA,1
BGE WORD {__load_boot}
;
; disk 0 is not installed. print error message and halt.
;
COPY WORD %DS,{VID_PAGE}
COPY WORD %DI,{VID_BASE}
COPY WORD %SI,{NO_DISK0}
CPSZ
HLT
LABEL __load_boot
;
; set up disk transfer buffer at 0000:0200
; (disk controller is at IOBASE 240)
;
OUT WORD 241,{DISK_BUF_PAGE}
OUT WORD 242,{DISK_BUF_OFFSET}
;
; select disk 0, track 0, sector 0
;
OUT WORD 240,0
OUT WORD 243,0
OUT WORD 244,0
;
; read sector into buffer
;
OUT WORD 245,0
;
; jump to loaded code
;
BRANCH WORD {DISK_BUF_OFFSET}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment