Skip to content

Commit

Permalink
Did some code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
chessmaster42 committed May 6, 2012
1 parent 473cd91 commit c5efd82
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 145 deletions.
32 changes: 20 additions & 12 deletions apps/AtlasShell.dasm16
Expand Up @@ -903,45 +903,53 @@
SET A, POP
SET PC, POP

; Data
; Misc data
:text_versionoutput dat "Atlas-Shell v0.4.0", 0xA0, 0x00
:text_prompt dat " $> ", 0x00
:text_unrecognized dat "Unrecognized command", 0xA0, 0x00
:input_text_buffer dat " ", 0x00
:input_buffer dat 0x0000
:ack_command dat 0x00
:command_clear dat "clear", 0
:command_version dat "version", 0
:command_version_os dat "os", 0
:command_version_separator dat ".", 0
:command_load dat "load", 0
:command_load_help dat "Syntax: load [appID]", 0xA0, 0x00
:command_load_unknown dat "Failed to load application", 0xA0, 0x00
:command_kill dat "kill", 0
:command_kill_forbidden dat "Cannot kill process: Forbidden", 0xA0, 0x00
:command_kill_help dat "Syntax: kill [last|procID]", 0xA0, 0x00
:command_kill_last dat "last", 0
:command_list dat "list", 0
:command_list_info dat "Process list:", 0xA0, 0x00
:command_parameter_buffer dat " ", 0x00
:command_number_buffer dat " ", 0x00
:command_ls dat "ls", 0
:command_ls_row dat " ", 0x00
:command_cd dat "cd", 0
:command_cd_back dat "..", 0
:command_cd_root dat "/", 0
:command_cd_help dat "Syntax : cd [directory|..|/]", 0xA0, 0x00
:command_cd_unknown dat " doesnt exist", 0xA0, 0
:command_runfile_notexe_text dat "File is not executable", 0xA0, 0x00

; Command list
:command_clear dat "clear", 0
:command_version dat "version", 0
:command_load dat "load", 0
:command_kill dat "kill", 0
:command_list dat "list", 0
:command_ls dat "ls", 0
:command_cd dat "cd", 0
:command_cat dat "cat", 0
:command_mkdir dat "mkdir", 0 ; UNFINISHED
:command_rmdir dat "rmdir", 0 ; UNFINISHED
:command_cp dat "cp", 0 ; UNFINISHED
:command_ln dat "ln", 0 ; UNFINISHED
:command_mv dat "mv", 0 ; UNFINISHED

; Process list buffer. Used for the 'kill' command
:proc_list_buffer
dat 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
dat 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
:proc_list_buffer_end
:last_proc dat 0x0000

:text_unrecognized dat "Unrecognized command", 0xA0, 0x00
:text_versionoutput dat "Atlas-Shell v0.4.0", 0xA0, 0x00
:text_prompt dat " $> ", 0x00

; Filesystem data
:present_working_directory dat 0x0000
:present_working_directory_name dat " ", 0x00
:directory_stack
Expand Down
238 changes: 111 additions & 127 deletions kernel/drivers.dasm16
@@ -1,134 +1,116 @@
; ################START BIOS#################

:bios_boot
HWN Z
IFE Z, 0 ; Loop indefinitely until we have hardware connected
SET PC, bios_boot

:bios_display_initloop
SUB Z, 1
HWQ Z

IFN A, 0xf615 ; LEM1802 Monitor
SET PC,bios_display_initloop
IFN B, 0x7349 ; LEM1802 Monitor
SET PC,bios_display_initloop

SET [display_address], Z

;;map screen
SET A, 0
SET B, [video_mem]
HWI Z

;; dump palette
SET A, 5
SET B, [video_palette]
HWI Z
;;map palette
SET A, 2
SET B, [video_palette]
HWI Z

;; dump font
SET A, 4
SET B, [video_font]
HWI Z
;;map font
SET A, 1
SET B, [video_font]
HWI Z

:bios_keyboard_start
HWN Z
:bios_keyboard_initloop
IFE Z, 0 ; Check if the keyboard doesn't exist
SET PC, bios_clock_start
SUB Z, 1
HWQ Z

IFN A, 0x7406 ; Generic Keyboard (lower 8 bits)
SET PC, bios_keyboard_initloop
IFN B, 0x30CF ; Generic Keyboard (upper 8 bits)
SET PC, bios_keyboard_initloop

SET [keyboard_address], Z

SET A, 3
SET B, [keyboard_address] ; Our magic word to tell the handler we have a keyboard keypress
ADD B, 1 ; Always use HW+1 so we never pass a 0 to B as that would disable interrupts
HWI Z

:bios_clock_start
HWN Z
:bios_clock_initloop
IFE Z, 0 ; Check if the clock doesn't exist
SET PC, bios_floppy_start
SUB Z, 1
HWQ Z

IFN A, 0xB402 ; Generic Clock (lower 8 bits)
SET PC, bios_clock_initloop
IFN B, 0x12D0 ; Generic Clock (upper 8 bits)
SET PC, bios_clock_initloop

SET [clock_address], Z

; Set clock tick rate (60/B = 5/sec)
SET A, 0
SET B, 12 ; 5/sec
HWI [clock_address]

; Setup interrupts for clock
SET A, 2
SET B, [clock_address] ; Our magic word to tell the handler we have a clock tick
ADD B, 1 ; Always use HW+1 so we never pass a 0 to B as that would disable interrupts
HWI [clock_address]

:bios_floppy_start

SET PC, bios_hardware_end ; Disable floppy code for now

HWN Z
:bios_floppy_init_loop
IFE Z, 0 ; Check if the flooppy drive doesn't exist
SET PC, bios_hardware_end
SUB Z, 1
HWQ Z

IFN A, 0x4CAE
SET PC, bios_floppy_init_loop
IFN B, 0x74FA
SET PC, bios_floppy_init_loop

SET [floppy_address], Z

;Set interrupts for floppy
SET A, 5
SET B, [floppy_address] ; Our magic word to tell the handler we have a floppy event
ADD B, 1
HWI [floppy_address]

SET A, 0 ; check if media is present
HWI [floppy_address]
IFE B, 0
SET PC, bios_floppy_end

SET A, 0x001 ;check media parameters
HWI [floppy_address]
SET [floppy_words_per_sector], B
SET [floppy_sectors], C
SET [floppy_write_locked], X

;check media quality
SET A, 0xFFFF
HWI [floppy_address]
SET [floppy_quality], B
HWN Z
IFE Z, 0 ; Loop indefinitely until we have hardware connected
SET PC, bios_boot

:bios_discover_hardware_loop
SUB Z, 1
HWQ Z

IFE A, 0xF615 ; LEM1802 Monitor (lower 16 bits)
IFE B, 0x7349 ; LEM1802 Monitor (upper 16 bits)
JSR bios_display_init

IFE A, 0x7406 ; Generic keyboard (lower 16 bits)
IFE B, 0x30CF ; Generic keyboard (upper 16 bits)
JSR bios_keyboard_init

IFE A, 0xB402 ; Generic Clock (lower 16 bits)
IFE B, 0x12D0 ; Generic Clock (upper 16 bits)
JSR bios_clock_init

;IFE A, 0x4CAE ; HMD2043 floppy disc drive (lower 16 bits)
; IFE B, 0x74FA ; HMD2043 floppy disc drive (upper 16 bits)
; JSR bios_floppy_init

IFN Z, 0
SET PC, bios_discover_hardware_loop

:bios_floppy_end
SET PC, POP


:bios_display_init
SET [display_address], Z

; map screen
SET A, 0
SET B, [video_mem]
HWI Z

; dump palette
SET A, 5
SET B, [video_palette]
HWI Z
; map palette
SET A, 2
SET B, [video_palette]
HWI Z

; dump font
SET A, 4
SET B, [video_font]
HWI Z
; map font
SET A, 1
SET B, [video_font]
HWI Z

SET PC, POP

:bios_keyboard_init
SET [keyboard_address], Z

:bios_hardware_end
SET PC, POP
SET A, 3
SET B, [keyboard_address] ; Our magic word to tell the handler we have a keyboard keypress
ADD B, 1 ; Always use HW+1 so we never pass a 0 to B as that would disable interrupts
HWI Z

SET PC, POP

:bios_clock_init
SET [clock_address], Z

; Set clock tick rate (60/B = 5/sec)
SET A, 0
SET B, 12 ; 5/sec
HWI [clock_address]

; Setup interrupts for clock
SET A, 2
SET B, [clock_address] ; Our magic word to tell the handler we have a clock tick
ADD B, 1 ; Always use HW+1 so we never pass a 0 to B as that would disable interrupts
HWI [clock_address]

SET PC, POP

:bios_floppy_init
SET [floppy_address], Z

;Set interrupts for floppy
SET A, 5
SET B, [floppy_address] ; Our magic word to tell the handler we have a floppy event
ADD B, 1
HWI [floppy_address]

SET A, 0 ; check if media is present
HWI [floppy_address]
IFE B, 0
SET PC, bios_floppy_end

SET A, 0x0001 ;check media parameters
HWI [floppy_address]
SET [floppy_words_per_sector], B
SET [floppy_sectors], C
SET [floppy_write_locked], X

;check media quality
SET A, 0xFFFF
HWI [floppy_address]
SET [floppy_quality], B
:bios_floppy_end
SET PC, POP

:display_address
dat 0x0000
Expand All @@ -149,7 +131,7 @@ dat 0x0000

; ################END BIOS#################

; Driver functions
; ############DRIVER FUNCTIONS#############

; START OF THE KEYBOARD DRIVER
:driver_keyboard
Expand Down Expand Up @@ -286,3 +268,5 @@ dat 0x0000
:keyboard_unregister_all_end
SET A, POP
SET PC, POP

; ########### END DRIVER FUNCTIONS##########
7 changes: 7 additions & 0 deletions kernel/interrupts.dasm16
Expand Up @@ -7,6 +7,8 @@
JSR kernel_interrupt_handler_keyboard
IFE A, [clock_address]
JSR kernel_interrupt_handler_clock
IFE A, [floppy_address]
JSR kernel_interrupt_handler_floppy

SET EX, POP
RFI 0
Expand All @@ -30,3 +32,8 @@
SET B, POP
SET C, POP
SET PC, POP

:kernel_interrupt_handler_floppy
; TODO
SET PC, POP

21 changes: 15 additions & 6 deletions misc/vfs.dasm16
@@ -1,23 +1,26 @@
:files

; Primary file table
; Flags: Bit 0 - read, Bit 1 - write, Bit 2 - hidden, Bit 3 - executable, Bit 4 - directory
; Flags: Bit 1 - read, Bit 2 - write, Bit 3 - hidden, Bit 4 - executable, Bit 5 - directory
; Bit 6 - encrypted, Bit 7 - compressed
; Each entry must be 20 words long
; directory ID, flags, name, null terminator, padding, start, end
; For directory entries, the 'start' contains the ID and the 'end' is unused
; dat DirID , Flags , "File name goes here ", Start , End dat ModifiedTime dat CreatedTime dat SymLink
:files_table
dat 0x000B ; Number of files in table
dat 0xFFFF, 0x0011, "/", 0, " ", 0x0000, 0x0000 ; root directory
dat 0x0000, 0x0011, "TextFiles", 0, " ", 0x0001, 0x0000
dat 0x000C ; Number of files in table
dat 0xFFFF, 0x0011, "/", 0, " ", 0x0000, 0x0000
dat 0x0004, 0x0011, "TextFiles", 0, " ", 0x0001, 0x0000
dat 0x0000, 0x0011, "Programs", 0, " ", 0x0002, 0x0000
dat 0x0000, 0x0011, "Data", 0, " ", 0x0004, 0x0000
dat 0x0002, 0x0011, "System", 0, " ", 0x0003, 0x0000
dat 0x0000, 0x0011, "libs", 0, " ", 0x0005, 0x0000
dat 0x0000, 0x0011, "System", 0, " ", 0x0003, 0x0000
dat 0x0003, 0x0011, "libs", 0, " ", 0x0005, 0x0000
dat 0x0001, 0x0003, "file01", 0, " ", file01, file01_end
dat 0x0002, 0x0009, "hello_world", 0, " ", file02, file02_end
dat 0x0003, 0x0009, "free_mem", 0, " ", file03, file03_end
dat 0x0001, 0x0005, "file04", 0, " ", file04, file04_end
dat 0x0002, 0x0009, "ball_game", 0, " ", file05, file05_end
dat 0x0001, 0x0003, "file06", 0, " ", file06, file06_end
:files_table_end

; Basic flat text file
Expand All @@ -27,6 +30,12 @@
dat "Termination", 0x00
:file01_end

:file06
dat "Now some tests for output", 0xA0
dat "to see how we handle things", 0xA0
dat "I hope it works", 0x00
:file06_end

; HelloWorld
; Description: Displays "Hello World"
:file02 ; AtlasOS ABI-compliant executable file
Expand Down

0 comments on commit c5efd82

Please sign in to comment.