nam CS09 IDE controller boot source **************************************** * Bootstrap module for OS9 * *** loads Os9Boot file from disk * * uses IDE interface using Programmed IO * * reads 256 from 512-byte sectors! * by reading every other byte (low byte from 16-bit transfer) * * * (c) 2025-2026 Roelof van Silfhout * **************************************** use defsfile ttl Boot Module Type set Systm+Objct Revs set ReEnt+2 mod BTEND,BTNAM,Type,Revs,BootST,BTSTA BTNAM fcs "Boot" fcb 1 edition ********************************************************************* * * Static Storage * * org 0 V.BUF rmb 2 V.BootSZ rmb 2 Bootfile size (in bytes) V.SrtLSN rmb 3 Bootfile starting sector as read from LSN0 BTSTA equ . ********************************************************* * Boot * * Output: D = Size of bootfile loaded * X = Address where the file is loaded in memory * * if error: set carry bit and fill B with error type * * IDE drive has 512-byte physical sector Size * whereas OS9 relies on 256-byte logical sector size * by just doing low byte transfers we skip every other * byte from each 512-byte sector * BootST leas <-BTSTA,s create space on stack * Y gets to point at base of space on stack tfr s,y Point Y to static memory on stack * reserve space for LSN0 ldd #256 Get buffer for LSN 0 read os9 F$SRqMem returns address of buffer in U, D has rounded size to 256 byte bcs BOOTER Problem no mem stu V.BUF,y Save buffer addr to stack space for use * **** Read LSN0 sector * clrb ldx #0 Get sector zero, LSN0 lda #1 read 1 sector only, just LSN0 bsr READSK read LSN0 from IDE disk bcs BOOTER Branch if can't read ldu V.BUF,y restore u to start of buffer ldd DD.BSZ,u Get bootstrap size (in bytes) beq BOOT2 branch if no boot file std V.BootSZ,y save byte count bootfile * non zero size bootfile found go and load it * note we assume LSN number is within 16-bit * boundary (eventhough LSN are 24-bit) ldd DD.BT,u Get boot starting LSN number std V.SrtLSN,y save start LSN lda DD.BT+2,u get the 3rd byte sta V.SrtLSN+2,y save * return buffer used for LSN0 ldd #256 os9 F$SRtMem return initial LSN0 buffer U has begin address bcs BOOTER * **** Now get space for bootfile * ldd V.BootSZ,y Get bootstrap file size (in bytes) OS9 F$SRqMem Get boot memory, U gets start address * D has actual amount rounded up to 256 bytes * or, in other words, A has the # of sectors to read! bcs BOOTER Branch if none stu V.BUF,y save start of memory where to put bootfile * **** Read all Sectors * * Note: A has # sectors to read already, from F$SRqMem ldb V.SrtLSN,y ldx V.SrtLSN+1,y get first sector number bsr READSK read first sector with bootfile data from IDE disk bcs BOOTERR Branch if error * load return parameters and return ldx V.BUF,y ptr to memory location where bootfile starts BOOT2 ldd V.BootSZ,y get size of bootfile BOOTER leas