2026-07-08 21:15:30 -05:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2026-07-16 14:44:08 -05:00
|
|
|
#include <sys/video.h>
|
|
|
|
|
|
2026-07-16 16:09:12 -05:00
|
|
|
typedef struct {
|
2026-07-12 04:37:46 -05:00
|
|
|
|
2026-07-16 16:09:12 -05:00
|
|
|
} font_t;
|
|
|
|
|
|
|
|
|
|
void term_write_char(char c);
|
|
|
|
|
void render_char_at(char c, int x, int y);
|
|
|
|
|
|
|
|
|
|
int spawn_shell();
|
2026-07-08 21:15:30 -05:00
|
|
|
|
|
|
|
|
int ptys;
|
|
|
|
|
int ptym;
|
2026-07-07 00:13:24 -05:00
|
|
|
|
2026-07-16 16:09:12 -05:00
|
|
|
void* fb;
|
2026-07-16 14:44:08 -05:00
|
|
|
fb_info_t fb_info;
|
|
|
|
|
|
|
|
|
|
int terminal_col = 0;
|
|
|
|
|
int terminal_row = 0;
|
|
|
|
|
|
2026-07-16 16:09:12 -05:00
|
|
|
font_t* terminal_font = NULL;
|
2026-07-16 14:44:08 -05:00
|
|
|
|
2026-07-07 00:13:24 -05:00
|
|
|
int main(int argc, char *argv[]) {
|
2026-07-08 21:15:30 -05:00
|
|
|
(void)argc;
|
|
|
|
|
(void)argv;
|
|
|
|
|
|
2026-07-16 14:44:08 -05:00
|
|
|
int vga_fd = open("/dev/vga");
|
|
|
|
|
if (vga_fd == -1) return 1;
|
2026-07-08 21:15:30 -05:00
|
|
|
|
2026-07-16 14:44:08 -05:00
|
|
|
int kbd_fd = open("/dev/kbd");
|
|
|
|
|
if (kbd_fd == -1) return 1;
|
2026-07-08 21:15:30 -05:00
|
|
|
|
2026-07-16 14:44:08 -05:00
|
|
|
int res = ioctl(vga_fd, FBIOGET_INFO, &fb_info);
|
|
|
|
|
if (!res) {
|
|
|
|
|
return 1;
|
2026-07-12 04:37:46 -05:00
|
|
|
}
|
|
|
|
|
|
2026-07-16 16:09:12 -05:00
|
|
|
mmap(vga_fd);
|
2026-07-16 14:44:08 -05:00
|
|
|
|
2026-07-16 16:09:12 -05:00
|
|
|
// if (!spawn_shell()) {
|
|
|
|
|
// return 1;
|
|
|
|
|
// }
|
2026-07-16 14:44:08 -05:00
|
|
|
|
|
|
|
|
return 0;
|
2026-07-16 16:09:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void render_char_at(char c, int x, int y) {
|
|
|
|
|
if (!terminal_font) return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void term_write_char(char c) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int spawn_shell() {
|
|
|
|
|
ptym = pty(&ptys);
|
|
|
|
|
|
|
|
|
|
if (fork() == 0) {
|
|
|
|
|
close(ptym);
|
|
|
|
|
dup2(ptys, 0);
|
|
|
|
|
dup2(0, 1);
|
|
|
|
|
dup2(0, 2);
|
|
|
|
|
|
|
|
|
|
if (!exec("/usr/bin/rocksh")) return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
close(ptys);
|
|
|
|
|
dup2(ptym, 0);
|
|
|
|
|
dup2(0, 1);
|
|
|
|
|
dup2(0, 2);
|
|
|
|
|
return 1;
|
2026-07-07 00:13:24 -05:00
|
|
|
}
|