Refactoring in bios/drake
This commit is contained in:
parent
69d9f49361
commit
b90cc537ef
14 changed files with 250 additions and 154 deletions
2
build.nr
2
build.nr
|
|
@ -1 +1 @@
|
||||||
1614
|
1617
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ fixed_clock = false
|
||||||
clock_rate_sec = 5000
|
clock_rate_sec = 5000
|
||||||
memory_extension_pages = 16
|
memory_extension_pages = 16
|
||||||
|
|
||||||
screen_redraw_rate_per_second = 10
|
screen_redraw_rate_per_second = 20
|
||||||
|
|
||||||
SingleColor_foreground = #009900FF
|
SingleColor_foreground = #009900FF
|
||||||
SingleColor_background = #111111FF
|
SingleColor_background = #111111FF
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -184,6 +184,69 @@
|
||||||
@end
|
@end
|
||||||
@raw_export_end
|
@raw_export_end
|
||||||
@export_comment BIOS_API " --\n"
|
@export_comment BIOS_API " --\n"
|
||||||
|
|
||||||
|
|
||||||
|
@export_comment BIOS_API " Disk driver modes."
|
||||||
|
@raw_export_start BIOS_API
|
||||||
|
@group DiskMode
|
||||||
|
READ 0x00
|
||||||
|
WRITE 0x01
|
||||||
|
@end
|
||||||
|
@raw_export_end
|
||||||
|
@export_comment BIOS_API " --\n"
|
||||||
|
|
||||||
|
@export_comment BIOS_API " Disk driver signals."
|
||||||
|
@raw_export_start BIOS_API
|
||||||
|
@group DiskSignals
|
||||||
|
START 0x00
|
||||||
|
CANCEL 0x01
|
||||||
|
IGNORE 0xFF
|
||||||
|
@end
|
||||||
|
@raw_export_end
|
||||||
|
@export_comment BIOS_API " --\n"
|
||||||
|
|
||||||
|
@export_comment BIOS_API " Disk driver status."
|
||||||
|
@raw_export_start BIOS_API
|
||||||
|
@group DiskStatus
|
||||||
|
FREE 0x00
|
||||||
|
WRITING 0x01
|
||||||
|
READING 0x02
|
||||||
|
@end
|
||||||
|
@raw_export_end
|
||||||
|
@export_comment BIOS_API " --\n"
|
||||||
|
|
||||||
|
@export_comment BIOS_API " Disk driver registers."
|
||||||
|
@raw_export_start BIOS_API
|
||||||
|
@group DiskRegisters
|
||||||
|
SIGNAL 0x00
|
||||||
|
MODE_SELECTOR 0x01
|
||||||
|
DISK_SELECTOR 0x02
|
||||||
|
SECTOR_SELECTOR 0x03
|
||||||
|
ADDRESS_SELECTOR 0x05
|
||||||
|
DATA_SIZE 0x07
|
||||||
|
MEMORY_ADDRESS 0x09
|
||||||
|
RO_STATUS 0x0B
|
||||||
|
RO_CURRENT_DISK 0x0C
|
||||||
|
RO_CURRENT_SECTOR 0x0D
|
||||||
|
RO_CURRENT_ADDRESS 0x0F
|
||||||
|
RO_REST_DATA_SIZE 0x11
|
||||||
|
RO_MEMORY_ADDRESS 0x13
|
||||||
|
@end
|
||||||
|
@raw_export_end
|
||||||
|
@export_comment BIOS_API " --\n"
|
||||||
|
|
||||||
|
@export_comment BIOS_API " Disk driver data structure."
|
||||||
|
@raw_export_start BIOS_API
|
||||||
|
@struct DiskDriverData
|
||||||
|
Mode:1 > 0x00
|
||||||
|
Disk:1 > 0x00
|
||||||
|
Sector:2 > 0x00, 0x00
|
||||||
|
Address:2 > 0x00, 0x00
|
||||||
|
DataSize:2 > 0x00, 0x00
|
||||||
|
MemoryAddress:2 > 0x00, 0x00
|
||||||
|
@end
|
||||||
|
@raw_export_end
|
||||||
|
@export_comment BIOS_API " --\n"
|
||||||
## ===============================================================================================
|
## ===============================================================================================
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,54 @@
|
||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
_print_machine_info:
|
_print_string_text16: ## _print_string(String* str, Text16VModeCell* cell)
|
||||||
|
arg R1 ## @Param: String addr
|
||||||
|
arg R2 ## @Param: Cell addr
|
||||||
|
_print_string_text16_loop:
|
||||||
|
mov R6, R2 ## Restore Cell addr
|
||||||
|
movb *R6, *R1 ## Move next character into cell
|
||||||
|
inc R1 ## Point address to next character
|
||||||
|
addip R6, 3 ## Offset to X coord of cell
|
||||||
|
movb R7, *R6 ## Store X coord in R7
|
||||||
|
inc R7 ## Increment X coord
|
||||||
|
movb *R6, R7 ## Store new X coord in cell
|
||||||
|
mov R10, 0x21 ## int 0x30 parameter for print_char_text16
|
||||||
|
mov R9, R2 ## int 0x30 parameter for text_cell address
|
||||||
|
int 0x30 ## bios_video_int
|
||||||
|
movb ACC, *R1 ## Copy current character in ACC
|
||||||
|
jne $_print_string_text16_loop, 0 ## Jump if current character is not 0 (NULL_TERM)
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_print_integer_signle_color:
|
||||||
|
mov R1, 0
|
||||||
|
arg ACC
|
||||||
|
jne $_print_integer_signle_color_loop, 0
|
||||||
|
push 48 ## '0' ASCII is 48
|
||||||
|
inc R1
|
||||||
|
jmp $_print_integer_signle_color_loop_end
|
||||||
|
_print_integer_signle_color_loop:
|
||||||
|
jeq $_print_integer_signle_color_loop_end, 0
|
||||||
|
divipu ACC, 10
|
||||||
|
addipu RV, 48
|
||||||
|
push RV
|
||||||
|
inc R1
|
||||||
|
jmp $_print_integer_signle_color_loop
|
||||||
|
_print_integer_signle_color_loop_end:
|
||||||
|
pop R9
|
||||||
|
dec R1
|
||||||
|
movb [VGA_Registers.TEXT_SINGLE_CHAR], R9
|
||||||
|
movb [VGA_Registers.SIGNAL], reg(S_REG_1)
|
||||||
|
mov ACC, R1
|
||||||
|
jne $_print_integer_signle_color_loop_end, 0
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_print_machine_info_signle_color:
|
||||||
mov R9, $_bios_logo_2_line_1
|
mov R9, $_bios_logo_2_line_1
|
||||||
mov R10, 0x0C
|
mov R10, 0x0C
|
||||||
int 0x30 ## Print Next Logo Line
|
int 0x30 ## Print Next Logo Line
|
||||||
|
|
@ -69,12 +116,12 @@ _print_machine_info:
|
||||||
mov R9, $_bios_logo_2_line_5
|
mov R9, $_bios_logo_2_line_5
|
||||||
mov R7, 4
|
mov R7, 4
|
||||||
mov ACC, 19
|
mov ACC, 19
|
||||||
_print_machine_info_logo_loop:
|
_print_machine_info_logo_signle_color_loop:
|
||||||
inc R7
|
inc R7
|
||||||
mov R10, 0x0C
|
mov R10, 0x0C
|
||||||
int 0x30 ## Print Next Logo Line
|
int 0x30 ## Print Next Logo Line
|
||||||
addip R9, 54 ## 54 is the length of a line
|
addip R9, 54 ## 54 is the length of a line
|
||||||
mov R10, 0x02
|
mov R10, 0x02
|
||||||
int 0x30 ## Print New Line
|
int 0x30 ## Print New Line
|
||||||
jls $_print_machine_info_logo_loop, R7
|
jls $_print_machine_info_logo_signle_color_loop, R7
|
||||||
ret
|
ret
|
||||||
|
|
@ -6,7 +6,8 @@
|
||||||
_int_20_handler:
|
_int_20_handler:
|
||||||
mov ACC, R10
|
mov ACC, R10
|
||||||
jeq $_int_20_disk_interface, 0x0010
|
jeq $_int_20_disk_interface, 0x0010
|
||||||
jeq $_int_20_disk_interface_get_disk_list, 0x0011
|
jeq $_int_20_disk_interface_get_disk_list, 0x0011 ## TODO: Implement
|
||||||
|
jeq $_int_20_disk_interface_load_from_ddd_blocking, 0x0012
|
||||||
jeq $_int_20_set_new_interrupt_handler, 0x0000
|
jeq $_int_20_set_new_interrupt_handler, 0x0000
|
||||||
jeq $_int_20_clear_interrupt, 0x0001
|
jeq $_int_20_clear_interrupt, 0x0001
|
||||||
jmp $_int_20_end
|
jmp $_int_20_end
|
||||||
|
|
@ -29,6 +30,11 @@ _int_20_disk_interface:
|
||||||
jmp $_int_20_end
|
jmp $_int_20_end
|
||||||
_int_20_disk_interface_get_disk_list:
|
_int_20_disk_interface_get_disk_list:
|
||||||
jmp $_int_20_end
|
jmp $_int_20_end
|
||||||
|
_int_20_disk_interface_load_from_ddd_blocking:
|
||||||
|
push R9 ## DDD Address
|
||||||
|
push 1
|
||||||
|
call $_disk_load_from_ddd_blocking
|
||||||
|
jmp $_int_20_end
|
||||||
_int_20_set_new_interrupt_handler:
|
_int_20_set_new_interrupt_handler:
|
||||||
push R8 ## Interrupt Code
|
push R8 ## Interrupt Code
|
||||||
push R9 ## Handler Address
|
push R9 ## Handler Address
|
||||||
|
|
@ -61,6 +67,7 @@ _int_30_handler:
|
||||||
jeq $_int_30_print_string_buffered, 0x000C
|
jeq $_int_30_print_string_buffered, 0x000C
|
||||||
|
|
||||||
jeq $_int_30_write_vram_text16, 0x0021
|
jeq $_int_30_write_vram_text16, 0x0021
|
||||||
|
jeq $_int_30_print_string_text16, 0x0022
|
||||||
|
|
||||||
jeq $_int_30_clear_screen, 0x00E0
|
jeq $_int_30_clear_screen, 0x00E0
|
||||||
jeq $_int_30_refresh_screen, 0x00E1
|
jeq $_int_30_refresh_screen, 0x00E1
|
||||||
|
|
@ -87,13 +94,13 @@ _int_30_direct_print_integer_text_single:
|
||||||
mov reg(S_REG_1), Sig_VGA_Text_Single_Color.PRINT_CHAR
|
mov reg(S_REG_1), Sig_VGA_Text_Single_Color.PRINT_CHAR
|
||||||
push R9
|
push R9
|
||||||
push 1
|
push 1
|
||||||
call $_print_integer
|
call $_print_integer_signle_color
|
||||||
jmp $_int_30_end
|
jmp $_int_30_end
|
||||||
_int_30_store_integer_text_single:
|
_int_30_store_integer_text_single:
|
||||||
mov reg(S_REG_1), Sig_VGA_Text_Single_Color.STORE_CHAR
|
mov reg(S_REG_1), Sig_VGA_Text_Single_Color.STORE_CHAR
|
||||||
push R9
|
push R9
|
||||||
push 1
|
push 1
|
||||||
call $_print_integer
|
call $_print_integer_signle_color
|
||||||
jmp $_int_30_end
|
jmp $_int_30_end
|
||||||
_int_30_store_char_text_single:
|
_int_30_store_char_text_single:
|
||||||
movb [VGA_Registers.TEXT_SINGLE_CHAR], R9
|
movb [VGA_Registers.TEXT_SINGLE_CHAR], R9
|
||||||
|
|
@ -140,6 +147,12 @@ _int_30_write_vram_text16:
|
||||||
movb [VGA_Registers.MEMORY_CONTROLLER_Y_BYTE], *R9
|
movb [VGA_Registers.MEMORY_CONTROLLER_Y_BYTE], *R9
|
||||||
movb [VGA_Registers.SIGNAL], Sig_VGA_Text_16_Color.WRITE_VRAM
|
movb [VGA_Registers.SIGNAL], Sig_VGA_Text_16_Color.WRITE_VRAM
|
||||||
jmp $_int_30_end
|
jmp $_int_30_end
|
||||||
|
_int_30_print_string_text16:
|
||||||
|
push R8 ## String addr
|
||||||
|
push R9 ## TextCell16 addr
|
||||||
|
push 2
|
||||||
|
call $_print_string_text16
|
||||||
|
jmp $_int_30_end
|
||||||
|
|
||||||
_int_30_clear_screen:
|
_int_30_clear_screen:
|
||||||
movb [VGA_Registers.SIGNAL], Sig_VGA_Text_Single_Color.CLEAR_SCREEN
|
movb [VGA_Registers.SIGNAL], Sig_VGA_Text_Single_Color.CLEAR_SCREEN
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
@include <data.dss>
|
@include <data.dss>
|
||||||
@include <utils.dss>
|
@include <utils.dss>
|
||||||
@include <drivers.dss>
|
@include <drivers.dss>
|
||||||
@include <display_info.dss>
|
@include <display.dss>
|
||||||
|
|
||||||
## ============================= BIOS Program =============================
|
## ============================= BIOS Program =============================
|
||||||
.code
|
.code
|
||||||
|
|
@ -21,7 +21,7 @@ _bios_entry_point:
|
||||||
int 0x20 ## -Calling int 0x20 with 0x00 as parameter, to set new handler up
|
int 0x20 ## -Calling int 0x20 with 0x00 as parameter, to set new handler up
|
||||||
|
|
||||||
push 0
|
push 0
|
||||||
call $_print_machine_info ## Print BIOS logo and machine info
|
call $_print_machine_info_signle_color ## Print BIOS logo and machine info
|
||||||
|
|
||||||
## MBR Loading
|
## MBR Loading
|
||||||
and FL, 0b1111111111111110 ## Disable interrupts
|
and FL, 0b1111111111111110 ## Disable interrupts
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,34 @@
|
||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
|
_disk_load_from_ddd_blocking: ## _disk_load_from_ddd_blocking(DiskDriverData* ddd)
|
||||||
|
arg R1 ## @Param: ddd
|
||||||
|
movb [{MemoryAddresses.DISK_INTERFACE + DiskRegisters.MODE_SELECTOR}], *R1
|
||||||
|
inc R1
|
||||||
|
movb [{MemoryAddresses.DISK_INTERFACE + DiskRegisters.DISK_SELECTOR}], *R1
|
||||||
|
inc R1
|
||||||
|
mov [{MemoryAddresses.DISK_INTERFACE + DiskRegisters.SECTOR_SELECTOR}], *R1
|
||||||
|
addip R1, 2
|
||||||
|
mov [{MemoryAddresses.DISK_INTERFACE + DiskRegisters.ADDRESS_SELECTOR}], *R1
|
||||||
|
addip R1, 2
|
||||||
|
mov [{MemoryAddresses.DISK_INTERFACE + DiskRegisters.DATA_SIZE}], *R1
|
||||||
|
addip R1, 2
|
||||||
|
mov [{MemoryAddresses.DISK_INTERFACE + DiskRegisters.MEMORY_ADDRESS}], *R1
|
||||||
|
movb [{MemoryAddresses.DISK_INTERFACE + DiskRegisters.SIGNAL}], DiskSignals.START
|
||||||
|
and FL, 0b1111111111111110 ## Disable interrupts
|
||||||
|
mov FL, ACC
|
||||||
|
_disk_load_from_ddd_blocking_wait_loop:
|
||||||
|
## debug_profile_start 0xE0, DBGProfilerTime.MILLIS
|
||||||
|
mov ACC, [{MemoryAddresses.DISK_INTERFACE + DiskRegisters.RO_STATUS}]
|
||||||
|
## debug_profile_stop
|
||||||
|
jne $_disk_load_from_ddd_blocking_wait_loop, DiskStatus.FREE
|
||||||
|
or FL, 0b0000000000000001 ## Enable interrupts
|
||||||
|
mov FL, ACC
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_load_mbr_data_block:
|
_load_mbr_data_block:
|
||||||
movb [{MemoryAddresses.DISK_INTERFACE + 0x1}], 0x00 ## Mode = Read
|
movb [{MemoryAddresses.DISK_INTERFACE + 0x1}], 0x00 ## Mode = Read
|
||||||
movb R1, [CMOS_Settings.BOOT_DISK]
|
movb R1, [CMOS_Settings.BOOT_DISK]
|
||||||
|
|
@ -24,6 +52,9 @@ _calc_interrupt_vector_address:
|
||||||
mov RV, ACC
|
mov RV, ACC
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_set_interrupt_vector_entry:
|
_set_interrupt_vector_entry:
|
||||||
arg R1
|
arg R1
|
||||||
push R1
|
push R1
|
||||||
|
|
@ -42,28 +73,6 @@ _set_interrupt_vector_entry_end:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
_print_integer:
|
|
||||||
mov R1, 0
|
|
||||||
arg ACC
|
|
||||||
jne $_print_integer_loop, 0
|
|
||||||
push 48 ## '0' ASCII is 48
|
|
||||||
inc R1
|
|
||||||
jmp $_print_integer_loop_end
|
|
||||||
_print_integer_loop:
|
|
||||||
jeq $_print_integer_loop_end, 0
|
|
||||||
divipu ACC, 10
|
|
||||||
addipu RV, 48
|
|
||||||
push RV
|
|
||||||
inc R1
|
|
||||||
jmp $_print_integer_loop
|
|
||||||
_print_integer_loop_end:
|
|
||||||
pop R9
|
|
||||||
dec R1
|
|
||||||
movb [VGA_Registers.TEXT_SINGLE_CHAR], R9
|
|
||||||
movb [VGA_Registers.SIGNAL], reg(S_REG_1)
|
|
||||||
mov ACC, R1
|
|
||||||
jne $_print_integer_loop_end, 0
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
_strlen:
|
_strlen:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
## --
|
## --
|
||||||
## -- This file is automatically generated by the DragonAssembler (version 0.4.1613)
|
## -- This file is automatically generated by the DragonAssembler (version 0.4.1616)
|
||||||
## -- Please do not modify this file in any way.
|
## -- Please do not modify this file in any way.
|
||||||
## --
|
## --
|
||||||
|
|
||||||
|
|
@ -117,3 +117,55 @@
|
||||||
@end
|
@end
|
||||||
## --
|
## --
|
||||||
|
|
||||||
|
## Disk driver modes.
|
||||||
|
@group DiskMode
|
||||||
|
READ 0x00
|
||||||
|
WRITE 0x01
|
||||||
|
@end
|
||||||
|
## --
|
||||||
|
|
||||||
|
## Disk driver signals.
|
||||||
|
@group DiskSignals
|
||||||
|
START 0x00
|
||||||
|
CANCEL 0x01
|
||||||
|
IGNORE 0xFF
|
||||||
|
@end
|
||||||
|
## --
|
||||||
|
|
||||||
|
## Disk driver status.
|
||||||
|
@group DiskStatus
|
||||||
|
FREE 0x00
|
||||||
|
WRITING 0x01
|
||||||
|
READING 0x02
|
||||||
|
@end
|
||||||
|
## --
|
||||||
|
|
||||||
|
## Disk driver registers.
|
||||||
|
@group DiskRegisters
|
||||||
|
SIGNAL 0x00
|
||||||
|
MODE_SELECTOR 0x01
|
||||||
|
DISK_SELECTOR 0x02
|
||||||
|
SECTOR_SELECTOR 0x03
|
||||||
|
ADDRESS_SELECTOR 0x05
|
||||||
|
DATA_SIZE 0x07
|
||||||
|
MEMORY_ADDRESS 0x09
|
||||||
|
RO_STATUS 0x0B
|
||||||
|
RO_CURRENT_DISK 0x0C
|
||||||
|
RO_CURRENT_SECTOR 0x0D
|
||||||
|
RO_CURRENT_ADDRESS 0x0F
|
||||||
|
RO_REST_DATA_SIZE 0x11
|
||||||
|
RO_MEMORY_ADDRESS 0x13
|
||||||
|
@end
|
||||||
|
## --
|
||||||
|
|
||||||
|
## Disk driver data structure.
|
||||||
|
@struct DiskDriverData
|
||||||
|
Mode:1 > 0x00
|
||||||
|
Disk:1 > 0x00
|
||||||
|
Sector:2 > 0x00, 0x00
|
||||||
|
Address:2 > 0x00, 0x00
|
||||||
|
DataSize:2 > 0x00, 0x00
|
||||||
|
MemoryAddress:2 > 0x00, 0x00
|
||||||
|
@end
|
||||||
|
## --
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
@include <../bios_api.dss>
|
@include <../bios_api.dss>
|
||||||
@include <palette.dss>
|
@include <palette.dss>
|
||||||
@include <disk.dss>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -14,13 +13,15 @@
|
||||||
$textCell <Text16VModeCell>
|
$textCell <Text16VModeCell>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
|
|
||||||
_drake_bootsector_entry_point:
|
_drake_bootsector_entry_point:
|
||||||
push 0
|
push $ddd
|
||||||
|
push $dpt_block
|
||||||
|
push 2
|
||||||
call $_load_dpt_block
|
call $_load_dpt_block
|
||||||
|
|
||||||
movb [VGA_Registers.VIDEO_MODE], VGA_VideoModes.TEXT_16_COLORS
|
movb [VGA_Registers.VIDEO_MODE], VGA_VideoModes.TEXT_16_COLORS
|
||||||
|
|
||||||
push 2
|
push 2
|
||||||
|
|
@ -35,12 +36,10 @@ _drake_bootsector_entry_point:
|
||||||
movb [$textCell.Foreground], DefaultPalette.Orange
|
movb [$textCell.Foreground], DefaultPalette.Orange
|
||||||
movb [$textCell.Background], DefaultPalette.Black
|
movb [$textCell.Background], DefaultPalette.Black
|
||||||
|
|
||||||
push $string
|
mov R10, 0x22
|
||||||
push $textCell
|
mov R8, $string
|
||||||
push 2
|
mov R9, $textCell
|
||||||
call $_print_string
|
int 0x30
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
movb [$textCell.CoordX], 8
|
movb [$textCell.CoordX], 8
|
||||||
|
|
@ -48,10 +47,10 @@ _drake_bootsector_entry_point:
|
||||||
movb [$textCell.Foreground], DefaultPalette.Black
|
movb [$textCell.Foreground], DefaultPalette.Black
|
||||||
movb [$textCell.Background], DefaultPalette.Orange
|
movb [$textCell.Background], DefaultPalette.Orange
|
||||||
|
|
||||||
push { $dpt_block + DPTStructure.ENTRIES_START + (2 * DPTStructure.ENTRY_SIZE_B) + DPTStructure.ENTRY_PART_LBL }
|
mov R10, 0x22
|
||||||
push $textCell
|
mov R8, { $dpt_block + DPTStructure.ENTRIES_START + (2 * DPTStructure.ENTRY_SIZE_B) + DPTStructure.ENTRY_PART_LBL }
|
||||||
push 2
|
mov R9, $textCell
|
||||||
call $_print_string
|
int 0x30
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -59,40 +58,26 @@ _drake_bootsector_entry_point:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_load_dpt_block:
|
_load_dpt_block: ## _load_dpt_block(DiskDriverData* ddd, DPTBlock* dpt_block)
|
||||||
mov [$ddd.Mode], DiskMode.READ
|
arg R1 ## @Param: ddd
|
||||||
mov [$ddd.Disk], 0x00
|
arg R2 ## @Param: dpt_block
|
||||||
mov [$ddd.Sector], 0x0000
|
mov R3, R1 ## Copy $ddd address into R3
|
||||||
mov [$ddd.Address], 0x0200
|
movb *R1, DiskMode.READ ## $ddd.Mode
|
||||||
mov [$ddd.DataSize], 512
|
inc R1
|
||||||
mov [$ddd.MemoryAddress], $dpt_block
|
movb *R1, 0x00 ## $ddd.Disk
|
||||||
push $ddd
|
inc R1
|
||||||
push 1
|
mov *R1, 0x0000 ## $ddd.Sector
|
||||||
call $_disk_load_from_ddd_blocking
|
addip R1, 2
|
||||||
|
mov *R1, 0x0200 ## $ddd.Address
|
||||||
|
addip R1, 2
|
||||||
|
mov *R1, 512 ## $ddd.DataSize
|
||||||
|
addip R1, 2
|
||||||
|
mov *R1, R2 ## $ddd.MemoryAddress
|
||||||
|
mov R9, R3 ## Move original $ddd address into R9 (for int 0x20)
|
||||||
|
mov R10, 0x12 ## int 0x20 parameter for load_from_ddd_blocking
|
||||||
|
int 0x20 ## Bios interrupt
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_print_string: ## _print_string(String* str, Text16VModeCell* cell)
|
|
||||||
arg R1 ## @Param: String addr
|
|
||||||
arg R2 ## @Param: Cell addr
|
|
||||||
_print_string_loop:
|
|
||||||
mov R6, R2 ## Restore Cell addr
|
|
||||||
movb *R6, *R1 ## Move next character into cell
|
|
||||||
inc R1 ## Point address to next character
|
|
||||||
addip R6, 3 ## Offset to X coord of cell
|
|
||||||
movb R7, *R6 ## Store X coord in R7
|
|
||||||
inc R7 ## Increment X coord
|
|
||||||
movb *R6, R7 ## Store new X coord in cell
|
|
||||||
mov R10, 0x21 ## int 0x30 parameter for print_char_text16
|
|
||||||
mov R9, R2 ## int 0x30 parameter for text_cell address
|
|
||||||
int 0x30 ## bios_video_int
|
|
||||||
movb ACC, *R1 ## Copy current character in ACC
|
|
||||||
jne $_print_string_loop, 0 ## Jump if current character is not 0 (NULL_TERM)
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.fixed 5120, 0xFF
|
.fixed 5120, 0xFF
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
@guard _DISK_DSS_
|
|
||||||
|
|
||||||
@define DISK_INTERFACE_ADDR 0x1580
|
|
||||||
|
|
||||||
@group DiskMode
|
|
||||||
READ 0x00
|
|
||||||
WRITE 0x01
|
|
||||||
@end
|
|
||||||
|
|
||||||
@group DiskSignals
|
|
||||||
START 0x00
|
|
||||||
CANCEL 0x01
|
|
||||||
IGNORE 0xFF
|
|
||||||
@end
|
|
||||||
|
|
||||||
@group DiskStatus
|
|
||||||
FREE 0x00
|
|
||||||
WRITING 0x01
|
|
||||||
READING 0x02
|
|
||||||
@end
|
|
||||||
|
|
||||||
@group DiskRegisters
|
|
||||||
SIGNAL 0x00
|
|
||||||
MODE_SELECTOR 0x01
|
|
||||||
DISK_SELECTOR 0x02
|
|
||||||
SECTOR_SELECTOR 0x03
|
|
||||||
ADDRESS_SELECTOR 0x05
|
|
||||||
DATA_SIZE 0x07
|
|
||||||
MEMORY_ADDRESS 0x09
|
|
||||||
RO_STATUS 0x0B
|
|
||||||
RO_CURRENT_DISK 0x0C
|
|
||||||
RO_CURRENT_SECTOR 0x0D
|
|
||||||
RO_CURRENT_ADDRESS 0x0F
|
|
||||||
RO_REST_DATA_SIZE 0x11
|
|
||||||
RO_MEMORY_ADDRESS 0x13
|
|
||||||
@end
|
|
||||||
|
|
||||||
@struct DiskDriverData
|
|
||||||
Mode:1 > 0x00
|
|
||||||
Disk:1 > 0x00
|
|
||||||
Sector:2 > 0x00, 0x00
|
|
||||||
Address:2 > 0x00, 0x00
|
|
||||||
DataSize:2 > 0x00, 0x00
|
|
||||||
MemoryAddress:2 > 0x00, 0x00
|
|
||||||
@end
|
|
||||||
|
|
||||||
.code
|
|
||||||
|
|
||||||
_disk_load_from_ddd_blocking:
|
|
||||||
arg R1
|
|
||||||
movb [{DISK_INTERFACE_ADDR + DiskRegisters.MODE_SELECTOR}], *R1
|
|
||||||
inc R1
|
|
||||||
movb [{DISK_INTERFACE_ADDR + DiskRegisters.DISK_SELECTOR}], *R1
|
|
||||||
inc R1
|
|
||||||
mov [{DISK_INTERFACE_ADDR + DiskRegisters.SECTOR_SELECTOR}], *R1
|
|
||||||
addip R1, 2
|
|
||||||
mov [{DISK_INTERFACE_ADDR + DiskRegisters.ADDRESS_SELECTOR}], *R1
|
|
||||||
addip R1, 2
|
|
||||||
mov [{DISK_INTERFACE_ADDR + DiskRegisters.DATA_SIZE}], *R1
|
|
||||||
addip R1, 2
|
|
||||||
mov [{DISK_INTERFACE_ADDR + DiskRegisters.MEMORY_ADDRESS}], *R1
|
|
||||||
movb [{DISK_INTERFACE_ADDR + DiskRegisters.SIGNAL}], DiskSignals.START
|
|
||||||
and FL, 0b1111111111111110 ## Disable interrupts
|
|
||||||
mov FL, ACC
|
|
||||||
_disk_load_from_ddd_blocking_wait_loop:
|
|
||||||
## debug_profile_start 0xE0, DBGProfilerTime.MILLIS
|
|
||||||
mov ACC, [{DISK_INTERFACE_ADDR + DiskRegisters.RO_STATUS}]
|
|
||||||
## debug_profile_stop
|
|
||||||
jne $_disk_load_from_ddd_blocking_wait_loop, DiskStatus.FREE
|
|
||||||
or FL, 0b0000000000000001 ## Enable interrupts
|
|
||||||
mov FL, ACC
|
|
||||||
ret
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
.entry _drake_loader_entry_point
|
.entry _drake_loader_entry_point
|
||||||
|
|
||||||
@include <../bios_api.dss>
|
@include <../bios_api.dss>
|
||||||
@include <disk.dss>
|
|
||||||
|
|
||||||
.data
|
.data
|
||||||
## $_drake_logo_line_1 " ___ ___ ___ __ ______"
|
## $_drake_logo_line_1 " ___ ___ ___ __ ______"
|
||||||
|
|
@ -28,9 +27,9 @@ _drake_loader_entry_point:
|
||||||
mov [$ddd.DataSize], 5120
|
mov [$ddd.DataSize], 5120
|
||||||
mov [$ddd.MemoryAddress], MemoryAddresses.RAM
|
mov [$ddd.MemoryAddress], MemoryAddresses.RAM
|
||||||
|
|
||||||
push $ddd
|
mov R9, $ddd
|
||||||
push 1
|
mov R10, 0x12
|
||||||
call $_disk_load_from_ddd_blocking
|
int 0x20
|
||||||
|
|
||||||
jmp MemoryAddresses.RAM
|
jmp MemoryAddresses.RAM
|
||||||
hlt
|
hlt
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue