finish all but game may some little problem

master
unknown 3 years ago
parent d923c30d9b
commit e2b0d6db45

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

@ -96,6 +96,9 @@ extern int sys_getdents();
extern int sys_something(); extern int sys_something();
extern int sys_sleep(); extern int sys_sleep();
extern long sys_getcwd(); extern long sys_getcwd();
extern int sys_init_graphics();
extern int sys_get_message();
extern int sys_repaint();
fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read, fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read,
sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link, sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link,
@ -112,7 +115,9 @@ sys_getpgrp, sys_setsid, sys_sigaction, sys_sgetmask, sys_ssetmask,
sys_setreuid,sys_setregid, sys_sigsuspend, sys_sigpending, sys_sethostname, sys_setreuid,sys_setregid, sys_sigsuspend, sys_sigpending, sys_sethostname,
sys_setrlimit, sys_getrlimit, sys_getrusage, sys_gettimeofday, sys_setrlimit, sys_getrlimit, sys_getrusage, sys_gettimeofday,
sys_settimeofday, sys_getgroups, sys_setgroups, sys_select, sys_symlink, sys_settimeofday, sys_getgroups, sys_setgroups, sys_select, sys_symlink,
sys_lstat, sys_readlink, sys_uselib, sys_execve2, sys_getdents, sys_something ,sys_sleep, sys_getcwd}; sys_lstat, sys_readlink, sys_uselib, sys_execve2, sys_getdents, sys_something ,sys_sleep, sys_getcwd
,sys_init_graphics,sys_get_message,sys_repaint
};
/* So we don't have to do any more manual updating.... */ /* So we don't have to do any more manual updating.... */
int NR_syscalls = sizeof(sys_call_table)/sizeof(fn_ptr); int NR_syscalls = sizeof(sys_call_table)/sizeof(fn_ptr);

@ -54,6 +54,19 @@ struct tty_struct {
extern struct tty_struct tty_table[]; extern struct tty_struct tty_table[];
struct message{
int mid;
int pid;
struct message *next;
};
struct message *headd;
/* intr=^C quit=^| erase=del kill=^U /* intr=^C quit=^| erase=del kill=^U
eof=^D vtime=\0 vmin=\1 sxtc=\0 eof=^D vtime=\0 vmin=\1 sxtc=\0
start=^Q stop=^S susp=^Z eol=\0 start=^Q stop=^S susp=^Z eol=\0
@ -74,4 +87,5 @@ void con_write(struct tty_struct * tty);
void copy_to_cooked(struct tty_struct * tty); void copy_to_cooked(struct tty_struct * tty);
#endif #endif

@ -1,6 +1,6 @@
#ifndef _UNISTD_H #ifndef _UNISTD_H
#define _UNISTD_H #define _UNISTD_H
#include<linux/tty.h>
/* ok, this may be a joke, but I'm working on it */ /* ok, this may be a joke, but I'm working on it */
#define _POSIX_VERSION 198808L #define _POSIX_VERSION 198808L
@ -152,6 +152,10 @@
#define __NR_something 89 #define __NR_something 89
#define __NR_sleep 90 #define __NR_sleep 90
#define __NR_getcwd 91 #define __NR_getcwd 91
#define __NR_init_graphics 92
#define __NR_get_message 93
#define __NR_repaint 94
#define _syscall0(type,name) \ #define _syscall0(type,name) \
type name(void) \ type name(void) \
{ \ { \
@ -273,11 +277,13 @@ pid_t getpgrp(void);
pid_t setsid(void); pid_t setsid(void);
long getcwd(char *buf,size_t size); char* getcwd(char *buf,size_t size);
int something(void); int something(void);
int sleep(unsigned int seconds); int sleep(unsigned int seconds);
int execve2(const char *path,char *argv[],char *envp[]); int execve2(const char *path,char *argv[],char *envp[]);
int init_graphics(void);
int get_message(struct message *msg);
int repaint(int x,int y,int h);
#define __always_inline inline __attribute__((always_inline)) #define __always_inline inline __attribute__((always_inline))

@ -25,6 +25,7 @@ __always_inline _syscall0(int,fork)
__always_inline _syscall0(int,pause) __always_inline _syscall0(int,pause)
__always_inline _syscall1(int,setup,void *,BIOS) __always_inline _syscall1(int,setup,void *,BIOS)
__always_inline _syscall0(int,sync) __always_inline _syscall0(int,sync)
__always_inline _syscall0(int,init_graphics)
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/sched.h> #include <linux/sched.h>
@ -52,6 +53,8 @@ extern long rd_init(long mem_start, int length);
extern long kernel_mktime(struct tm * tm); extern long kernel_mktime(struct tm * tm);
extern long startup_time; extern long startup_time;
extern int init_graphics();
/* /*
* This is set up by the setup-routine at boot-time * This is set up by the setup-routine at boot-time
*/ */
@ -134,6 +137,7 @@ void main(void) /* This really IS void, no error here. */
buffer_init(buffer_memory_end); buffer_init(buffer_memory_end);
hd_init(); hd_init();
floppy_init(); floppy_init();
//init_graphics();
sti(); sti();
move_to_user_mode(); move_to_user_mode();
if (!fork()) { /* we count on this going ok */ if (!fork()) { /* we count on this going ok */

@ -26,7 +26,7 @@ CPP =gcc -E -nostdinc -I../include
OBJS = sched.o system_call.o traps.o asm.o fork.o \ OBJS = sched.o system_call.o traps.o asm.o fork.o \
panic.o printk.o vsprintf.o sys.o exit.o \ panic.o printk.o vsprintf.o sys.o exit.o \
signal.o mktime.o signal.o mktime.o init_graphics.o
kernel.o: $(OBJS) kernel.o: $(OBJS)
$(LD) -r -o kernel.o $(OBJS) $(LD) -r -o kernel.o $(OBJS)
@ -81,3 +81,5 @@ traps.s traps.o : traps.c ../include/string.h ../include/linux/head.h \
../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \
../include/asm/system.h ../include/asm/segment.h ../include/asm/io.h ../include/asm/system.h ../include/asm/segment.h ../include/asm/io.h
vsprintf.s vsprintf.o : vsprintf.c ../include/stdarg.h ../include/string.h vsprintf.s vsprintf.o : vsprintf.c ../include/stdarg.h ../include/string.h
init_graphics.s init_graphi.o:init_graphics.c ../include/linux/kernel.h\
../include/asm/io.h ../include/linux/tty.h

@ -25,7 +25,7 @@ CPP =gcc -E -nostdinc -I../../include
-c -o $*.o $< -c -o $*.o $<
OBJS = tty_io.o console.o keyboard.2.o serial.o rs_io.o \ OBJS = tty_io.o console.o keyboard.2.o serial.o rs_io.o \
tty_ioctl.o mouse.o tty_ioctl.o mouse.2.o
chr_drv.a: $(OBJS) chr_drv.a: $(OBJS)
$(AR) rcs chr_drv.a $(OBJS) $(AR) rcs chr_drv.a $(OBJS)
@ -38,7 +38,7 @@ mouse.2.s:mouse.S ../../include/linux/config.h
clean: clean:
rm -f core *.o *.a tmp_make keyboard.2.s rm -f core *.o *.a tmp_make keyboard.2.s
for i in *.c;do rm -f `basename $$i .c`.s;done for i in *.c;do rm -f `basename $$i .c`.s;done
rm -f core *.o *.a tmp_make mouse.2.s
dep: dep:
sed '/\#\#\# Dependencies/q' < Makefile > tmp_make sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
(for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \

@ -0,0 +1,52 @@
# 1 "mouse.S"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "mouse.S"
.globl mouse_interrupt
mouse_interrupt:
pushl %eax
pushl %ebx
pushl %ecx
pushl %edx
push %ds
#prepare for call readmouse
movl $0x10,%eax
mov %ax,%ds
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
#EOI
movb $0x20,%al #8259A EOI
outb %al,$0xA0 #send EOI to 8259a second
outb %al,$0x20 #send EOI to 8259a first
pop %ds
popl %edx
popl %ecx
popl %ebx
popl %eax
iret

@ -1,36 +1,3 @@
# 1 "mouse.S"
# 1 "/home/mz/1/linux-0.11/kernel/chr_drv//"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "mouse.S"
# 1 "../../include/linux/config.h" 1
# 36 "../../include/linux/config.h"
# 47 "../../include/linux/config.h"
# 2 "mouse.S" 2
.globl mouse_interrupt .globl mouse_interrupt
mouse_interrupt: mouse_interrupt:
pushl %eax pushl %eax
@ -39,7 +6,7 @@ mouse_interrupt:
pushl %edx pushl %edx
push %ds push %ds
//prepare for call readmouse #prepare for call readmouse
movl $0x10,%eax movl $0x10,%eax
mov %ax,%ds mov %ax,%ds
@ -48,13 +15,29 @@ mouse_interrupt:
inb $0x60,%al inb $0x60,%al
pushl %eax pushl %eax
call readmouse call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp addl $4,%esp
//EOI #EOI
movb $0x20,%al //8259A EOI movb $0x20,%al #8259A EOI
outb %al,$0xA0 //send EOI to 8259a second outb %al,$0xA0 #send EOI to 8259a second
outb %al,$0x20 //send EOI to 8259a first outb %al,$0x20 #send EOI to 8259a first
pop %ds pop %ds

@ -349,6 +349,8 @@ void chr_dev_init(void)
{ {
} }
#define MSG_MOUSE_CLICK 1
static unsigned char mouse_input_count = 0; //用来记录是鼠标输入的第几个字节的全局变量 static unsigned char mouse_input_count = 0; //用来记录是鼠标输入的第几个字节的全局变量
static unsigned char mouse_left_down; //用来记录鼠标左键是否按下 static unsigned char mouse_left_down; //用来记录鼠标左键是否按下
static unsigned char mouse_right_down; //用来记录鼠标右键是否按下 static unsigned char mouse_right_down; //用来记录鼠标右键是否按下
@ -359,9 +361,10 @@ static int mouse_x_position; //用来记录鼠标的 x 轴位置
static int mouse_y_position;//用来记录鼠标的 y 轴位置 static int mouse_y_position;//用来记录鼠标的 y 轴位置
static int fcreate=0; static int fcreate=0;
int cnt=0; int cnt=0;
extern struct message *headd;
void readmouse(int mousecode) void readmouse(int mousecode)
{ {
printk("1\n"); //printk("1\n");
if(fcreate==0) if(fcreate==0)
{ {
fcreate=1; fcreate=1;
@ -384,10 +387,18 @@ switch(mouse_input_count)
case 1: case 1:
//Misplaced abandonment //Misplaced abandonment
mouse_left_down=(mousecode &0x01) ==0x01; mouse_left_down=(mousecode &0x01) ==0x01;
mouse_right_down=(mousecode &0x02)==0x02; mouse_right_down=(mousecode &0x02)==0x02;
mouse_left_move=(mousecode & 0x10)==0x10; mouse_left_move=(mousecode & 0x10)==0x10;
mouse_down_move=(mousecode & 0x20)==0x20; mouse_down_move=(mousecode & 0x20)==0x20;
mouse_input_count++; mouse_input_count++;
if(mouse_left_down==1 && mouse_left_move==0 && mouse_down_move==0)
{
struct message *msg = malloc(sizeof(struct message));
msg -> mid = MSG_MOUSE_CLICK;
msg -> pid = -1;
post_message(msg);
}
break; break;
@ -397,8 +408,7 @@ case 2:
//get the x of mouse //get the x of mouse
if(mouse_left_move) mouse_x_position +=(int)(0xFFFFFF00|mousecode); if(mouse_left_move) mouse_x_position +=(int)(0xFFFFFF00|mousecode);
if(mouse_x_position>100) mouse_x_position=100; if(mouse_x_position>100) mouse_x_position=100;
if(mouse_x_position<0) mouse_x_position=10; if(mouse_x_position<0) mouse_x_position=0;
mouse_input_count++; mouse_input_count++;
break; break;
@ -413,8 +423,34 @@ case 3:
case 4: case 4:
//get the z but we do not need it //get the z but we do not need it
break; break;
} }
if(mouse_input_count==4)
{
//printk("%d\n",mouse_left_down);
//printk("%d %d\n",mouse_x_position,mouse_y_position);
}
//sys_init_graphics();
}
void post_message(struct message * msg)
{
cli();
//printk("mid:%d pid:%d\n",msg->mid,msg->pid);
if(headd==NULL&& msg!=NULL)
{
headd=msg;
sti();
return ;
}
struct message *curr=headd;
if(msg==NULL)return;
while(curr->next!=NULL)
{
curr=curr->next;
}
curr->next=msg;
sti();
return;
} }

@ -0,0 +1,105 @@
#include <linux/kernel.h>
#include<asm/io.h>
#include "linux/tty.h"
#define memstart 0xA0000
#define memsize 64000
#define cursor_side 3
#define width 320
#define height 200
#define barrier_width 10
struct message *headd;
static int ff=0;
int sys_init_graphics()
{
int i,j,x,y;
char *p=0xA0000;
if(ff==0)
{
outb(0x05,0x3CE);
outb(0x40,0x3CF);/* shift256=1*/
outb(0x06,0x3CE);
outb(0x05,0x3CF);/*0101 0xA0000*/
outb(0x04,0x3C4);
outb(0x08,0x3C5);/*0000 jilian*/
outb(0x01,0x3D4);
outb(0x4F,0x3D5);/* end horizontal display=79 ??*/
outb(0x03,0x3D4);
outb(0x82,0x3D5);/*display enable skew=0*/
outb(0x07,0x3D4);
outb(0x1F,0x3D5);/*vertical display end No8,9 bit=1,0*/
outb(0x12,0x3D4);
outb(0x8F,0x3D5);/*vertical display end low 7b =0x8F*/
outb(0x17,0x3D4);
outb(0xA3,0x3D5);/*SLDIV=1 ,scanline clock/2*/
outb(0x14,0x3D4);
outb(0x40,0x3D5);/*DW=1*/
outb(0x13,0x3D4);
outb(0x28,0x3D5);/*Offset=40, 20:become long*/
outb(0x0C,0x3D4);/**/
outb(0x00,0x3D5);/**/
outb(0x0D,0x3D4);/**/
outb(0x00,0x3D5);/*Start Address=0xA0000*/
ff=1;
}
p=memstart;
for(i=0;i<memsize;i++) *p++=3;
//3-blue 4-red 12-purple
x=50;
y=40;
for(i=x-cursor_side;i<=x+cursor_side;i++)
for(j=y-cursor_side;j<=y+cursor_side;j++){
p=(char *) memstart+j*width+i;
*p=12;
}
return 0;
}
int sys_get_message(struct message * msg)
{
msg=headd;
if(headd->mid!=1)return 0;
headd=headd->next;
return 0;
}
int sys_repaint(int x,int y,int h)
{
int i,j,w;
char *p;
i=x;
j=y;
p=0xA0000;
w=barrier_width;
if(i+w>=320 || i<20 ) return 0;
if(i==33 || j==33){
p=0xA0000;
for(i=0;i<memsize;i++) *p++=3;
return 0;
}
else if(i==44 || j==44 ){
p=0xA0000;
for(i=0;i<memsize;i++) *p++=4;
return 0;
}else{
for(i=x;i<=x+w;i++){
for(j=y;j<=y+h;j++){
p=0xA0000+j*320+i;
*p=12;
}
}
}
return 0;
}

@ -58,7 +58,7 @@ sa_mask = 4
sa_flags = 8 sa_flags = 8
sa_restorer = 12 sa_restorer = 12
nr_system_calls = 92 /* 72 the number of system*/ nr_system_calls = 96 /* 72 the number of system*/
/* /*
* Ok, I get parallel printer interrupts while using the floppy for some * Ok, I get parallel printer interrupts while using the floppy for some

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,19 @@
#define __LIBRARY__
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
_syscall1(void ,get_message ,struct message ,* msg)
int main()
{
struct message *msg;
int i;
for(i=0;i<10;i++)
{
get_message(msg);
printf("mid:%d pid:%d\n",msg->mid,msg->pid);
}
return 0;
}

@ -0,0 +1,100 @@
#define __LIBRARY__
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<errno.h>
#include<time.h>
#include<linux/tty.h>
#define vga_graph_memstart 0xA0000
#define vga_graph_memsize 64000
#define cursor_side 6
#define vga_width 320
#define vga_height 200
#define BIRD_X 120
#define BIRD_Y 100
#define BIRD_WIDTH 10
#define BIRD_HEIGHT 8
#define MAX 40
char *p;
int i,j,x_pos,y_pos,k;
struct message *msg;
int cnt;
int bird_y;
int px[MAX];
int py[MAX];
int h[MAX];
char *pp;
int ii,jj;
int nn;
_syscall0(int,init_graphics)
_syscall1(int,get_message,struct message * ,msg)
_syscall3(int,repaint,int ,x,int ,y,int ,h)
int main()
{
x_pos=20;
y_pos=20;
bird_y=BIRD_Y;
init_graphics();
px[0]=BIRD_X;
py[0]=bird_y;
h[0]=BIRD_HEIGHT;
cnt=30;
for(i=1;i<cnt;i++)
{
if(i%2==0)
{
px[i]=120+20*i;
py[i]=0;
h[i]=90+i*2;
}
else
{
px[i]=30+20*i;
h[i]=h[i-1]-13*i%17;
py[i]=200-1-h[i];
}
}
msg=NULL;
nn=50;
while(--nn)
{
repaint(px[0],py[0],h[0]);
for(i=1;i<cnt;i++)
{
px[i]-=20;
repaint(px[i],py[i],h[i]);
}
k=3;
while(k>0)
{
--k;
get_message(msg);
if(msg!=NULL)py[0]-=10;
sleep(2);
}
sleep(4);
for(k=1;k<cnt;k++)
{
if(k%2==0)
if(px[0]+6>px[k] && px[0]+6<px[k]+10 && py[0]<h[k])
{
repaint(44,44,44);
return 0;
}else{
if(px[0]+6>px[k] && px[0]+6<px[k]+10 && py[0]+6+h[k]>199)
{
repaint(44,44,44);
return 0;
}
}
}
}
repaint(44,44,44);
return 0;
}

@ -0,0 +1,10 @@
#define __LIBRARY__
#include<stdio.h>
#include<unistd.h>
#include<errno.h>
#include<time.h>
#define vga_graph_memstart 0xA0000
#define vga_graph_memsize 64000
#define cursor_side 6

Binary file not shown.

@ -0,0 +1,19 @@
#define __LIBRARY__
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
_syscall1(void ,get_message ,struct message ,* msg)
int main()
{
struct message *msg;
int i;
for(i=0;i<10;i++)
{
get_message(msg);
printf("mid:%d pid:%d\n",msg->mid,msg->pid);
}
return 0;
}

@ -0,0 +1,20 @@
#define __LIBRARY__
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include"linux/tty.h"
_syscall1(void ,get_message ,struct message ,* msg)
int main()
{
struct message *msg;
int i;
for(i=0;i<10;i++)
{
get_message(msg);
printf("mid:%d pid:%d\n",msg->mid,msg->pid);
}
return 0;
}

@ -0,0 +1,123 @@
/*
* Why isn't this a .c file? Enquiring minds....
*/
extern int sys_setup();
extern int sys_exit();
extern int sys_fork();
extern int sys_read();
extern int sys_write();
extern int sys_open();
extern int sys_close();
extern int sys_waitpid();
extern int sys_creat();
extern int sys_link();
extern int sys_unlink();
extern int sys_execve();
extern int sys_chdir();
extern int sys_time();
extern int sys_mknod();
extern int sys_chmod();
extern int sys_chown();
extern int sys_break();
extern int sys_stat();
extern int sys_lseek();
extern int sys_getpid();
extern int sys_mount();
extern int sys_umount();
extern int sys_setuid();
extern int sys_getuid();
extern int sys_stime();
extern int sys_ptrace();
extern int sys_alarm();
extern int sys_fstat();
extern int sys_pause();
extern int sys_utime();
extern int sys_stty();
extern int sys_gtty();
extern int sys_access();
extern int sys_nice();
extern int sys_ftime();
extern int sys_sync();
extern int sys_kill();
extern int sys_rename();
extern int sys_mkdir();
extern int sys_rmdir();
extern int sys_dup();
extern int sys_pipe();
extern int sys_times();
extern int sys_prof();
extern int sys_brk();
extern int sys_setgid();
extern int sys_getgid();
extern int sys_signal();
extern int sys_geteuid();
extern int sys_getegid();
extern int sys_acct();
extern int sys_phys();
extern int sys_lock();
extern int sys_ioctl();
extern int sys_fcntl();
extern int sys_mpx();
extern int sys_setpgid();
extern int sys_ulimit();
extern int sys_uname();
extern int sys_umask();
extern int sys_chroot();
extern int sys_ustat();
extern int sys_dup2();
extern int sys_getppid();
extern int sys_getpgrp();
extern int sys_setsid();
extern int sys_sigaction();
extern int sys_sgetmask();
extern int sys_ssetmask();
extern int sys_setreuid();
extern int sys_setregid();
extern int sys_sigpending();
extern int sys_sigsuspend();
extern int sys_sethostname();
extern int sys_setrlimit();
extern int sys_getrlimit();
extern int sys_getrusage();
extern int sys_gettimeofday();
extern int sys_settimeofday();
extern int sys_getgroups();
extern int sys_setgroups();
extern int sys_select();
extern int sys_symlink();
extern int sys_lstat();
extern int sys_readlink();
extern int sys_uselib();
extern int sys_execve2();
extern int sys_getdents();
extern int sys_something();
extern int sys_sleep();
extern long sys_getcwd();
extern int sys_init_graphics();
extern int sys_get_message();
extern int sys_repaint();
fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read,
sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link,
sys_unlink, sys_execve, sys_chdir, sys_time, sys_mknod, sys_chmod,
sys_chown, sys_break, sys_stat, sys_lseek, sys_getpid, sys_mount,
sys_umount, sys_setuid, sys_getuid, sys_stime, sys_ptrace, sys_alarm,
sys_fstat, sys_pause, sys_utime, sys_stty, sys_gtty, sys_access,
sys_nice, sys_ftime, sys_sync, sys_kill, sys_rename, sys_mkdir,
sys_rmdir, sys_dup, sys_pipe, sys_times, sys_prof, sys_brk, sys_setgid,
sys_getgid, sys_signal, sys_geteuid, sys_getegid, sys_acct, sys_phys,
sys_lock, sys_ioctl, sys_fcntl, sys_mpx, sys_setpgid, sys_ulimit,
sys_uname, sys_umask, sys_chroot, sys_ustat, sys_dup2, sys_getppid,
sys_getpgrp, sys_setsid, sys_sigaction, sys_sgetmask, sys_ssetmask,
sys_setreuid,sys_setregid, sys_sigsuspend, sys_sigpending, sys_sethostname,
sys_setrlimit, sys_getrlimit, sys_getrusage, sys_gettimeofday,
sys_settimeofday, sys_getgroups, sys_setgroups, sys_select, sys_symlink,
sys_lstat, sys_readlink, sys_uselib, sys_execve2, sys_getdents, sys_something ,sys_sleep, sys_getcwd
,sys_init_graphics,sys_get_message,sys_repaint
};
/* So we don't have to do any more manual updating.... */
int NR_syscalls = sizeof(sys_call_table)/sizeof(fn_ptr);

@ -0,0 +1,91 @@
/*
* 'tty.h' defines some structures used by tty_io.c and some defines.
*
* NOTE! Don't touch this without checking that nothing in rs_io.s or
* con_io.s breaks. Some constants are hardwired into the system (mainly
* offsets into 'tty_queue'
*/
#ifndef _TTY_H
#define _TTY_H
#include <termios.h>
#define TTY_BUF_SIZE 1024
struct tty_queue {
unsigned long data;
unsigned long head;
unsigned long tail;
struct task_struct * proc_list;
char buf[TTY_BUF_SIZE];
};
#define INC(a) ((a) = ((a)+1) & (TTY_BUF_SIZE-1))
#define DEC(a) ((a) = ((a)-1) & (TTY_BUF_SIZE-1))
#define EMPTY(a) ((a).head == (a).tail)
#define LEFT(a) (((a).tail-(a).head-1)&(TTY_BUF_SIZE-1))
#define LAST(a) ((a).buf[(TTY_BUF_SIZE-1)&((a).head-1)])
#define FULL(a) (!LEFT(a))
#define CHARS(a) (((a).head-(a).tail)&(TTY_BUF_SIZE-1))
#define GETCH(queue,c) \
(void)({c=(queue).buf[(queue).tail];INC((queue).tail);})
#define PUTCH(c,queue) \
(void)({(queue).buf[(queue).head]=(c);INC((queue).head);})
#define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
#define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
#define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
#define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
#define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
#define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
#define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
#define SUSPEND_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
struct tty_struct {
struct termios termios;
int pgrp;
int stopped;
void (*write)(struct tty_struct * tty);
struct tty_queue read_q;
struct tty_queue write_q;
struct tty_queue secondary;
};
extern struct tty_struct tty_table[];
struct message{
int mid;
int pid;
struct message *next;
};
struct message *headd;
/* intr=^C quit=^| erase=del kill=^U
eof=^D vtime=\0 vmin=\1 sxtc=\0
start=^Q stop=^S susp=^Z eol=\0
reprint=^R discard=^U werase=^W lnext=^V
eol2=\0
*/
#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
void rs_init(void);
void con_init(void);
void tty_init(void);
int tty_read(unsigned c, char * buf, int n);
int tty_write(unsigned c, char * buf, int n);
void rs_write(struct tty_struct * tty);
void con_write(struct tty_struct * tty);
void copy_to_cooked(struct tty_struct * tty);
#endif

@ -0,0 +1,290 @@
#ifndef _UNISTD_H
#define _UNISTD_H
#include<linux/tty.h>
/* ok, this may be a joke, but I'm working on it */
#define _POSIX_VERSION 198808L
#define _POSIX_CHOWN_RESTRICTED /* only root can do a chown (I think..) */
#define _POSIX_NO_TRUNC /* no pathname truncation (but see in kernel) */
#define _POSIX_VDISABLE '\0' /* character to disable things like ^C */
/*#define _POSIX_SAVED_IDS */ /* we'll get to this yet */
/*#define _POSIX_JOB_CONTROL */ /* we aren't there quite yet. Soon hopefully */
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#ifndef NULL
#define NULL ((void *)0)
#endif
/* access */
#define F_OK 0
#define X_OK 1
#define W_OK 2
#define R_OK 4
/* lseek */
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
/* _SC stands for System Configuration. We don't use them much */
#define _SC_ARG_MAX 1
#define _SC_CHILD_MAX 2
#define _SC_CLOCKS_PER_SEC 3
#define _SC_NGROUPS_MAX 4
#define _SC_OPEN_MAX 5
#define _SC_JOB_CONTROL 6
#define _SC_SAVED_IDS 7
#define _SC_VERSION 8
/* more (possibly) configurable things - now pathnames */
#define _PC_LINK_MAX 1
#define _PC_MAX_CANON 2
#define _PC_MAX_INPUT 3
#define _PC_NAME_MAX 4
#define _PC_PATH_MAX 5
#define _PC_PIPE_BUF 6
#define _PC_NO_TRUNC 7
#define _PC_VDISABLE 8
#define _PC_CHOWN_RESTRICTED 9
#include <sys/stat.h>
#include <sys/times.h>
#include <sys/utsname.h>
#include <utime.h>
#ifdef __LIBRARY__
#define __NR_setup 0 /* used only by init, to get system going */
#define __NR_exit 1
#define __NR_fork 2
#define __NR_read 3
#define __NR_write 4
#define __NR_open 5
#define __NR_close 6
#define __NR_waitpid 7
#define __NR_creat 8
#define __NR_link 9
#define __NR_unlink 10
#define __NR_execve 11
#define __NR_chdir 12
#define __NR_time 13
#define __NR_mknod 14
#define __NR_chmod 15
#define __NR_chown 16
#define __NR_break 17
#define __NR_stat 18
#define __NR_lseek 19
#define __NR_getpid 20
#define __NR_mount 21
#define __NR_umount 22
#define __NR_setuid 23
#define __NR_getuid 24
#define __NR_stime 25
#define __NR_ptrace 26
#define __NR_alarm 27
#define __NR_fstat 28
#define __NR_pause 29
#define __NR_utime 30
#define __NR_stty 31
#define __NR_gtty 32
#define __NR_access 33
#define __NR_nice 34
#define __NR_ftime 35
#define __NR_sync 36
#define __NR_kill 37
#define __NR_rename 38
#define __NR_mkdir 39
#define __NR_rmdir 40
#define __NR_dup 41
#define __NR_pipe 42
#define __NR_times 43
#define __NR_prof 44
#define __NR_brk 45
#define __NR_setgid 46
#define __NR_getgid 47
#define __NR_signal 48
#define __NR_geteuid 49
#define __NR_getegid 50
#define __NR_acct 51
#define __NR_phys 52
#define __NR_lock 53
#define __NR_ioctl 54
#define __NR_fcntl 55
#define __NR_mpx 56
#define __NR_setpgid 57
#define __NR_ulimit 58
#define __NR_uname 59
#define __NR_umask 60
#define __NR_chroot 61
#define __NR_ustat 62
#define __NR_dup2 63
#define __NR_getppid 64
#define __NR_getpgrp 65
#define __NR_setsid 66
#define __NR_sigaction 67
#define __NR_sgetmask 68
#define __NR_ssetmask 69
#define __NR_setreuid 70
#define __NR_setregid 71
#define __NR_sigsuspend 72
#define __NR_sigpending 73
#define __NR_sethostname 74
#define __NR_setrlimit 75
#define __NR_getrlimit 76
#define __NR_getrusage 77
#define __NR_gettimeofday 78
#define __NR_settimeofday 79
#define __NR_getgroups 80
#define __NR_setgroups 81
#define __NR_select 82
#define __NR_symlink 83
#define __NR_lstat 84
#define __NR_readlink 85
#define __NR_uselib 86
#define __NR_execve2 87
#define __NR_getdents 88
#define __NR_something 89
#define __NR_sleep 90
#define __NR_getcwd 91
#define __NR_init_graphics 92
#define __NR_get_message 93
#define __NR_repaint 94
#define _syscall0(type,name) \
type name(void) \
{ \
long __res; \
__asm__ volatile ("int $0x80" \
: "=a" (__res) \
: "0" (__NR_##name)); \
if (__res >= 0) \
return (type) __res; \
errno = -__res; \
return -1; \
}
#define _syscall1(type,name,atype,a) \
type name(atype a) \
{ \
long __res; \
__asm__ volatile ("int $0x80" \
: "=a" (__res) \
: "0" (__NR_##name),"b" ((long)(a))); \
if (__res >= 0) \
return (type) __res; \
errno = -__res; \
return -1; \
}
#define _syscall2(type,name,atype,a,btype,b) \
type name(atype a,btype b) \
{ \
long __res; \
__asm__ volatile ("int $0x80" \
: "=a" (__res) \
: "0" (__NR_##name),"b" ((long)(a)),"c" ((long)(b))); \
if (__res >= 0) \
return (type) __res; \
errno = -__res; \
return -1; \
}
#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
type name(atype a,btype b,ctype c) \
{ \
long __res; \
__asm__ volatile ("int $0x80" \
: "=a" (__res) \
: "0" (__NR_##name),"b" ((long)(a)),"c" ((long)(b)),"d" ((long)(c))); \
if (__res>=0) \
return (type) __res; \
errno=-__res; \
return -1; \
}
#endif /* __LIBRARY__ */
extern int errno;
int access(const char * filename, mode_t mode);
int acct(const char * filename);
int alarm(int sec);
int brk(void * end_data_segment);
void * sbrk(ptrdiff_t increment);
int chdir(const char * filename);
int chmod(const char * filename, mode_t mode);
int chown(const char * filename, uid_t owner, gid_t group);
int chroot(const char * filename);
int close(int fildes);
int creat(const char * filename, mode_t mode);
int dup(int fildes);
int execve(const char * filename, char ** argv, char ** envp);
int execv(const char * pathname, char ** argv);
int execvp(const char * file, char ** argv);
int execl(const char * pathname, char * arg0, ...);
int execlp(const char * file, char * arg0, ...);
int execle(const char * pathname, char * arg0, ...);
volatile void exit(int status);
volatile void _exit(int status);
int fcntl(int fildes, int cmd, ...);
int fork(void);
int getpid(void);
int getuid(void);
int geteuid(void);
int getgid(void);
int getegid(void);
int ioctl(int fildes, int cmd, ...);
int kill(pid_t pid, int signal);
int link(const char * filename1, const char * filename2);
int lseek(int fildes, off_t offset, int origin);
int mknod(const char * filename, mode_t mode, dev_t dev);
int mount(const char * specialfile, const char * dir, int rwflag);
int nice(int val);
int open(const char * filename, int flag, ...);
int pause(void);
int pipe(int * fildes);
int read(int fildes, char * buf, off_t count);
int setpgrp(void);
int setpgid(pid_t pid,pid_t pgid);
int setuid(uid_t uid);
int setgid(gid_t gid);
void (*signal(int sig, void (*fn)(int)))(int);
int stat(const char * filename, struct stat * stat_buf);
int fstat(int fildes, struct stat * stat_buf);
int stime(time_t * tptr);
int sync(void);
time_t time(time_t * tloc);
time_t times(struct tms * tbuf);
int ulimit(int cmd, long limit);
mode_t umask(mode_t mask);
int umount(const char * specialfile);
int uname(struct utsname * name);
int unlink(const char * filename);
int ustat(dev_t dev, struct ustat * ubuf);
int utime(const char * filename, struct utimbuf * times);
pid_t waitpid(pid_t pid,int * wait_stat,int options);
pid_t wait(int * wait_stat);
int write(int fildes, const char * buf, off_t count);
int dup2(int oldfd, int newfd);
int getppid(void);
pid_t getpgrp(void);
pid_t setsid(void);
char* getcwd(char *buf,size_t size);
int something(void);
int sleep(unsigned int seconds);
int execve2(const char *path,char *argv[],char *envp[]);
int init_graphics(void);
int get_message(struct message *msg);
int repaint(int x,int y,int h);
#define __always_inline inline __attribute__((always_inline))
#endif

@ -31,7 +31,7 @@
00000000000i[ ] Sound support: no 00000000000i[ ] Sound support: no
00000000000i[ ] USB support: no 00000000000i[ ] USB support: no
00000000000i[ ] VGA extension support: vbe 00000000000i[ ] VGA extension support: vbe
00000000000i[MEM0 ] allocated memory at 0xb590a008. after alignment, vector=0xb590b000 00000000000i[MEM0 ] allocated memory at 0xb591b008. after alignment, vector=0xb591c000
00000000000i[MEM0 ] 16.00MB 00000000000i[MEM0 ] 16.00MB
00000000000i[MEM0 ] mem block size = 0x00020000, blocks=128 00000000000i[MEM0 ] mem block size = 0x00020000, blocks=128
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('/usr/local/share/bochs/BIOS-bochs-latest') 00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('/usr/local/share/bochs/BIOS-bochs-latest')
@ -42,7 +42,7 @@
00000000000i[DEV ] PIIX3 PCI-to-ISA bridge present at device 1, function 0 00000000000i[DEV ] PIIX3 PCI-to-ISA bridge present at device 1, function 0
00000000000i[PLUGIN] init_dev of 'cmos' plugin device by virtual method 00000000000i[PLUGIN] init_dev of 'cmos' plugin device by virtual method
00000000000i[CMOS ] Using local time for initial clock 00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Wed Jun 29 10:19:36 2022 (time0=1656494376) 00000000000i[CMOS ] Setting initial clock to: Fri Jul 1 04:51:49 2022 (time0=1656647509)
00000000000i[PLUGIN] init_dev of 'dma' plugin device by virtual method 00000000000i[PLUGIN] init_dev of 'dma' plugin device by virtual method
00000000000i[DMA ] channel 4 used by cascade 00000000000i[DMA ] channel 4 used by cascade
00000000000i[PLUGIN] init_dev of 'pic' plugin device by virtual method 00000000000i[PLUGIN] init_dev of 'pic' plugin device by virtual method
@ -60,7 +60,7 @@
00000000000i[FLOPPY] fd0: 'cur/linux/Image' ro=0, h=2,t=80,spt=18 00000000000i[FLOPPY] fd0: 'cur/linux/Image' ro=0, h=2,t=80,spt=18
00000000000i[IMG ] redolog : Standard Header : magic='Bochs Virtual HD Image', type='Redolog', subtype='Volatile', version = 2.0 00000000000i[IMG ] redolog : Standard Header : magic='Bochs Virtual HD Image', type='Redolog', subtype='Volatile', version = 2.0
00000000000i[IMG ] redolog : Specific Header : #entries=512, bitmap size=1, exent size = 4096 disk size = 1474560 00000000000i[IMG ] redolog : Specific Header : #entries=512, bitmap size=1, exent size = 4096 disk size = 1474560
00000000000i[IMG ] 'vvfat' disk opened: directory is 'b/', redolog is 'b//vvfat.dir.8ea7jc' 00000000000i[IMG ] 'vvfat' disk opened: directory is 'b/', redolog is 'b//vvfat.dir.3Ca5jm'
00000000000i[FLOPPY] fd1: 'vvfat:b/' ro=0, h=2,t=80,spt=18 00000000000i[FLOPPY] fd1: 'vvfat:b/' ro=0, h=2,t=80,spt=18
00000000000i[FLOPPY] Using boot sequence floppy, none, none 00000000000i[FLOPPY] Using boot sequence floppy, none, none
00000000000i[FLOPPY] Floppy boot signature check is enabled 00000000000i[FLOPPY] Floppy boot signature check is enabled
@ -185,13 +185,11 @@
00001647811i[BXVGA ] VBE known Display Interface b0c0 00001647811i[BXVGA ] VBE known Display Interface b0c0
00001647843i[BXVGA ] VBE known Display Interface b0c5 00001647843i[BXVGA ] VBE known Display Interface b0c5
00001650768i[VBIOS ] VBE Bios $Id: vbe.c,v 1.64 2011/07/19 18:25:05 vruppert Exp $ 00001650768i[VBIOS ] VBE Bios $Id: vbe.c,v 1.64 2011/07/19 18:25:05 vruppert Exp $
00001789455i[XGUI ] charmap update. Font is 9 x 16 00001869270i[XGUI ] charmap update. Font is 9 x 16
00001995333i[BIOS ] ata0-0: PCHS=512/2/20 translation=none LCHS=512/2/20 00001995333i[BIOS ] ata0-0: PCHS=512/2/20 translation=none LCHS=512/2/20
00005872240i[BIOS ] IDE time out 00005872240i[BIOS ] IDE time out
00051753879i[BIOS ] Booting from 0000:7c00 00051753879i[BIOS ] Booting from 0000:7c00
00096455859i[FLOPPY] partial read() on floppy image returns 240/512 00096790235i[FLOPPY] partial read() on floppy image returns 400/512
00096623570i[FLOPPY] read() on floppy image returns 0
00096790235i[FLOPPY] read() on floppy image returns 0
00096956900i[FLOPPY] read() on floppy image returns 0 00096956900i[FLOPPY] read() on floppy image returns 0
00097123565i[FLOPPY] read() on floppy image returns 0 00097123565i[FLOPPY] read() on floppy image returns 0
00097290230i[FLOPPY] read() on floppy image returns 0 00097290230i[FLOPPY] read() on floppy image returns 0
@ -310,27 +308,27 @@
00116129680i[FLOPPY] read() on floppy image returns 0 00116129680i[FLOPPY] read() on floppy image returns 0
00116296345i[FLOPPY] read() on floppy image returns 0 00116296345i[FLOPPY] read() on floppy image returns 0
00116467319i[BIOS ] int13_harddisk: function 15, unmapped device for ELDL=81 00116467319i[BIOS ] int13_harddisk: function 15, unmapped device for ELDL=81
00204585000i[XGUI ] Mouse capture on 00227715000i[XGUI ] Mouse capture on
00269970000i[ ] cpu loop quit, shutting down simulator 00576540000i[ ] cpu loop quit, shutting down simulator
00269970000i[CPU0 ] CPU is in protected mode (active) 00576540000i[CPU0 ] CPU is in protected mode (active)
00269970000i[CPU0 ] CS.mode = 32 bit 00576540000i[CPU0 ] CS.mode = 32 bit
00269970000i[CPU0 ] SS.mode = 32 bit 00576540000i[CPU0 ] SS.mode = 32 bit
00269970000i[CPU0 ] EFER = 0x00000000 00576540000i[CPU0 ] EFER = 0x00000000
00269970000i[CPU0 ] | EAX=00000000 EBX=00090080 ECX=0001d580 EDX=00000000 00576540000i[CPU0 ] | EAX=0001eb04 EBX=00090080 ECX=0001da20 EDX=00000000
00269970000i[CPU0 ] | ESP=0001e52c EBP=0002434c ESI=000900a0 EDI=00023360 00576540000i[CPU0 ] | ESP=0001e9cc EBP=0002482c ESI=000900a0 EDI=00023840
00269970000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf sf zf af pf cf 00576540000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf sf zf af pf cf
00269970000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D 00576540000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00269970000i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 00ffffff 1 1 00576540000i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 00ffffff 1 1
00269970000i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 00ffffff 1 1 00576540000i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 00ffffff 1 1
00269970000i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 00ffffff 1 1 00576540000i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 00ffffff 1 1
00269970000i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 00ffffff 1 1 00576540000i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 00ffffff 1 1
00269970000i[CPU0 ] | FS:0017( 0002| 1| 3) 00000000 0009ffff 1 1 00576540000i[CPU0 ] | FS:0017( 0002| 1| 3) 00000000 0009ffff 1 1
00269970000i[CPU0 ] | GS:0017( 0002| 1| 3) 00000000 0009ffff 1 1 00576540000i[CPU0 ] | GS:0017( 0002| 1| 3) 00000000 0009ffff 1 1
00269970000i[CPU0 ] | EIP=00006e10 (00006e10) 00576540000i[CPU0 ] | EIP=00006e3e (00006e3e)
00269970000i[CPU0 ] | CR0=0x8000001b CR2=0x08032ef0 00576540000i[CPU0 ] | CR0=0x8000001b CR2=0x0804253c
00269970000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000 00576540000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00269970000i[CPU0 ] 0x00006e10>> test eax, eax : 85C0 00576540000i[CPU0 ] 0x00006e3e>> mov eax, dword ptr ds:[eax] : 8B00
00269970000i[CMOS ] Last time is 1656494393 (Wed Jun 29 10:19:53 2022) 00576540000i[CMOS ] Last time is 1656647547 (Fri Jul 1 04:52:27 2022)
00269970000i[XGUI ] Exit 00576540000i[XGUI ] Exit
00269970000i[ ] restoring default signal behavior 00576540000i[ ] restoring default signal behavior
00269970000i[SIM ] quit_sim called with exit code 1 00576540000i[SIM ] quit_sim called with exit code 1

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

@ -96,6 +96,9 @@ extern int sys_getdents();
extern int sys_something(); extern int sys_something();
extern int sys_sleep(); extern int sys_sleep();
extern long sys_getcwd(); extern long sys_getcwd();
extern int sys_init_graphics();
extern int sys_get_message();
extern int sys_repaint();
fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read, fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read,
sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link, sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link,
@ -112,7 +115,9 @@ sys_getpgrp, sys_setsid, sys_sigaction, sys_sgetmask, sys_ssetmask,
sys_setreuid,sys_setregid, sys_sigsuspend, sys_sigpending, sys_sethostname, sys_setreuid,sys_setregid, sys_sigsuspend, sys_sigpending, sys_sethostname,
sys_setrlimit, sys_getrlimit, sys_getrusage, sys_gettimeofday, sys_setrlimit, sys_getrlimit, sys_getrusage, sys_gettimeofday,
sys_settimeofday, sys_getgroups, sys_setgroups, sys_select, sys_symlink, sys_settimeofday, sys_getgroups, sys_setgroups, sys_select, sys_symlink,
sys_lstat, sys_readlink, sys_uselib, sys_execve2, sys_getdents, sys_something ,sys_sleep, sys_getcwd}; sys_lstat, sys_readlink, sys_uselib, sys_execve2, sys_getdents, sys_something ,sys_sleep, sys_getcwd
,sys_init_graphics,sys_get_message,sys_repaint
};
/* So we don't have to do any more manual updating.... */ /* So we don't have to do any more manual updating.... */
int NR_syscalls = sizeof(sys_call_table)/sizeof(fn_ptr); int NR_syscalls = sizeof(sys_call_table)/sizeof(fn_ptr);

@ -54,6 +54,19 @@ struct tty_struct {
extern struct tty_struct tty_table[]; extern struct tty_struct tty_table[];
struct message{
int mid;
int pid;
struct message *next;
};
struct message *headd;
/* intr=^C quit=^| erase=del kill=^U /* intr=^C quit=^| erase=del kill=^U
eof=^D vtime=\0 vmin=\1 sxtc=\0 eof=^D vtime=\0 vmin=\1 sxtc=\0
start=^Q stop=^S susp=^Z eol=\0 start=^Q stop=^S susp=^Z eol=\0
@ -74,4 +87,5 @@ void con_write(struct tty_struct * tty);
void copy_to_cooked(struct tty_struct * tty); void copy_to_cooked(struct tty_struct * tty);
#endif #endif

@ -1,6 +1,6 @@
#ifndef _UNISTD_H #ifndef _UNISTD_H
#define _UNISTD_H #define _UNISTD_H
#include<linux/tty.h>
/* ok, this may be a joke, but I'm working on it */ /* ok, this may be a joke, but I'm working on it */
#define _POSIX_VERSION 198808L #define _POSIX_VERSION 198808L
@ -152,6 +152,10 @@
#define __NR_something 89 #define __NR_something 89
#define __NR_sleep 90 #define __NR_sleep 90
#define __NR_getcwd 91 #define __NR_getcwd 91
#define __NR_init_graphics 92
#define __NR_get_message 93
#define __NR_repaint 94
#define _syscall0(type,name) \ #define _syscall0(type,name) \
type name(void) \ type name(void) \
{ \ { \
@ -273,11 +277,13 @@ pid_t getpgrp(void);
pid_t setsid(void); pid_t setsid(void);
long getcwd(char *buf,size_t size); char* getcwd(char *buf,size_t size);
int something(void); int something(void);
int sleep(unsigned int seconds); int sleep(unsigned int seconds);
int execve2(const char *path,char *argv[],char *envp[]); int execve2(const char *path,char *argv[],char *envp[]);
int init_graphics(void);
int get_message(struct message *msg);
int repaint(int x,int y,int h);
#define __always_inline inline __attribute__((always_inline)) #define __always_inline inline __attribute__((always_inline))

@ -25,6 +25,7 @@ __always_inline _syscall0(int,fork)
__always_inline _syscall0(int,pause) __always_inline _syscall0(int,pause)
__always_inline _syscall1(int,setup,void *,BIOS) __always_inline _syscall1(int,setup,void *,BIOS)
__always_inline _syscall0(int,sync) __always_inline _syscall0(int,sync)
__always_inline _syscall0(int,init_graphics)
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/sched.h> #include <linux/sched.h>
@ -52,6 +53,8 @@ extern long rd_init(long mem_start, int length);
extern long kernel_mktime(struct tm * tm); extern long kernel_mktime(struct tm * tm);
extern long startup_time; extern long startup_time;
extern int init_graphics();
/* /*
* This is set up by the setup-routine at boot-time * This is set up by the setup-routine at boot-time
*/ */
@ -134,6 +137,7 @@ void main(void) /* This really IS void, no error here. */
buffer_init(buffer_memory_end); buffer_init(buffer_memory_end);
hd_init(); hd_init();
floppy_init(); floppy_init();
//init_graphics();
sti(); sti();
move_to_user_mode(); move_to_user_mode();
if (!fork()) { /* we count on this going ok */ if (!fork()) { /* we count on this going ok */

@ -26,7 +26,7 @@ CPP =gcc -E -nostdinc -I../include
OBJS = sched.o system_call.o traps.o asm.o fork.o \ OBJS = sched.o system_call.o traps.o asm.o fork.o \
panic.o printk.o vsprintf.o sys.o exit.o \ panic.o printk.o vsprintf.o sys.o exit.o \
signal.o mktime.o signal.o mktime.o init_graphics.o
kernel.o: $(OBJS) kernel.o: $(OBJS)
$(LD) -r -o kernel.o $(OBJS) $(LD) -r -o kernel.o $(OBJS)
@ -81,3 +81,5 @@ traps.s traps.o : traps.c ../include/string.h ../include/linux/head.h \
../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \
../include/asm/system.h ../include/asm/segment.h ../include/asm/io.h ../include/asm/system.h ../include/asm/segment.h ../include/asm/io.h
vsprintf.s vsprintf.o : vsprintf.c ../include/stdarg.h ../include/string.h vsprintf.s vsprintf.o : vsprintf.c ../include/stdarg.h ../include/string.h
init_graphics.s init_graphi.o:init_graphics.c ../include/linux/kernel.h\
../include/asm/io.h ../include/linux/tty.h

@ -25,7 +25,7 @@ CPP =gcc -E -nostdinc -I../../include
-c -o $*.o $< -c -o $*.o $<
OBJS = tty_io.o console.o keyboard.2.o serial.o rs_io.o \ OBJS = tty_io.o console.o keyboard.2.o serial.o rs_io.o \
tty_ioctl.o mouse.o tty_ioctl.o mouse.2.o
chr_drv.a: $(OBJS) chr_drv.a: $(OBJS)
$(AR) rcs chr_drv.a $(OBJS) $(AR) rcs chr_drv.a $(OBJS)
@ -38,7 +38,7 @@ mouse.2.s:mouse.S ../../include/linux/config.h
clean: clean:
rm -f core *.o *.a tmp_make keyboard.2.s rm -f core *.o *.a tmp_make keyboard.2.s
for i in *.c;do rm -f `basename $$i .c`.s;done for i in *.c;do rm -f `basename $$i .c`.s;done
rm -f core *.o *.a tmp_make mouse.2.s
dep: dep:
sed '/\#\#\# Dependencies/q' < Makefile > tmp_make sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
(for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \

@ -0,0 +1,52 @@
# 1 "mouse.S"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "mouse.S"
.globl mouse_interrupt
mouse_interrupt:
pushl %eax
pushl %ebx
pushl %ecx
pushl %edx
push %ds
#prepare for call readmouse
movl $0x10,%eax
mov %ax,%ds
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
#EOI
movb $0x20,%al #8259A EOI
outb %al,$0xA0 #send EOI to 8259a second
outb %al,$0x20 #send EOI to 8259a first
pop %ds
popl %edx
popl %ecx
popl %ebx
popl %eax
iret

@ -1,36 +1,3 @@
# 1 "mouse.S"
# 1 "/home/mz/1/linux-0.11/kernel/chr_drv//"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "mouse.S"
# 1 "../../include/linux/config.h" 1
# 36 "../../include/linux/config.h"
# 47 "../../include/linux/config.h"
# 2 "mouse.S" 2
.globl mouse_interrupt .globl mouse_interrupt
mouse_interrupt: mouse_interrupt:
pushl %eax pushl %eax
@ -39,7 +6,7 @@ mouse_interrupt:
pushl %edx pushl %edx
push %ds push %ds
//prepare for call readmouse #prepare for call readmouse
movl $0x10,%eax movl $0x10,%eax
mov %ax,%ds mov %ax,%ds
@ -48,13 +15,29 @@ mouse_interrupt:
inb $0x60,%al inb $0x60,%al
pushl %eax pushl %eax
call readmouse call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp
xor %eax,%eax
inb $0x60,%al
pushl %eax
call readmouse
addl $4,%esp addl $4,%esp
//EOI #EOI
movb $0x20,%al //8259A EOI movb $0x20,%al #8259A EOI
outb %al,$0xA0 //send EOI to 8259a second outb %al,$0xA0 #send EOI to 8259a second
outb %al,$0x20 //send EOI to 8259a first outb %al,$0x20 #send EOI to 8259a first
pop %ds pop %ds

@ -349,6 +349,8 @@ void chr_dev_init(void)
{ {
} }
#define MSG_MOUSE_CLICK 1
static unsigned char mouse_input_count = 0; //用来记录是鼠标输入的第几个字节的全局变量 static unsigned char mouse_input_count = 0; //用来记录是鼠标输入的第几个字节的全局变量
static unsigned char mouse_left_down; //用来记录鼠标左键是否按下 static unsigned char mouse_left_down; //用来记录鼠标左键是否按下
static unsigned char mouse_right_down; //用来记录鼠标右键是否按下 static unsigned char mouse_right_down; //用来记录鼠标右键是否按下
@ -359,9 +361,10 @@ static int mouse_x_position; //用来记录鼠标的 x 轴位置
static int mouse_y_position;//用来记录鼠标的 y 轴位置 static int mouse_y_position;//用来记录鼠标的 y 轴位置
static int fcreate=0; static int fcreate=0;
int cnt=0; int cnt=0;
extern struct message *headd;
void readmouse(int mousecode) void readmouse(int mousecode)
{ {
printk("1\n"); //printk("1\n");
if(fcreate==0) if(fcreate==0)
{ {
fcreate=1; fcreate=1;
@ -384,10 +387,18 @@ switch(mouse_input_count)
case 1: case 1:
//Misplaced abandonment //Misplaced abandonment
mouse_left_down=(mousecode &0x01) ==0x01; mouse_left_down=(mousecode &0x01) ==0x01;
mouse_right_down=(mousecode &0x02)==0x02; mouse_right_down=(mousecode &0x02)==0x02;
mouse_left_move=(mousecode & 0x10)==0x10; mouse_left_move=(mousecode & 0x10)==0x10;
mouse_down_move=(mousecode & 0x20)==0x20; mouse_down_move=(mousecode & 0x20)==0x20;
mouse_input_count++; mouse_input_count++;
if(mouse_left_down==1 && mouse_left_move==0 && mouse_down_move==0)
{
struct message *msg = malloc(sizeof(struct message));
msg -> mid = MSG_MOUSE_CLICK;
msg -> pid = -1;
post_message(msg);
}
break; break;
@ -397,8 +408,7 @@ case 2:
//get the x of mouse //get the x of mouse
if(mouse_left_move) mouse_x_position +=(int)(0xFFFFFF00|mousecode); if(mouse_left_move) mouse_x_position +=(int)(0xFFFFFF00|mousecode);
if(mouse_x_position>100) mouse_x_position=100; if(mouse_x_position>100) mouse_x_position=100;
if(mouse_x_position<0) mouse_x_position=10; if(mouse_x_position<0) mouse_x_position=0;
mouse_input_count++; mouse_input_count++;
break; break;
@ -413,8 +423,34 @@ case 3:
case 4: case 4:
//get the z but we do not need it //get the z but we do not need it
break; break;
} }
if(mouse_input_count==4)
{
//printk("%d\n",mouse_left_down);
//printk("%d %d\n",mouse_x_position,mouse_y_position);
}
//sys_init_graphics();
}
void post_message(struct message * msg)
{
cli();
//printk("mid:%d pid:%d\n",msg->mid,msg->pid);
if(headd==NULL&& msg!=NULL)
{
headd=msg;
sti();
return ;
}
struct message *curr=headd;
if(msg==NULL)return;
while(curr->next!=NULL)
{
curr=curr->next;
}
curr->next=msg;
sti();
return;
} }

@ -0,0 +1,105 @@
#include <linux/kernel.h>
#include<asm/io.h>
#include "linux/tty.h"
#define memstart 0xA0000
#define memsize 64000
#define cursor_side 3
#define width 320
#define height 200
#define barrier_width 10
struct message *headd;
static int ff=0;
int sys_init_graphics()
{
int i,j,x,y;
char *p=0xA0000;
if(ff==0)
{
outb(0x05,0x3CE);
outb(0x40,0x3CF);/* shift256=1*/
outb(0x06,0x3CE);
outb(0x05,0x3CF);/*0101 0xA0000*/
outb(0x04,0x3C4);
outb(0x08,0x3C5);/*0000 jilian*/
outb(0x01,0x3D4);
outb(0x4F,0x3D5);/* end horizontal display=79 ??*/
outb(0x03,0x3D4);
outb(0x82,0x3D5);/*display enable skew=0*/
outb(0x07,0x3D4);
outb(0x1F,0x3D5);/*vertical display end No8,9 bit=1,0*/
outb(0x12,0x3D4);
outb(0x8F,0x3D5);/*vertical display end low 7b =0x8F*/
outb(0x17,0x3D4);
outb(0xA3,0x3D5);/*SLDIV=1 ,scanline clock/2*/
outb(0x14,0x3D4);
outb(0x40,0x3D5);/*DW=1*/
outb(0x13,0x3D4);
outb(0x28,0x3D5);/*Offset=40, 20:become long*/
outb(0x0C,0x3D4);/**/
outb(0x00,0x3D5);/**/
outb(0x0D,0x3D4);/**/
outb(0x00,0x3D5);/*Start Address=0xA0000*/
ff=1;
}
p=memstart;
for(i=0;i<memsize;i++) *p++=3;
//3-blue 4-red 12-purple
x=50;
y=40;
for(i=x-cursor_side;i<=x+cursor_side;i++)
for(j=y-cursor_side;j<=y+cursor_side;j++){
p=(char *) memstart+j*width+i;
*p=12;
}
return 0;
}
int sys_get_message(struct message * msg)
{
msg=headd;
if(headd->mid!=1)return 0;
headd=headd->next;
return 0;
}
int sys_repaint(int x,int y,int h)
{
int i,j,w;
char *p;
i=x;
j=y;
p=0xA0000;
w=barrier_width;
if(i+w>=320 || i<20 ) return 0;
if(i==33 || j==33){
p=0xA0000;
for(i=0;i<memsize;i++) *p++=3;
return 0;
}
else if(i==44 || j==44 ){
p=0xA0000;
for(i=0;i<memsize;i++) *p++=4;
return 0;
}else{
for(i=x;i<=x+w;i++){
for(j=y;j<=y+h;j++){
p=0xA0000+j*320+i;
*p=12;
}
}
}
return 0;
}

@ -58,7 +58,7 @@ sa_mask = 4
sa_flags = 8 sa_flags = 8
sa_restorer = 12 sa_restorer = 12
nr_system_calls = 92 /* 72 the number of system*/ nr_system_calls = 96 /* 72 the number of system*/
/* /*
* Ok, I get parallel printer interrupts while using the floppy for some * Ok, I get parallel printer interrupts while using the floppy for some

Loading…
Cancel
Save