From 2a6690e9fd53a02613796764248006e06ac482d6 Mon Sep 17 00:00:00 2001 From: Miguel Date: Sun, 14 Oct 2018 22:36:16 +0200 Subject: ported vim et al --- Makefile | 1 + README.md | 16 +- driver/e1000.c | 2 +- driver/keyboard.c | 4 +- fs/ext2.c | 2 +- fs/mount.c | 18 +- grubiso/boot/grub/grub.cfg | 2 +- interface/Makefile.am | 25 +++ interface/configure.in | 7 + interface/crt0.s | 3 + interface/fs.h | 11 + interface/syscalls.c | 421 +++++++++++++++++++++++++++++++++++---- interface/syscalls.h | 31 ++- kernel/kernel.c | 2 + kernel/syscalls.c | 82 ++++++-- packages/ncurses-6.1/foolterm.ti | 44 ++-- userspace/Makefile | 5 +- userspace/date.c | 5 - userspace/echo.c | 10 + userspace/echoapp.c | 17 ++ userspace/files/.vimrc | 12 ++ userspace/fonts/Makefile | 6 +- userspace/fsh.c | 2 - userspace/init.c | 5 +- userspace/myclear.c | 7 +- userspace/ncurses/Makefile | 11 +- userspace/ncurses/foolstart.c | 149 -------------- userspace/ncurses/nc.c | 200 +++++++++++++++++++ userspace/ncurses/ncurs.c | 70 ------- userspace/sysc.c | 4 - userspace/xterm/Makefile | 3 +- userspace/xterm/terminal.c | 43 ++-- userspace/xterm/vesa.c | 20 +- video/compositor.c | 15 +- 34 files changed, 911 insertions(+), 344 deletions(-) create mode 100644 interface/Makefile.am create mode 100644 interface/configure.in create mode 100644 userspace/echo.c create mode 100644 userspace/echoapp.c create mode 100644 userspace/files/.vimrc delete mode 100644 userspace/ncurses/foolstart.c create mode 100644 userspace/ncurses/nc.c delete mode 100644 userspace/ncurses/ncurs.c delete mode 100644 userspace/sysc.c diff --git a/Makefile b/Makefile index bbf4252..c3efbee 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,7 @@ CFLAGS+=-ffreestanding # do we need this if using own compiler? CFLAGS+=-nostdlib #CFLAGS+=-Og CFLAGS+=-O0 +#CFLAGS+=-O3 CFLAGS+=-I. CFLAGS+=-I/home/miguel/temp/foolos/usr/i686-foolos/include/ CFLAGS+=-I./asm diff --git a/README.md b/README.md index c8e05bc..0665379 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,8 @@ FoolOS was/is tested/developed on the following emulators/machines Todos ----- + https://wiki.osdev.org/Text_Mode_Cursor +cnrom civis term pipes! schedulig! DMA! splice (2) Autobuild via Jenkins (sanbboxed?) @@ -160,7 +162,7 @@ mesa3d, quake,doom, netwookring tcp/ip --with-fallbacks="fool-term" --with-debug --prefix=/usr --with-termlib - ../ncurses-6.1/configure --host=i686-foolos --with-fallbacks="fool-term" --prefix=/usr + ../ncurses-6.1/configure --host=i686-foolos --with-fallbacks="fool-term" --prefix=/usr --with-termlib * ncurses-examples: ../ncurses-examples-20180127/configure --host=i686-foolos --prefix=/usr --with-ncurses make DESTDIR=/home/miguel/temp/foolos/ install @@ -168,6 +170,18 @@ mesa3d, quake,doom, netwookring tcp/ip * vim: vim_cv_memcpy_handles_overlap=no vim_cv_bcopy_handles_overlap=no vim_cv_memmove_handles_overlap=no vim_cv_stat_ignores_slash=no vim_cv_getcwd_broken=no vim_cv_tty_group=world vim_cv_tty_mode=0620 vim_cv_tgetent=zero vim_cv_terminfo=no vim_cv_toupper_broken=no ./configure --host=i686-foolos --prefix=/usr --with-tlib=tinfo +Content +======= + +Third party software and content used some of which is: + +newlib +ncurses +ncurses-examples +vim + +envypn fonts + Disclaimer ========== diff --git a/driver/e1000.c b/driver/e1000.c index 7b4a7cb..5a1c847 100644 --- a/driver/e1000.c +++ b/driver/e1000.c @@ -503,7 +503,7 @@ struct netdev e1000_init(uint32_t base) detectEEProm(); if (! readMACAddress()) return dev; - klog("mac : %02x:%02x:%02x:%02x:%02x:%02x",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[6]); + klog("mac : %02x:%02x:%02x:%02x:%02x:%02x",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]); memcpy(dev.hwaddr,mac,6); // use mac obtained from device dev.ip=(192<<0)+(168<<8)+(0<<16)+(20<<24); // 192.168.0.20 // TODO: not hardcode! diff --git a/driver/keyboard.c b/driver/keyboard.c index a153c9b..da8fe54 100644 --- a/driver/keyboard.c +++ b/driver/keyboard.c @@ -231,13 +231,13 @@ void keyboard_handle(uint8_t in) else if(in==0xB4) { ascii='.'; - if(shift_l||shift_r||capslock) ascii='<'; + if(shift_l||shift_r||capslock) ascii='>'; match=true; } else if(in==0xB3) { ascii=','; - if(shift_l||shift_r||capslock) ascii='>'; + if(shift_l||shift_r||capslock) ascii='<'; match=true; } else if(in==0x8D) diff --git a/fs/ext2.c b/fs/ext2.c index 49484c4..9b41d6c 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -238,7 +238,7 @@ static uint32_t ext2_filename_to_inode_traverse(uint32_t ext2_start_addr, char * } } - klog("file not found!"); + klog("file not found! : %s",path); return 0; } diff --git a/fs/mount.c b/fs/mount.c index 62cfe9f..9aa1aeb 100644 --- a/fs/mount.c +++ b/fs/mount.c @@ -6,6 +6,7 @@ #include "log.h" #include "lib/string/string.h" +#include "lib/printf/printf.h" #include "fd.h" @@ -58,12 +59,15 @@ static uint32_t check_match(char *p1, char *p2) */ static char* get_mount_for_path(char *path,mount *mnt) { - if(path[0]!='/')kpanic("this works only for absolute paths!"); // start with root as default uint32_t best=0; uint32_t best_len=1; + if(path[0]!='/'){ + kpanic("this works only for absolute paths! supplied: %s",path); + } + for(int i=0;i +#include +#include #include #include #include +#include #include "fs.h" #include "syscalls.h" -extern char **environ; -// TODO: errno! +// everybody is root +uid_t getuid(void) +{ + return 0; +} -int _readdir(const char *name,fs_dirent *dirs,int max) +// everybody is root +uid_t getgid(void) { - return syscall(SYSCALL_READDIR,name,dirs,max); + return 0; } -int _poll(int file) +// no sync needed for our ram-image so far (DMA?) +void sync(void) { - return syscall(SYSCALL_POLL,file,0,0); } -void _exit(int ret) +// C NEWLIB // + +// first of all we have a few posix syscalls required by newlib +// (we use version newlib-3.0.0.20180802) +// https://sourceware.org/newlib/libc.html#Syscalls +// just check liunx man-pages, how they SHOULD work. + +// holds environment variables +extern char **environ; + +// terminate caller +void _exit(int status) { - return syscall(SYSCALL_EXIT,ret,environ,0); + return syscall(SYSCALL_EXIT,status,0,0); } +// close file int _close(int file) { return syscall(SYSCALL_CLOSE,file,0,0); } +int close(int file) +{ + return syscall(SYSCALL_CLOSE,file,0,0); +} + +// execute programm +int _execve(const char *filename, char *const argv[], char *const envp[]) +{ + return syscall(SYSCALL_EXECVE,filename,argv,envp); +} +int execve(const char *filename, char *const argv[], char *const envp[]) +{ + return syscall(SYSCALL_EXECVE,filename,argv,envp); +} + +// create a child process +pid_t _fork(void) +{ + return syscall(SYSCALL_FORK,0,0,0); +} +pid_t fork(void) +{ + return syscall(SYSCALL_FORK,0,0,0); +} + +int _fstat(int file, struct stat *st) +{ + return syscall(SYSCALL_FSTAT,file,st,0); +} +int fstat(int file, struct stat *st) +{ + return syscall(SYSCALL_FSTAT,file,st,0); +} + +int _getpid(void) +{ + return syscall(SYSCALL_GETPID,0,0,0); +} +int getpid(void) +{ + return syscall(SYSCALL_GETPID,0,0,0); +} int _isatty(int file) { return syscall(SYSCALL_ISATTY,file,0,0); } +int isatty(int file) +{ + return syscall(SYSCALL_ISATTY,file,0,0); +} + +int _kill(int pid, int sig) +{ + return syscall(SYSCALL_KILL,pid,sig,0); +} +int kill(int pid, int sig) +{ + return syscall(SYSCALL_KILL,pid,sig,0); +} + +int _link(char *old, char *ne) +{ + return syscall(SYSCALL_LINK,old,ne,0); +} +int link(char *old, char *ne) +{ + return syscall(SYSCALL_LINK,old,ne,0); +} int _lseek(int file, int ptr, int dir) { return syscall(SYSCALL_LSEEK,file,ptr,dir); } +int lseek(int file, int ptr, int dir) +{ + return syscall(SYSCALL_LSEEK,file,ptr,dir); +} + +int _open(const char *name, int flags, int mode) +{ + return syscall(SYSCALL_OPEN,name,flags,mode); +} +int open(const char *name, int flags, int mode) +{ + return syscall(SYSCALL_OPEN,name,flags,mode); +} int _read(int file, char *ptr, int len) { return syscall(SYSCALL_READ,file,ptr,len); } +int read(int file, char *ptr, int len) +{ + return syscall(SYSCALL_READ,file,ptr,len); +} -int _open(const char *name, int flags, int mode) +uint32_t _sbrk(int incr) { - return syscall(SYSCALL_OPEN,name,flags,mode); + return syscall(SYSCALL_SBRK,incr,0,0); +} +uint32_t sbrk(int incr) +{ + return syscall(SYSCALL_SBRK,incr,0,0); +} + +int _stat(const char *file, struct stat *st) +{ + return syscall(SYSCALL_STAT,file,st,0); +} +int stat(const char *file, struct stat *st) +{ + return syscall(SYSCALL_STAT,file,st,0); +} + +int _times(struct tms *buf) +{ + return syscall(SYSCALL_TIMES,buf,0,0); +} +int times(struct tms *buf) +{ + return syscall(SYSCALL_TIMES,buf,0,0); +} + +int _unlink(char *name) +{ + return syscall(SYSCALL_UNLINK,name,0,0); +} +int unlink(char *name) +{ + return syscall(SYSCALL_UNLINK,name,0,0); +} + +int _wait(int *status) +{ + return syscall(SYSCALL_WAIT,status,0,0); +} +int wait(int *status) +{ + return syscall(SYSCALL_WAIT,status,0,0); } int _write(int file, char *ptr, int len) { return syscall(SYSCALL_WRITE,file,ptr,len); } +int write(int file, char *ptr, int len) +{ + return syscall(SYSCALL_WRITE,file,ptr,len); +} + +////////////////////////////////////////////////////////////////////// + -int _execve(char *name, char **argv, char **env) +int _readdir(const char *name,fs_dirent *dirs,int max) { - return syscall(SYSCALL_EXECVE,name,argv,env); + return syscall(SYSCALL_READDIR,name,dirs,max); } -uint32_t _sbrk(int incr) +int _poll(int file) { - return syscall(SYSCALL_SBRK,incr,0,0); + return syscall(SYSCALL_POLL,file,0,0); } int _gettimeofday(struct timeval *tv, void *tz) @@ -70,57 +217,263 @@ int _gettimeofday(struct timeval *tv, void *tz) return syscall(SYSCALL_GETTIMEOFDAY,tv,tz,0); } -int _fork(void) +int _lstat(const char *file, struct stat *st) { - return syscall(SYSCALL_FORK,0,0,0); + return syscall(SYSCALL_LSTAT,file,st,0); } +// EXTRA STUFF + + static struct termios tty1; // only one global terminal managed here... more might/should follow + //TODO : implement this properly + + int tcgetattr(int fd, struct termios *termios_p) + { + syscall(SYSCALL_UNIMPLEMENTED,"tcgetattr",0,0); + *termios_p=tty1; + return 0; + } + + int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) + { + syscall(SYSCALL_UNIMPLEMENTED,"tcsetattr",0,0); + tty1=*termios_p; + return 0; + } + +/* + + int tcsendbreak(int fd, int duration); + + int tcdrain(int fd); + + + int tcflow(int fd, int action); +*/ + +// void cfmakeraw(struct termios *termios_p); + + /* + speed_t cfgetispeed(const struct termios *termios_p); + + */ + + speed_t cfgetospeed(const struct termios *termios_p) + { + syscall(SYSCALL_UNIMPLEMENTED,"cfgetospeed",0,0); + return B230400; + } + + long fpathconf(int fd, int name) + { + return syscall(SYSCALL_UNIMPLEMENTED,"fpathconf",0,0); + } + + int tcflush(int fd, int queue_selector) + { + return syscall(SYSCALL_UNIMPLEMENTED,"tcflush",0,0); + } + + /* + int cfsetispeed(struct termios *termios_p, speed_t speed); + + int cfsetospeed(struct termios *termios_p, speed_t speed); + + int cfsetspeed(struct termios *termios_p, speed_t speed); + */ + +////////////////////////////////////////// move along /// + + int access(const char *pathname, int mode) + { + return syscall(SYSCALL_UNIMPLEMENTED,"access",0,0); + } + + #include + #include + + mode_t umask(mode_t mask) + { + return syscall(SYSCALL_UNIMPLEMENTED,"umask",0,0); + } + + int mkdir(const char *pathname, mode_t mode) + { + return syscall(SYSCALL_UNIMPLEMENTED,"mkdir",0,0); + } + + int chdir(const char *path) + { + return syscall(SYSCALL_UNIMPLEMENTED,"chdir",0,0); + } + + char* getwd(char *buf) + { + return syscall(SYSCALL_UNIMPLEMENTED,"getwd",0,0); + } + + char *ttyname(int fd) + { + return syscall(SYSCALL_UNIMPLEMENTED,"ttyname",0,0); + } + +// + + struct dirent *readdir(DIR *dirp) + { + return syscall(SYSCALL_UNIMPLEMENTED,"readdir",0,0); + } + + DIR *opendir(const char *name) + { + return syscall(SYSCALL_UNIMPLEMENTED,"opendir",0,0); + } + + int closedir(DIR *dirp) + { + return syscall(SYSCALL_UNIMPLEMENTED,"closedir",0,0); + } + + + unsigned int sleep(unsigned int seconds) + { + return syscall(SYSCALL_UNIMPLEMENTED,"sleep",0,0); + } + + char *getlogin(void) + { + return syscall(SYSCALL_UNIMPLEMENTED,"getlogin",0,0); + } + + + /** + * Monitor multiple descriptors + * ============================ + * + * nfds is the MAX file descriptor number +1. + * + * It is possible to provide 3 different sets of filedescriptors + * (they can be NULL as well) + * + * - readfds - reading + * - writefds - writing + * - exceptfds - exceptions (all cleared unless exception occurs) + * + * The call returns the total number of descriptors contained in all + * sets after returning. + * + * This call will block until time (timeout) runs out + * OR a file descriptor becomes ready. + */ + + int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) + { + // pack all our sets togehter + fd_set *fd_sets[3]; + + fd_sets[0]=readfds; + fd_sets[1]=writefds; + fd_sets[2]=exceptfds; + + return syscall(SYSCALL_SELECT,nfds,timeout,fd_sets); + } + + int pclose(FILE *stream) + { + return syscall(SYSCALL_UNIMPLEMENTED,"pclose",0,0); + } + + FILE *popen(const char *command, const char *type) + { + return syscall(SYSCALL_UNIMPLEMENTED,"popen",0,0); + } + + // call dup2 in dup emulation mode + int dup(int oldfd) + { + return _dup2(oldfd,0xffffffff); // dup emulation mode + } + + int _clone(void) { return syscall(SYSCALL_CLONE,0,0,0); } +int _pipe(uint32_t fds[2]) +{ + return syscall(SYSCALL_PIPE,fds,0,0); +} +int pipe(uint32_t fds[2]) +{ + return syscall(SYSCALL_PIPE,fds,0,0); +} +int _dup2(uint32_t oldfd,uint32_t newfd) +{ + return syscall(SYSCALL_DUP2,oldfd,newfd,0); +} +int dup2(uint32_t oldfd,uint32_t newfd) +{ + return syscall(SYSCALL_DUP2,oldfd,newfd,0); +} +int _gui_rect() +{ + return syscall(SYSCALL_GUI_RECT,0,0,0); +} +int _gui_win() +{ + return syscall(SYSCALL_GUI_WIN,0,0,0); +} -int _getpid(void) +int gethostname(char *name, size_t len) { - return syscall(SYSCALL_GETPID,0,0,0); + strcpy(name,"foolcomp"); + return 0; //success } -int _kill(int pid, int sig) +ssize_t readlink(const char *pathname, char *buf, size_t bufsiz) { - return syscall(SYSCALL_KILL,pid,sig,0); + syscall(SYSCALL_UNIMPLEMENTED,"readlink",0,0); + return 0; } -int _link(char *old, char *ne) +int rmdir(const char *pathname) { - return syscall(SYSCALL_LINK,old,ne,0); + syscall(SYSCALL_UNIMPLEMENTED,"rmdir",0,0); + return 0; } -int _unlink(char *name) +int fcntl(int fd, int cmd, ... /* arg */ ) { - return syscall(SYSCALL_UNLINK,name,0,0); + syscall(SYSCALL_UNIMPLEMENTED,"fcntl",0,0); + return 0; } -int _times(struct tms *buf) +pid_t waitpid(pid_t pid, int *wstatus, int options) { - return syscall(SYSCALL_TIMES,buf,0,0); + syscall(SYSCALL_UNIMPLEMENTED,"waitpid",0,0); + return 0; } -int _wait(uint32_t pid) +int execl(const char *path, const char *arg, ...) { - return syscall(SYSCALL_WAIT,pid,0,0); + syscall(SYSCALL_UNIMPLEMENTED,"execl",0,0); + return 0; } -int _stat(const char *file, struct stat *st) +int execvp(const char *file, char *const argv[]) { - return syscall(SYSCALL_STAT,file,st,0); + syscall(SYSCALL_UNIMPLEMENTED,"execvp",0,0); + return 0; } -int _lstat(const char *file, struct stat *st) +long sysconf(int name) { - return syscall(SYSCALL_LSTAT,file,st,0); + syscall(SYSCALL_UNIMPLEMENTED,"sysconf",0,0); + return 0; } -int _fstat(int file, struct stat *st) +int chmod(const char *pathname, mode_t mode) { - return syscall(SYSCALL_FSTAT,file,st,0); + syscall(SYSCALL_UNIMPLEMENTED,"chmod",0,0); + return 0; } diff --git a/interface/syscalls.h b/interface/syscalls.h index 40a8c17..e758fd9 100644 --- a/interface/syscalls.h +++ b/interface/syscalls.h @@ -1 +1,30 @@ -/* empty */ +#define SYSCALL_EXIT 60 +#define SYSCALL_CLOSE 66 +#define SYSCALL_EXECVE 64 +#define SYSCALL_FORK 72 +#define SYSCALL_GETPID 78 +#define SYSCALL_ISATTY 68 +#define SYSCALL_LINK 82 +#define SYSCALL_LSEEK 69 +#define SYSCALL_OPEN 65 +#define SYSCALL_READ 62 +#define SYSCALL_SBRK 70 +#define SYSCALL_STAT 74 +#define SYSCALL_FSTAT 67 +#define SYSCALL_LSTAT 79 +#define SYSCALL_TIMES 75 +#define SYSCALL_UNLINK 76 +#define SYSCALL_WAIT 77 +#define SYSCALL_WRITE 61 +#define SYSCALL_GETTIMEOFDAY 71 +#define SYSCALL_READDIR 63 +#define SYSCALL_KILL 73 +#define SYSCALL_POLL 80 +#define SYSCALL_CLONE 83 +#define SYSCALL_PIPE 84 +#define SYSCALL_DUP2 86 +#define SYSCALL_GUI_RECT 87 +#define SYSCALL_GUI_WIN 88 +#define SYSCALL_SELECT 89 + +#define SYSCALL_UNIMPLEMENTED 255 diff --git a/kernel/kernel.c b/kernel/kernel.c index 7f92a25..3692b17 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -158,11 +158,13 @@ void kernel_main(uint32_t eax,uint32_t ebx) mouse_init(); // -- E1000 DRIVER --/ + #ifndef DISABLE_E1000 if(e1000_addr) { klog("E1000 init ..."); e1000_init(e1000_addr); } + #endif // we wait until the end since the time will only start ticking once // we enable interrupts. diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 228b70a..1c1d2c7 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -12,6 +12,7 @@ #include "driver/screen.h" #include #include +#include #include #include #include "syscalls.h" @@ -120,8 +121,10 @@ char* syscall_get_name(uint32_t num) return "SYSCALL_GUI_WIN"; case SYSCALL_SELECT: return "SYSCALL_SELECT"; + case SYSCALL_UNIMPLEMENTED: + return "SYSCALL_UNKNOWN"; } - kpanic("UNKNOWN SYSCALL NUM"); + kpanic("UNKNOWN SYSCALL NUM: %d",num); } int syscall_gettimeofday(struct timeval *tv, struct timezone *tz,uint32_t none1, uint32_t pid) @@ -183,13 +186,26 @@ int syscall_read(int file, char *buf, int len,uint32_t pid) int syscall_select(int maxxfd,struct timeval *tv, fd_set **fd_sets, uint32_t pid, bool test) { int ret=0; + + if(test&&tv!=NULL) // check if time did not run out already + { + if(tv->tv_sec==0&&tv->tv_usec==0)return 1; + + uint64_t t=timer_get_ms(); // current time in milliseconds (10^-3) + + uint64_t t0=0; + t0+=tv->tv_sec*1000; // seconds * 10^3 + t0+=tv->tv_usec/1000; // microseconds * 10^-3 + + if(t>t0)return 1; // ready to fire! + } // TODO: wake when timeout runs out! if(!test) { - if(tv==NULL)klog("select with infinite timeout"); - else klog ("select with timeout: sec=%d, usec=%d",tv->tv_sec,tv->tv_usec); + // if(tv==NULL)klog("select with infinite timeout"); +// else klog ("select with timeout: sec=%d, usec=%d",tv->tv_sec,tv->tv_usec); } for(int i=0;itv_sec*1000; // seconds * 10^3 - t0+=tv->tv_usec/1000; // microseconds * 10^-3 - - if(t>t0)return 1; // ready to fire! - } return ret; @@ -439,7 +445,6 @@ int syscall_stat(const char *path, struct stat *st,int none,uint32_t pid) return 0; } - uint32_t syscall_pipe(uint32_t *addr,int none1, int none2, uint32_t pid) { fd pipfds[2]; @@ -462,11 +467,46 @@ uint32_t syscall_pipe(uint32_t *addr,int none1, int none2, uint32_t pid) uint32_t syscall_dup2(uint32_t oldfd,int newfd, int none2, uint32_t pid) { - if(newfd==0xffffffff)klog("dup mode not supported yet !!!"); + if(newfd==0xffffffff)kpanic("dup mode not supported yet !!!"); fds[pid][newfd]=fd_dupl(&fds[pid][oldfd]); return newfd; } + + /// testing TODO: + struct termios tty1; + bool termios_init=false; + +uint32_t syscall_tcgetattr(int fd, struct termios *termios_p, uint32_t none, uint32_t pid) +{ + if(!termios_init) + { + tty1.c_cc[VMIN]=1; // reading from terminal returns after each byte + termios_init=true; + } + klog("pid %d calls tcgetattr on %d",pid,fd); + *termios_p=tty1; + return 0; +} + +uint32_t syscall_tcsetattr(int fd, struct termios *termios_p, uint32_t none, uint32_t pid) +{ + klog("pid %d calls tcsetattr on %d",pid,fd); + klog("c_iflag=%08X",termios_p->c_iflag); + klog("c_oflag=%08X",termios_p->c_oflag); + klog("c_cflag=%08X",termios_p->c_cflag); + klog("c_lflag=%08X",termios_p->c_lflag); + for(int i=0;ic_cc[i]!=0) + { + klog("set c_cc[%d]=%d",i,termios_p->c_cc[i]); + } + } + tty1=*termios_p; + return 0; +} + uint32_t syscall_gui_rect(uint32_t p1, uint32_t p2, uint32_t p3, uint32_t pid) { compositor_wake(); @@ -492,7 +532,7 @@ uint32_t syscall_generic_prep(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, case SYSCALL_SELECT : // change to absolute time for easier timout - if(tv!=NULL) + if(tv!=NULL&&(tv->tv_sec!=0||tv->tv_usec!=0)) { uint64_t t=timer_get_ms(); // current time in milliseconds (10^-3) t+=tv->tv_sec*1000; // seconds * 10^3 @@ -500,7 +540,6 @@ uint32_t syscall_generic_prep(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, tv->tv_sec=t/1000; tv->tv_usec=(t%1000)*1000; - } break; @@ -528,6 +567,9 @@ uint32_t syscall_generic_test(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, /** Generics */ uint32_t syscall_generic(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, uint32_t pid) { + +// klog("processing syscall [%s] for pid:%d",syscall_get_name(nr),pid); + switch(nr){ case SYSCALL_EXIT : return syscall_exit(p1,p2,p3,pid); @@ -588,8 +630,12 @@ uint32_t syscall_generic(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, uint return syscall_gui_rect(p1,p2,p3,pid); case SYSCALL_GUI_WIN : return syscall_gui_win(p1,p2,p3,pid); + case SYSCALL_TCGETATTR: + return syscall_tcgetattr(p1,p2,p3,pid); + case SYSCALL_TCSETATTR: + return syscall_tcsetattr(p1,p2,p3,pid); } - klog("unknown syscall %s / %d",p1,nr); + klog("unknown syscall %s / %d we just return 0",p1,nr); return 0; } diff --git a/packages/ncurses-6.1/foolterm.ti b/packages/ncurses-6.1/foolterm.ti index acef9ad..0b316fa 100644 --- a/packages/ncurses-6.1/foolterm.ti +++ b/packages/ncurses-6.1/foolterm.ti @@ -1,19 +1,23 @@ # https://en.wikipedia.org/wiki/ANSI_escape_code # FoolOS built-in terminal emulator # check "man 5 terminfo" to understand this file +# https://invisible-island.net/xterm/terminfo.html +# we want to be a vt52? fool-term|FoolOS built-in terminal emulator, -# automargins +# automargins. (line feed and carriage return when end of line is reached) am, -# erased with background color + +# erased with CURRENT background color when using dch1 ('\Ex') bce, + # can erase overstrikes with blanks - eo, +# eo, # safe to move in insert mode - mir, +## mir, # safe to move in standout mode - msgr, +## msgr, # xenl, xon, @@ -30,12 +34,17 @@ fool-term|FoolOS built-in terminal emulator, # this could hold an alterntive table paiting method # acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i\316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376, - clear=\Ec, cr=\015, +# clear + clear=\Ec, + +# carraige return (to x=0) (\r) + cr=\015, # movement -# +# Home home=\EH, +# back/down/forward/up cub1=\Eb, cud1=\Ed, cuf1=\Ef, @@ -49,27 +58,31 @@ fool-term|FoolOS built-in terminal emulator, # cup=\EY%p1%' '%+%c%p2%' '%+%c, -# clear to end of screen / line +# clear to end of screen ed=\EJ, + +# clear to end of line el=\EK, -# delchar +# del char under cursor dch1=\Ex, -# backspace +# backspace (not echoed anyway?) kbs=\010, # tab ht=\011, -# newline +# newline (\n) nel=\012, -# scrolling (down,reverse) +# scrolling text up ind=\ED, + +# scrolling text down ri=\EM, -# keys +# arrow keys kcub1=\E<, kcud1=\Ev, kcuf1=\E>, kcuu1=\Ea, @@ -95,8 +108,9 @@ fool-term|FoolOS built-in terminal emulator, ## kf8=\E[19~, ## kf9=\E[20~, -#colors +#colors background/foreground setab=\E[4%p1%dm, setaf=\E[3%p1%dm, - oc=\E[37;40m, +#set original color pair (simply white on black) + op=\E[37;40m, diff --git a/userspace/Makefile b/userspace/Makefile index 4823598..950a8d6 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -46,17 +46,20 @@ ext2.img: $(PROGS) @sudo chown miguel mnt @mkdir -p mnt/home/miguel @cp files/* mnt/home/miguel/ + @cp files/.vimrc mnt/home/miguel/ @mkdir -p mnt/boot @mkdir -p mnt/bin @mkdir -p mnt/doc/fonts @mkdir -p mnt/sys # mountpoint for sysfs @mkdir -p mnt/pipes # mountpoint for pipes @cp $(PROGS) mnt/bin + @mkdir -p mnt/usr/share/vim @cp /home/miguel/git/EXT/vim/src/vim mnt/bin + @cp /home/miguel/git/EXT/vim/runtime/syntax mnt/usr/share/vim/syntax -r @cp fonts/*.bin mnt/doc/fonts @cp xterm/xterm mnt/bin @cp cpp/testcpp mnt/bin - @cp ncurses/foolstart mnt/bin + @cp ncurses/nc mnt/bin # @cp /home/miguel/temp/foolos/usr/bin/* mnt/bin @cp /home/miguel/temp/foolos/usr/bin/worm mnt/bin @cp /home/miguel/temp/foolos/usr/bin/xmas mnt/bin diff --git a/userspace/date.c b/userspace/date.c index 64b8dfc..b2c497e 100644 --- a/userspace/date.c +++ b/userspace/date.c @@ -12,8 +12,3 @@ int main(int argc, char **argv) printf("%s", ctime(<ime)); return 0; } - - - - - diff --git a/userspace/echo.c b/userspace/echo.c new file mode 100644 index 0000000..9f6b9df --- /dev/null +++ b/userspace/echo.c @@ -0,0 +1,10 @@ +int main(int argc, char **argv) +{ + for (int i=1;i + +int main() +{ + printf("echo app -- press Q to quit\n"); + + while(1) + { + uint8_t c; + _read(0,&c,1); + printf("%d",c); + fflush(stdout); + + if(c=='q')break; + } +} + diff --git a/userspace/files/.vimrc b/userspace/files/.vimrc new file mode 100644 index 0000000..a86c950 --- /dev/null +++ b/userspace/files/.vimrc @@ -0,0 +1,12 @@ +set nocompatible +set nobackup "no backup files +set nowritebackup "only in case you don't want a backup file while editing +set noswapfile "no swap files +syntax on +set number +set colorcolumn=73 + +" following should be set from terminfo automatically +set t_me= +" todo t_ve +" todo t_vi diff --git a/userspace/fonts/Makefile b/userspace/fonts/Makefile index 31dfb20..dad4df7 100644 --- a/userspace/fonts/Makefile +++ b/userspace/fonts/Makefile @@ -7,9 +7,7 @@ FONT_SRC=$(wildcard ./*.src) FONT_BIN=$(patsubst %.src, %.bin, $(FONT_SRC)) -all: +all: $(FONT_BIN) clean: - -rm binfont.bin - -rm binfont_v2.bin - -rm tinyfont.bin + -rm $(FONT_BIN) diff --git a/userspace/fsh.c b/userspace/fsh.c index d74d9d5..85fc5e4 100644 --- a/userspace/fsh.c +++ b/userspace/fsh.c @@ -21,7 +21,6 @@ #include #include "interface/fs.h" - extern char **environ; bool process(char *buf); @@ -58,7 +57,6 @@ void prompt() int main(int argc, char **argv) { - for(int i=0;i int main() { - printf("\033c"); - fflush(stdout); // force printing to console + printf("x"); + //printf("\033c"); + //printf("\033[10;10H"); +// fflush(stdout); // force printing to console +// tputs("clear",1,putchar); return 0; } diff --git a/userspace/ncurses/Makefile b/userspace/ncurses/Makefile index 5fa350f..e920dc7 100644 --- a/userspace/ncurses/Makefile +++ b/userspace/ncurses/Makefile @@ -1,13 +1,14 @@ CC=i686-foolos-gcc CFLAGS= CFLAGS+=-O0 -#CFLAGS+=-gstabs -CFLAGS+=-g +CFLAGS+=-gstabs #LDLIBS=-lncurses -lform -lmenu -lpanel -ltinfo -LDLIBS=-lncurses -ltinfo +#DLIBS=-ltinfo_g -lncurses_g +#LDLIBS=-lncurses -ltinfo +LDLIBS=-ltinfo_g -foolstart: +nc: clean: - rm -f *.o ncurs foolstart + rm -f *.o nc diff --git a/userspace/ncurses/foolstart.c b/userspace/ncurses/foolstart.c deleted file mode 100644 index 0b795aa..0000000 --- a/userspace/ncurses/foolstart.c +++ /dev/null @@ -1,149 +0,0 @@ -#include - -// http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/printw.html - -#include -#include - -#define WIDTH 50 -#define HEIGHT 20 - -int startx = 0; -int starty = 0; - - -/* - COLOR_BLACK 0 - COLOR_RED 1 - COLOR_GREEN 2 - COLOR_YELLOW 3 - COLOR_BLUE 4 - COLOR_MAGENTA 5 - COLOR_CYAN 6 - COLOR_WHITE 7 - */ - -char *choices[] = { - "Choice 1", - "Choice 2", - "Choice 3", - "Choice 4", - "Exit", - }; - - -int n_choices = sizeof(choices) / sizeof(char *); -void print_menu(WINDOW *menu_win, int highlight); - -int main() -{ WINDOW *menu_win; - int highlight = 1; - int choice = 0; - int c; - - initscr(); - clear(); - noecho(); - cbreak(); /* Line buffering disabled. pass on everything */ - - startx = (80 - WIDTH) / 2; - starty = (24 - HEIGHT) / 2; - - start_color(); /* Start color */ - init_pair(1, COLOR_BLACK, COLOR_WHITE); - init_pair(2, COLOR_WHITE, COLOR_BLUE); - - menu_win = newwin(HEIGHT, WIDTH, starty, startx); - wbkgd(menu_win, COLOR_PAIR(2)); - - keypad(menu_win, TRUE); - - /* - nodelay(menu_win,FALSE); - notimeout(menu_win,FALSE); - wtimeout(menu_win,-1); - */ - - mvprintw(0, 0, "Use W/S/A/D to go up and down, Press enter to select a choice"); - refresh(); - print_menu(menu_win, highlight); - while(1) - { - choice=0; - int y=0; - while(1) - { c = wgetch(menu_win); - mvprintw(y++,0, "%3d / '%c'", c, c); - y%=24; - - refresh(); - switch(c) - { case 'w': - case KEY_UP: - - if(highlight == 1) - highlight = n_choices; - else - --highlight; - break; - - case 's': - case KEY_DOWN: - - if(highlight == n_choices) - highlight = 1; - else - ++highlight; - break; - - case 10: - - choice = highlight; - break; - } - print_menu(menu_win, highlight); - if(choice != 0) /* User did a choice come out of the infinite loop */ - break; - } - mvprintw(23, 0, "You chose choice %d with choice string %s\n", choice, choices[choice - 1]); - - char *argv1[]={"xterm","/bin/fsh",0}; - char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; - - - int pid=_fork(); - - if(pid==0) - { - _execve("/bin/xterm",argv1,env1); - } -} - - clrtoeol(); - refresh(); - endwin(); - return 0; -} - - -void print_menu(WINDOW *menu_win, int highlight) -{ - int x, y, i; - - x = 2; - y = 2; - - box(menu_win, 0, 0); - - for(i = 0; i < n_choices; ++i) - { if(highlight == i + 1) /* High light the present choice */ - { wattron(menu_win, COLOR_PAIR(1)); - mvwprintw(menu_win, y, x, ">> %40s <<", choices[i]); - wattroff(menu_win, COLOR_PAIR(1)); - } - else - mvwprintw(menu_win, y, x, " %40s ", choices[i]); - ++y; - } - wrefresh(menu_win); -} diff --git a/userspace/ncurses/nc.c b/userspace/ncurses/nc.c new file mode 100644 index 0000000..58be71e --- /dev/null +++ b/userspace/ncurses/nc.c @@ -0,0 +1,200 @@ +// http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/printw.html + +#include +#include +#include + +#define WIDTH 50 +#define HEIGHT 20 + +int startx = 0; +int starty = 0; + + +/* + COLOR_BLACK 0 + COLOR_RED 1 + COLOR_GREEN 2 + COLOR_YELLOW 3 + COLOR_BLUE 4 + COLOR_MAGENTA 5 + COLOR_CYAN 6 + COLOR_WHITE 7 + */ + +char *choices[] = { + "Choice 1", + "Choice 2", + "Choice 3", + "Choice 4", + "Exit", + }; + + +int n_choices = sizeof(choices) / sizeof(char *); + +//void print_menu(WINDOW *menu_win, int highlight); + +int main() +{ + printf("HELLO\n"); + setupterm(getenv("TERM"), 1, (int *)0); + putp(tigetstr("clear")); + putchar('X'); + putp(tparm(tigetstr("cup"),10,10)); + putchar('X'); + printf("BYE\n"); + while(1); + + putp(tigetstr("clear")); + putp("XXX"); + return 0; + + tputs(tparm(tigetstr("cup"),1,5),1,putchar); + tputs(tparm(tigetstr("cup"),5,1),1,putchar); + + return 0; + + for(int i=2;i<40;i+=2) + { +// tputs(tparm(tigetstr("cup"),2,i),1,putchar); + putchar('X'); + } + + tputs(tparm(tigetstr("cup"),1,5),1,putchar); + putchar('X'); + fflush(stdout); + + + endwin(); + + + /* + //printf("x"); + putchar('A'); + tputs("clear",1,putchar); + // putp("buum"); + putchar('B'); + + return 0; + putc('a',stdout); + putchar('\n'); + */ + return 0; +} + +//// int main2() +//// { +//// +//// WINDOW *menu_win; +//// +//// int highlight = 1; +//// int choice = 0; +//// int c; +//// +//// initscr(); +//// clear(); +//// noecho(); +//// cbreak(); /// Line buffering disabled. pass on everything +//// +//// startx = (80 - WIDTH) / 2; +//// starty = (24 - HEIGHT) / 2; +//// +//// start_color(); +//// init_pair(1, COLOR_BLACK, COLOR_WHITE); +//// init_pair(2, COLOR_WHITE, COLOR_BLUE); +//// +//// menu_win = newwin(HEIGHT, WIDTH, starty, startx); +//// wbkgd(menu_win, COLOR_PAIR(2)); +//// +//// keypad(menu_win, TRUE); +//// +//// /* +//// nodelay(menu_win,FALSE); +//// notimeout(menu_win,FALSE); +//// wtimeout(menu_win,-1); +//// */ +//// +//// mvprintw(0, 0, "Use W/S/A/D to go up and down, Press enter to select a choice"); +//// refresh(); +//// print_menu(menu_win, highlight); +//// while(1) +//// { +//// choice=0; +//// int y=0; +//// while(1) +//// { c = wgetch(menu_win); +//// mvprintw(y++,0, "%3d / '%c'", c, c); +//// y%=24; +//// +//// refresh(); +//// switch(c) +//// { case 'w': +//// case KEY_UP: +//// +//// if(highlight == 1) +//// highlight = n_choices; +//// else +//// --highlight; +//// break; +//// +//// case 's': +//// case KEY_DOWN: +//// +//// if(highlight == n_choices) +//// highlight = 1; +//// else +//// ++highlight; +//// break; +//// +//// case 10: +//// +//// choice = highlight; +//// break; +//// } +//// print_menu(menu_win, highlight); +//// if(choice != 0) /* User did a choice come out of the infinite loop */ +//// break; +//// } +//// mvprintw(23, 0, "You chose choice %d with choice string %s\n", choice, choices[choice - 1]); +//// +//// char *argv1[]={"xterm","/bin/fsh",0}; +//// char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; +//// +//// +//// int pid=_fork(); +//// +//// if(pid==0) +//// { +//// _execve("/bin/xterm",argv1,env1); +//// } +//// } +//// +//// clrtoeol(); +//// refresh(); +//// endwin(); +//// return 0; +//// } +//// +//// +//// void print_menu(WINDOW *menu_win, int highlight) +//// { +//// int x, y, i; +//// +//// x = 2; +//// y = 2; +//// +//// box(menu_win, 0, 0); +//// +//// for(i = 0; i < n_choices; ++i) +//// { if(highlight == i + 1) /* High light the present choice */ +//// { wattron(menu_win, COLOR_PAIR(1)); +//// mvwprintw(menu_win, y, x, ">> %40s <<", choices[i]); +//// wattroff(menu_win, COLOR_PAIR(1)); +//// } +//// else +//// mvwprintw(menu_win, y, x, " %40s ", choices[i]); +//// ++y; +//// } +//// wrefresh(menu_win); +//// } diff --git a/userspace/ncurses/ncurs.c b/userspace/ncurses/ncurs.c deleted file mode 100644 index 88b6e09..0000000 --- a/userspace/ncurses/ncurs.c +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include "../newcalls.h" - -void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string) -{ - int length, x, y; - float temp; - - if(win == NULL) - win = stdscr; - getyx(win, y, x); - if(startx != 0) - x = startx; - if(starty != 0) - y = starty; - if(width == 0) - width = 80; - - length = strlen(string); - temp = (width - length)/ 2; - x = startx + (int)temp; - mvwprintw(win, y, x, "%s", string); - refresh(); -} - -/* -int write() -{ - printf("hi\n"); -} -*/ - -int main() -{ - - initscr(); - - //cbreak(); - ////noecho(); - -if(has_colors() == FALSE) - - { endwin(); - printf("Your terminal does not support color\n"); - exit(1); - } - - start_color(); /* Start color */ - init_pair(1, COLOR_RED, COLOR_BLACK); - - attron(COLOR_PAIR(1)); - print_in_middle(stdscr, LINES / 2, 0, 0, "Viola !!! In color ..."); - attroff(COLOR_PAIR(1)); - getch(); - print_in_middle(stdscr, LINES / 2, 0, 0, "Fool Masters"); - getch(); - endwin(); - - //write(); - -// initscr(); /* Start curses mode */ -// printw("Hello World !!!"); /* Print Hello World */ -// refresh(); /* Print it on to the real screen */ -// getch(); /* Wait for user input */ - //while(1); - -// endwin(); /* End curses mode */ - -// return 0; -} diff --git a/userspace/sysc.c b/userspace/sysc.c deleted file mode 100644 index f5a6719..0000000 --- a/userspace/sysc.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() -{ - write(1,"dupa\n",5); -} diff --git a/userspace/xterm/Makefile b/userspace/xterm/Makefile index b6bac6e..fdec016 100644 --- a/userspace/xterm/Makefile +++ b/userspace/xterm/Makefile @@ -1,6 +1,7 @@ CC=i686-foolos-gcc -AS=i686-foolos-as + +CFLAGS = -ggdb -O0 # best gdb debugging experience xterm: vesa.o terminal.o clean: diff --git a/userspace/xterm/terminal.c b/userspace/xterm/terminal.c index 60cd8b0..15fbd36 100644 --- a/userspace/xterm/terminal.c +++ b/userspace/xterm/terminal.c @@ -1,7 +1,11 @@ // https://en.wikipedia.org/wiki/ANSI_escape_code // http://en.wikipedia.org/wiki/VT52 // http://vt100.net/docs/vt520-rm/ +// https://invisible-island.net/xterm/terminfo.html // man 4 console_codes +// + +// AIMING TO BE A vt52? #include #include @@ -49,6 +53,7 @@ typedef enum{ ecma48_blinkoff, ecma48_reverse_video_off, + // fg codes are 3x ecma48_fg_black =30, ecma48_fg_red, ecma48_fg_green, @@ -56,10 +61,12 @@ typedef enum{ ecma48_fg_blue, ecma48_fg_magenta, ecma48_fg_cyan, - ecma48_fg_white, + ecma48_fg_white, // 37 + ecma48_underscore_on, // set def color ecma48_underscore_off, // set def color + // bg codes are 4x ecma48_bg_black, //40 ecma48_bg_red, ecma48_bg_green, @@ -210,6 +217,7 @@ static void process_graphic_npar(terminal_tty *tty, terminal_settings s) case ecma48_fg_white: tty->fg=SCR_WHITE; break; + // bg case ecma48_bg_black: @@ -303,6 +311,7 @@ static void process_cup(terminal_tty *tty) } tty->npar=0; + tty->escaping=0; } static void process_graphic_npars(terminal_tty *tty) @@ -331,10 +340,8 @@ static void process_graphic_npars(terminal_tty *tty) } -static void reset(terminal_tty *tty) +static void clear(terminal_tty *tty) { - tty->bg=SCR_BLACK; - tty->fg=SCR_WHITE; for(int x=0;xwidth;x++) for(int y=0;yheight;y++) @@ -360,7 +367,7 @@ terminal_tty terminal_init(term_out *screen,term_in *input) tty.set_lfnl=true; // tty.set_lfnl=false; - + // termios! tty.set_echo=true; tty.set_echo=false; @@ -375,12 +382,15 @@ terminal_tty terminal_init(term_out *screen,term_in *input) tty.x=0; tty.y=0; + tty.bg=SCR_BLACK; + tty.fg=SCR_WHITE; + tty.width=TERM_WIDTH; tty.height=TERM_HEIGHT; tty.reverse_video=false; - reset(&tty); + clear(&tty); return tty; } @@ -390,13 +400,10 @@ 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 @@ -438,7 +445,7 @@ void terminal_put(terminal_tty *tty, uint8_t c) } } - else if(c==0x0D) // CR + else if(c==0x0D) // CR \r { tty->x=0; return; @@ -448,7 +455,7 @@ void terminal_put(terminal_tty *tty, uint8_t c) { for(uint32_t x=tty->x;xwidth;x++) { - set_char(tty,x,tty->y,' ',tty->fg,tty->bg); + // set_char(tty,x,tty->y,' ',tty->fg,tty->bg); } tty->y++; if(tty->set_lfnl)tty->x=0; @@ -468,7 +475,7 @@ void terminal_put(terminal_tty *tty, uint8_t c) { for(uint32_t x=tty->x;xwidth;x++) { - set_char(tty, x, tty->y, ' ', tty->fg, tty->bg); + set_char(tty, x, tty->y, ' ', tty->fg,tty->bg); } } // FOOL-TERM: clear to end of screen @@ -478,6 +485,7 @@ void terminal_put(terminal_tty *tty, uint8_t c) { set_char(tty, x, tty->y, ' ', tty->fg, tty->bg); } + for(uint32_t y=tty->y+1;yheight;y++) { for(uint32_t x=0;xwidth;x++) @@ -520,9 +528,13 @@ void terminal_put(terminal_tty *tty, uint8_t c) /// - if(c=='c'){reset(tty);} // RESET + if(c=='c'){clear(tty);} // RESET - if(c=='D'){tty->y++;} // LINEFEED + if(c=='D'){tty->y++; + + tty->fg=SCR_WHITE; + tty->bg=SCR_BLACK; + } // LINEFEED if(c=='E'){tty->y++;tty->x=0;} //NEWLINE //if(c=='H'){} // SET TABSTOP: TODO @@ -534,7 +546,8 @@ void terminal_put(terminal_tty *tty, uint8_t c) { for(uint32_t x=0;xwidth;x++) { - uint32_t c=' '|tty->fg<<8|tty->bg<<16; + //uint32_t c=' '|tty->fg<<8|tty->bg<<16; + uint32_t c=' '|tty->fg<<8|SCR_BLACK<<16; if(y!=0) c=tty->data[index(tty,x,y-1)]; tty->data[index(tty,x,y)] = c; diff --git a/userspace/xterm/vesa.c b/userspace/xterm/vesa.c index 7f22a5f..745e7fb 100644 --- a/userspace/xterm/vesa.c +++ b/userspace/xterm/vesa.c @@ -29,6 +29,10 @@ static int console_y; static int console_lines; static int console_cols; +static uint8_t termdata[80*24]; +static uint8_t termdata_bg[80*24]; +static uint8_t termdata_fg[80*24]; + // same colors as in screen.h static uint32_t cols[] = { 0x0, // black @@ -52,14 +56,26 @@ static uint32_t cols[] = { /** update cursor position */ void vesa_update_cursor(uint32_t col,uint32_t row) { + int oldx=console_x; + int oldy=console_y; + 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); } /** put char */ void vesa_console_put_char(uint8_t c,uint8_t color_bg, uint8_t color_fg, uint32_t x, uint32_t y) { - PutFont(c, x,y, cols[color_bg],cols[color_fg]); + termdata[y*80+x]=c; + termdata_bg[y*80+x]=color_bg; + termdata_fg[y*80+x]=color_fg; + + if(x==console_x&&y==console_y)PutFont(c, x,y, cols[color_fg],cols[color_bg]); + else PutFont(c, x,y, cols[color_bg],cols[color_fg]); } // @@ -88,7 +104,7 @@ uint32_t vesa_init(char *fontname) FILE *f; //if(fontname==NULL)f=fopen("/doc/fonts/binfont.bin","r"); //if(fontname==NULL)f=fopen("/doc/fonts/tinyfont.bin","r"); - if(fontname==NULL)f=fopen("/doc/fonts/binfont_v2.bin","r"); + if(fontname==NULL)f=fopen("/doc/fonts/envypn7x13.bin","r"); fread(&font_width,1,1,f); fread(&font_height,1,1,f); diff --git a/video/compositor.c b/video/compositor.c index d6689a7..3751c05 100644 --- a/video/compositor.c +++ b/video/compositor.c @@ -59,12 +59,12 @@ static void put_pixel(int x,int y, uint32_t color) static void put_win(struct window *win) { struct pdirectory* mydir; - if(win->vmem) - { +// if(win->vmem) + // { x86_cli();// do not reschedule us til ready! mydir=x86_get_page_directory(); x86_set_page_directory(win->vmem); - } + // } uint32_t *user_vmem=VMEM_USER_FRAMEBUFFER; uint32_t userx=0; @@ -134,14 +134,14 @@ static void put_win(struct window *win) } userx++; } - if(win->vmem) - { - + //if(win->vmem) + //{ x86_set_page_directory(mydir); x86_sti(); - } + //} //draw boundaries + /* for(uint16_t x=win->posx;xposx+win->width;x++) { backbuffer[(win->posy)*vesa_width+x]=0xffffff; //TOP @@ -153,6 +153,7 @@ static void put_win(struct window *win) backbuffer[(y)*vesa_width+(win->posx)]=0xffffff; //LEFT backbuffer[(y)*vesa_width+win->posx+win->width-1]=0xffffff; //RIGHT } + */ // } -- cgit v1.2.3