diff --git a/Makefile b/Makefile index ea897b79..8b54cc00 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ MODULES = $(patsubst %.c,%.o,$(wildcard kernel/core/*.c)) FILESYSTEMS = $(patsubst %.c,%.o,$(wildcard kernel/core/fs/*.c)) VIDEODRIVERS = $(patsubst %.c,%.o,$(wildcard kernel/core/video/*.c)) BINARIES = initrd/bin/hello initrd/bin/echo initrd/bin/yes -UTILITIES = util/bin/readelf +UTILITIES = util/bin/readelf util/bin/typewriter EMU = qemu GENEXT = genext2fs DD = dd conv=notrunc @@ -99,12 +99,7 @@ initrd/boot/kernel: toaruos-kernel # Utilities # ################ -util/bin/mrboots-installer: util/mrboots-installer.c - @${ECHO} -n "\033[32m CC $<\033[0m" - @${CC} ${NATIVEFLAGS} -o $@ $< - @${ECHO} "\r\033[32;1m CC $<\033[0m" - -util/bin/readelf: util/readelf.c +util/bin/%: util/%.c @${ECHO} -n "\033[32m CC $<\033[0m" @${CC} ${NATIVEFLAGS} -o $@ $< @${ECHO} "\r\033[32;1m CC $<\033[0m" diff --git a/initrd/etc/.htop b/initrd/etc/.htop new file mode 100644 index 00000000..81188ab2 --- /dev/null +++ b/initrd/etc/.htop @@ -0,0 +1 @@ +[?7h[?25l[?1c[?1000h 1 [0.0%] Tasks: 143, 200 thr; 1 running2 [|||||8.3%] Load average: 1.08 1.03 1.05 3 [|||||8.3%] Uptime: 08:45:214 [||||||||||||||||||33.3%]Mem[|||||||||||||||||||||||||||||||||||||||||||1775/3824MB]Swp[|0/41006MB]  PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command  6409 klange 20 0 20088 1692 1092 R 35.0 0.0 0:00.07 htop1215 root  20 0  285M 153M 20400 S 8.0 4.0 26:55.19 /usr/bin/X :0 -nr -verbose -auth /var/run/gdm/auth-for-gdm-lsJzWV/2247 klange 20 0  326M 20960 13352 S 8.0 0.5 2:17.75 gnome-terminal  5690 klange 20 0  194M 101M 22564 S 8.0 2.7 10:52.80 /usr/lib/nspluginwrapper/i386/linux/npviewer.bin --plugin /usr/lib1 root  20 0 24132  2308  1356 S 0.0 0.1 0:01.42 /sbin/init296 root  20 0  7200 244 144 S 0.0 0.0 0:00.57 /sbin/v86d366 root  20 0 17300  1072 616 S 0.0 0.0 0:00.08 upstart-udev-bridge --daemon410 root  16  -4 21860  1408 352 S 0.0 0.0 0:00.05 udevd --daemon895 root  20 0 15004 388 196 S 0.0 0.0 0:00.01 upstart-socket-bridge --daemon940 root  20 0 19216  1128 588 S 0.0 0.0 0:00.07 /sbin/mount.ntfs-3g /dev/sda3 /media/ntfs -o rw,locale=en_US.utf8962 root  20 0 49464  2644  2076 S 0.0 0.1 0:00.00 /usr/sbin/sshd -D974 syslog  20 0  181M 1968  1072 S 0.0 0.1 0:00.03 rsyslogd -c4975 syslog  20 0  181M 1968  1072 S 0.0 0.1 0:00.51 rsyslogd -c4966 syslog  20 0  181M 1968  1072 S 0.0 0.1 0:01.72 rsyslogd -c4  1008 messageb  20 0 25492  2644 828 S 0.0 0.1 0:08.58 dbus-daemon --system --fork --activation=upstart  1210 root  20 0 80144  3992  3064 S 0.0 0.1 0:00.00 gdm-binary  1045 root  20 0 80144  3992  3064 S 0.0 0.1 0:00.06 gdm-binary  1052 root  20 0  162M 6488  4816 S 0.0 0.2 0:00.02 NetworkManager  2115 root  20 0  162M 6488  4816 S 0.0 0.2 0:00.00 NetworkManager  1048 root  20 0  162M 6488  4816 S 0.0 0.2 0:06.91 NetworkManager  1051 root  20 0 64656  2896  2248 S 0.0 0.1 0:00.06 /usr/sbin/modem-manager  1056 root  20 0  126M 4024  2820 S 0.0 0.1 0:00.31 /usr/lib/policykit-1/polkitd  1054 root  20 0  126M 4024  2820 S 0.0 0.1 0:00.51 /usr/lib/policykit-1/polkitd  1088 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1090 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1091 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1092 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1093 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1094 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1095 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1096 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1097 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1098 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1099 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1100 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1101 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1102 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1103 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1104 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1105 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1106 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1107 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1108 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1109 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1110 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1111 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1112 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon  1113 root  20 0  124M 4072  2796 S 0.0 0.1 0:00.00 /usr/sbin/console-kit-daemon --no-daemon F1Help F2Setup F3SearchF4InvertF5Tree F6SortByF7Nice -F8Nice +F9Kill F10Quit[?1000l[?25h[?0c diff --git a/kernel/core/shell.c b/kernel/core/shell.c index b76bbfe8..94271e0a 100644 --- a/kernel/core/shell.c +++ b/kernel/core/shell.c @@ -128,7 +128,7 @@ start_shell() { size_t bytes_read = read_fs(file, 0, file->length, (uint8_t *)bufferb); size_t i = 0; for (i = 0; i < bytes_read; ++i) { - ansi_put(bufferb[i]); + kprintf("%c", bufferb[i]); } free(bufferb); close_fs(file); diff --git a/kernel/core/video/ansi.c b/kernel/core/video/ansi.c index 95a8ab7a..83e35488 100644 --- a/kernel/core/video/ansi.c +++ b/kernel/core/video/ansi.c @@ -12,7 +12,7 @@ #define ANSI_BRACKET '[' /* Anything in this range (should) exit escape mode. */ #define ANSI_LOW 'A' -#define ANSI_HIGH 'u' +#define ANSI_HIGH 'z' /* Escape commands */ #define ANSI_CUU 'A' /* CUrsor Up */ #define ANSI_CUD 'B' /* CUrsor Down */ @@ -153,9 +153,12 @@ ansi_put( } else if (arg >= 40 && arg < 50) { /* Set background */ state.bg = arg - 40; - } else if (arg >= 30 && arg < 40) { + } else if (arg >= 30 && arg < 39) { /* Set Foreground */ state.fg = arg - 30; + } else if (arg == 39) { + /* Default Foreground */ + state.fg = 7; } else if (arg == 20) { /* FRAKTUR: Like old German stuff */ state.flags |= ANSI_FRAKTUR; @@ -187,6 +190,58 @@ ansi_put( } } break; + case ANSI_SHOW: + if (!strcmp(argv[0], "?1049")) { + cls(); + bochs_set_csr(0,0); + } + break; + case ANSI_CUP: + if (argc < 2) { + bochs_set_csr(0,0); + break; + } + bochs_set_csr(atoi(argv[1]) - 1, atoi(argv[0]) - 1); + break; + case ANSI_EL: + { + int what = 0, x = 0, y = 0; + if (argc >= 1) { + what = atoi(argv[0]); + } + if (what == 0) { + x = bochs_get_csr_x(); + y = bochs_get_width(); + } else if (what == 1) { + x = 0; + y = bochs_get_csr_x(); + } else if (what == 2) { + x = 0; + y = bochs_get_width(); + } + for (int i = x; i < y; ++i) { + bochs_set_cell(i, bochs_get_csr_y(), ' '); + } + } + break; + case 'X': + { + int how_many = 1; + if (argc >= 1) { + how_many = atoi(argv[0]); + } + for (int i = 0; i < how_many; ++i) { + ansi_writer(' '); + } + } + break; + case 'd': + if (argc < 1) { + bochs_set_csr(bochs_get_csr_x(), 0); + } else { + bochs_set_csr(bochs_get_csr_x(), atoi(argv[0]) - 1); + } + break; default: /* Meh */ break; diff --git a/kernel/core/video/bochs.c b/kernel/core/video/bochs.c index fdf06bb1..00523099 100644 --- a/kernel/core/video/bochs.c +++ b/kernel/core/video/bochs.c @@ -38,6 +38,7 @@ static uint8_t * term_buffer; static uint8_t current_fg = 7; static uint8_t current_bg = 0; static uint16_t current_scroll = 0; +static uint8_t cursor_on = 1; void bochs_set_y_offset(uint16_t y) { @@ -307,6 +308,7 @@ void bochs_reset_colors() { } void draw_cursor() { + if (!cursor_on) return; for (uint32_t x = 0; x < 8; ++x) { bochs_set_point(csr_x * 8 + x, csr_y * 12 + 11, bochs_colors[current_fg]); } @@ -323,6 +325,9 @@ void bochs_write(char c) { } csr_x = 0; ++csr_y; + } else if (c == '\r') { + cell_redraw(csr_x,csr_y); + csr_x = 0; } else if (c == '\b') { --csr_x; cell_set(csr_x, csr_y, ' ',current_fg, current_bg, 0); @@ -365,3 +370,41 @@ void bochs_draw_line(uint16_t x0, uint16_t x1, uint16_t y0, uint16_t y1, uint32_ } } } + +void +bochs_set_csr(int x, int y) { + cell_redraw(csr_x,csr_y); + csr_x = x; + csr_y = y; +} + +int +bochs_get_csr_x() { + return csr_x; +} + +int +bochs_get_csr_y() { + return csr_y; +} + +void +bochs_set_csr_show(uint8_t on) { + cursor_on = on; +} + +int +bochs_get_width() { + return bochs_resolution_x / 8; +} + +int +bochs_get_height() { + return bochs_resolution_y / 12; +} + +void +bochs_set_cell(int x, int y, char c) { + cell_set(x, y, c, current_fg, current_bg, 0); + cell_redraw(x, y); +} diff --git a/kernel/include/system.h b/kernel/include/system.h index 202b8b06..de7d3712 100644 --- a/kernel/include/system.h +++ b/kernel/include/system.h @@ -249,6 +249,10 @@ extern int detect_cpu(); /* Video Drivers */ /* BOCHS / QEMU VBE Driver */ extern void graphics_install_bochs(); +extern void bochs_set_csr(int x, int y); +extern int bochs_get_csr_x(); +extern int bochs_get_csr_y(); +extern void bochs_set_csr_on(uint8_t); extern void bochs_set_bank(uint16_t bank); extern void bochs_set_coord(uint16_t x, uint16_t y, uint32_t color); extern void bochs_fill_rect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t color); @@ -267,6 +271,9 @@ extern void bochs_write(char c); extern void bochs_reset_colors(); extern void bochs_set_colors(uint8_t, uint8_t); extern void bochs_draw_line(uint16_t,uint16_t,uint16_t,uint16_t,uint32_t); +extern int bochs_get_width(); +extern int bochs_get_height(); +extern void bochs_set_cell(int x, int y, char c); /* ANSI Terminal Escape Processor */ void ansi_put(char c); diff --git a/util/typewriter.c b/util/typewriter.c new file mode 100644 index 00000000..12ebc077 --- /dev/null +++ b/util/typewriter.c @@ -0,0 +1,17 @@ +#include +#include +#include + +int main(int argc, char ** argv) { + if (argc < 3) { return -1; } + FILE * f = fopen(argv[2],"r"); + char * buffer = malloc(sizeof(char) * 1); + while (!feof(f)) { + fread(buffer, 1, 1, f); + printf("%c", buffer[0]); + fflush(stdout); + usleep(atoi(argv[1])); + } + fclose(f); + return 0; +}