forked from yhzhang0128/egos-2000
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add printf and log functions to the grass layer
- Loading branch information
1 parent
ceb7fba
commit c88238e
Showing
4 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include <stdlib.h> | ||
|
||
extern struct earth *earth; | ||
#define printf earth->tty_write | ||
|
||
#define INFO earth->log.log_info | ||
#define HIGHLIGHT earth->log.log_highlight | ||
#define SUCCESS earth->log.log_success | ||
#define ERROR earth->log.log_error | ||
#define FATAL earth->log.log_fatal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
#pragma once | ||
|
||
/* Interface between earth and grass */ | ||
|
||
#define TIMER_INTR_ID 7 | ||
#define QUANTUM_NCYCLES 2000 | ||
#define EARTH_ADDR (0x8004000 - 0x40) | ||
|
||
typedef void (*handler_t)(int, void*); | ||
|
||
struct dev_log { | ||
int (*log_info)(const char *format, ...); | ||
int (*log_highlight)(const char *format, ...); | ||
int (*log_success)(const char *format, ...); | ||
int (*log_error)(const char *format, ...); | ||
int (*log_fatal)(const char *format, ...); | ||
}; | ||
|
||
struct earth { | ||
int (*tty_read)(char* buf, int len); | ||
int (*tty_write)(const char *format, ...); | ||
int (*tty_write)(const char *format, ...); | ||
|
||
int (*disk_read)(int block_no, int nblocks, char* dst); | ||
int (*disk_write)(int block_no, int nblocks, char* src); | ||
|
||
int (*intr_enable)(); | ||
int (*intr_disable)(); | ||
int (*intr_register)(int id, handler_t handler); | ||
|
||
struct dev_log log; | ||
}; | ||
|
||
/* Interface between grass and apps */ |