2019-08-31 16:46:52 -05:00
|
|
|
#include <mailboxes.h>
|
|
|
|
#include <ipc/devfs.h>
|
|
|
|
#include <ipc/vfs.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <tasking.h>
|
|
|
|
#include <memory.h>
|
|
|
|
#include "vga.h"
|
2019-08-31 16:48:11 -05:00
|
|
|
#include <dbg.h>
|
2019-08-31 16:46:52 -05:00
|
|
|
|
2019-09-05 09:39:13 -05:00
|
|
|
uint32_t devfs_box;
|
2019-08-31 16:46:52 -05:00
|
|
|
#define DEVFS_PID 3
|
2019-08-31 11:04:30 -05:00
|
|
|
|
2019-08-31 10:49:52 -05:00
|
|
|
int main() {
|
2020-07-09 11:28:57 -05:00
|
|
|
serial_print("IN VGA DRV");
|
2019-09-01 13:52:32 -05:00
|
|
|
uint32_t box=mailbox_new(16,"vga");
|
2019-09-05 14:12:04 -05:00
|
|
|
devfs_box=mailbox_find_by_name("devfs_driver");
|
2019-08-31 11:04:30 -05:00
|
|
|
text_fb_info info;
|
2020-07-23 11:50:23 -05:00
|
|
|
vga_init();
|
2019-08-31 16:46:52 -05:00
|
|
|
yield();
|
|
|
|
devfs_message* msg_data=malloc(sizeof(devfs_message));
|
|
|
|
msg_data->msg_type=DEVFS_REGISTER;
|
|
|
|
msg_data->dev_type=DEV_GLOBAL;
|
|
|
|
msg_data->mbox=box;
|
|
|
|
strcpy(&msg_data->name[0],"vga");
|
|
|
|
Message msg;
|
|
|
|
msg.from=box;
|
2019-09-05 14:12:04 -05:00
|
|
|
msg.to=mailbox_find_by_name("devfs_register");
|
2019-08-31 16:46:52 -05:00
|
|
|
msg.size=sizeof(devfs_message);
|
|
|
|
msg.msg=msg_data;
|
|
|
|
mailbox_send_msg(&msg);
|
2019-09-01 14:15:01 -05:00
|
|
|
free(msg_data);
|
2019-08-31 16:46:52 -05:00
|
|
|
yieldToPID(DEVFS_PID);
|
|
|
|
for (;;) {
|
|
|
|
Message msg;
|
|
|
|
msg.msg=malloc(sizeof(vfs_message));
|
|
|
|
mailbox_get_msg(box,&msg,sizeof(vfs_message));
|
2019-09-01 14:15:01 -05:00
|
|
|
if (msg.from==0) {
|
|
|
|
free(msg.msg);
|
|
|
|
} else {
|
2019-08-31 16:46:52 -05:00
|
|
|
vfs_message* vfs_msg=(vfs_message*)msg.msg;
|
2019-09-01 14:15:01 -05:00
|
|
|
char* gets_data=NULL;
|
2019-08-31 16:46:52 -05:00
|
|
|
switch (vfs_msg->type) {
|
|
|
|
case VFS_OPEN:
|
|
|
|
vfs_msg->flags=0;
|
|
|
|
break;
|
|
|
|
case VFS_PUTS: {
|
|
|
|
char* data=malloc(sizeof(char)*vfs_msg->data);
|
|
|
|
Message msg;
|
|
|
|
msg.msg=data;
|
|
|
|
mailbox_get_msg(box,&msg,vfs_msg->data);
|
|
|
|
while (msg.from==0 && msg.size==0) {
|
|
|
|
yield();
|
|
|
|
mailbox_get_msg(box,&msg,sizeof(vfs_message));
|
|
|
|
}
|
|
|
|
if (msg.from==0) {
|
|
|
|
serial_print("Could not recieve fputs data from the devfs\n");
|
|
|
|
vfs_msg->flags=2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
vga_write_string(data);
|
|
|
|
vfs_msg->flags=0;
|
2019-09-01 14:15:01 -05:00
|
|
|
break;
|
2019-08-31 16:46:52 -05:00
|
|
|
}
|
2019-09-01 14:15:01 -05:00
|
|
|
case VFS_GETS: {
|
|
|
|
vfs_msg->flags=2;
|
2019-08-31 16:46:52 -05:00
|
|
|
break;
|
2019-09-01 14:15:01 -05:00
|
|
|
}
|
2019-08-31 16:46:52 -05:00
|
|
|
default:
|
|
|
|
vfs_msg->flags=1;
|
|
|
|
}
|
|
|
|
msg.to=msg.from;
|
|
|
|
msg.from=box;
|
|
|
|
mailbox_send_msg(&msg);
|
2019-09-01 14:15:01 -05:00
|
|
|
free(msg.msg);
|
|
|
|
if (gets_data && vfs_msg->flags==0) {
|
|
|
|
serial_print("GETS DATA VGA\n");
|
|
|
|
msg.msg=gets_data;
|
|
|
|
msg.size=vfs_msg->data;
|
|
|
|
mailbox_send_msg(&msg);
|
|
|
|
free(gets_data);
|
|
|
|
} else {
|
|
|
|
if (vfs_msg->type==VFS_GETS) {
|
|
|
|
serial_print("NO GETS DATA VGA\n");
|
|
|
|
}
|
|
|
|
}
|
2019-09-05 14:12:04 -05:00
|
|
|
yieldToPID(DEVFS_PID);
|
2019-08-31 16:46:52 -05:00
|
|
|
}
|
|
|
|
yield();
|
|
|
|
}
|
2019-08-31 10:49:52 -05:00
|
|
|
}
|