diff options
author | Alex AUVOLAT <alexis211@gmail.com> | 2013-07-11 22:38:20 +0200 |
---|---|---|
committer | Alex AUVOLAT <alexis211@gmail.com> | 2013-07-11 22:38:20 +0200 |
commit | d2aebee488b71e6f28b8728e7473b63f412ca897 (patch) | |
tree | fbe432590bfcf0b77b189a3db99762fb4f104f39 /src/user/app | |
parent | 78d7ffce4861dea5624ff29ceb39f1643dff8235 (diff) | |
download | TCE-d2aebee488b71e6f28b8728e7473b63f412ca897.tar.gz TCE-d2aebee488b71e6f28b8728e7473b63f412ca897.zip |
Added direct acces to video memory from userland.std_c_userland
Next : same for keyboard ; move VT handling to userland.
Consequence : a foreground app has total control over I/O.
Next : implement sockets & a userland console multiplexer.
Diffstat (limited to 'src/user/app')
-rw-r--r-- | src/user/app/test/main.c | 48 | ||||
-rw-r--r-- | src/user/app/yosh/main.c | 6 |
2 files changed, 34 insertions, 20 deletions
diff --git a/src/user/app/test/main.c b/src/user/app/test/main.c index 2c42cf8..d9b6332 100644 --- a/src/user/app/test/main.c +++ b/src/user/app/test/main.c @@ -1,14 +1,34 @@ #include <tce/syscall.h> #include <stdio.h> #include <stdlib.h> +#include <sched.h> int threads = 1; +mutex_t d_mutex = MUTEX_UNLOCKED; +int d_pos = 0; +int vgatxt = -1; + +void display_it(char k) { + mutex_lock(&d_mutex); + + // just display some stuff on /.dev/vgatxt + if (vgatxt == -1) { + vgatxt = open("/.dev/vgatxt", FM_READ | FM_WRITE); + } + uint16_t c = k | (4 << 8); + write(vgatxt, 2 * d_pos, 2, (char*)&c); + + d_pos++; + + mutex_unlock(&d_mutex); +} + void thread_cascade(void* d) { int n = (int)d; char *v = malloc(2048); - if (!v) printk("!"); + if (!v) display_it('!'); if (d == 0) { //printk("{#} 0 cascade element started => end\n"); @@ -16,21 +36,21 @@ void thread_cascade(void* d) { } else { if (n < 0) { //printk("{#} - cascade element started\n"); - printk("-"); + display_it('-'); n = 0 - n; } else { //printk("{#} + cascade element started\n"); - printk("+"); + display_it('+'); } //printk("{#} FORK + ...\n"); - printk(">"); + display_it('>'); threads += 2; thread_new(thread_cascade, (void*)(n - 1)); //printk("{#} FORK - ...\n"); - printk("<"); + display_it('<'); thread_new(thread_cascade, (void*)(1 - n)); //printk("{#} Thread cascade element finished.\n"); - printk("."); + display_it('.'); } free(v); @@ -40,25 +60,15 @@ void thread_cascade(void* d) { void useless_thread(void* d) { while(1) { - printk("~"); + display_it('~'); schedule(); } } int main(int argc, char** args) { - char**a; - if (args != 0) { - printk("(test) args"); - for (a = args; *a != 0; a++) { - printk(" - "); - printk(*a); - } - printk("\n"); - } - - printk("(test) Creating thread cascade (total 2**6 = 64 threads)\n"); + printk("(test) Creating thread cascade (total 2**7 = 128 threads)\n"); thread_new(useless_thread, 0); - thread_new(thread_cascade, (void*)6); + thread_new(thread_cascade, (void*)7); while (1) { schedule(); diff --git a/src/user/app/yosh/main.c b/src/user/app/yosh/main.c index f7ee7e7..e989dc1 100644 --- a/src/user/app/yosh/main.c +++ b/src/user/app/yosh/main.c @@ -80,7 +80,11 @@ void ls_dir(int fd) { printf("\t"); if (info.type & FT_TERMINAL) { printf("%ix%i", info.size >> 16, info.size & 0xFFFF); - } else if ((info.type & FT_DEV) == 0) { + } else if (info.type & FT_DEV) { + if (info.dev_type == DT_VGATXT) { + printf("%ix%i", info.size >> 16, info.size & 0xFFFF); + } + } else { printf("%i", info.size); } |