Add terminal write as well, use it in kernel
This commit is contained in:
@@ -27,7 +27,7 @@ terminal_buf: .res 128
|
|||||||
bge FAIL
|
bge FAIL
|
||||||
sta tmp1 ; Store nbytes in tmp1
|
sta tmp1 ; Store nbytes in tmp1
|
||||||
|
|
||||||
jsr pushax ; Check that buf != NULL
|
jsr popax ; Check that buf != NULL
|
||||||
cmp #$00
|
cmp #$00
|
||||||
bne L1
|
bne L1
|
||||||
cpx #$00
|
cpx #$00
|
||||||
@@ -90,14 +90,34 @@ FAIL: lda #$ff ; return -1 on fail
|
|||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
; terminal_write
|
; int8_t terminal_write(uint8_t fd, const void* buf, uint8_t nbytes);
|
||||||
; write characters to the terminal
|
; write characters to the terminal
|
||||||
; Inputs: int8_t* buf - buffer of characters to write
|
; Inputs: int8_t* buf - buffer of characters to write
|
||||||
; uint8_t n - number of characters to write
|
; uint8_t n - number of characters to write
|
||||||
; Return Value: 0 on success, -1 on failure
|
; Return Value: 0 on success, -1 on failure
|
||||||
; Writes to screen. Only stops after n chars written.
|
; Writes to screen. Only stops after n chars written.
|
||||||
|
; This seems to not care about null termination?
|
||||||
.proc _terminal_write
|
.proc _terminal_write
|
||||||
|
sta tmp1 ; put nbytes in tmp1
|
||||||
|
|
||||||
|
jsr popax ; check that buf is not null
|
||||||
|
cmp #$00
|
||||||
|
bne L1
|
||||||
|
cpx #$00
|
||||||
|
bne L1
|
||||||
|
bra FAIL
|
||||||
|
L1:
|
||||||
|
ldy #$00
|
||||||
|
LOOP: lda (ptr1),y ; Loop through buffer and print
|
||||||
|
jsr _serial_putc
|
||||||
|
iny
|
||||||
|
cmp tmp1
|
||||||
|
blt LOOP
|
||||||
|
lda #$00
|
||||||
|
rts
|
||||||
|
|
||||||
|
FAIL: lda #$ff ; old code didn't fail, but new code does.
|
||||||
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
; terminal_open
|
; terminal_open
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "devices/interrupt_controller.h"
|
#include "devices/interrupt_controller.h"
|
||||||
#include "interrupts/interrupt.h"
|
#include "interrupts/interrupt.h"
|
||||||
#include "devices/mapper.h"
|
#include "devices/mapper.h"
|
||||||
#include "devices/rtc.h"
|
#include "devices/rtc.h"
|
||||||
#include "devices/serial.h"
|
#include "devices/serial.h"
|
||||||
|
|
||||||
|
#include "devices/terminal.h"
|
||||||
|
|
||||||
|
|
||||||
void handle_rtc_interrupt() {
|
void handle_rtc_interrupt() {
|
||||||
// cputs("In IRQ interrupt!\n");
|
// cputs("In IRQ interrupt!\n");
|
||||||
@@ -13,9 +17,9 @@ void handle_rtc_interrupt() {
|
|||||||
asm volatile ("rti");
|
asm volatile ("rti");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
char buf[128];
|
||||||
|
|
||||||
uint8_t c;
|
int main() {
|
||||||
|
|
||||||
cputs("Kernel\n");
|
cputs("Kernel\n");
|
||||||
|
|
||||||
@@ -40,11 +44,13 @@ int main() {
|
|||||||
|
|
||||||
serial_puts("Hello from serial!\n");
|
serial_puts("Hello from serial!\n");
|
||||||
|
|
||||||
|
terminal_open(NULL);
|
||||||
|
terminal_write(0, "Terminal Write\n", 15);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
c = serial_getc();
|
terminal_read(0, buf, 128);
|
||||||
serial_puts("Got a character!: ");
|
terminal_write(0, "Got: ", 5);
|
||||||
serial_putc(c);
|
terminal_write(0, buf, strlen(buf));
|
||||||
serial_putc('\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user