Skip to content

Commit de7fadd

Browse files
authored
Merge pull request #11 from ReturnInfinity/lfb
Remove Linear Frame Buffer support
2 parents ef741b5 + 2b968c3 commit de7fadd

File tree

8 files changed

+132
-6403
lines changed

8 files changed

+132
-6403
lines changed

api/lib-ui.asm

Lines changed: 0 additions & 25 deletions
This file was deleted.

api/lib-ui.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/monitor.asm

Lines changed: 132 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99

1010
BITS 64
1111
ORG 0x001E0000
12-
MONITORSIZE equ 8192 ; Pad Monitor to this length
12+
MONITORSIZE equ 6144 ; Pad Monitor to this length
1313

1414
%include 'api/libBareMetal.asm'
1515

1616
start:
1717
cmp byte [firstrun], 1 ; Check if the first run flag is set
1818
jne poll ; If not, jump to poll
19-
call ui_init ; Otherwise run ui_init
20-
mov byte [firstrun], 0 ; And clear the first run flag
19+
mov byte [firstrun], 0 ; Otherwise clear the first run flag
2120

2221
; Move RAM drive image to proper location (if it was provided)
2322
cmp byte [0x410000], 0 ; Check for a non-zero value
@@ -44,6 +43,10 @@ check_next:
4443
rep movsq
4544
skip_ramdrive:
4645

46+
; Clear screen
47+
mov al, 0x01 ; Code for Clear Screen
48+
call output_char
49+
4750
; Output system details
4851

4952
; Output core count and speed
@@ -250,7 +253,8 @@ exec:
250253
jmp poll
251254

252255
cls:
253-
call screen_clear
256+
mov al, 0x01
257+
call output_char
254258
jmp poll_nonewline
255259

256260
dir:
@@ -441,8 +445,7 @@ loadr:
441445
mov rdi, [ProgramLocation]
442446
rep movsb
443447
jmp poll
444-
445-
448+
446449
dump:
447450
cmp byte [args], 4
448451
jl insuf
@@ -742,6 +745,29 @@ toomany:
742745

743746
; Internal functions
744747

748+
; -----------------------------------------------------------------------------
749+
; string_length -- Return length of a string
750+
; IN: RSI = string location
751+
; OUT: RCX = length (not including the NULL terminator)
752+
; All other registers preserved
753+
string_length:
754+
push rdi
755+
push rax
756+
757+
xor ecx, ecx
758+
xor eax, eax
759+
mov rdi, rsi
760+
not rcx
761+
repne scasb ; compare byte at RDI to value in AL
762+
not rcx
763+
dec rcx
764+
765+
pop rax
766+
pop rdi
767+
ret
768+
; -----------------------------------------------------------------------------
769+
770+
745771
; -----------------------------------------------------------------------------
746772
; string_compare -- See if two strings match
747773
; IN: RSI = string one
@@ -1002,6 +1028,106 @@ string_to_int_invalid:
10021028
; -----------------------------------------------------------------------------
10031029

10041030

1031+
; -----------------------------------------------------------------------------
1032+
; ui_input -- Take string from keyboard entry
1033+
; IN: RDI = location where string will be stored
1034+
; RCX = maximum number of characters to accept
1035+
; OUT: RCX = length of string that was received (NULL not counted)
1036+
; All other registers preserved
1037+
ui_input:
1038+
push rdi
1039+
push rdx ; Counter to keep track of max accepted characters
1040+
push rax
1041+
1042+
mov rdx, rcx ; Max chars to accept
1043+
xor ecx, ecx ; Offset from start
1044+
1045+
ui_input_more:
1046+
mov al, '_' ; Cursor character
1047+
call output_char ; Output the cursor
1048+
mov al, 0x03 ; Decrement cursor
1049+
call output_char ; Output the cursor
1050+
ui_input_halt:
1051+
hlt ; Halt until an interrupt is received
1052+
call [b_input] ; Returns the character entered. 0 if there was none
1053+
jz ui_input_halt ; If there was no character then halt until an interrupt is received
1054+
ui_input_process:
1055+
cmp al, 0x1C ; If Enter key pressed, finish
1056+
je ui_input_done
1057+
cmp al, 0x0E ; Backspace
1058+
je ui_input_backspace
1059+
cmp al, 32 ; In ASCII range (32 - 126)?
1060+
jl ui_input_more
1061+
cmp al, 126
1062+
jg ui_input_more
1063+
cmp rcx, rdx ; Check if we have reached the max number of chars
1064+
je ui_input_more ; Jump if we have (should beep as well)
1065+
stosb ; Store AL at RDI and increment RDI by 1
1066+
inc rcx ; Increment the counter
1067+
call output_char ; Display char
1068+
jmp ui_input_more
1069+
1070+
ui_input_backspace:
1071+
test rcx, rcx ; backspace at the beginning? get a new char
1072+
jz ui_input_more
1073+
mov al, ' '
1074+
call output_char ; Output backspace as a character
1075+
mov al, 0x03 ; Decrement cursor
1076+
call output_char ; Output the cursor
1077+
mov al, 0x03 ; Decrement cursor
1078+
call output_char ; Output the cursor
1079+
dec rdi ; go back one in the string
1080+
mov byte [rdi], 0x00 ; NULL out the char
1081+
dec rcx ; decrement the counter by one
1082+
jmp ui_input_more
1083+
1084+
ui_input_done:
1085+
xor al, al
1086+
stosb ; We NULL terminate the string
1087+
mov al, ' '
1088+
call output_char ; Overwrite the cursor
1089+
1090+
pop rax
1091+
pop rdx
1092+
pop rdi
1093+
ret
1094+
; -----------------------------------------------------------------------------
1095+
1096+
1097+
; -----------------------------------------------------------------------------
1098+
; ui_output -- Displays text
1099+
; IN: RSI = message location (zero-terminated string)
1100+
; OUT: All registers preserved
1101+
ui_output:
1102+
push rcx
1103+
1104+
call string_length ; Calculate the length of the provided string
1105+
call [b_output] ; Output the required number of characters
1106+
1107+
pop rcx
1108+
ret
1109+
; -----------------------------------------------------------------------------
1110+
1111+
1112+
; -----------------------------------------------------------------------------
1113+
; output_char -- Displays a char
1114+
; IN: AL = char to display
1115+
; OUT: All registers preserved
1116+
output_char:
1117+
push rsi
1118+
push rcx
1119+
1120+
mov [tchar], al
1121+
mov rsi, tchar
1122+
mov ecx, 1
1123+
call [b_output]
1124+
1125+
pop rcx
1126+
pop rsi
1127+
ret
1128+
; -----------------------------------------------------------------------------
1129+
1130+
10051131
; -----------------------------------------------------------------------------
10061132
; hex_string_to_int -- Convert up to 8 hexascii to bin
10071133
; IN: RSI = Location of hex asciiz string
@@ -1144,8 +1270,6 @@ FSType: db 0 ; File System
11441270
firstrun: db 1 ; A flag for running ui_init only once
11451271

11461272

1147-
%include 'ui/ui.asm'
1148-
11491273
; Temporary data
11501274
tchar: db 0, 0, 0
11511275
temp_string1: times 50 db 0

0 commit comments

Comments
 (0)