diff options
Diffstat (limited to 'src/sysbin/login')
-rw-r--r-- | src/sysbin/login/main.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/sysbin/login/main.c b/src/sysbin/login/main.c index b836eec..1d5da8a 100644 --- a/src/sysbin/login/main.c +++ b/src/sysbin/login/main.c @@ -1,22 +1,26 @@ #include <string.h> #include <malloc.h> - +#include <user_region.h> #include <debug.h> #include <gip.h> typedef struct { framebuffer_info_t mode; + + size_t fb_size; void* map; + fd_t fd; - uint32_t features; + + uint32_t sv_features, cl_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); +void c_async_initiate(gip_handler_t *s, gip_msg_header *p, void* msgdata, void* hdata); gip_handler_callbacks_t loginc_cb = { .reset = 0, @@ -56,7 +60,36 @@ int main(int argc, char **argv) { 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 + + loginc_t *c = (loginc_t*)s->data; + + if (c->fd != 0) close(c->fd); + if (c->map != 0) { + munmap(c->map); + region_free(c->map); + } + + c->fd = use_token(&m->tok); + if (c->fd != 0) { + memcpy(&c->mode, &m->geom, sizeof(framebuffer_info_t)); + + dbg_printf("[login] Got buffer on FD %d, %dx%dx%d\n", + c->fd, c->mode.width, c->mode.height, c->mode.bpp); + + c->fb_size = c->mode.pitch * c->mode.height; + + c->map = region_alloc(c->fb_size, "Framebuffer"); + if (c->map != 0) { + bool ok = mmap_file(c->fd, 0, c->map, c->fb_size, MM_READ | MM_WRITE); + if (ok) { + memset(c->map, 0, c->fb_size); + } else { + dbg_printf("[login] Could not mmap buffer.\n"); + region_free(c->map); + c->map = 0; + } + } + } } void c_unknown_msg(gip_handler_t *s, gip_msg_header *p) { @@ -67,8 +100,11 @@ 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"); +void c_async_initiate(gip_handler_t *s, gip_msg_header *p, void* msgdata, void* hdata) { + loginc_t *c = (loginc_t*)s->data; + c->sv_features = p->arg; + + dbg_printf("[login] Got initiate reply to reset request (features 0x%p).\n", c->sv_features); } /* vim: set ts=4 sw=4 tw=0 noet :*/ |