Doom port #21
@@ -8,4 +8,10 @@ Name | Number (%rax) | arg0 (%rdi) | arg1 (%rsi) | arg2 (%rdx) |
|
||||
| sys_write | 1 | unsigned int fd | const char* buf | size_t count |
|
||||
| sys_open | 2 | const char* filename | int flags | |
|
||||
| sys_close | 3 | unsigned int fd | | |
|
||||
|
||||
| sys_lseek | 8 | unsigned int fd | int offset | int whence |
|
||||
| sys_tell | 9 | unsigned int fd |
|
||||
| sys_eof | 10 | unsigned int fd |
|
||||
| sys_draw | 11 | const uint8_t* src | int width | int height | int channels |
|
||||
|
||||
| sys_exit | 60 | int error_code | | |
|
||||
+8
-8
@@ -77,9 +77,9 @@ int sys_open(const char* filename, int flags)
|
||||
* %0 - file closed
|
||||
* %-EBADFD - bad file descriptor
|
||||
*/
|
||||
int sys_close(int fd)
|
||||
int sys_close(unsigned int fd)
|
||||
{
|
||||
if (fd < 0 || fd >= FDT_MAX) {
|
||||
if (fd >= FDT_MAX) {
|
||||
return -EBADFD;
|
||||
}
|
||||
|
||||
@@ -109,9 +109,9 @@ int sys_close(int fd)
|
||||
* %new_cursor - the new cursor value
|
||||
* On error, a negative value corresponding to an error code is returned.
|
||||
*/
|
||||
int sys_lseek(int fd, int offset, int whence)
|
||||
int sys_lseek(unsigned int fd, int offset, int whence)
|
||||
{
|
||||
if (fd < 0 || fd >= FDT_MAX) {
|
||||
if (fd >= FDT_MAX) {
|
||||
return -EBADFD;
|
||||
}
|
||||
if (!current_process->fdt[fd].open) {
|
||||
@@ -148,9 +148,9 @@ int sys_lseek(int fd, int offset, int whence)
|
||||
* %cursor - cursor position of the file descriptor
|
||||
* On error, a negative value with the corresponding error code is set.
|
||||
*/
|
||||
int sys_tell(int fd)
|
||||
int sys_tell(unsigned int fd)
|
||||
{
|
||||
if (fd < 0 || fd >= FDT_MAX) {
|
||||
if (fd >= FDT_MAX) {
|
||||
return -EBADFD;
|
||||
}
|
||||
if (!current_process->fdt[fd].open) {
|
||||
@@ -171,9 +171,9 @@ int sys_tell(int fd)
|
||||
* %>0 - we are at or past EOF
|
||||
* %0 - not yet (still have bytes to read)
|
||||
*/
|
||||
int sys_eof(int fd)
|
||||
int sys_eof(unsigned int fd)
|
||||
{
|
||||
if (fd < 0 || fd >= FDT_MAX) {
|
||||
if (fd >= FDT_MAX) {
|
||||
return -EBADFD;
|
||||
}
|
||||
if (!current_process->fdt[fd].open) {
|
||||
|
||||
@@ -41,7 +41,7 @@ static uint32_t pack_rgba_to_fb(uint8_t r, uint8_t g, uint8_t b)
|
||||
}
|
||||
|
||||
/*
|
||||
* sys_draw_fb - Draw a framebuffer subset
|
||||
* sys_draw - Draw a framebuffer subset
|
||||
* @src: Source frame
|
||||
* @width: width of the frame
|
||||
* @height: height of the frame
|
||||
@@ -55,7 +55,7 @@ static uint32_t pack_rgba_to_fb(uint8_t r, uint8_t g, uint8_t b)
|
||||
* %0 - on success
|
||||
* On error, a negative value with an error code is returned.
|
||||
*/
|
||||
int sys_draw_fb(const uint8_t* src, int width, int height, int channels)
|
||||
int sys_draw(const uint8_t* src, int width, int height, int channels)
|
||||
{
|
||||
if (!boot_ctx.fb || !src) {
|
||||
return -EINVAL;
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
extern struct process* current_process;
|
||||
|
||||
int sys_open(const char* filename, int flags);
|
||||
int sys_close(int fd);
|
||||
int sys_lseek(int fd, int offset, int whence);
|
||||
int sys_tell(int fd); // needed by doom, therefore TOP PRIORITY
|
||||
int sys_eof(int fd); // same
|
||||
int sys_close(unsigned int fd);
|
||||
int sys_lseek(unsigned int fd, int offset, int whence);
|
||||
int sys_tell(unsigned int fd); // needed by doom, therefore TOP PRIORITY
|
||||
int sys_eof(unsigned int fd); // same
|
||||
int sys_read(unsigned int fd, char* buf, size_t count);
|
||||
int sys_write(unsigned int fd, const char* buf, size_t count);
|
||||
int sys_exit(int error_code);
|
||||
int sys_draw_fb(const uint8_t* src, int width, int height, int channels);
|
||||
int sys_draw(const uint8_t* src, int width, int height, int channels);
|
||||
|
||||
/*
|
||||
* syscall_handler - System call dispatcher
|
||||
@@ -79,7 +79,7 @@ struct cpu_status* syscall_handler(struct cpu_status* regs)
|
||||
regs->rax = sys_eof(regs->rdi);
|
||||
break;
|
||||
case 11: // No DEBUG() here because it makes significant overhead
|
||||
regs->rax = sys_draw_fb((const uint8_t*)regs->rdi, regs->rsi, regs->rdx, regs->r10);
|
||||
regs->rax = sys_draw((const uint8_t*)regs->rdi, regs->rsi, regs->rdx, regs->r10);
|
||||
break;
|
||||
case 60:
|
||||
DEBUG("sys_exit(error_code=%d)", regs->rdi);
|
||||
@@ -92,7 +92,6 @@ struct cpu_status* syscall_handler(struct cpu_status* regs)
|
||||
break;
|
||||
}
|
||||
|
||||
// save overhead for present_fb
|
||||
//DEBUG("returned rax=%p (%u)", regs->rax, regs->rax);
|
||||
|
||||
return regs;
|
||||
|
||||
Reference in New Issue
Block a user