summaryrefslogtreecommitdiff
path: root/src/user/include
diff options
context:
space:
mode:
authorBenji Dial <Benji3.141@gmail.com>2020-08-11 11:33:21 -0400
committerBenji Dial <Benji3.141@gmail.com>2020-08-11 11:33:21 -0400
commit63167f223e1f54910f6b80e698390ee60aec79ee (patch)
tree41844f646bdcb5c9ba241bb5867c5e4f51737d52 /src/user/include
parent77d7a284c02bc6b1b3a3a92ad5d957172cee9b81 (diff)
downloadportland-os-63167f223e1f54910f6b80e698390ee60aec79ee.tar.gz
lots of progress
currently, BAR fields of IDE drives are all returning zero, and the ATA read function isn't working. i'm not sure why. i'm going to work on VESA next, and come back to the IDE driver later
Diffstat (limited to 'src/user/include')
-rw-r--r--src/user/include/canyo/file.h9
-rw-r--r--src/user/include/pland.h157
2 files changed, 166 insertions, 0 deletions
diff --git a/src/user/include/canyo/file.h b/src/user/include/canyo/file.h
new file mode 100644
index 0000000..5f09387
--- /dev/null
+++ b/src/user/include/canyo/file.h
@@ -0,0 +1,9 @@
+#ifndef CANYO_FILE_H
+#define CANYO_FILE_H
+
+#include <stdint.h>
+#include <pland.h>
+
+uint32_t read_line(fs_handle handle, uint32_t max_length, void *buffer);
+
+#endif \ No newline at end of file
diff --git a/src/user/include/pland.h b/src/user/include/pland.h
new file mode 100644
index 0000000..f174a51
--- /dev/null
+++ b/src/user/include/pland.h
@@ -0,0 +1,157 @@
+#ifndef PLAND_H
+#define PLAND_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef uint8_t fs_handle;
+typedef uint8_t task_handle;
+
+static inline void exit() __attribute__ ((noreturn)) {
+ asm volatile ("int $0x30");
+ __builtin_unreachable();
+}
+
+static inline void yield() {
+ asm volatile ("int $0x31");
+}
+
+static inline uint32_t data_extend(uint32_t amount) {
+ uint32_t actual_amount;
+ asm volatile (
+ "int $0x33"
+ : "eax" (actual_amount) : "eax" (amount));
+ return actual_amount;
+}
+
+static inline void vga_blank() {
+ asm volatile (
+ "xor %%eax, %%eax\n"
+ "int $0x32"
+ : : : "eax");
+}
+
+static inline void vga_set_color(uint8_t color) {
+ asm volatile (
+ "mov $0x1, %%eax\n"
+ "int $0x32"
+ : : "ebx" (color) : "eax");
+}
+
+static inline void vga_printch(uint8_t ch) {
+ asm volatile (
+ "mov $0x2, %%eax\n"
+ "int $0x32"
+ : : "ebx" (ch) : "eax");
+}
+
+static inline void vga_printsz(uint8_t *sz) {
+ asm volatile (
+ "mov $0x3, %%eax\n"
+ "int $0x32"
+ : : "ebx" (sz) : "eax");
+}
+
+static inline void vga_printsn(uint8_t *sn, uint8_t length) {
+ asm volatile (
+ "mov $0x4, %%eax\n"
+ "int $0x32"
+ : : "ebx" (sn), "ecx" (length) : "eax");
+}
+
+static inline fs_handle fs_open(uint8_t *path) {
+ fs_handle handle;
+ asm volatile (
+ "mov $0x5, %%eax\n"
+ "int $0x32"
+ : "eax" (handle) : "ebx" (path));
+ return handle;
+}
+
+static inline fs_handle fs_open_root() {
+ fs_handle handle;
+ asm volatile (
+ "mov $0x6, %%eax\n"
+ "int $0x32"
+ : "eax" (handle));
+ return handle;
+}
+
+static inline fs_handle fs_new(uint8_t *path) {
+ fs_handle handle;
+ asm volatile (
+ "mov $0x7, %%eax\n"
+ "int $0x32"
+ : "eax" (handle) : "ebx" (path));
+ return handle;
+}
+
+static inline void fs_close(fs_handle handle) {
+ asm volatile (
+ "mov $0x8, %%eax\n"
+ "int $0x32"
+ : : "ebx" (handle) : "eax");
+}
+
+static inline void fs_delete(uint8_t *path) {
+ asm volatile (
+ "mov $0x9, %%eax\n"
+ "int $0x32"
+ : : "ebx" (path) : "eax");
+}
+
+static inline bool fs_exists(uint8_t *path) {
+ bool does;
+ asm volatile (
+ "mov $0xa, %%eax\n"
+ "int $0x32"
+ : "eax" (does) : "ebx" (path));
+ return does;
+}
+
+static inline int32_t fs_seek(fs_handle handle, int32_t by) {
+ int32_t seeked_by;
+ asm volatile (
+ "mov $0xb, %%eax\n"
+ "int $0x32"
+ : "eax" (seeked_by) : "ebx" (handle), "ecx" (by));
+ return seeked_by;
+}
+
+static inline uint32_t fs_tell(fs_handle handle) {
+ uint32_t position;
+ asm volatile (
+ "mov $0xc, %%eax\n"
+ "int $0x32"
+ : "eax" (position) : "ebx" (handle));
+ return position;
+}
+
+static inline uint32_t fs_read(fs_handle handle, uint32_t max, void *buffer) {
+ uint32_t read;
+ asm volatile (
+ "mov %0xd, %%eax\n"
+ "int $0x32"
+ : "eax" (read) : "ebx" (handle), "ecx" (max), "edx" (buffer) : "memory");
+ return read;
+}
+
+static inline uint32_t fs_write(fs_handle handle, uint32_t max, void *buffer) {
+ uint32_t written;
+ asm volatile (
+ "mov %0xe, %%eax\n"
+ "int $0x32"
+ : "eax" (written) : "ebx" (handle), "ecx" (max), "edx" (buffer));
+ return written;
+}
+
+static inline task_handle plef_run(uint8_t *image_path) {
+ task_handle handle;
+ asm volatile (
+ "mov %0xf, %%eax\n"
+ "int $0x32"
+ : "eax" (handle) : "ebx" (image_path));
+ return handle;
+}
+
+#endif