Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 84 additions & 2 deletions src/drivers/lfb/lfb.asm
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ render_done:
mul ecx
mov [Screen_Bytes], eax

; call lfb_clear

; Calculate display parameters based on font dimensions
xor eax, eax
xor edx, edx
Expand Down Expand Up @@ -112,6 +110,7 @@ render_done:

mov rax, [os_screen_lfb]
mov [LastLine], rax
mov [lfb_last_cursor], rax

; Overwrite the kernel b_output function so output goes to the screen instead of the serial port
mov rax, lfb_output_chars
Expand Down Expand Up @@ -143,7 +142,10 @@ lfb_inc_cursor:
cmp ax, [Screen_Rows] ; Compare it to the # of rows for the screen
jne lfb_inc_cursor_done ; If not equal we are done
mov word [Screen_Cursor_Row], 0 ; Wrap around

lfb_inc_cursor_done:
call lfb_update_cursor

pop rax
ret
; -----------------------------------------------------------------------------
Expand All @@ -164,12 +166,89 @@ lfb_dec_cursor:

lfb_dec_cursor_done:
dec word [Screen_Cursor_Col] ; Decrement the cursor as usual
call lfb_update_cursor

pop rax
ret
; -----------------------------------------------------------------------------


; -----------------------------------------------------------------------------
; lfb_update_cursor -- Update the cursor
; IN: Nothing
; OUT: All registers preserved
lfb_update_cursor:
; Check if cursor is enabled
cmp byte [lfb_cursor_on], 1 ; 1 means enabled
jne lfb_update_cursor_skip ; If not, skip entire function

push rdi
push rdx
push rcx
push rbx
push rax

; Clear old cursor
mov rdi, [lfb_last_cursor] ; Gather the LFB memory address of the start of the cursor
xor ecx, ecx
xor ebx, ebx ; Used for value of bytes per line
mov bx, [os_screen_ppsl]
shl ebx, 2 ; Quick multiply by 4
mov cl, font_h
sub cl, 2
sub rdi, 4
mov eax, [BG_Color]
lfb_update_cursor_line_old:
add rdi, rbx ; Add value of bytes per line
mov [rdi], eax
dec cl
jnz lfb_update_cursor_line_old

; Calculate where to put cursor in the Linear Frame Buffer
mov rdi, [os_screen_lfb]

; Calculate offset for row into Linear Frame Buffer
xor ecx, ecx
mov eax, [lfb_glyph_bytes_per_row]
mov cx, [Screen_Cursor_Row]
mul ecx ; EDX:EAX := EAX * ECX
add rdi, rax

; Calculate offset for column into Linear Frame Buffer
xor ecx, ecx
mov eax, [lfb_glyph_bytes_per_col]
mov cx, [Screen_Cursor_Col]
mul ecx ; EDX:EAX := EAX * ECX
add rdi, rax

; Store cursor location
mov [lfb_last_cursor], rdi

; Draw new cursor
xor ecx, ecx
xor ebx, ebx
mov bx, [os_screen_ppsl]
shl ebx, 2 ; Quick multiply by 4
mov cl, font_h
sub cl, 2
sub rdi, 4
mov eax, [Cursor_Color]
lfb_update_cursor_line:
add rdi, rbx
mov [rdi], eax
dec cl
jnz lfb_update_cursor_line

pop rax
pop rbx
pop rcx
pop rdx
pop rdi
lfb_update_cursor_skip:
ret
; -----------------------------------------------------------------------------


; -----------------------------------------------------------------------------
; lfb_output_chars -- Output text to LFB
; IN: RSI = message location (an ASCII string, not zero-terminated)
Expand Down Expand Up @@ -524,9 +603,11 @@ align 16
align 16

LastLine: dq 0
lfb_last_cursor: dq 0
lfb_glyph_next_line: dq 0
FG_Color: dd 0x00FFFFFF ; White
BG_Color: dd 0x00404040 ; Dark grey
Cursor_Color: dd 0x00A0A0A0
Line_Color: dd 0x00F7CA54 ; Return Infinity Yellow/Orange
Screen_Pixels: dd 0
Screen_Bytes: dd 0
Expand All @@ -537,6 +618,7 @@ Screen_Rows: dw 0
Screen_Cols: dw 0
Screen_Cursor_Row: dw 0
Screen_Cursor_Col: dw 0
lfb_cursor_on: db 1


; =============================================================================
Expand Down
24 changes: 24 additions & 0 deletions src/drivers/ps2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ ps2_keyboard_interrupt:
in al, PS2_DATA ; Get the scan code from the keyboard
cmp al, 0x01
je keyboard_escape
cmp al, 0x48
je keyboard_up
cmp al, 0x50
je keyboard_down
cmp al, 0x4B
je keyboard_left
cmp al, 0x4D
je keyboard_right
cmp al, 0x1D
je keyboard_control
cmp al, 0x2A ; Left Shift Make
Expand Down Expand Up @@ -148,6 +156,22 @@ keyboard_escape:
keyup:
jmp keyboard_done

keyboard_left:
mov byte [key], 0x03
jmp keyboard_done

keyboard_right:
mov byte [key], 0x02
jmp keyboard_done

keyboard_up:
mov byte [key], 0x04
jmp keyboard_done

keyboard_down:
mov byte [key], 0x05
jmp keyboard_done

keyboard_control:
mov byte [key_control], 0x01
jmp keyboard_done
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/serial.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
serial_init:
; Pure64 has already initialized the serial port

; Check if PS/2 is present via ACPI IAPC_BOOT_ARCH
; Check if Serial is present via ACPI IAPC_BOOT_ARCH
mov ax, [os_boot_arch]
bt ax, 0 ; LEGACY_DEVICES
jnc serial_init_error
Expand Down