aboutsummaryrefslogtreecommitdiff
path: root/src/sysbin
diff options
context:
space:
mode:
Diffstat (limited to 'src/sysbin')
-rw-r--r--src/sysbin/giosrv/Makefile2
-rw-r--r--src/sysbin/giosrv/main.c112
-rw-r--r--src/sysbin/init/Makefile2
-rw-r--r--src/sysbin/init/main.c2
-rw-r--r--src/sysbin/login/Makefile2
-rw-r--r--src/sysbin/login/main.c65
6 files changed, 164 insertions, 21 deletions
diff --git a/src/sysbin/giosrv/Makefile b/src/sysbin/giosrv/Makefile
index 102bf4c..9adc05a 100644
--- a/src/sysbin/giosrv/Makefile
+++ b/src/sysbin/giosrv/Makefile
@@ -1,7 +1,7 @@
OBJ = main.o
-LIB = ../../lib/libkogata/libkogata.lib ../../common/libc/libc.lib
+LIB = ../../lib/libkogata/libkogata.lib
CFLAGS = -I ./include -I ../../common/include -I ../../lib/include
diff --git a/src/sysbin/giosrv/main.c b/src/sysbin/giosrv/main.c
index 7827670..9dfd697 100644
--- a/src/sysbin/giosrv/main.c
+++ b/src/sysbin/giosrv/main.c
@@ -6,29 +6,117 @@
#include <debug.h>
#include <user_region.h>
-#include <proto/fb.h>
+#include <gip.h>
+
+typedef struct {
+ framebuffer_info_t mode;
+ fd_t fd;
+ uint32_t features;
+} giosrv_t;
+
+void reset(gip_handler_t *s, gip_msg_header *p);
+void enable_features(gip_handler_t *s, gip_msg_header *p);
+void disable_features(gip_handler_t *s, gip_msg_header *p);
+void query_mode(gip_handler_t *s, gip_msg_header *p);
+void set_mode(gip_handler_t *s, gip_msg_header *p);
+void unknown_msg(gip_handler_t *s, gip_msg_header *p);
+void fd_error(gip_handler_t *s);
+
+gip_handler_callbacks_t giosrv_cb = {
+ .reset = reset,
+ .initiate = 0,
+ .ok = 0,
+ .failure = 0,
+ .enable_features = enable_features,
+ .disable_features = disable_features,
+ .query_mode = query_mode,
+ .set_mode = set_mode,
+ .buffer_info = 0,
+ .mode_info = 0,
+ .buffer_damage = 0,
+ .unknown_msg = unknown_msg,
+ .fd_error = fd_error,
+};
int main(int argc, char **argv) {
dbg_print("[giosrv] Starting up.\n");
- fd_t fbdev = open("io:/display/vesa", FM_IOCTL | FM_READ | FM_WRITE | FM_MMAP);
- if (fbdev == 0) PANIC("Could not open fbdev");
+ giosrv_t srv;
+
+ srv.fd = open("io:/display/vesa", FM_IOCTL | FM_READ | FM_WRITE | FM_MMAP);
+ if (srv.fd == 0) PANIC("Could not open fbdev");
- framebuffer_info_t i;
- int r = ioctl(fbdev, IOCTL_FB_GET_INFO, &i);
- dbg_printf("[giosrv] ioctl -> %d\n", r);
+
+ int r = ioctl(srv.fd, IOCTL_FB_GET_INFO, &srv.mode);
ASSERT(r == 1);
- dbg_printf("[giosrv] Running on FB %dx%d\n", i.width, i.height);
+ dbg_printf("[giosrv] Running on FB %dx%d\n", srv.mode.width, srv.mode.height);
- void* fb_map = region_alloc(i.height * i.pitch, "Framebuffer");
- ASSERT(fb_map != 0);
+ gip_handler_t *h = new_gip_handler(&giosrv_cb, &srv);
+ ASSERT(h != 0);
- ASSERT(mmap_file(fbdev, 0, fb_map, i.height * i.pitch, MM_READ | MM_WRITE));
- memset(fb_map, 0, i.height * i.pitch);
+ h->mainloop_item.fd = 1;
+ mainloop_add_fd(&h->mainloop_item);
+ mainloop_run();
- while(true); // nothing to do
+ dbg_printf("[giosrv] Main loop exited, terminating.\n");
return 0;
}
+void send_buffer_info(gip_handler_t *h, giosrv_t *s) {
+ gip_msg_header msg = {
+ .code = GIPN_BUFFER_INFO,
+ .arg = 0,
+ };
+ gip_buffer_info_msg msg_data;
+
+ msg_data.geom = s->mode;
+ if (!gen_token(s->fd, &msg_data.tok)) {
+ dbg_printf("Could not generate token for buffer_info_msg.\n");
+ } else {
+ dbg_printf("Token: %x %x\n", ((uint32_t*)&msg_data.tok)[0], ((uint32_t*)&msg_data.tok)[1]);
+ gip_notify(h, &msg, &msg_data);
+ }
+}
+
+void reset(gip_handler_t *h, gip_msg_header *p) {
+ giosrv_t *s = (giosrv_t*)h->data;
+
+ s->features = 0;
+
+ // ---- Send initiate message
+ gip_msg_header msg = {
+ .code = GIPR_INITIATE,
+ .arg = GIPF_MODESET
+ };
+ gip_reply(h, p, &msg, 0);
+
+ // ---- Send buffer information
+ send_buffer_info(h, s);
+}
+
+void enable_features(gip_handler_t *h, gip_msg_header *p) {
+ gip_reply_fail(h, p);
+}
+
+void disable_features(gip_handler_t *h, gip_msg_header *p) {
+ gip_reply_fail(h, p);
+}
+
+void query_mode(gip_handler_t *h, gip_msg_header *p) {
+ // TODO
+}
+
+void set_mode(gip_handler_t *h, gip_msg_header *p) {
+ // TODO
+}
+
+void unknown_msg(gip_handler_t *h, gip_msg_header *p) {
+ // TODO
+}
+
+void fd_error(gip_handler_t *h) {
+ // TODO
+}
+
/* vim: set ts=4 sw=4 tw=0 noet :*/
diff --git a/src/sysbin/init/Makefile b/src/sysbin/init/Makefile
index 53a1f45..e56d4c0 100644
--- a/src/sysbin/init/Makefile
+++ b/src/sysbin/init/Makefile
@@ -1,7 +1,7 @@
OBJ = main.o
-LIB = ../../lib/libkogata/libkogata.lib ../../common/libc/libc.lib ../../common/libalgo/libalgo.lib
+LIB = ../../lib/libkogata/libkogata.lib
CFLAGS = -I ./include -I ../../common/include -I ../../lib/include
diff --git a/src/sysbin/init/main.c b/src/sysbin/init/main.c
index a2c607d..d7f3f36 100644
--- a/src/sysbin/init/main.c
+++ b/src/sysbin/init/main.c
@@ -140,7 +140,7 @@ void launch_login() {
ok = bind_fs(login_pid, "config", "config");
if (!ok) PANIC("[init] Could not bind config:/ to login");
- ok = bind_fd(login_pid, 1, root_gip_chan.a);
+ ok = bind_fd(login_pid, 1, root_gip_chan.b);
if (!ok) PANIC("[init] Could not bind root GIP channel FD to login");
ok = proc_exec(login_pid, "sys:/bin/login.bin");
diff --git a/src/sysbin/login/Makefile b/src/sysbin/login/Makefile
index 01be4e1..1232fa8 100644
--- a/src/sysbin/login/Makefile
+++ b/src/sysbin/login/Makefile
@@ -1,7 +1,7 @@
OBJ = main.o
-LIB = ../../lib/libkogata/libkogata.lib ../../common/libc/libc.lib
+LIB = ../../lib/libkogata/libkogata.lib
CFLAGS = -I ./include -I ../../common/include -I ../../lib/include
diff --git a/src/sysbin/login/main.c b/src/sysbin/login/main.c
index f92b18c..b836eec 100644
--- a/src/sysbin/login/main.c
+++ b/src/sysbin/login/main.c
@@ -1,19 +1,74 @@
#include <string.h>
-
#include <malloc.h>
-#include <syscall.h>
#include <debug.h>
-#include <user_region.h>
+
+#include <gip.h>
+
+typedef struct {
+ framebuffer_info_t mode;
+ void* map;
+ fd_t fd;
+ uint32_t features;
+} loginc_t;
+
+void c_buffer_info(gip_handler_t *s, gip_msg_header *p, gip_buffer_info_msg *m);
+void c_unknown_msg(gip_handler_t *s, gip_msg_header *p);
+void c_fd_error(gip_handler_t *s);
+
+void c_async_initiate(gip_handler_t *s, gip_msg_header *p, void* data);
+
+gip_handler_callbacks_t loginc_cb = {
+ .reset = 0,
+ .initiate = 0,
+ .ok = 0,
+ .failure = 0,
+ .enable_features = 0,
+ .disable_features = 0,
+ .query_mode = 0,
+ .set_mode = 0,
+ .buffer_info = c_buffer_info,
+ .mode_info = 0,
+ .buffer_damage = 0,
+ .unknown_msg = c_unknown_msg,
+ .fd_error = c_fd_error,
+};
int main(int argc, char **argv) {
dbg_print("[login] Starting up.\n");
- usleep(10000000); // pretend we are doing something
+ loginc_t loginc;
+ memset(&loginc, 0, sizeof(loginc));
+
+ gip_handler_t *h = new_gip_handler(&loginc_cb, &loginc);
+ ASSERT(h != 0);
+
+ h->mainloop_item.fd = 1;
+ mainloop_add_fd(&h->mainloop_item);
+
+ gip_msg_header reset_msg = { .code = GIPC_RESET, .arg = 0 };
+ gip_cmd(h, &reset_msg, 0, c_async_initiate, 0);
- // and now pretend we have exited due to some kind of failure
+ mainloop_run();
return 0;
}
+void c_buffer_info(gip_handler_t *s, gip_msg_header *p, gip_buffer_info_msg *m) {
+ dbg_printf("[login] Got buffer info msg\n");
+ // TODO
+}
+
+void c_unknown_msg(gip_handler_t *s, gip_msg_header *p) {
+ // TODO
+}
+
+void c_fd_error(gip_handler_t *s) {
+ // TODO
+}
+
+void c_async_initiate(gip_handler_t *s, gip_msg_header *p, void* data) {
+ dbg_printf("[login] Got initiate reply to reset request.\n");
+}
+
/* vim: set ts=4 sw=4 tw=0 noet :*/