summaryrefslogtreecommitdiff
path: root/userspace
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-10-17 02:39:56 +0200
committerMiguel <m.i@gmx.at>2018-10-17 02:39:56 +0200
commit474c803c32fe055b4f09cb779f22b70d7eba8325 (patch)
treefda4241ebd53688c17379a9dd11b111c5bf5e7a0 /userspace
parent39f271589fb9db3d6a383857817b13a9bb59d981 (diff)
screen areas invalidation
Diffstat (limited to 'userspace')
-rw-r--r--userspace/files/icons.ppmbin6220801 -> 6220801 bytes
-rw-r--r--userspace/init.c24
-rw-r--r--userspace/newcalls.h9
-rw-r--r--userspace/xterm/terminal.c17
-rw-r--r--userspace/xterm/vesa.c6
-rw-r--r--userspace/xterm/xterm.c53
6 files changed, 76 insertions, 33 deletions
diff --git a/userspace/files/icons.ppm b/userspace/files/icons.ppm
index 45ce414..9d0ae35 100644
--- a/userspace/files/icons.ppm
+++ b/userspace/files/icons.ppm
Binary files differ
diff --git a/userspace/init.c b/userspace/init.c
index 4c55a12..e1ab531 100644
--- a/userspace/init.c
+++ b/userspace/init.c
@@ -6,8 +6,28 @@ char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PA
int main(int argc, char **argv)
{
- _execve("/bin/xterm",argv1,env1);
- while(1); // never reached hopefully
+ execve("/bin/xterm",argv1,env1);
+ /*
+
+ int pid=fork();
+
+ if(!pid)
+ {
+ execve("/bin/xterm",argv1,env1);
+ }
+ else
+ {
+ while(1)
+ {
+ _gui_win();
+ vesa_init(0);
+ void *tty=terminal_init_vesa();
+ getchar();
+ terminal_put('X');
+ }
+
+ }
+ */
}
/*
diff --git a/userspace/newcalls.h b/userspace/newcalls.h
new file mode 100644
index 0000000..177e100
--- /dev/null
+++ b/userspace/newcalls.h
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include "../interface/syscalls.h"
+
+/** invalidate screen rectangle */
+// we pack x,y and width,height togehter
+int _gui_inval(uint32_t xy, uint32_t wh)
+{
+ return syscall(SYSCALL_GUI_RECT,xy,wh,0);
+}
diff --git a/userspace/xterm/terminal.c b/userspace/xterm/terminal.c
index 15fbd36..07c21cf 100644
--- a/userspace/xterm/terminal.c
+++ b/userspace/xterm/terminal.c
@@ -86,6 +86,7 @@ typedef struct term_out_struct
void (*update_cursor)(uint32_t col,uint32_t row);
}term_out;
+// NOT USED (TODO?)
typedef struct term_in_struct
{
void (*put_char)(uint8_t c);
@@ -398,13 +399,6 @@ terminal_tty terminal_init(term_out *screen,term_in *input)
term_out tout;
terminal_tty tty;
-terminal_tty* terminal_init_vesa()
-{
- tout.put_char=vesa_console_put_char;
- tout.update_cursor=vesa_update_cursor;
- tty=(terminal_init(&tout,NULL));
- return &tty;
-}
// send one ASCII character to the terminal
void terminal_put(terminal_tty *tty, uint8_t c)
@@ -655,3 +649,12 @@ void terminal_put(terminal_tty *tty, uint8_t c)
tty->screen->update_cursor(tty->x,tty->y);
return;
}
+
+// initialize terminal for vesa
+terminal_tty* terminal_init_vesa()
+{
+ tout.put_char=vesa_console_put_char;
+ tout.update_cursor=vesa_update_cursor;
+ tty=(terminal_init(&tout,NULL));
+ return &tty;
+}
diff --git a/userspace/xterm/vesa.c b/userspace/xterm/vesa.c
index b6cec2f..6d61498 100644
--- a/userspace/xterm/vesa.c
+++ b/userspace/xterm/vesa.c
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <malloc.h>
#include "vesa.h"
+#include "../newcalls.h"
void PutFont(char c, int x,int y, int color_fg,int color_bg);
@@ -62,7 +63,6 @@ void vesa_update_cursor(uint32_t col,uint32_t row)
console_x=col;
console_y=row;
-
vesa_console_put_char(termdata[oldy*80+oldx],termdata_bg[oldy*80+oldx],termdata_fg[oldy*80+oldx],oldx,oldy);
vesa_console_put_char(termdata[row*80+col],termdata_bg[row*80+col],termdata_fg[row*80+col],col,row);
}
@@ -194,6 +194,10 @@ void PutFont(char c, int x,int y, int color_fg,int color_bg)
else PutPixel(posx,posy,color_bg);
}
}
+
+ // invalidate area
+ _gui_inval((x<<16)|(y),(font_width+1<<16)|(font_height+1));
+
/*
for(int y=0;y<vesaYres;y++)
{
diff --git a/userspace/xterm/xterm.c b/userspace/xterm/xterm.c
index b333794..5540ac9 100644
--- a/userspace/xterm/xterm.c
+++ b/userspace/xterm/xterm.c
@@ -8,49 +8,56 @@ char *argv1[]={"xterm","/bin/fsh",0};
int main(int argc, char **argv)
{
+ // we need a window
_gui_win();
+ // basically loads font and sets a few constants
vesa_init(NULL);
+
+ // init tty and set vesa output funcs
void *tty=terminal_init_vesa();
//int xterm_in[2];
int xterm_out[2];
//_pipe(xterm_in);
- _pipe(xterm_out);
+ pipe(xterm_out);
- int pid=_fork();
+ int pid=fork();
- if(!pid)
+ if(!pid) // child
{
int tty_fd=_open("/dev/tty");
//_close(xterm_in[1]);
- _close(xterm_out[0]);
+ close(xterm_out[0]);
- _dup2(tty_fd,0);// stdin
- _dup2(xterm_out[1],1);// stdout
- _dup2(xterm_out[1],2);// stderr
+ dup2(tty_fd,0);// stdin
+ dup2(xterm_out[1],1);// stdout
+ dup2(xterm_out[1],2);// stderr
// replace process with our foolshell or whatever
if(argc==1)_execve(argv1[1],argv1,environ);
- _execve(argv[1],argv,environ);
+ execve(argv[1],argv,environ);
- while(1);
+ printf("unable to execve %s",argv[1]); // never reached
}
-
- //_close(xterm_in[0]);
- _close(xterm_out[1]);
-
- //_dup2(xterm_in[1],0); // compositor writes here.
- //_close(xterm_in[1]);
-
- while(1)
- {
- char buf[1];
-
- _read(xterm_out[0],buf,1); // show what foolshell writes to its stdout/stderr
- terminal_put(tty,buf[0]);
- _gui_rect();
+ else{
+
+ //_close(xterm_in[0]);
+ close(xterm_out[1]);
+
+ //_dup2(xterm_in[1],0); // compositor writes here.
+ //_close(xterm_in[1]);
+
+ // TODO quit if execve fails or child exits...
+ while(1)
+ {
+ char buf[1];
+
+ read(xterm_out[0],buf,1); // show what foolshell writes to its stdout/stderr
+ terminal_put(tty,buf[0]);
+ }
}
+
}