working on exposing vga to userspace
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include "syscall.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/video.h>
|
||||
|
||||
#define VGA_TEXT_W 80
|
||||
#define VGA_TEXT_H 25
|
||||
|
||||
@@ -8,6 +11,16 @@ void term();
|
||||
int ptys;
|
||||
int ptym;
|
||||
|
||||
fb_info_t fb_info;
|
||||
void* framebuffer_address;
|
||||
|
||||
int terminal_col = 0;
|
||||
int terminal_row = 0;
|
||||
|
||||
void term_write_char(char c) {
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
@@ -28,42 +41,20 @@ int main(int argc, char *argv[]) {
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
|
||||
term();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void clear(int fd) {
|
||||
lseek(fd, 0, 0);
|
||||
size_t bytes = VGA_TEXT_W * VGA_TEXT_H;
|
||||
char c = ' ';
|
||||
for (size_t i = 0; i < bytes; i++) {
|
||||
write(fd, &c, 1);
|
||||
}
|
||||
lseek(fd, 0, 0);
|
||||
}
|
||||
|
||||
void term() {
|
||||
int vga_fd = open("/dev/tvga");
|
||||
if (vga_fd == -1) return;
|
||||
int vga_fd = open("/dev/vga");
|
||||
if (vga_fd == -1) return 1;
|
||||
|
||||
int kbd_fd = open("/dev/kbd");
|
||||
if (kbd_fd == -1) return;
|
||||
if (kbd_fd == -1) return 1;
|
||||
|
||||
clear(vga_fd);
|
||||
|
||||
char c;
|
||||
while (1) {
|
||||
// first, get shell output
|
||||
int rd = read(0, &c, 1);
|
||||
if (rd > 0) {
|
||||
write(vga_fd, &c, 1);
|
||||
}
|
||||
|
||||
// then read a byte from the kbd. If we got one, pass it to the shell
|
||||
rd = read(kbd_fd, &c, 1);
|
||||
if (rd > 0) {
|
||||
write(1, &c, 1);
|
||||
}
|
||||
int res = ioctl(vga_fd, FBIOGET_INFO, &fb_info);
|
||||
if (!res) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
framebuffer_address = mmap(vga_fd);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user