some progress on dos vesa, but not quite

This commit is contained in:
veclavtlica committed 2026-10-31 14:15:49 +03:00
1 parent 55ac075e4d
commit 4998fafef9
11 files changed
+342 -180

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
#include "../std.h"
#include <assert.h>
#include <stdarg.h>
#include <stdint.h>
#include "any.c"
#include "nolibc.c"
// void *com_std_alloc(void *ptr, size_t size) {
// return size != 0 ? realloc(ptr, size) : (free(ptr), NULL);
// }
// double com_std_sqrt(double v) { return sqrt(v); }
// double com_std_fabs(double v) { return fabs(v); }
// double com_std_sin(double v) { return sin(v); }
// double com_std_cos(double v) { return cos(v); }
// com_std_fd com_std_open(char const *path, uint32_t flags) {
// com_std_assert(flags != 0);
// char *mode = flags & COM_STD_OPEN_READ && flags & COM_STD_OPEN_WRITE ? "r+"
// : flags & COM_STD_OPEN_READ ? "r"
// : "w";
// return fopen(path, mode);
// }
bool com_std_write(com_std_fd fd, void const *data, uint32_t bytes) {
uint32_t written;
bool carry_clear;
__asm__ volatile("int $0x21"
: "=a"(written), "=@ccnc"(carry_clear)
: "a"(0x4000), "b"(fd), "c"(bytes), "d"(data)
: "memory", "cc");
return !carry_clear && written == bytes;
}
// int32_t com_std_read(com_std_fd fd, void *data, uint32_t upto) {
// com_std_assert(data != NULL && upto != 0);
// return fread(data, 1, upto, fd);
// }
// bool com_std_has_data(com_std_fd fd) {
// struct pollfd pfd = {.fd = (intptr_t)fd, .events = POLLIN};
// int ret = poll(&pfd, 1, 0);
// if (ret > 0) {
// return pfd.revents & POLLIN;
// } else
// return false;
// }
// bool com_std_sfwd(com_std_fd fd, uint32_t bytes) {
// com_std_assert(fd != NULL && bytes != 0);
// return fseek(fd, bytes, SEEK_CUR) == 0;
// }
// com_std_fd com_std_socket(bool isnetwork) {
// if (!isnetwork) {
// int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
// return fdopen(sockfd, "w+b");
// } else
// return NULL;
// }
// bool com_std_connect(com_std_fd fd, bool isnetwork, char const *address) {
// com_std_assert(address != NULL);
// if (!isnetwork) {
// struct sockaddr_un addr = {.sun_family = AF_UNIX};
// __builtin_memcpy(&addr.sun_path, address, com_str_ext_len(address));
// return connect(fileno(fd), (struct sockaddr *)&addr, sizeof(addr)) == 0;
// } else
// return NULL;
// }
void com_std_exit(int32_t status) {
(void)status;
__asm__ volatile("int $0x21" ::"a"(0x4c00 | (status & 0xff))
: "memory", "cc");
__builtin_unreachable();
}
// void com_std_close(com_std_fd fd) { fclose(fd); }