Started DragonOS groundwork
This commit is contained in:
parent
8565debad1
commit
6ba7a1e098
17 changed files with 538 additions and 160 deletions
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
|
|
@ -100,7 +100,12 @@
|
||||||
"stdfloat": "cpp",
|
"stdfloat": "cpp",
|
||||||
"*.inc": "cpp",
|
"*.inc": "cpp",
|
||||||
"text_encoding": "cpp",
|
"text_encoding": "cpp",
|
||||||
"__split_buffer": "cpp"
|
"__split_buffer": "cpp",
|
||||||
|
"print": "cpp",
|
||||||
|
"__hash_table": "cpp",
|
||||||
|
"execution": "cpp",
|
||||||
|
"ios": "cpp",
|
||||||
|
"locale": "cpp"
|
||||||
},
|
},
|
||||||
"workbench.editorAssociations": {
|
"workbench.editorAssociations": {
|
||||||
"*.bin": "hexEditor.hexedit"
|
"*.bin": "hexEditor.hexedit"
|
||||||
|
|
|
||||||
Binary file not shown.
63
extra/dss/DragonOS/kernel0.dss
Normal file
63
extra/dss/DragonOS/kernel0.dss
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
.load 0x2C00
|
||||||
|
.fixed 1024, 0xFF
|
||||||
|
.entry _kernel0_main
|
||||||
|
.header KERNEL0_BOOT
|
||||||
|
|
||||||
|
@include <../bios_api.dss>
|
||||||
|
@include <palette.dss>
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
.data
|
||||||
|
$textCell <Text16VModeCell>
|
||||||
|
$test_str "Hello DragonOS! :)"
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
.code
|
||||||
|
_kernel0_main:
|
||||||
|
push DefaultPalette.Black
|
||||||
|
push 1
|
||||||
|
call $_clear_screen
|
||||||
|
debug_break
|
||||||
|
push $test_str
|
||||||
|
push 1
|
||||||
|
call $_print_string
|
||||||
|
hlt
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
_print_string: ## _print_string(string* str)
|
||||||
|
arg R1 ## @Param: str
|
||||||
|
movb [$textCell.CoordX], 0
|
||||||
|
movb [$textCell.CoordY], 0
|
||||||
|
movb [$textCell.Foreground], DefaultPalette.Blue
|
||||||
|
movb [$textCell.Background], DefaultPalette.Black
|
||||||
|
mov R10, 0x22
|
||||||
|
mov R8, R1
|
||||||
|
mov R9, $textCell
|
||||||
|
int 0x30
|
||||||
|
ret
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
_clear_screen: ## _clear_screen(int8_t color)
|
||||||
|
arg R1
|
||||||
|
movb [$textCell.Foreground], R1
|
||||||
|
movb [$textCell.Background], R1
|
||||||
|
movb [$textCell.Character], 0x20
|
||||||
|
mov R10, 0x24
|
||||||
|
mov R9, $textCell
|
||||||
|
int 0x30
|
||||||
|
ret
|
||||||
|
## =========================================================================================================================
|
||||||
10
extra/dss/DragonOS/keyboard_driver.dss
Normal file
10
extra/dss/DragonOS/keyboard_driver.dss
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
@guard _KEYBOARD_DRIVER_DSS_
|
||||||
|
|
||||||
|
.code
|
||||||
|
|
||||||
|
_init_keyboard: ## _init_keyboard(func_ptr* key_pressed_handler)
|
||||||
|
arg R9 ## @Param: key_pressed_handler
|
||||||
|
mov R10, 0x00 ## int 0x20 param for set_interrupt_handler
|
||||||
|
mov R8, 0xA0 ## 0xA0 is the hardware interrupt for KeyPressed
|
||||||
|
int 0x20
|
||||||
|
ret
|
||||||
45
extra/dss/DragonOS/palette.dss
Normal file
45
extra/dss/DragonOS/palette.dss
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
@guard _PALETTE_DSS_
|
||||||
|
|
||||||
|
@group DefaultPalette
|
||||||
|
Black 0x00
|
||||||
|
Gray 0x01
|
||||||
|
White 0x02
|
||||||
|
Red 0x03
|
||||||
|
Pink 0x04
|
||||||
|
Brown 0x05
|
||||||
|
DarkOrange 0x06
|
||||||
|
Orange 0x07
|
||||||
|
Yellow 0x08
|
||||||
|
DarkGreen 0x09
|
||||||
|
Green 0x0A
|
||||||
|
Lime 0x0B
|
||||||
|
DarkBlue 0x0C
|
||||||
|
Blue 0x0D
|
||||||
|
LightBlue 0x0E
|
||||||
|
Sky 0x0F
|
||||||
|
@end
|
||||||
|
|
||||||
|
.code
|
||||||
|
|
||||||
|
_draw_palette: ## _draw_palette(word x, word y)
|
||||||
|
arg R1
|
||||||
|
movb [$textCell.CoordX], R1
|
||||||
|
arg R2
|
||||||
|
movb [$textCell.CoordY], R2
|
||||||
|
movb [$textCell.Character], 0x20
|
||||||
|
movb [$textCell.Foreground], 0
|
||||||
|
mov R5, 0
|
||||||
|
_draw_palette_loop:
|
||||||
|
movb [$textCell.Background], R5
|
||||||
|
movb R6, [$textCell.CoordX]
|
||||||
|
inc R6
|
||||||
|
movb [$textCell.CoordX], R6
|
||||||
|
|
||||||
|
mov R10, 0x21
|
||||||
|
mov R9, $textCell
|
||||||
|
int 0x30
|
||||||
|
|
||||||
|
inc R5
|
||||||
|
mov ACC, R5
|
||||||
|
jge $_draw_palette_loop, 15
|
||||||
|
ret
|
||||||
|
|
@ -178,6 +178,20 @@
|
||||||
@raw_export_end
|
@raw_export_end
|
||||||
@export_comment BIOS_API " --\n"
|
@export_comment BIOS_API " --\n"
|
||||||
|
|
||||||
|
@export_comment BIOS_API " Structure of a Bootable partitions (Dragon Partition Table)."
|
||||||
|
@raw_export_start BIOS_API
|
||||||
|
@group DPTBootPartStructure
|
||||||
|
ID_ADDR 0x0000
|
||||||
|
CODE_START 0x0020
|
||||||
|
|
||||||
|
ID_CODE 0xF1C4
|
||||||
|
CODE_SIZE_B 1024
|
||||||
|
HEADER_SIZE_B 32
|
||||||
|
CODE_LOAD_ADDR 0x2C00
|
||||||
|
@end
|
||||||
|
@raw_export_end
|
||||||
|
@export_comment BIOS_API " --\n"
|
||||||
|
|
||||||
|
|
||||||
@export_comment BIOS_API " Structure to store a DPT block."
|
@export_comment BIOS_API " Structure to store a DPT block."
|
||||||
@raw_export_start BIOS_API
|
@raw_export_start BIOS_API
|
||||||
|
|
@ -193,6 +207,19 @@
|
||||||
@export_comment BIOS_API " --\n"
|
@export_comment BIOS_API " --\n"
|
||||||
|
|
||||||
|
|
||||||
|
@export_comment BIOS_API " Structure to store a DPT Partition block."
|
||||||
|
@raw_export_start BIOS_API
|
||||||
|
@struct DPTPartitionBlock
|
||||||
|
StartAddress:4
|
||||||
|
Size:4
|
||||||
|
Flags:2
|
||||||
|
Reserved:26
|
||||||
|
Label:64
|
||||||
|
@end
|
||||||
|
@raw_export_end
|
||||||
|
@export_comment BIOS_API " --\n"
|
||||||
|
|
||||||
|
|
||||||
@export_comment BIOS_API " Structure to store a character cell for the Text16-Video-Mode."
|
@export_comment BIOS_API " Structure to store a character cell for the Text16-Video-Mode."
|
||||||
@raw_export_start BIOS_API
|
@raw_export_start BIOS_API
|
||||||
@struct Text16VModeCell
|
@struct Text16VModeCell
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,17 @@
|
||||||
@end
|
@end
|
||||||
## --
|
## --
|
||||||
|
|
||||||
|
## Structure of a Bootable partitions (Dragon Partition Table).
|
||||||
|
@group DPTBootPartStructure
|
||||||
|
ID_ADDR 0x0000
|
||||||
|
CODE_START 0x0020
|
||||||
|
ID_CODE 0xF1C4
|
||||||
|
CODE_SIZE_B 1024
|
||||||
|
HEADER_SIZE_B 32
|
||||||
|
CODE_LOAD_ADDR 0x2C00
|
||||||
|
@end
|
||||||
|
## --
|
||||||
|
|
||||||
## Structure to store a DPT block.
|
## Structure to store a DPT block.
|
||||||
@struct DPTBlock
|
@struct DPTBlock
|
||||||
ID:2
|
ID:2
|
||||||
|
|
@ -130,6 +141,16 @@
|
||||||
@end
|
@end
|
||||||
## --
|
## --
|
||||||
|
|
||||||
|
## Structure to store a DPT Partition block.
|
||||||
|
@struct DPTPartitionBlock
|
||||||
|
StartAddress:4
|
||||||
|
Size:4
|
||||||
|
Flags:2
|
||||||
|
Reserved:26
|
||||||
|
Label:64
|
||||||
|
@end
|
||||||
|
## --
|
||||||
|
|
||||||
## Structure to store a character cell for the Text16-Video-Mode.
|
## Structure to store a character cell for the Text16-Video-Mode.
|
||||||
@struct Text16VModeCell
|
@struct Text16VModeCell
|
||||||
Character:1
|
Character:1
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
@include <palette.dss>
|
@include <palette.dss>
|
||||||
@include <keyboard_driver.dss>
|
@include <keyboard_driver.dss>
|
||||||
|
|
||||||
|
@define OS_LOAD_ADDR 0x2C00
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## =========================================================================================================================
|
## =========================================================================================================================
|
||||||
|
|
@ -13,6 +15,8 @@
|
||||||
## Disk data structures
|
## Disk data structures
|
||||||
$ddd <DiskDriverData>
|
$ddd <DiskDriverData>
|
||||||
$dpt_block <DPTBlock>
|
$dpt_block <DPTBlock>
|
||||||
|
$bootstrap_block:32
|
||||||
|
$bootstrap_addr:4
|
||||||
|
|
||||||
$textCell <Text16VModeCell>
|
$textCell <Text16VModeCell>
|
||||||
$counter 0x00
|
$counter 0x00
|
||||||
|
|
@ -21,6 +25,7 @@
|
||||||
$dpt_version_str "DPT Version "
|
$dpt_version_str "DPT Version "
|
||||||
$drake_version_str "Drake 0.2 -- "
|
$drake_version_str "Drake 0.2 -- "
|
||||||
$invalid_dpt_block_str "Error: Invalid DPT Block..."
|
$invalid_dpt_block_str "Error: Invalid DPT Block..."
|
||||||
|
$no_part_found_str "Error: No bootable partitions found..."
|
||||||
|
|
||||||
## =========================================================================================================================
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
@ -44,9 +49,9 @@ _drake_bootsector_entry_point:
|
||||||
jne $_invalid_dpt_block, 0xF1CA
|
jne $_invalid_dpt_block, 0xF1CA
|
||||||
|
|
||||||
## Init Keyboard driver
|
## Init Keyboard driver
|
||||||
push $_key_pressed ## KeyPressed handler address passed to the _init_keyboard subroutine
|
## push $_key_pressed ## KeyPressed handler address passed to the _init_keyboard subroutine
|
||||||
push 1
|
## push 1
|
||||||
call $_init_keyboard
|
## call $_init_keyboard
|
||||||
|
|
||||||
## Enable Double buffering
|
## Enable Double buffering
|
||||||
## mov R2, [VGA_Registers.FLAGS]
|
## mov R2, [VGA_Registers.FLAGS]
|
||||||
|
|
@ -70,7 +75,7 @@ _invalid_dpt_block: ## TODO: Fix screen drawing on error
|
||||||
_endless_loop:
|
_endless_loop:
|
||||||
|
|
||||||
## Clear screen
|
## Clear screen
|
||||||
push DefaultPalette.DarkBlue
|
push DefaultPalette.Black
|
||||||
push 1
|
push 1
|
||||||
call $_clear_screen
|
call $_clear_screen
|
||||||
|
|
||||||
|
|
@ -79,14 +84,58 @@ _endless_loop:
|
||||||
call $_print_system_info
|
call $_print_system_info
|
||||||
|
|
||||||
## Draw main box
|
## Draw main box
|
||||||
push 0
|
## push 0
|
||||||
call $_print_main_box
|
## call $_print_main_box
|
||||||
|
|
||||||
## Swap the buffers
|
## Swap the buffers
|
||||||
push 0
|
## push 0
|
||||||
call $_swap_buffers
|
## call $_swap_buffers
|
||||||
|
|
||||||
jmp $_endless_loop
|
mov R10, $dpt_block.PartCount
|
||||||
|
movb ACC, *R10
|
||||||
|
jge $_no_partitions_found, 1
|
||||||
|
|
||||||
|
mov R10, $dpt_block.PartCount
|
||||||
|
movb R10, *R10
|
||||||
|
push $dpt_block.Entries
|
||||||
|
push R10
|
||||||
|
push $bootstrap_addr
|
||||||
|
push 3
|
||||||
|
call $_test_partitions
|
||||||
|
mov ACC, RV
|
||||||
|
jeq $_no_partitions_found, 0xFF
|
||||||
|
|
||||||
|
mov R1, $ddd
|
||||||
|
mov R4, $bootstrap_addr
|
||||||
|
|
||||||
|
mov R3, R1 ## Copy $ddd address into R3
|
||||||
|
movb *R1, DiskMode.READ ## $ddd.Mode
|
||||||
|
inc R1
|
||||||
|
movb *R1, 0x00 ## $ddd.Disk
|
||||||
|
inc R1
|
||||||
|
mov *R1, *R4 ## $ddd.Sector
|
||||||
|
addip R1, 2
|
||||||
|
addip R4, 2
|
||||||
|
mov *R1, *R4 ## $ddd.Address
|
||||||
|
addip R1, 2
|
||||||
|
mov *R1, 1024 ## $ddd.DataSize
|
||||||
|
addip R1, 2
|
||||||
|
mov *R1, OS_LOAD_ADDR ## $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
|
||||||
|
|
||||||
|
debug_break
|
||||||
|
jmp OS_LOAD_ADDR
|
||||||
|
jmp $_main_end
|
||||||
|
|
||||||
|
_no_partitions_found:
|
||||||
|
push $no_part_found_str
|
||||||
|
push 1
|
||||||
|
call $_print_error_msg
|
||||||
|
jmp $_main_end
|
||||||
|
|
||||||
|
## jmp $_endless_loop
|
||||||
_main_end:
|
_main_end:
|
||||||
hlt
|
hlt
|
||||||
## =========================================================================================================================
|
## =========================================================================================================================
|
||||||
|
|
@ -95,10 +144,73 @@ _main_end:
|
||||||
|
|
||||||
|
|
||||||
## =========================================================================================================================
|
## =========================================================================================================================
|
||||||
_key_pressed:
|
_test_partitions: ## _test_partitions(DPTBlock* dpt_entries_block, (1 Byte) dpt_entries_count, (4 Bytes*) part_addr)
|
||||||
mov ACC, [Keyboard_Registers.KEYCODE]
|
arg R1 ## dpt_entries_block
|
||||||
jne $_key_pressed_end, 0x0127
|
arg R2 ## dpt_entries_count
|
||||||
_key_pressed_end:
|
arg R4 ## part_addr
|
||||||
|
mov R3, 0 ## Entry counter
|
||||||
|
_test_partitions_loop:
|
||||||
|
push $ddd
|
||||||
|
push $bootstrap_block
|
||||||
|
push R3
|
||||||
|
push 3
|
||||||
|
call $_load_bootstrap_block
|
||||||
|
mov ACC, $bootstrap_block
|
||||||
|
mov ACC, *ACC
|
||||||
|
jeq $_test_partitions_found, DPTBootPartStructure.ID_CODE
|
||||||
|
inc R3
|
||||||
|
mov ACC, R3
|
||||||
|
jle $_test_partitions_not_found, R2
|
||||||
|
jmp $_test_partitions_loop
|
||||||
|
|
||||||
|
_test_partitions_found:
|
||||||
|
mov R10, R3
|
||||||
|
mulip R10, DPTStructure.ENTRY_SIZE_B
|
||||||
|
addip R10, R1
|
||||||
|
mov *R4, *R10
|
||||||
|
addip R4, 2
|
||||||
|
addip R10, 2
|
||||||
|
mov *R4, *R10
|
||||||
|
mov R9, *R4
|
||||||
|
addip R9, DPTBootPartStructure.HEADER_SIZE_B ## TODO: This doesn't take into account integer overflow, since it is a 32-Bit address
|
||||||
|
mov *R4, R9
|
||||||
|
mov RV, R3
|
||||||
|
ret
|
||||||
|
_test_partitions_not_found:
|
||||||
|
mov *R4, 0xFFFF
|
||||||
|
addip R4, 2
|
||||||
|
mov *R4, 0xFFFF
|
||||||
|
mov RV, 0xFF
|
||||||
|
ret
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
_load_bootstrap_block: ## _load_bootstrap_block(DiskDriverData* ddd, (32 Byte*) bootstrap_block, (1 Byte) dpt_entry)
|
||||||
|
arg R1 ## @Param: ddd
|
||||||
|
arg R2 ## @Param: bootstrap_block
|
||||||
|
arg R7 ## @Param: dpt_entry
|
||||||
|
mov R3, R1 ## Copy $ddd address into R3
|
||||||
|
movb *R1, DiskMode.READ ## $ddd.Mode
|
||||||
|
inc R1
|
||||||
|
movb *R1, 0x00 ## $ddd.Disk
|
||||||
|
inc R1
|
||||||
|
mov R10, $dpt_block.Entries
|
||||||
|
mulip R7, DPTStructure.ENTRY_SIZE_B
|
||||||
|
addip R10, R7
|
||||||
|
mov *R1, *R10 ## $ddd.Sector
|
||||||
|
addip R1, 2
|
||||||
|
addip R10, 2
|
||||||
|
mov *R1, *R10 ## $ddd.Address
|
||||||
|
addip R1, 2
|
||||||
|
mov *R1, DPTBootPartStructure.HEADER_SIZE_B ## $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
|
||||||
## =========================================================================================================================
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
@ -129,135 +241,13 @@ _load_dpt_block: ## _load_dpt_block(DiskDriverData* ddd, DPTBlock* dpt_block)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## =========================================================================================================================
|
|
||||||
_clear_screen: ## _clear_screen(int8_t color)
|
|
||||||
arg R1
|
|
||||||
movb [$textCell.Foreground], R1
|
|
||||||
movb [$textCell.Background], R1
|
|
||||||
movb [$textCell.Character], 0x20
|
|
||||||
mov R10, 0x24
|
|
||||||
mov R9, $textCell
|
|
||||||
int 0x30
|
|
||||||
ret
|
|
||||||
## =========================================================================================================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## =========================================================================================================================
|
|
||||||
_redraw_screen:
|
|
||||||
movb [VGA_Registers.SIGNAL], Sig_VGA_Text_16_Color.FORCE_REDRAW_SCREEN
|
|
||||||
ret
|
|
||||||
## =========================================================================================================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## =========================================================================================================================
|
|
||||||
_swap_buffers:
|
|
||||||
movb [VGA_Registers.SIGNAL], Sig_VGA_Text_16_Color.SWAP_BUFFERS
|
|
||||||
ret
|
|
||||||
## =========================================================================================================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## =========================================================================================================================
|
|
||||||
_print_main_box:
|
|
||||||
movb [$textCell.CoordX], 5
|
|
||||||
movb [$textCell.CoordY], 2
|
|
||||||
movb [$textCell.Foreground], DefaultPalette.Sky
|
|
||||||
movb [$textCell.Background], DefaultPalette.DarkBlue
|
|
||||||
movb [$textCell.Character], 0x3D
|
|
||||||
|
|
||||||
mov R8, [CMOS_Settings.SCREEN_WIDTH]
|
|
||||||
subip R8, 10
|
|
||||||
|
|
||||||
push $textCell
|
|
||||||
push R8
|
|
||||||
push 2
|
|
||||||
call $_draw_horizontal_line
|
|
||||||
|
|
||||||
movb [$textCell.CoordX], 5
|
|
||||||
movb [$textCell.CoordY], 12
|
|
||||||
push $textCell
|
|
||||||
push R8
|
|
||||||
push 2
|
|
||||||
call $_draw_horizontal_line
|
|
||||||
|
|
||||||
movb [$textCell.CoordX], 4
|
|
||||||
movb [$textCell.CoordY], 2
|
|
||||||
movb [$textCell.Character], 0x7C
|
|
||||||
push $textCell
|
|
||||||
push 11
|
|
||||||
push 2
|
|
||||||
call $_draw_vertical_line
|
|
||||||
|
|
||||||
addip R8, 5
|
|
||||||
movb [$textCell.CoordX], R8
|
|
||||||
movb [$textCell.CoordY], 2
|
|
||||||
push $textCell
|
|
||||||
push 11
|
|
||||||
push 2
|
|
||||||
call $_draw_vertical_line
|
|
||||||
ret
|
|
||||||
## =========================================================================================================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## =========================================================================================================================
|
|
||||||
_draw_horizontal_line: ## _draw_horizontal_line(TextCell16* cell, int8_t length)
|
|
||||||
arg R1 ## @Param: cell
|
|
||||||
arg R2 ## @Param: length
|
|
||||||
mov R3, R1
|
|
||||||
addip R3, 3
|
|
||||||
movb R4, *R3
|
|
||||||
|
|
||||||
mov R10, 0x21
|
|
||||||
mov R9, R1
|
|
||||||
_draw_horizontal_line_loop:
|
|
||||||
int 0x30
|
|
||||||
movb R5, *R3
|
|
||||||
inc R5
|
|
||||||
movb *R3, R5
|
|
||||||
sub R5, R4
|
|
||||||
jgr $_draw_horizontal_line_loop, R2
|
|
||||||
ret
|
|
||||||
## =========================================================================================================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## =========================================================================================================================
|
|
||||||
_draw_vertical_line: ## _draw_line(TextCell16* cell, int8_t length)
|
|
||||||
arg R1 ## @Param: cell
|
|
||||||
arg R2 ## @Param: length
|
|
||||||
mov R3, R1
|
|
||||||
addip R3, 4
|
|
||||||
movb R4, *R3
|
|
||||||
|
|
||||||
mov R10, 0x21
|
|
||||||
mov R9, R1
|
|
||||||
_draw_vertical_line_loop:
|
|
||||||
int 0x30
|
|
||||||
movb R5, *R3
|
|
||||||
inc R5
|
|
||||||
movb *R3, R5
|
|
||||||
sub R5, R4
|
|
||||||
jgr $_draw_vertical_line_loop, R2
|
|
||||||
ret
|
|
||||||
## =========================================================================================================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## =========================================================================================================================
|
## =========================================================================================================================
|
||||||
_print_error_msg: ## _print_error_msg(string* error_msg)
|
_print_error_msg: ## _print_error_msg(string* error_msg)
|
||||||
arg R1 ## @Param: error_msg
|
arg R1 ## @Param: error_msg
|
||||||
## TODO: Clear the screen
|
## TODO: Clear the screen
|
||||||
movb [$textCell.CoordX], 0
|
movb [$textCell.CoordX], 0
|
||||||
movb [$textCell.CoordY], 0
|
movb [$textCell.CoordY], 1
|
||||||
movb [$textCell.Foreground], DefaultPalette.Red
|
movb [$textCell.Foreground], DefaultPalette.Red
|
||||||
movb [$textCell.Background], DefaultPalette.Black
|
movb [$textCell.Background], DefaultPalette.Black
|
||||||
mov R10, 0x22
|
mov R10, 0x22
|
||||||
|
|
@ -274,8 +264,8 @@ _print_error_msg: ## _print_error_msg(string* error_msg)
|
||||||
_print_system_info:
|
_print_system_info:
|
||||||
movb [$textCell.CoordX], 0
|
movb [$textCell.CoordX], 0
|
||||||
movb [$textCell.CoordY], 0
|
movb [$textCell.CoordY], 0
|
||||||
movb [$textCell.Foreground], DefaultPalette.Sky
|
movb [$textCell.Foreground], DefaultPalette.Green
|
||||||
movb [$textCell.Background], DefaultPalette.DarkBlue
|
movb [$textCell.Background], DefaultPalette.Black
|
||||||
mov R10, 0x22
|
mov R10, 0x22
|
||||||
mov R8, $drake_version_str
|
mov R8, $drake_version_str
|
||||||
mov R9, $textCell
|
mov R9, $textCell
|
||||||
|
|
@ -302,3 +292,136 @@ _print_system_info:
|
||||||
int 0x30
|
int 0x30
|
||||||
ret
|
ret
|
||||||
## =========================================================================================================================
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
_clear_screen: ## _clear_screen(int8_t color)
|
||||||
|
arg R1
|
||||||
|
movb [$textCell.Foreground], R1
|
||||||
|
movb [$textCell.Background], R1
|
||||||
|
movb [$textCell.Character], 0x20
|
||||||
|
mov R10, 0x24
|
||||||
|
mov R9, $textCell
|
||||||
|
int 0x30
|
||||||
|
ret
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
_redraw_screen:
|
||||||
|
movb [VGA_Registers.SIGNAL], Sig_VGA_Text_16_Color.FORCE_REDRAW_SCREEN
|
||||||
|
ret
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
## _swap_buffers:
|
||||||
|
## movb [VGA_Registers.SIGNAL], Sig_VGA_Text_16_Color.SWAP_BUFFERS
|
||||||
|
## ret
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
## _key_pressed:
|
||||||
|
## mov ACC, [Keyboard_Registers.KEYCODE]
|
||||||
|
## jne $_key_pressed_end, 0x0127
|
||||||
|
## _key_pressed_end:
|
||||||
|
## ret
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
## _print_main_box:
|
||||||
|
## movb [$textCell.CoordX], 5
|
||||||
|
## movb [$textCell.CoordY], 2
|
||||||
|
## movb [$textCell.Foreground], DefaultPalette.Sky
|
||||||
|
## movb [$textCell.Background], DefaultPalette.DarkBlue
|
||||||
|
## movb [$textCell.Character], 0x3D
|
||||||
|
##
|
||||||
|
## mov R8, [CMOS_Settings.SCREEN_WIDTH]
|
||||||
|
## subip R8, 10
|
||||||
|
##
|
||||||
|
## push $textCell
|
||||||
|
## push R8
|
||||||
|
## push 2
|
||||||
|
## call $_draw_horizontal_line
|
||||||
|
##
|
||||||
|
## movb [$textCell.CoordX], 5
|
||||||
|
## movb [$textCell.CoordY], 12
|
||||||
|
## push $textCell
|
||||||
|
## push R8
|
||||||
|
## push 2
|
||||||
|
## call $_draw_horizontal_line
|
||||||
|
##
|
||||||
|
## movb [$textCell.CoordX], 4
|
||||||
|
## movb [$textCell.CoordY], 2
|
||||||
|
## movb [$textCell.Character], 0x7C
|
||||||
|
## push $textCell
|
||||||
|
## push 11
|
||||||
|
## push 2
|
||||||
|
## call $_draw_vertical_line
|
||||||
|
##
|
||||||
|
## addip R8, 5
|
||||||
|
## movb [$textCell.CoordX], R8
|
||||||
|
## movb [$textCell.CoordY], 2
|
||||||
|
## push $textCell
|
||||||
|
## push 11
|
||||||
|
## push 2
|
||||||
|
## call $_draw_vertical_line
|
||||||
|
## ret
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
## _draw_horizontal_line: ## _draw_horizontal_line(TextCell16* cell, int8_t length)
|
||||||
|
## arg R1 ## @Param: cell
|
||||||
|
## arg R2 ## @Param: length
|
||||||
|
## mov R3, R1
|
||||||
|
## addip R3, 3
|
||||||
|
## movb R4, *R3
|
||||||
|
##
|
||||||
|
## mov R10, 0x21
|
||||||
|
## mov R9, R1
|
||||||
|
## _draw_horizontal_line_loop:
|
||||||
|
## int 0x30
|
||||||
|
## movb R5, *R3
|
||||||
|
## inc R5
|
||||||
|
## movb *R3, R5
|
||||||
|
## sub R5, R4
|
||||||
|
## jgr $_draw_horizontal_line_loop, R2
|
||||||
|
## ret
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## =========================================================================================================================
|
||||||
|
## _draw_vertical_line: ## _draw_line(TextCell16* cell, int8_t length)
|
||||||
|
## arg R1 ## @Param: cell
|
||||||
|
## arg R2 ## @Param: length
|
||||||
|
## mov R3, R1
|
||||||
|
## addip R3, 4
|
||||||
|
## movb R4, *R3
|
||||||
|
##
|
||||||
|
## mov R10, 0x21
|
||||||
|
## mov R9, R1
|
||||||
|
## _draw_vertical_line_loop:
|
||||||
|
## int 0x30
|
||||||
|
## movb R5, *R3
|
||||||
|
## inc R5
|
||||||
|
## movb *R3, R5
|
||||||
|
## sub R5, R4
|
||||||
|
## jgr $_draw_vertical_line_loop, R2
|
||||||
|
## ret
|
||||||
|
## =========================================================================================================================
|
||||||
|
|
@ -247,3 +247,14 @@
|
||||||
Unallocated 90 kb 92160 bytes (0x16800) 0x0000.1800 -> 0x0001.7FFF
|
Unallocated 90 kb 92160 bytes (0x16800) 0x0000.1800 -> 0x0001.7FFF
|
||||||
DragonOS 2000 kb 2048000 bytes (0x1F4000) 0x0001.8000 -> 0x0020.BFFF
|
DragonOS 2000 kb 2048000 bytes (0x1F4000) 0x0001.8000 -> 0x0020.BFFF
|
||||||
Test Partition 2000 kb 2048000 bytes (0x1F4000) 0x0020.C000 -> 0x0040.0000
|
Test Partition 2000 kb 2048000 bytes (0x1F4000) 0x0020.C000 -> 0x0040.0000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#==========================================================================================================================================
|
||||||
|
# Bootstrap structure
|
||||||
|
#==========================================================================================================================================
|
||||||
|
Starting bytes of bootable partition:
|
||||||
|
Identifier (2 Bytes) - Must be set to 0xF1C4
|
||||||
|
Reserved (30 Bytes)
|
||||||
|
|
||||||
|
Kernel first stage block must start at PART_ADDR + 32 and must be 1024 bytes in size
|
||||||
|
|
@ -16,6 +16,7 @@ if [ $? -eq 0 ]; then
|
||||||
/bin/bash ./bios_flash
|
/bin/bash ./bios_flash
|
||||||
cp ../dss/bios_api.dss ../../extra/dss/bios_api.dss
|
cp ../dss/bios_api.dss ../../extra/dss/bios_api.dss
|
||||||
/bin/bash ./build_drake
|
/bin/bash ./build_drake
|
||||||
|
/bin/bash ./build_dragonos
|
||||||
cd ..
|
cd ..
|
||||||
printf "\n${green}Running Application...\n\n${clear}"
|
printf "\n${green}Running Application...\n\n${clear}"
|
||||||
./ddb config/testMachine.dvm --verbose-load
|
./ddb config/testMachine.dvm --verbose-load
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ if [ $? -eq 0 ]; then
|
||||||
/bin/bash ./bios_flash
|
/bin/bash ./bios_flash
|
||||||
cp ../dss/bios_api.dss ../../extra/dss/bios_api.dss
|
cp ../dss/bios_api.dss ../../extra/dss/bios_api.dss
|
||||||
/bin/bash ./build_drake
|
/bin/bash ./build_drake
|
||||||
|
/bin/bash ./build_dragonos
|
||||||
cd ..
|
cd ..
|
||||||
printf "\n${green}Running Application...\n\n${clear}"
|
printf "\n${green}Running Application...\n\n${clear}"
|
||||||
./dvm config/testMachine.dvm
|
./dvm config/testMachine.dvm
|
||||||
|
|
|
||||||
18
extra/scripts/build_dragonos
Normal file
18
extra/scripts/build_dragonos
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
green='\033[0;32m'
|
||||||
|
clear='\033[0m'
|
||||||
|
|
||||||
|
printf "\n${green}Compiling DragonOS...\n${clear}"
|
||||||
|
cd ..
|
||||||
|
cp ../extra/dss/DragonOS/* ./dss/DragonOS/
|
||||||
|
|
||||||
|
printf "\n${green}1) kernel0.dss\n${clear}"
|
||||||
|
./dasm dss/DragonOS/kernel0.dss -o dragon/kernel0.bin -D
|
||||||
|
./dtools load-binary dragon/disk1.dr dragon/kernel0.bin 0x00018000
|
||||||
|
|
||||||
|
printf "\n"
|
||||||
|
|
||||||
|
|
||||||
|
cp dragon/disk1.dr ../extra/dragon/disk1.dr
|
||||||
|
rm dragon/kernel0.bin
|
||||||
|
|
@ -57,6 +57,7 @@ namespace dragon
|
||||||
for (int16_t i = m_code.size(); i < m_fixedSize; i++)
|
for (int16_t i = m_code.size(); i < m_fixedSize; i++)
|
||||||
m_code.push_back(m_fixedFillValue);
|
m_code.push_back(m_fixedFillValue);
|
||||||
}
|
}
|
||||||
|
insertHeader();
|
||||||
return m_code;
|
return m_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,6 +158,32 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Assembler::insertHeader(void)
|
||||||
|
{
|
||||||
|
if (m_code.size() == 0) return;
|
||||||
|
ostd::ByteStream header;
|
||||||
|
|
||||||
|
m_headerStr.toLower().trim();
|
||||||
|
if (m_headerStr == "") return;
|
||||||
|
//TODO: Expand header functionality to allow for custom values maybe
|
||||||
|
if (m_headerStr == "kernel0_boot")
|
||||||
|
{
|
||||||
|
header.push_back((uint8_t)((data::DPTStructure::BootPart_ID_CODE & 0xFF00) >> 8));
|
||||||
|
header.push_back((uint8_t)(data::DPTStructure::BootPart_ID_CODE & 0x00FF));
|
||||||
|
for (int32_t i = 0; i < 30; i++)
|
||||||
|
header.push_back(0xFF);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Invalid .header value: " << m_headerStr << "\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_code.insert(m_code.begin(), header.begin(), header.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Assembler::removeComments(void)
|
void Assembler::removeComments(void)
|
||||||
{
|
{
|
||||||
std::vector<ostd::String> newLines;
|
std::vector<ostd::String> newLines;
|
||||||
|
|
@ -800,6 +827,18 @@ namespace dragon
|
||||||
m_entry_lbl = lineEdit;
|
m_entry_lbl = lineEdit;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (lineEdit.startsWith(".header "))
|
||||||
|
{
|
||||||
|
if (lineEdit.len() < 9)
|
||||||
|
{
|
||||||
|
//TODO: Error
|
||||||
|
std::cout << "Invalid .header value: " << lineEdit << "\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lineEdit.substr(8).trim();
|
||||||
|
m_headerStr = lineEdit;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else if (lineEdit.startsWith(".load "))
|
else if (lineEdit.startsWith(".load "))
|
||||||
{
|
{
|
||||||
if (lineEdit.len() < 7)
|
if (lineEdit.len() < 7)
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,8 @@ namespace dragon
|
||||||
static void printProgramInfo(void);
|
static void printProgramInfo(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void insertHeader(void);
|
||||||
|
|
||||||
static void removeComments(void);
|
static void removeComments(void);
|
||||||
static void replaceDefines(void);
|
static void replaceDefines(void);
|
||||||
static void replaceGroupDefines(void);
|
static void replaceGroupDefines(void);
|
||||||
|
|
@ -163,6 +165,7 @@ namespace dragon
|
||||||
inline static uint16_t m_dataSize { 0x0000 };
|
inline static uint16_t m_dataSize { 0x0000 };
|
||||||
inline static uint16_t m_programSize { 0x0000 };
|
inline static uint16_t m_programSize { 0x0000 };
|
||||||
inline static ostd::String m_entry_lbl { "" };
|
inline static ostd::String m_entry_lbl { "" };
|
||||||
|
inline static ostd::String m_headerStr { "" };
|
||||||
|
|
||||||
inline static std::vector<tStructDefinition> m_structDefs;
|
inline static std::vector<tStructDefinition> m_structDefs;
|
||||||
inline static std::vector<tDisassemblyLine> m_disassembly;
|
inline static std::vector<tDisassemblyLine> m_disassembly;
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,9 @@ namespace dragon
|
||||||
|
|
||||||
inline bool isInitialized(void) const { return m_initialized; }
|
inline bool isInitialized(void) const { return m_initialized; }
|
||||||
inline bool isRunning(void) const { return m_running; }
|
inline bool isRunning(void) const { return m_running; }
|
||||||
inline void hide(void) { SDL_HideWindow(m_window); }
|
inline bool isVisible(void) const { return m_visible; }
|
||||||
inline void show(void) { SDL_ShowWindow(m_window); }
|
inline void hide(void) { SDL_HideWindow(m_window); m_visible = false; }
|
||||||
|
inline void show(void) { SDL_ShowWindow(m_window); m_visible = true; }
|
||||||
inline ostd::String getTitle(void) const { return m_title; }
|
inline ostd::String getTitle(void) const { return m_title; }
|
||||||
inline int32_t getFPS(void) const { return m_fps; }
|
inline int32_t getFPS(void) const { return m_fps; }
|
||||||
inline int32_t getWindowWidth(void) const { return m_windowWidth; }
|
inline int32_t getWindowWidth(void) const { return m_windowWidth; }
|
||||||
|
|
@ -63,6 +64,7 @@ namespace dragon
|
||||||
bool m_deagEventEnabled { false };
|
bool m_deagEventEnabled { false };
|
||||||
bool m_running { false };
|
bool m_running { false };
|
||||||
bool m_initialized { false };
|
bool m_initialized { false };
|
||||||
|
bool m_visible { true };
|
||||||
};
|
};
|
||||||
class WindowResizedData : public ostd::BaseObject
|
class WindowResizedData : public ostd::BaseObject
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ namespace dragon
|
||||||
|
|
||||||
void VirtualDisplay::onRender(void)
|
void VirtualDisplay::onRender(void)
|
||||||
{
|
{
|
||||||
|
if (!isVisible()) return;
|
||||||
auto& config = DragonRuntime::machine_config;
|
auto& config = DragonRuntime::machine_config;
|
||||||
auto& mem = DragonRuntime::memMap;
|
auto& mem = DragonRuntime::memMap;
|
||||||
uint16_t vga_addr = data::MemoryMapAddresses::VideoCardInterface_Start;
|
uint16_t vga_addr = data::MemoryMapAddresses::VideoCardInterface_Start;
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ namespace dragon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline static constexpr uint16_t HeaderReservedSizeBytes= 7;
|
inline static constexpr uint16_t HeaderReservedSizeBytes = 7;
|
||||||
inline static constexpr uint16_t DiskAddress = 0x200;
|
inline static constexpr uint16_t DiskAddress = 0x200;
|
||||||
inline static constexpr uint16_t DPT_ID_CODE = 0xF1CA;
|
inline static constexpr uint16_t DPT_ID_CODE = 0xF1CA;
|
||||||
inline static constexpr uint16_t EntrySizeBytes = 100;
|
inline static constexpr uint16_t EntrySizeBytes = 100;
|
||||||
|
|
@ -260,6 +260,14 @@ namespace dragon
|
||||||
inline static constexpr uint8_t CurrentDPTVersionMin = 0x02;
|
inline static constexpr uint8_t CurrentDPTVersionMin = 0x02;
|
||||||
inline static constexpr uint32_t DiskStartAddr = 0x00000400;
|
inline static constexpr uint32_t DiskStartAddr = 0x00000400;
|
||||||
inline static constexpr uint8_t MaxPartCount = 5;
|
inline static constexpr uint8_t MaxPartCount = 5;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline static constexpr uint16_t BootPart_IDAddr = 0x0000;
|
||||||
|
inline static constexpr uint16_t BootPart_CodeStart = 0x0020;
|
||||||
|
inline static constexpr uint16_t BootPart_ID_CODE = 0xF1C4;
|
||||||
|
inline static constexpr uint16_t BootPart_CodeSizeBytes = 1024;
|
||||||
|
inline static constexpr uint8_t BootPart_HeaderSizeBytes = 32;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPUExtension
|
class CPUExtension
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue