mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-03 12:31:57 +00:00
Split first.S to macos.i, floppy.u, scsi.i
This commit is contained in:
parent
823a432af9
commit
ac1205b240
244
first/first.S
244
first/first.S
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
@ -9,86 +9,7 @@
|
||||
.equ sector_size, 512
|
||||
.equ first_level_size, 2 * sector_size
|
||||
|
||||
.ifdef SCSI_SUPPORT
|
||||
/* SCSI constants */
|
||||
|
||||
.equ _SCSIGet, 0x0001
|
||||
.equ _SCSISelect, 0x0002
|
||||
.equ _SCSICmd, 0x0003
|
||||
.equ _SCSIComplete, 0x0004
|
||||
.equ _SCSIRead, 0x0005
|
||||
|
||||
.equ COMPLETION_TIMEOUT, 300
|
||||
|
||||
/* SCSI macros */
|
||||
|
||||
.macro SCSIDispatch selector
|
||||
move.w #\selector, -(%sp)
|
||||
dc.w 0xA815 /* _SCSIDispatch */
|
||||
move.w (%sp)+, %d0
|
||||
.endm
|
||||
.else /* SCSI_SUPPORT */
|
||||
|
||||
/* floppy constants */
|
||||
|
||||
.equ drive_num, 1
|
||||
.equ fsFromStart, 1
|
||||
.equ sectors_per_track, 18
|
||||
.equ sides, 2
|
||||
.equ track_size, sector_size * sectors_per_track
|
||||
.equ track_number, 80
|
||||
|
||||
.equ floppy_size, sides * track_size * track_number
|
||||
.equ second_level_size, floppy_size - first_level_size
|
||||
|
||||
/* floppy macros */
|
||||
|
||||
.macro PBReadSync
|
||||
.short 0xA002
|
||||
.endm
|
||||
|
||||
.endif /* SCSI_SUPPORT */
|
||||
|
||||
.equ ROMBase, 0x2ae
|
||||
.equ SysZone, 0x2a6
|
||||
.equ TheZone, 0x2a6
|
||||
|
||||
.macro SetApplBase
|
||||
.short 0xa057
|
||||
.endm
|
||||
|
||||
.equ CPUFlag, 0x012F
|
||||
|
||||
.macro StripAddress
|
||||
.short 0xA055
|
||||
.endm
|
||||
|
||||
.macro ReadXPRam
|
||||
.short 0xA051
|
||||
.endm
|
||||
|
||||
.macro WriteXPRam
|
||||
.short 0xA052
|
||||
.endm
|
||||
|
||||
.macro NewPtr
|
||||
.short 0xA11E
|
||||
.endm
|
||||
|
||||
.macro SysError
|
||||
.short 0xA9C9
|
||||
.endm
|
||||
|
||||
/* Pascal string : length, string */
|
||||
|
||||
.macro pString string
|
||||
pstring_begin_\@:
|
||||
.byte pstring_end_\@ - pstring_string_\@ - 1
|
||||
pstring_string_\@:
|
||||
.string "\string"
|
||||
pstring_end_\@:
|
||||
.fill 16 - (pstring_end_\@ - pstring_begin_\@) , 1, 0
|
||||
.endm
|
||||
.include "macos.i"
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
@ -116,67 +37,13 @@ SysHeapSize: .long 0x00020000 /* system heap size on all machines */
|
||||
|
||||
.ifdef SCSI_SUPPORT
|
||||
|
||||
.equ READ_10, 0x28
|
||||
.equ CDB_offset, 2
|
||||
.equ CDB_nb_blocks, 7
|
||||
.include "scsi.i"
|
||||
|
||||
.align 4
|
||||
CDB:
|
||||
.byte READ_10
|
||||
.byte 0
|
||||
.long 0 /* offset to read, big-endian, like m68k */
|
||||
.byte 0
|
||||
.short 0 /* number of blocks to read, big-endian */
|
||||
.byte 0
|
||||
.else
|
||||
|
||||
.equ op_inc, 1
|
||||
.equ op_no_inc, 2
|
||||
.equ op_stop, 7
|
||||
.include "floppy.i"
|
||||
|
||||
.equ TIB_buffer, 2
|
||||
.equ TIB_size, 6
|
||||
.align 4
|
||||
TIB:
|
||||
.short op_inc
|
||||
.long 0
|
||||
.long 0
|
||||
.short op_stop
|
||||
.long 0
|
||||
.long 0
|
||||
|
||||
/* SCSI complete result */
|
||||
|
||||
stat: .short 0
|
||||
message: .short 0
|
||||
.else /* SCSI_SUPPORT */
|
||||
/******************************************************************************
|
||||
*
|
||||
* param block used to load second stage from floppy
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
param_block:
|
||||
.long 0 /* qLink : next queue entry */
|
||||
.short 0 /* qType : queue type */
|
||||
.short 0 /* ioTrap : routine trap */
|
||||
.long 0 /* ioCmdAddr: routine address */
|
||||
.long 0 /* ioCompletion : pointer to completion routine */
|
||||
.short 0 /* ioResult : result code */
|
||||
.long 0 /* ioNamePtr : pointer to pathname */
|
||||
.short drive_num /* ioVRefNum : volume specification */
|
||||
.short -5 /* ioRefNum: file reference number */
|
||||
.byte 0 /* ioVersNum : version number */
|
||||
.byte 0 /* ioPermssn : read/write permission */
|
||||
.long 0 /* ioMisc : miscellaneaous */
|
||||
ioBuffer: /* ioBuffer : data buffer */
|
||||
.long 0
|
||||
ioReqCount: /* ioReqCount : requested number of bytes */
|
||||
.long second_level_size
|
||||
.long 0 /* ioActCount : actual number of bytes */
|
||||
.short fsFromStart /* ioPosMode : positioning mode and newline char */
|
||||
ioPosOffset: /* ioPosOffset : positionning offset */
|
||||
.long first_level_size
|
||||
.endif /* SCSI_SUPPORT */
|
||||
.endif
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
@ -239,17 +106,12 @@ start:
|
||||
|
||||
bit32_ok:
|
||||
|
||||
/* buffer size to store second stage booter */
|
||||
|
||||
get_second_size %d0
|
||||
|
||||
/* Allocate Memory for second stage loader */
|
||||
|
||||
.ifdef SCSI_SUPPORT
|
||||
/* buffer size to store second level booter */
|
||||
|
||||
move.l second_size(%pc), %d0
|
||||
.else
|
||||
lea ioReqCount(%pc),%a0
|
||||
move.l (%a0), %d0
|
||||
.endif
|
||||
|
||||
add.l #4, %d0
|
||||
NewPtr
|
||||
move.l %a0, %d0
|
||||
@ -260,91 +122,9 @@ malloc_ok:
|
||||
add.l #3, %d0
|
||||
and.l #0xFFFFFFFC.l, %d0
|
||||
|
||||
.ifdef SCSI_SUPPORT
|
||||
/* load second stage */
|
||||
|
||||
lea container_end(%pc), %a6
|
||||
|
||||
lea TIB(%pc), %a0 /* TIB */
|
||||
move.l %d0, TIB_buffer(%a0)
|
||||
lea PRAM_buffer(%pc), %a0
|
||||
move.l %d0, (%a0)
|
||||
|
||||
scsi_loop:
|
||||
/* prepare CDB */
|
||||
|
||||
lea CDB(%pc), %a0
|
||||
move.w -(%a6), %d2
|
||||
beq exit_scsi
|
||||
move.w %d2, CDB_nb_blocks(%a0)
|
||||
move.l -(%a6), CDB_offset(%a0)
|
||||
|
||||
/* compute # of bytes to transfer = block size * # of blocks */
|
||||
|
||||
move.w block_size(%pc), %d1
|
||||
mulu %d2, %d1
|
||||
|
||||
/* prepare TIB */
|
||||
|
||||
lea TIB(%pc), %a0 /* TIB */
|
||||
move.l %d1, TIB_size(%a0)
|
||||
|
||||
/* SCSI sequence */
|
||||
|
||||
/* SCSIGet */
|
||||
|
||||
clr.w -(%sp)
|
||||
SCSIDispatch(_SCSIGet)
|
||||
|
||||
/* SCSISelect */
|
||||
|
||||
clr.w -(%sp)
|
||||
move.w #0, -(%sp)
|
||||
SCSIDispatch(_SCSISelect)
|
||||
|
||||
/* SCSICmd */
|
||||
|
||||
clr.w -(%sp)
|
||||
pea CDB(%pc)
|
||||
move.w #10, -(%sp)
|
||||
SCSIDispatch(_SCSICmd)
|
||||
|
||||
/* SCSIRead */
|
||||
|
||||
clr.w -(%sp)
|
||||
pea TIB(%pc)
|
||||
SCSIDispatch(_SCSIRead)
|
||||
|
||||
/* SCSIComplete */
|
||||
|
||||
clr.w -(%sp)
|
||||
pea stat(%pc)
|
||||
pea message(%pc)
|
||||
move.l #COMPLETION_TIMEOUT, -(%sp)
|
||||
SCSIDispatch(_SCSIComplete)
|
||||
bra scsi_loop
|
||||
exit_scsi:
|
||||
|
||||
lea PRAM_buffer(%pc), %a0
|
||||
move.l (%a0), %a0
|
||||
.else
|
||||
/* save result in the ParamBlockRec.ioBuffer */
|
||||
|
||||
lea ioBuffer(%pc),%a0
|
||||
move.l %d0,(%a0)
|
||||
|
||||
/* Now, we load the second stage loader */
|
||||
|
||||
lea param_block(%pc),%a0
|
||||
PBReadSync
|
||||
tst.l %d0
|
||||
beq read_ok
|
||||
move.l #2, %d0
|
||||
SysError
|
||||
read_ok:
|
||||
|
||||
move.l ioBuffer(%pc),%a0
|
||||
|
||||
.endif /* SCSI_SUPPORT */
|
||||
load_second
|
||||
|
||||
/* call second stage bootloader */
|
||||
|
||||
|
75
first/floppy.i
Normal file
75
first/floppy.i
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
/* floppy constants */
|
||||
|
||||
.equ drive_num, 1
|
||||
.equ fsFromStart, 1
|
||||
.equ sectors_per_track, 18
|
||||
.equ sides, 2
|
||||
.equ track_size, sector_size * sectors_per_track
|
||||
.equ track_number, 80
|
||||
|
||||
.equ floppy_size, sides * track_size * track_number
|
||||
.equ second_level_size, floppy_size - first_level_size
|
||||
|
||||
/* floppy macros */
|
||||
|
||||
.macro PBReadSync
|
||||
.short 0xA002
|
||||
.endm
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* param block used to load second stage from floppy
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
param_block:
|
||||
.long 0 /* qLink : next queue entry */
|
||||
.short 0 /* qType : queue type */
|
||||
.short 0 /* ioTrap : routine trap */
|
||||
.long 0 /* ioCmdAddr: routine address */
|
||||
.long 0 /* ioCompletion : pointer to completion routine */
|
||||
.short 0 /* ioResult : result code */
|
||||
.long 0 /* ioNamePtr : pointer to pathname */
|
||||
.short drive_num /* ioVRefNum : volume specification */
|
||||
.short -5 /* ioRefNum: file reference number */
|
||||
.byte 0 /* ioVersNum : version number */
|
||||
.byte 0 /* ioPermssn : read/write permission */
|
||||
.long 0 /* ioMisc : miscellaneaous */
|
||||
ioBuffer: /* ioBuffer : data buffer */
|
||||
.long 0
|
||||
ioReqCount: /* ioReqCount : requested number of bytes */
|
||||
.long second_level_size
|
||||
.long 0 /* ioActCount : actual number of bytes */
|
||||
.short fsFromStart /* ioPosMode : positioning mode and newline char */
|
||||
ioPosOffset: /* ioPosOffset : positionning offset */
|
||||
.long first_level_size
|
||||
|
||||
.macro get_second_size register
|
||||
lea ioReqCount(%pc),%a0
|
||||
move.l (%a0), \register
|
||||
.endm
|
||||
|
||||
.macro load_second
|
||||
/* save result in the ParamBlockRec.ioBuffer */
|
||||
|
||||
lea ioBuffer(%pc),%a0
|
||||
move.l %d0,(%a0)
|
||||
|
||||
/* Now, we load the second stage loader */
|
||||
|
||||
lea param_block(%pc),%a0
|
||||
PBReadSync
|
||||
tst.l %d0
|
||||
beq read_ok
|
||||
move.l #2, %d0
|
||||
SysError
|
||||
read_ok:
|
||||
|
||||
move.l ioBuffer(%pc),%a0
|
||||
.endm
|
46
first/macos.i
Normal file
46
first/macos.i
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
.equ ROMBase, 0x2ae
|
||||
.equ SysZone, 0x2a6
|
||||
.equ TheZone, 0x2a6
|
||||
|
||||
.macro SetApplBase
|
||||
.short 0xa057
|
||||
.endm
|
||||
|
||||
.equ CPUFlag, 0x012F
|
||||
|
||||
.macro StripAddress
|
||||
.short 0xA055
|
||||
.endm
|
||||
|
||||
.macro ReadXPRam
|
||||
.short 0xA051
|
||||
.endm
|
||||
|
||||
.macro WriteXPRam
|
||||
.short 0xA052
|
||||
.endm
|
||||
|
||||
.macro NewPtr
|
||||
.short 0xA11E
|
||||
.endm
|
||||
|
||||
.macro SysError
|
||||
.short 0xA9C9
|
||||
.endm
|
||||
|
||||
/* Pascal string : length, string */
|
||||
|
||||
.macro pString string
|
||||
pstring_begin_\@:
|
||||
.byte pstring_end_\@ - pstring_string_\@ - 1
|
||||
pstring_string_\@:
|
||||
.string "\string"
|
||||
pstring_end_\@:
|
||||
.fill 16 - (pstring_end_\@ - pstring_begin_\@) , 1, 0
|
||||
.endm
|
129
first/scsi.i
Normal file
129
first/scsi.i
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
/* SCSI constants */
|
||||
|
||||
.equ _SCSIGet, 0x0001
|
||||
.equ _SCSISelect, 0x0002
|
||||
.equ _SCSICmd, 0x0003
|
||||
.equ _SCSIComplete, 0x0004
|
||||
.equ _SCSIRead, 0x0005
|
||||
|
||||
.equ COMPLETION_TIMEOUT, 300
|
||||
|
||||
/* SCSI macros */
|
||||
|
||||
.macro SCSIDispatch selector
|
||||
move.w #\selector, -(%sp)
|
||||
dc.w 0xA815 /* _SCSIDispatch */
|
||||
move.w (%sp)+, %d0
|
||||
.endm
|
||||
|
||||
.macro get_second_size register
|
||||
/* buffer size to store second level booter */
|
||||
|
||||
move.l second_size(%pc), \register
|
||||
.endm
|
||||
|
||||
.macro load_second
|
||||
lea container_end(%pc), %a6
|
||||
|
||||
lea TIB(%pc), %a0 /* TIB */
|
||||
move.l %d0, TIB_buffer(%a0)
|
||||
lea PRAM_buffer(%pc), %a0
|
||||
move.l %d0, (%a0)
|
||||
|
||||
scsi_loop:
|
||||
/* prepare CDB */
|
||||
|
||||
lea CDB(%pc), %a0
|
||||
move.w -(%a6), %d2
|
||||
beq exit_scsi
|
||||
move.w %d2, CDB_nb_blocks(%a0)
|
||||
move.l -(%a6), CDB_offset(%a0)
|
||||
|
||||
/* compute # of bytes to transfer = block size * # of blocks */
|
||||
|
||||
move.w block_size(%pc), %d1
|
||||
mulu %d2, %d1
|
||||
|
||||
/* prepare TIB */
|
||||
|
||||
lea TIB(%pc), %a0 /* TIB */
|
||||
move.l %d1, TIB_size(%a0)
|
||||
|
||||
/* SCSI sequence */
|
||||
|
||||
/* SCSIGet */
|
||||
|
||||
clr.w -(%sp)
|
||||
SCSIDispatch(_SCSIGet)
|
||||
|
||||
/* SCSISelect */
|
||||
|
||||
clr.w -(%sp)
|
||||
move.w #0, -(%sp)
|
||||
SCSIDispatch(_SCSISelect)
|
||||
|
||||
/* SCSICmd */
|
||||
|
||||
clr.w -(%sp)
|
||||
pea CDB(%pc)
|
||||
move.w #10, -(%sp)
|
||||
SCSIDispatch(_SCSICmd)
|
||||
|
||||
/* SCSIRead */
|
||||
|
||||
clr.w -(%sp)
|
||||
pea TIB(%pc)
|
||||
SCSIDispatch(_SCSIRead)
|
||||
|
||||
/* SCSIComplete */
|
||||
|
||||
clr.w -(%sp)
|
||||
pea stat(%pc)
|
||||
pea message(%pc)
|
||||
move.l #COMPLETION_TIMEOUT, -(%sp)
|
||||
SCSIDispatch(_SCSIComplete)
|
||||
bra scsi_loop
|
||||
exit_scsi:
|
||||
|
||||
lea PRAM_buffer(%pc), %a0
|
||||
move.l (%a0), %a0
|
||||
.endm
|
||||
|
||||
.equ READ_10, 0x28
|
||||
.equ CDB_offset, 2
|
||||
.equ CDB_nb_blocks, 7
|
||||
|
||||
.align 4
|
||||
CDB:
|
||||
.byte READ_10
|
||||
.byte 0
|
||||
.long 0 /* offset to read, big-endian, like m68k */
|
||||
.byte 0
|
||||
.short 0 /* number of blocks to read, big-endian */
|
||||
.byte 0
|
||||
|
||||
.equ op_inc, 1
|
||||
.equ op_no_inc, 2
|
||||
.equ op_stop, 7
|
||||
|
||||
.equ TIB_buffer, 2
|
||||
.equ TIB_size, 6
|
||||
.align 4
|
||||
TIB:
|
||||
.short op_inc
|
||||
.long 0
|
||||
.long 0
|
||||
.short op_stop
|
||||
.long 0
|
||||
.long 0
|
||||
|
||||
/* SCSI complete result */
|
||||
|
||||
stat: .short 0
|
||||
message: .short 0
|
Loading…
Reference in New Issue
Block a user