mirror of
https://github.com/JannisHeydemann/BoredOS.git
synced 2026-05-30 10:26:59 +00:00
Notepad port to userspace and bug fixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "libui.h"
|
||||
#include "syscall.h"
|
||||
#include "syscall_user.h"
|
||||
#include <stddef.h>
|
||||
|
||||
extern uint64_t syscall3(uint64_t sys_num, uint64_t arg1, uint64_t arg2, uint64_t arg3);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#define GUI_EVENT_CLICK 2
|
||||
#define GUI_EVENT_RIGHT_CLICK 3
|
||||
#define GUI_EVENT_CLOSE 4
|
||||
#define GUI_EVENT_KEY 5
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
@@ -26,7 +27,7 @@ typedef struct {
|
||||
} gui_event_t;
|
||||
|
||||
// Window Handle
|
||||
typedef int ui_window_t;
|
||||
typedef uint64_t ui_window_t;
|
||||
|
||||
// libui API
|
||||
ui_window_t ui_window_create(const char *title, int x, int y, int w, int h);
|
||||
|
||||
@@ -69,3 +69,48 @@ void sys_exit(int status) {
|
||||
int sys_write(int fd, const char *buf, int len) {
|
||||
return (int)syscall3(SYS_WRITE, (uint64_t)fd, (uint64_t)buf, (uint64_t)len);
|
||||
}
|
||||
|
||||
int sys_open(const char *path, const char *mode) {
|
||||
return (int)syscall3(SYS_FS, FS_CMD_OPEN, (uint64_t)path, (uint64_t)mode);
|
||||
}
|
||||
|
||||
int sys_read(int fd, void *buf, uint32_t len) {
|
||||
return (int)syscall4(SYS_FS, FS_CMD_READ, (uint64_t)fd, (uint64_t)buf, (uint64_t)len);
|
||||
}
|
||||
|
||||
int sys_write_fs(int fd, const void *buf, uint32_t len) {
|
||||
return (int)syscall4(SYS_FS, FS_CMD_WRITE, (uint64_t)fd, (uint64_t)buf, (uint64_t)len);
|
||||
}
|
||||
|
||||
void sys_close(int fd) {
|
||||
syscall2(SYS_FS, FS_CMD_CLOSE, (uint64_t)fd);
|
||||
}
|
||||
|
||||
int sys_seek(int fd, int offset, int whence) {
|
||||
return (int)syscall4(SYS_FS, FS_CMD_SEEK, (uint64_t)fd, (uint64_t)offset, (uint64_t)whence);
|
||||
}
|
||||
|
||||
uint32_t sys_tell(int fd) {
|
||||
return (uint32_t)syscall2(SYS_FS, FS_CMD_TELL, (uint64_t)fd);
|
||||
}
|
||||
|
||||
uint32_t sys_size(int fd) {
|
||||
return (uint32_t)syscall2(SYS_FS, FS_CMD_SIZE, (uint64_t)fd);
|
||||
}
|
||||
|
||||
int sys_list(const char *path, struct FAT32_FileInfo *entries, int max_entries) {
|
||||
return (int)syscall4(SYS_FS, FS_CMD_LIST, (uint64_t)path, (uint64_t)entries, (uint64_t)max_entries);
|
||||
}
|
||||
|
||||
int sys_delete(const char *path) {
|
||||
return (int)syscall2(SYS_FS, FS_CMD_DELETE, (uint64_t)path);
|
||||
}
|
||||
|
||||
int sys_mkdir(const char *path) {
|
||||
return (int)syscall2(SYS_FS, FS_CMD_MKDIR, (uint64_t)path);
|
||||
}
|
||||
|
||||
int sys_exists(const char *path) {
|
||||
return (int)syscall2(SYS_FS, FS_CMD_EXISTS, (uint64_t)path);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,21 @@
|
||||
// Standard syscalls available from Kernel mode
|
||||
#define SYS_EXIT 0
|
||||
#define SYS_WRITE 1
|
||||
#define SYS_GUI 3
|
||||
#define SYS_FS 4
|
||||
|
||||
// FS Commands
|
||||
#define FS_CMD_OPEN 1
|
||||
#define FS_CMD_READ 2
|
||||
#define FS_CMD_WRITE 3
|
||||
#define FS_CMD_CLOSE 4
|
||||
#define FS_CMD_SEEK 5
|
||||
#define FS_CMD_TELL 6
|
||||
#define FS_CMD_LIST 7
|
||||
#define FS_CMD_DELETE 8
|
||||
#define FS_CMD_SIZE 9
|
||||
#define FS_CMD_MKDIR 10
|
||||
#define FS_CMD_EXISTS 11
|
||||
|
||||
// Internal assembly entry into Ring 0
|
||||
extern uint64_t syscall0(uint64_t sys_num);
|
||||
@@ -19,4 +34,19 @@ extern uint64_t syscall5(uint64_t sys_num, uint64_t arg1, uint64_t arg2, uint64_
|
||||
void sys_exit(int status);
|
||||
int sys_write(int fd, const char *buf, int len);
|
||||
|
||||
// FS API
|
||||
int sys_open(const char *path, const char *mode);
|
||||
int sys_read(int fd, void *buf, uint32_t len);
|
||||
int sys_write_fs(int fd, const void *buf, uint32_t len);
|
||||
void sys_close(int fd);
|
||||
int sys_seek(int fd, int offset, int whence);
|
||||
uint32_t sys_tell(int fd);
|
||||
uint32_t sys_size(int fd);
|
||||
int sys_delete(const char *path);
|
||||
int sys_mkdir(const char *path);
|
||||
int sys_exists(const char *path);
|
||||
|
||||
struct FAT32_FileInfo;
|
||||
int sys_list(const char *path, struct FAT32_FileInfo *entries, int max_entries);
|
||||
|
||||
#endif
|
||||
|
||||
Binary file not shown.
11
src/kernel/userland/libc/syscall_user.h
Normal file
11
src/kernel/userland/libc/syscall_user.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef SYSCALL_USER_H
|
||||
#define SYSCALL_USER_H
|
||||
|
||||
#include "syscall.h"
|
||||
#include <stddef.h>
|
||||
|
||||
static inline void sys_serial_write(const char *str) {
|
||||
syscall2(8, 0, (uint64_t)str);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user