aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/libc/crt/crt0.c2
-rw-r--r--libs/libc/inc/print.h4
-rw-r--r--libs/libc/inc/sys.h46
-rw-r--r--libs/libc/print.c17
-rw-r--r--libs/libc/sys.c16
-rw-r--r--libs/libgui/gfx.c5
-rw-r--r--libs/libgui/msg.c8
7 files changed, 48 insertions, 50 deletions
diff --git a/libs/libc/crt/crt0.c b/libs/libc/crt/crt0.c
index 9e41ae2..409ec19 100644
--- a/libs/libc/crt/crt0.c
+++ b/libs/libc/crt/crt0.c
@@ -16,7 +16,7 @@ int _start(int argc, char **argv);
int _start(int argc, char **argv)
{
struct timer timer = { 0 };
- assert(io_read(IO_TIMER, &timer, 0, sizeof(timer)) == sizeof(timer));
+ assert(dev_read(DEV_TIMER, &timer, 0, sizeof(timer)) == sizeof(timer));
srand(timer.rtc + timer.time);
__stack_chk_guard = rand();
diff --git a/libs/libc/inc/print.h b/libs/libc/inc/print.h
index 6997796..af06318 100644
--- a/libs/libc/inc/print.h
+++ b/libs/libc/inc/print.h
@@ -16,9 +16,9 @@ NORETURN void panic(const char *format, ...) NONNULL;
#ifdef USER
#include <sys.h>
int vfprintf(const char *path, const char *format, va_list ap) NONNULL;
-int viprintf(enum io_type io, const char *format, va_list ap) NONNULL;
+int vdprintf(enum dev_type io, const char *format, va_list ap) NONNULL;
int fprintf(const char *path, const char *format, ...) NONNULL;
-int iprintf(enum io_type io, const char *format, ...) NONNULL;
+int dprintf(enum dev_type io, const char *format, ...) NONNULL;
int log(const char *format, ...) NONNULL;
NORETURN void err(int code, const char *format, ...) NONNULL;
#else
diff --git a/libs/libc/inc/sys.h b/libs/libc/inc/sys.h
index 14d9698..5b2130c 100644
--- a/libs/libc/inc/sys.h
+++ b/libs/libc/inc/sys.h
@@ -24,33 +24,33 @@ enum sys {
SYS_WRITE, // Write to file
SYS_STAT, // Get file information
SYS_EXEC, // Execute path
- SYS_IOPOLL, // Block proc until I/O device is ready
- SYS_IOREAD, // Read data from I/O device (blocking)
- SYS_IOWRITE, // Write data to I/O device
- SYS_IOCONTROL, // Interact with an I/O device
+ SYS_DEV_POLL, // Block proc until device is ready
+ SYS_DEV_READ, // Read data from device (blocking)
+ SYS_DEV_WRITE, // Write data to device
+ SYS_DEV_CONTROL, // Interact with an I/O device
SYS_EXIT, // Exit current process
SYS_BOOT, // Boot functions (e.g. reboot/shutdown)
SYS_YIELD, // Switch to next process
SYS_MAX,
};
-enum io_type {
- IO_MIN,
- IO_LOGGER,
- IO_FRAMEBUFFER,
- IO_NETWORK,
- IO_KEYBOARD,
- IO_MOUSE,
- IO_TIMER,
- IO_BUS,
- IO_MAX,
+enum dev_type {
+ DEV_MIN,
+ DEV_LOGGER,
+ DEV_FRAMEBUFFER,
+ DEV_NETWORK,
+ DEV_KEYBOARD,
+ DEV_MOUSE,
+ DEV_TIMER,
+ DEV_BUS,
+ DEV_MAX,
};
-// I/O control declarations
-#define IOCTL_FB_GET 0
-#define IOCTL_BUS_CONNECT_BUS 0
-#define IOCTL_BUS_CONNECT_CONN 1
-#define IOCTL_BUS_REGISTER 2
+// Device control declarations
+#define DEVCTL_FB_GET 0
+#define DEVCTL_BUS_CONNECT_BUS 0
+#define DEVCTL_BUS_CONNECT_CONN 1
+#define DEVCTL_BUS_REGISTER 2
struct fb_generic {
u16 bpp;
@@ -112,10 +112,10 @@ res write(const char *path, const void *buf, u32 offset, u32 count) NONNULL;
res stat(const char *path, struct stat *buf) NONNULL;
res exec(const char *path, ...) ATTR((nonnull(1))) SENTINEL;
-res io_poll(enum io_type *devs) NONNULL;
-res io_read(enum io_type io, void *buf, u32 offset, u32 count) NONNULL;
-res io_write(enum io_type io, const void *buf, u32 offset, u32 count) NONNULL;
-res io_control(enum io_type io, ...);
+res dev_poll(enum dev_type *devs) NONNULL;
+res dev_read(enum dev_type dev, void *buf, u32 offset, u32 count) NONNULL;
+res dev_write(enum dev_type dev, const void *buf, u32 offset, u32 count) NONNULL;
+res dev_control(enum dev_type dev, ...);
res yield(void);
res boot(u32 cmd);
diff --git a/libs/libc/print.c b/libs/libc/print.c
index 091df82..00b47c3 100644
--- a/libs/libc/print.c
+++ b/libs/libc/print.c
@@ -84,7 +84,7 @@ int snprintf(char *str, u32 size, const char *format, ...)
int vprintf(const char *format, va_list ap)
{
- return viprintf(IO_LOGGER, format, ap);
+ return vdprintf(DEV_LOGGER, format, ap);
}
int vfprintf(const char *path, const char *format, va_list ap)
@@ -94,11 +94,11 @@ int vfprintf(const char *path, const char *format, va_list ap)
return write(path, buf, 0, len);
}
-int viprintf(enum io_type io, const char *format, va_list ap)
+int vdprintf(enum dev_type io, const char *format, va_list ap)
{
char buf[1024] = { 0 };
int len = vsnprintf(buf, sizeof(buf), format, ap);
- return io_write(io, buf, 0, len);
+ return dev_write(io, buf, 0, len);
}
int fprintf(const char *path, const char *format, ...)
@@ -111,11 +111,11 @@ int fprintf(const char *path, const char *format, ...)
return len;
}
-int iprintf(enum io_type io, const char *format, ...)
+int dprintf(enum dev_type io, const char *format, ...)
{
va_list ap;
va_start(ap, format);
- int len = viprintf(io, format, ap);
+ int len = vdprintf(io, format, ap);
va_end(ap);
return len;
@@ -135,7 +135,7 @@ int log(const char *format, ...)
{
va_list ap;
va_start(ap, format);
- int len = viprintf(IO_LOGGER, format, ap);
+ int len = vdprintf(DEV_LOGGER, format, ap);
va_end(ap);
return len;
@@ -143,18 +143,19 @@ int log(const char *format, ...)
NORETURN void err(int code, const char *format, ...)
{
+ log("Exiting process with code %d\n", code);
if (errno != EOK)
log("ERRNO: %d (%s)\n", errno, strerror(errno));
va_list ap;
va_start(ap, format);
- viprintf(IO_LOGGER, format, ap);
+ vdprintf(DEV_LOGGER, format, ap);
va_end(ap);
exit(code);
}
int print(const char *str)
{
- return io_write(IO_LOGGER, str, 0, strlen(str));
+ return dev_write(DEV_LOGGER, str, 0, strlen(str));
}
#else
diff --git a/libs/libc/sys.c b/libs/libc/sys.c
index 8d0a9b8..b00bd32 100644
--- a/libs/libc/sys.c
+++ b/libs/libc/sys.c
@@ -128,22 +128,22 @@ res exec(const char *path, ...)
return sys5(SYS_EXEC, (int)path, args[0], args[1], args[2], args[3]);
}
-res io_poll(enum io_type *devs)
+res dev_poll(enum dev_type *devs)
{
- return sys1(SYS_IOPOLL, (int)devs);
+ return sys1(SYS_DEV_POLL, (int)devs);
}
-res io_read(enum io_type io, void *buf, u32 offset, u32 count)
+res dev_read(enum dev_type io, void *buf, u32 offset, u32 count)
{
- return sys4(SYS_IOREAD, (int)io, (int)buf, (int)offset, (int)count);
+ return sys4(SYS_DEV_READ, (int)io, (int)buf, (int)offset, (int)count);
}
-res io_write(enum io_type io, const void *buf, u32 offset, u32 count)
+res dev_write(enum dev_type io, const void *buf, u32 offset, u32 count)
{
- return sys4(SYS_IOWRITE, (int)io, (int)buf, (int)offset, (int)count);
+ return sys4(SYS_DEV_WRITE, (int)io, (int)buf, (int)offset, (int)count);
}
-res io_control(enum io_type io, ...)
+res dev_control(enum dev_type io, ...)
{
va_list ap;
int args[4] = { 0 };
@@ -153,7 +153,7 @@ res io_control(enum io_type io, ...)
args[i] = va_arg(ap, int);
va_end(ap);
- return sys5(SYS_IOCONTROL, (int)io, args[0], args[1], args[2], args[3]);
+ return sys5(SYS_DEV_CONTROL, (int)io, args[0], args[1], args[2], args[3]);
}
res yield(void)
diff --git a/libs/libgui/gfx.c b/libs/libgui/gfx.c
index bae98a0..f16b8dd 100644
--- a/libs/libgui/gfx.c
+++ b/libs/libgui/gfx.c
@@ -242,14 +242,11 @@ void gfx_draw_image_filter(struct gfx_context *ctx, vec2 pos, vec2 size, enum gf
// Scaling clones!
bmp = gfx_scale(bmp, size);
- assert(bmp->size.x + pos.x <= ctx->size.x);
- assert(bmp->size.y + pos.y <= ctx->size.y);
-
u8 bypp = bmp->bpp >> 3;
u8 *srcfb = bmp->fb;
u8 *destfb = &ctx->fb[pos.x * bypp + pos.y * ctx->pitch];
for (u32 cy = 0; cy < bmp->size.y && cy + pos.y < ctx->size.y; cy++) {
- int diff = 0;
+ u32 diff = 0;
for (u32 cx = 0; cx < bmp->size.x && cx + pos.x < ctx->size.x; cx++) {
if (srcfb[bypp - 1]) {
if (filter == GFX_FILTER_NONE) {
diff --git a/libs/libgui/msg.c b/libs/libgui/msg.c
index eda4c34..a8da87c 100644
--- a/libs/libgui/msg.c
+++ b/libs/libgui/msg.c
@@ -10,14 +10,14 @@
res msg_connect_bus(const char *bus, u32 *conn)
{
- res ret = io_control(IO_BUS, IOCTL_BUS_CONNECT_BUS, bus, conn);
+ res ret = dev_control(DEV_BUS, DEVCTL_BUS_CONNECT_BUS, bus, conn);
/* assert(ret == EOK && *conn); */
return ret;
}
res msg_connect_conn(u32 conn)
{
- res ret = io_control(IO_BUS, IOCTL_BUS_CONNECT_CONN, conn);
+ res ret = dev_control(DEV_BUS, DEVCTL_BUS_CONNECT_CONN, conn);
/* assert(ret == EOK); */
return ret;
}
@@ -28,14 +28,14 @@ res msg_send(enum message_type type, void *data, u32 size)
struct message_header *header = data;
header->magic = MSG_MAGIC;
header->type = type;
- res ret = io_write(IO_BUS, (u8 *)data + sizeof(struct bus_header), 0, size);
+ res ret = dev_write(DEV_BUS, (u8 *)data + sizeof(struct bus_header), 0, size);
/* assert(ret >= EOK); */
return ret;
}
res msg_receive(void *buf, u32 size)
{
- res ret = io_read(IO_BUS, buf, 0, size);
+ res ret = dev_read(DEV_BUS, buf, 0, size);
struct message_header *header = buf;
if (header->magic == MSG_MAGIC)
return ret;