Skip to content

Commit

Permalink
Add tty_write
Browse files Browse the repository at this point in the history
  • Loading branch information
yhzhang0128 committed Apr 5, 2022
1 parent a47ace8 commit 03fe377
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion earth/bus_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static int uart_getc(int* c) {
return *c = (ch & (1 << 31))? -1 : (ch & 0xFF);
}

static int uart_putc(char c) {
static void uart_putc(char c) {
while ((UART_REGW(UART0_TXDATA) & (1 << 31)));
UART_REGW(UART0_TXDATA) = c;
}
4 changes: 4 additions & 0 deletions earth/dev_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ int tty_read(char* buf, int len) {
return len - 1;
}

int tty_write(char* buf, int len) {
for (int i = 0; i < len; i++) uart_putc(buf[i]);
}

#define VPRINTF va_list args; \
va_start(args, format); \
vprintf(format, args); \
Expand Down
3 changes: 2 additions & 1 deletion earth/earth.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ void earth_init() {
tty_init();
earth->tty_intr = tty_intr;
earth->tty_read = tty_read;
earth->tty_write = tty_write;

earth->tty_printf = tty_printf;

earth->tty_info = tty_info;
earth->tty_fatal = tty_fatal;
earth->tty_success = tty_success;
Expand Down
3 changes: 2 additions & 1 deletion earth/earth.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ int disk_write(int block_no, int nblocks, char* src);

int tty_intr();
int tty_read(char* buf, int len);
int tty_printf(const char *format, ...);
int tty_write(char* buf, int len);

int tty_printf(const char *format, ...);
int tty_info(const char *format, ...);
int tty_fatal(const char *format, ...);
int tty_success(const char *format, ...);
Expand Down
6 changes: 4 additions & 2 deletions library/egos.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ struct earth {
int (*mmu_map)(int pid, int page_no, int frame_no);
int (*mmu_switch)(int pid);

/* Disk and tty device driver interface */
/* Devices interface */
int (*disk_read)(int block_no, int nblocks, char* dst);
int (*disk_write)(int block_no, int nblocks, char* src);

int (*tty_intr)();
int (*tty_read)(char* buf, int len);
int (*tty_printf)(const char *format, ...);
int (*tty_write)(char* buf, int len);

int (*tty_printf)(const char *format, ...);
int (*tty_info)(const char *format, ...);
int (*tty_fatal)(const char *format, ...);
int (*tty_success)(const char *format, ...);
int (*tty_critical)(const char *format, ...);
};

struct grass {
/* Process interface */
int (*proc_alloc)();
void (*proc_free)(int);
void (*proc_set_ready)(int);
Expand Down

0 comments on commit 03fe377

Please sign in to comment.