summaryrefslogtreecommitdiffstats
path: root/src/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/linux')
-rw-r--r--src/include/linux/config.h48
-rw-r--r--src/include/linux/fdreg.h71
-rw-r--r--src/include/linux/fs.h202
-rw-r--r--src/include/linux/hdreg.h65
-rw-r--r--src/include/linux/head.h20
-rw-r--r--src/include/linux/kernel.h22
-rw-r--r--src/include/linux/mm.h10
-rw-r--r--src/include/linux/sched.h256
-rw-r--r--src/include/linux/sys.h86
-rw-r--r--src/include/linux/tty.h77
10 files changed, 857 insertions, 0 deletions
diff --git a/src/include/linux/config.h b/src/include/linux/config.h
new file mode 100644
index 0000000..819b525
--- /dev/null
+++ b/src/include/linux/config.h
@@ -0,0 +1,48 @@
1#ifndef _CONFIG_H
2#define _CONFIG_H
3
4/*
5 * The root-device is no longer hard-coded. You can change the default
6 * root-device by changing the line ROOT_DEV = XXX in boot/bootsect.s
7 */
8
9/*
10 * define your keyboard here -
11 * KBD_FINNISH for Finnish keyboards
12 * KBD_US for US-type
13 * KBD_GR for German keyboards
14 * KBD_FR for Frech keyboard
15 */
16#define KBD_US
17/*#define KBD_GR */
18/*#define KBD_FR */
19/*#define KBD_FINNISH */
20
21/*
22 * Normally, Linux can get the drive parameters from the BIOS at
23 * startup, but if this for some unfathomable reason fails, you'd
24 * be left stranded. For this case, you can define HD_TYPE, which
25 * contains all necessary info on your harddisk.
26 *
27 * The HD_TYPE macro should look like this:
28 *
29 * #define HD_TYPE { head, sect, cyl, wpcom, lzone, ctl}
30 *
31 * In case of two harddisks, the info should be sepatated by
32 * commas:
33 *
34 * #define HD_TYPE { h,s,c,wpcom,lz,ctl },{ h,s,c,wpcom,lz,ctl }
35 */
36/*
37 This is an example, two drives, first is type 2, second is type 3:
38
39#define HD_TYPE { 4,17,615,300,615,8 }, { 6,17,615,300,615,0 }
40
41 NOTE: ctl is 0 for all drives with heads<=8, and ctl=8 for drives
42 with more than 8 heads.
43
44 If you want the BIOS to tell what kind of drive you have, just
45 leave HD_TYPE undefined. This is the normal thing to do.
46*/
47
48#endif
diff --git a/src/include/linux/fdreg.h b/src/include/linux/fdreg.h
new file mode 100644
index 0000000..01355af
--- /dev/null
+++ b/src/include/linux/fdreg.h
@@ -0,0 +1,71 @@
1/*
2 * This file contains some defines for the floppy disk controller.
3 * Various sources. Mostly "IBM Microcomputers: A Programmers
4 * Handbook", Sanches and Canton.
5 */
6#ifndef _FDREG_H
7#define _FDREG_H
8
9extern int ticks_to_floppy_on(unsigned int nr);
10extern void floppy_on(unsigned int nr);
11extern void floppy_off(unsigned int nr);
12extern void floppy_select(unsigned int nr);
13extern void floppy_deselect(unsigned int nr);
14
15/* Fd controller regs. S&C, about page 340 */
16#define FD_STATUS 0x3f4
17#define FD_DATA 0x3f5
18#define FD_DOR 0x3f2 /* Digital Output Register */
19#define FD_DIR 0x3f7 /* Digital Input Register (read) */
20#define FD_DCR 0x3f7 /* Diskette Control Register (write)*/
21
22/* Bits of main status register */
23#define STATUS_BUSYMASK 0x0F /* drive busy mask */
24#define STATUS_BUSY 0x10 /* FDC busy */
25#define STATUS_DMA 0x20 /* 0- DMA mode */
26#define STATUS_DIR 0x40 /* 0- cpu->fdc */
27#define STATUS_READY 0x80 /* Data reg ready */
28
29/* Bits of FD_ST0 */
30#define ST0_DS 0x03 /* drive select mask */
31#define ST0_HA 0x04 /* Head (Address) */
32#define ST0_NR 0x08 /* Not Ready */
33#define ST0_ECE 0x10 /* Equipment chech error */
34#define ST0_SE 0x20 /* Seek end */
35#define ST0_INTR 0xC0 /* Interrupt code mask */
36
37/* Bits of FD_ST1 */
38#define ST1_MAM 0x01 /* Missing Address Mark */
39#define ST1_WP 0x02 /* Write Protect */
40#define ST1_ND 0x04 /* No Data - unreadable */
41#define ST1_OR 0x10 /* OverRun */
42#define ST1_CRC 0x20 /* CRC error in data or addr */
43#define ST1_EOC 0x80 /* End Of Cylinder */
44
45/* Bits of FD_ST2 */
46#define ST2_MAM 0x01 /* Missing Addess Mark (again) */
47#define ST2_BC 0x02 /* Bad Cylinder */
48#define ST2_SNS 0x04 /* Scan Not Satisfied */
49#define ST2_SEH 0x08 /* Scan Equal Hit */
50#define ST2_WC 0x10 /* Wrong Cylinder */
51#define ST2_CRC 0x20 /* CRC error in data field */
52#define ST2_CM 0x40 /* Control Mark = deleted */
53
54/* Bits of FD_ST3 */
55#define ST3_HA 0x04 /* Head (Address) */
56#define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */
57#define ST3_WP 0x40 /* Write Protect */
58
59/* Values for FD_COMMAND */
60#define FD_RECALIBRATE 0x07 /* move to track 0 */
61#define FD_SEEK 0x0F /* seek track */
62#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */
63#define FD_WRITE 0xC5 /* write with MT, MFM */
64#define FD_SENSEI 0x08 /* Sense Interrupt Status */
65#define FD_SPECIFY 0x03 /* specify HUT etc */
66
67/* DMA commands */
68#define DMA_READ 0x46
69#define DMA_WRITE 0x4A
70
71#endif
diff --git a/src/include/linux/fs.h b/src/include/linux/fs.h
new file mode 100644
index 0000000..7a90b10
--- /dev/null
+++ b/src/include/linux/fs.h
@@ -0,0 +1,202 @@
1/*
2 * This file has definitions for some important file table
3 * structures etc.
4 */
5
6#ifndef _FS_H
7#define _FS_H
8
9#include <sys/types.h>
10
11/* devices are as follows: (same as minix, so we can use the minix
12 * file system. These are major numbers.)
13 *
14 * 0 - unused (nodev)
15 * 1 - /dev/mem
16 * 2 - /dev/fd
17 * 3 - /dev/hd
18 * 4 - /dev/ttyx
19 * 5 - /dev/tty
20 * 6 - /dev/lp
21 * 7 - unnamed pipes
22 */
23
24#define IS_SEEKABLE(x) ((x)>=1 && (x)<=3)
25
26#define READ 0
27#define WRITE 1
28#define READA 2 /* read-ahead - don't pause */
29#define WRITEA 3 /* "write-ahead" - silly, but somewhat useful */
30
31void buffer_init(long buffer_end);
32
33#define MAJOR(a) (((unsigned)(a))>>8)
34#define MINOR(a) ((a)&0xff)
35
36#define NAME_LEN 14
37#define ROOT_INO 1
38
39#define I_MAP_SLOTS 8
40#define Z_MAP_SLOTS 8
41#define SUPER_MAGIC 0x137F
42
43#define NR_OPEN 20
44#define NR_INODE 32
45#define NR_FILE 64
46#define NR_SUPER 8
47#define NR_HASH 307
48#define NR_BUFFERS nr_buffers
49#define BLOCK_SIZE 1024
50#define BLOCK_SIZE_BITS 10
51#ifndef NULL
52#define NULL ((void *) 0)
53#endif
54
55#define INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct d_inode)))
56#define DIR_ENTRIES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct dir_entry)))
57
58#define PIPE_HEAD(inode) ((inode).i_zone[0])
59#define PIPE_TAIL(inode) ((inode).i_zone[1])
60#define PIPE_SIZE(inode) ((PIPE_HEAD(inode)-PIPE_TAIL(inode))&(PAGE_SIZE-1))
61#define PIPE_EMPTY(inode) (PIPE_HEAD(inode)==PIPE_TAIL(inode))
62#define PIPE_FULL(inode) (PIPE_SIZE(inode)==(PAGE_SIZE-1))
63#define INC_PIPE(head) \
64__asm__("incl %0\n\tandl $4095,%0"::"m" (head))
65
66typedef char buffer_block[BLOCK_SIZE];
67
68struct buffer_head {
69 char * b_data; /* pointer to data block (1024 bytes) */
70 unsigned long b_blocknr; /* block number */
71 unsigned short b_dev; /* device (0 = free) */
72 unsigned char b_uptodate;
73 unsigned char b_dirt; /* 0-clean,1-dirty */
74 unsigned char b_count; /* users using this block */
75 unsigned char b_lock; /* 0 - ok, 1 -locked */
76 struct task_struct * b_wait;
77 struct buffer_head * b_prev;
78 struct buffer_head * b_next;
79 struct buffer_head * b_prev_free;
80 struct buffer_head * b_next_free;
81};
82
83struct d_inode {
84 unsigned short i_mode;
85 unsigned short i_uid;
86 unsigned long i_size;
87 unsigned long i_time;
88 unsigned char i_gid;
89 unsigned char i_nlinks;
90 unsigned short i_zone[9];
91};
92
93struct m_inode {
94 unsigned short i_mode;
95 unsigned short i_uid;
96 unsigned long i_size;
97 unsigned long i_mtime;
98 unsigned char i_gid;
99 unsigned char i_nlinks;
100 unsigned short i_zone[9];
101/* these are in memory also */
102 struct task_struct * i_wait;
103 unsigned long i_atime;
104 unsigned long i_ctime;
105 unsigned short i_dev;
106 unsigned short i_num;
107 unsigned short i_count;
108 unsigned char i_lock;
109 unsigned char i_dirt;
110 unsigned char i_pipe;
111 unsigned char i_mount;
112 unsigned char i_seek;
113 unsigned char i_update;
114};
115
116struct file {
117 unsigned short f_mode;
118 unsigned short f_flags;
119 unsigned short f_count;
120 struct m_inode * f_inode;
121 off_t f_pos;
122};
123
124struct super_block {
125 unsigned short s_ninodes;
126 unsigned short s_nzones;
127 unsigned short s_imap_blocks;
128 unsigned short s_zmap_blocks;
129 unsigned short s_firstdatazone;
130 unsigned short s_log_zone_size;
131 unsigned long s_max_size;
132 unsigned short s_magic;
133/* These are only in memory */
134 struct buffer_head * s_imap[8];
135 struct buffer_head * s_zmap[8];
136 unsigned short s_dev;
137 struct m_inode * s_isup;
138 struct m_inode * s_imount;
139 unsigned long s_time;
140 struct task_struct * s_wait;
141 unsigned char s_lock;
142 unsigned char s_rd_only;
143 unsigned char s_dirt;
144};
145
146struct d_super_block {
147 unsigned short s_ninodes;
148 unsigned short s_nzones;
149 unsigned short s_imap_blocks;
150 unsigned short s_zmap_blocks;
151 unsigned short s_firstdatazone;
152 unsigned short s_log_zone_size;
153 unsigned long s_max_size;
154 unsigned short s_magic;
155};
156
157struct dir_entry {
158 unsigned short inode;
159 char name[NAME_LEN];
160};
161
162extern struct m_inode inode_table[NR_INODE];
163extern struct file file_table[NR_FILE];
164extern struct super_block super_block[NR_SUPER];
165extern struct buffer_head * start_buffer;
166extern int nr_buffers;
167
168extern void check_disk_change(int dev);
169extern int floppy_change(unsigned int nr);
170extern int ticks_to_floppy_on(unsigned int dev);
171extern void floppy_on(unsigned int dev);
172extern void floppy_off(unsigned int dev);
173extern void truncate(struct m_inode * inode);
174extern void sync_inodes(void);
175extern void wait_on(struct m_inode * inode);
176extern int bmap(struct m_inode * inode,int block);
177extern int create_block(struct m_inode * inode,int block);
178extern struct m_inode * namei(const char * pathname);
179extern int open_namei(const char * pathname, int flag, int mode,
180 struct m_inode ** res_inode);
181extern void iput(struct m_inode * inode);
182extern struct m_inode * iget(int dev,int nr);
183extern struct m_inode * get_empty_inode(void);
184extern struct m_inode * get_pipe_inode(void);
185extern struct buffer_head * get_hash_table(int dev, int block);
186extern struct buffer_head * getblk(int dev, int block);
187extern void ll_rw_block(int rw, struct buffer_head * bh);
188extern void brelse(struct buffer_head * buf);
189extern struct buffer_head * bread(int dev,int block);
190extern void bread_page(unsigned long addr,int dev,int b[4]);
191extern struct buffer_head * breada(int dev,int block,...);
192extern int new_block(int dev);
193extern void free_block(int dev, int block);
194extern struct m_inode * new_inode(int dev);
195extern void free_inode(struct m_inode * inode);
196extern int sync_dev(int dev);
197extern struct super_block * get_super(int dev);
198extern int ROOT_DEV;
199
200extern void mount_root(void);
201
202#endif
diff --git a/src/include/linux/hdreg.h b/src/include/linux/hdreg.h
new file mode 100644
index 0000000..e6c593f
--- /dev/null
+++ b/src/include/linux/hdreg.h
@@ -0,0 +1,65 @@
1/*
2 * This file contains some defines for the AT-hd-controller.
3 * Various sources. Check out some definitions (see comments with
4 * a ques).
5 */
6#ifndef _HDREG_H
7#define _HDREG_H
8
9/* Hd controller regs. Ref: IBM AT Bios-listing */
10#define HD_DATA 0x1f0 /* _CTL when writing */
11#define HD_ERROR 0x1f1 /* see err-bits */
12#define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */
13#define HD_SECTOR 0x1f3 /* starting sector */
14#define HD_LCYL 0x1f4 /* starting cylinder */
15#define HD_HCYL 0x1f5 /* high byte of starting cyl */
16#define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */
17#define HD_STATUS 0x1f7 /* see status-bits */
18#define HD_PRECOMP HD_ERROR /* same io address, read=error, write=precomp */
19#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */
20
21#define HD_CMD 0x3f6
22
23/* Bits of HD_STATUS */
24#define ERR_STAT 0x01
25#define INDEX_STAT 0x02
26#define ECC_STAT 0x04 /* Corrected error */
27#define DRQ_STAT 0x08
28#define SEEK_STAT 0x10
29#define WRERR_STAT 0x20
30#define READY_STAT 0x40
31#define BUSY_STAT 0x80
32
33/* Values for HD_COMMAND */
34#define WIN_RESTORE 0x10
35#define WIN_READ 0x20
36#define WIN_WRITE 0x30
37#define WIN_VERIFY 0x40
38#define WIN_FORMAT 0x50
39#define WIN_INIT 0x60
40#define WIN_SEEK 0x70
41#define WIN_DIAGNOSE 0x90
42#define WIN_SPECIFY 0x91
43
44/* Bits for HD_ERROR */
45#define MARK_ERR 0x01 /* Bad address mark ? */
46#define TRK0_ERR 0x02 /* couldn't find track 0 */
47#define ABRT_ERR 0x04 /* ? */
48#define ID_ERR 0x10 /* ? */
49#define ECC_ERR 0x40 /* ? */
50#define BBD_ERR 0x80 /* ? */
51
52struct partition {
53 unsigned char boot_ind; /* 0x80 - active (unused) */
54 unsigned char head; /* ? */
55 unsigned char sector; /* ? */
56 unsigned char cyl; /* ? */
57 unsigned char sys_ind; /* ? */
58 unsigned char end_head; /* ? */
59 unsigned char end_sector; /* ? */
60 unsigned char end_cyl; /* ? */
61 unsigned int start_sect; /* starting sector counting from 0 */
62 unsigned int nr_sects; /* nr of sectors in partition */
63};
64
65#endif
diff --git a/src/include/linux/head.h b/src/include/linux/head.h
new file mode 100644
index 0000000..db3dda2
--- /dev/null
+++ b/src/include/linux/head.h
@@ -0,0 +1,20 @@
1#ifndef _HEAD_H
2#define _HEAD_H
3
4typedef struct desc_struct {
5 unsigned long a,b;
6} desc_table[256];
7
8extern unsigned long pg_dir[1024];
9extern desc_table idt,gdt;
10
11#define GDT_NUL 0
12#define GDT_CODE 1
13#define GDT_DATA 2
14#define GDT_TMP 3
15
16#define LDT_NUL 0
17#define LDT_CODE 1
18#define LDT_DATA 2
19
20#endif
diff --git a/src/include/linux/kernel.h b/src/include/linux/kernel.h
new file mode 100644
index 0000000..2a0f916
--- /dev/null
+++ b/src/include/linux/kernel.h
@@ -0,0 +1,22 @@
1/*
2 * 'kernel.h' contains some often-used function prototypes etc
3 */
4void verify_area(void * addr,int count);
5void panic(const char * str);
6int printf(const char * fmt, ...);
7int printk(const char * fmt, ...);
8int tty_write(unsigned ch,char * buf,int count);
9void * malloc(unsigned int size);
10void free_s(void * obj, int size);
11
12#define free(x) free_s((x), 0)
13
14/*
15 * This is defined as a macro, but at some point this might become a
16 * real subroutine that sets a flag if it returns true (to do
17 * BSD-style accounting where the process is flagged if it uses root
18 * privs). The implication of this is that you should do normal
19 * permissions checks first, and check suser() last.
20 */
21#define suser() (current->euid == 0)
22
diff --git a/src/include/linux/mm.h b/src/include/linux/mm.h
new file mode 100644
index 0000000..5a160f3
--- /dev/null
+++ b/src/include/linux/mm.h
@@ -0,0 +1,10 @@
1#ifndef _MM_H
2#define _MM_H
3
4#define PAGE_SIZE 4096
5
6extern unsigned long get_free_page(void);
7extern unsigned long put_page(unsigned long page,unsigned long address);
8extern void free_page(unsigned long addr);
9
10#endif
diff --git a/src/include/linux/sched.h b/src/include/linux/sched.h
new file mode 100644
index 0000000..e1b35be
--- /dev/null
+++ b/src/include/linux/sched.h
@@ -0,0 +1,256 @@
1#ifndef _SCHED_H
2#define _SCHED_H
3
4#define NR_TASKS 64
5#define HZ 100
6
7#define FIRST_TASK task[0]
8#define LAST_TASK task[NR_TASKS-1]
9
10#include <linux/head.h>
11#include <linux/fs.h>
12#include <linux/mm.h>
13#include <signal.h>
14
15#if (NR_OPEN > 32)
16#error "Currently the close-on-exec-flags are in one word, max 32 files/proc"
17#endif
18
19#define TASK_RUNNING 0
20#define TASK_INTERRUPTIBLE 1
21#define TASK_UNINTERRUPTIBLE 2
22#define TASK_ZOMBIE 3
23#define TASK_STOPPED 4
24
25#ifndef NULL
26#define NULL ((void *) 0)
27#endif
28
29extern int copy_page_tables(unsigned long from, unsigned long to, long size);
30extern int free_page_tables(unsigned long from, unsigned long size);
31
32extern void sched_init(void);
33extern void schedule(void);
34extern void trap_init(void);
35#ifndef PANIC
36void panic(const char * str);
37#endif
38extern int tty_write(unsigned minor,char * buf,int count);
39
40typedef int (*fn_ptr)();
41
42struct i387_struct {
43 long cwd;
44 long swd;
45 long twd;
46 long fip;
47 long fcs;
48 long foo;
49 long fos;
50 long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
51};
52
53struct tss_struct {
54 long back_link; /* 16 high bits zero */
55 long esp0;
56 long ss0; /* 16 high bits zero */
57 long esp1;
58 long ss1; /* 16 high bits zero */
59 long esp2;
60 long ss2; /* 16 high bits zero */
61 long cr3;
62 long eip;
63 long eflags;
64 long eax,ecx,edx,ebx;
65 long esp;
66 long ebp;
67 long esi;
68 long edi;
69 long es; /* 16 high bits zero */
70 long cs; /* 16 high bits zero */
71 long ss; /* 16 high bits zero */
72 long ds; /* 16 high bits zero */
73 long fs; /* 16 high bits zero */
74 long gs; /* 16 high bits zero */
75 long ldt; /* 16 high bits zero */
76 long trace_bitmap; /* bits: trace 0, bitmap 16-31 */
77 struct i387_struct i387;
78};
79
80struct task_struct {
81/* these are hardcoded - don't touch */
82 long state; /* -1 unrunnable, 0 runnable, >0 stopped */
83 long counter;
84 long priority;
85 long signal;
86 struct sigaction sigaction[32];
87 long blocked; /* bitmap of masked signals */
88/* various fields */
89 int exit_code;
90 unsigned long start_code,end_code,end_data,brk,start_stack;
91 long pid,father,pgrp,session,leader;
92 unsigned short uid,euid,suid;
93 unsigned short gid,egid,sgid;
94 long alarm;
95 long utime,stime,cutime,cstime,start_time;
96 unsigned short used_math;
97/* file system info */
98 int tty; /* -1 if no tty, so it must be signed */
99 unsigned short umask;
100 struct m_inode * pwd;
101 struct m_inode * root;
102 struct m_inode * executable;
103 unsigned long close_on_exec;
104 struct file * filp[NR_OPEN];
105/* ldt for this task 0 - zero 1 - cs 2 - ds&ss */
106 struct desc_struct ldt[3];
107/* tss for this task */
108 struct tss_struct tss;
109};
110
111/*
112 * INIT_TASK is used to set up the first task table, touch at
113 * your own risk!. Base=0, limit=0x9ffff (=640kB)
114 */
115#define INIT_TASK \
116/* state etc */ { 0,15,15, \
117/* signals */ 0,{{},},0, \
118/* ec,brk... */ 0,0,0,0,0,0, \
119/* pid etc.. */ 0,-1,0,0,0, \
120/* uid etc */ 0,0,0,0,0,0, \
121/* alarm */ 0,0,0,0,0,0, \
122/* math */ 0, \
123/* fs info */ -1,0022,NULL,NULL,NULL,0, \
124/* filp */ {NULL,}, \
125 { \
126 {0,0}, \
127/* ldt */ {0x9f,0xc0fa00}, \
128 {0x9f,0xc0f200}, \
129 }, \
130/*tss*/ {0,PAGE_SIZE+(long)&init_task,0x10,0,0,0,0,(long)&pg_dir,\
131 0,0,0,0,0,0,0,0, \
132 0,0,0x17,0x17,0x17,0x17,0x17,0x17, \
133 _LDT(0),0x80000000, \
134 {} \
135 }, \
136}
137
138extern struct task_struct *task[NR_TASKS];
139extern struct task_struct *last_task_used_math;
140extern struct task_struct *current;
141extern long volatile jiffies;
142extern long startup_time;
143
144#define CURRENT_TIME (startup_time+jiffies/HZ)
145
146extern void add_timer(long jiffies, void (*fn)(void));
147extern void sleep_on(struct task_struct ** p);
148extern void interruptible_sleep_on(struct task_struct ** p);
149extern void wake_up(struct task_struct ** p);
150
151/*
152 * Entry into gdt where to find first TSS. 0-nul, 1-cs, 2-ds, 3-syscall
153 * 4-TSS0, 5-LDT0, 6-TSS1 etc ...
154 */
155#define FIRST_TSS_ENTRY 4
156#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1)
157#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3))
158#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3))
159#define ltr(n) __asm__("ltr %%ax"::"a" (_TSS(n)))
160#define lldt(n) __asm__("lldt %%ax"::"a" (_LDT(n)))
161#define str(n) \
162__asm__("str %%ax\n\t" \
163 "subl %2,%%eax\n\t" \
164 "shrl $4,%%eax" \
165 :"=a" (n) \
166 :"a" (0),"i" (FIRST_TSS_ENTRY<<3))
167/*
168 * switch_to(n) should switch tasks to task nr n, first
169 * checking that n isn't the current task, in which case it does nothing.
170 * This also clears the TS-flag if the task we switched to has used
171 * tha math co-processor latest.
172 */
173#define switch_to(n) {\
174struct {long a,b;} __tmp; \
175__asm__("cmpl %%ecx,current\n\t" \
176 "je 1f\n\t" \
177 "movw %%dx,%1\n\t" \
178 "xchgl %%ecx,current\n\t" \
179 "ljmp *%0\n\t" \
180 "cmpl %%ecx,last_task_used_math\n\t" \
181 "jne 1f\n\t" \
182 "clts\n" \
183 "1:" \
184 ::"m" (*&__tmp.a),"m" (*&__tmp.b), \
185 "d" (_TSS(n)),"c" ((long) task[n])); \
186}
187
188#define PAGE_ALIGN(n) (((n)+0xfff)&0xfffff000)
189
190#define _set_base(addr,base) \
191__asm__ ("push %%edx\n\t" \
192 "movw %%dx,%0\n\t" \
193 "rorl $16,%%edx\n\t" \
194 "movb %%dl,%1\n\t" \
195 "movb %%dh,%2\n\t" \
196 "pop %%edx" \
197 ::"m" (*((addr)+2)), \
198 "m" (*((addr)+4)), \
199 "m" (*((addr)+7)), \
200 "d" (base) \
201 )
202
203#define _set_limit(addr,limit) \
204__asm__ ("push %%edx\n\t" \
205 "movw %%dx,%0\n\t" \
206 "rorl $16,%%edx\n\t" \
207 "movb %1,%%dh\n\t" \
208 "andb $0xf0,%%dh\n\t" \
209 "orb %%dh,%%dl\n\t" \
210 "movb %%dl,%1\n\t" \
211 "pop %%edx" \
212 ::"m" (*(addr)), \
213 "m" (*((addr)+6)), \
214 "d" (limit) \
215 )
216
217#define set_base(ldt,base) _set_base( ((char *)&(ldt)) , (base) )
218#define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , (limit-1)>>12 )
219
220/**
221#define _get_base(addr) ({\
222unsigned long __base; \
223__asm__("movb %3,%%dh\n\t" \
224 "movb %2,%%dl\n\t" \
225 "shll $16,%%edx\n\t" \
226 "movw %1,%%dx" \
227 :"=d" (__base) \
228 :"m" (*((addr)+2)), \
229 "m" (*((addr)+4)), \
230 "m" (*((addr)+7)) \
231 :"memory"); \
232__base;})
233**/
234
235static inline unsigned long _get_base(char * addr)
236{
237 unsigned long __base;
238 __asm__("movb %3,%%dh\n\t"
239 "movb %2,%%dl\n\t"
240 "shll $16,%%edx\n\t"
241 "movw %1,%%dx"
242 :"=&d" (__base)
243 :"m" (*((addr)+2)),
244 "m" (*((addr)+4)),
245 "m" (*((addr)+7)));
246 return __base;
247}
248
249#define get_base(ldt) _get_base( ((char *)&(ldt)) )
250
251#define get_limit(segment) ({ \
252unsigned long __limit; \
253__asm__("lsll %1,%0\n\tincl %0":"=r" (__limit):"r" (segment)); \
254__limit;})
255
256#endif
diff --git a/src/include/linux/sys.h b/src/include/linux/sys.h
new file mode 100644
index 0000000..c538fc1
--- /dev/null
+++ b/src/include/linux/sys.h
@@ -0,0 +1,86 @@
1extern int sys_setup();
2extern int sys_exit();
3extern int sys_fork();
4extern int sys_read();
5extern int sys_write();
6extern int sys_open();
7extern int sys_close();
8extern int sys_waitpid();
9extern int sys_creat();
10extern int sys_link();
11extern int sys_unlink();
12extern int sys_execve();
13extern int sys_chdir();
14extern int sys_time();
15extern int sys_mknod();
16extern int sys_chmod();
17extern int sys_chown();
18extern int sys_break();
19extern int sys_stat();
20extern int sys_lseek();
21extern int sys_getpid();
22extern int sys_mount();
23extern int sys_umount();
24extern int sys_setuid();
25extern int sys_getuid();
26extern int sys_stime();
27extern int sys_ptrace();
28extern int sys_alarm();
29extern int sys_fstat();
30extern int sys_pause();
31extern int sys_utime();
32extern int sys_stty();
33extern int sys_gtty();
34extern int sys_access();
35extern int sys_nice();
36extern int sys_ftime();
37extern int sys_sync();
38extern int sys_kill();
39extern int sys_rename();
40extern int sys_mkdir();
41extern int sys_rmdir();
42extern int sys_dup();
43extern int sys_pipe();
44extern int sys_times();
45extern int sys_prof();
46extern int sys_brk();
47extern int sys_setgid();
48extern int sys_getgid();
49extern int sys_signal();
50extern int sys_geteuid();
51extern int sys_getegid();
52extern int sys_acct();
53extern int sys_phys();
54extern int sys_lock();
55extern int sys_ioctl();
56extern int sys_fcntl();
57extern int sys_mpx();
58extern int sys_setpgid();
59extern int sys_ulimit();
60extern int sys_uname();
61extern int sys_umask();
62extern int sys_chroot();
63extern int sys_ustat();
64extern int sys_dup2();
65extern int sys_getppid();
66extern int sys_getpgrp();
67extern int sys_setsid();
68extern int sys_sigaction();
69extern int sys_sgetmask();
70extern int sys_ssetmask();
71extern int sys_setreuid();
72extern int sys_setregid();
73
74fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read,
75sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link,
76sys_unlink, sys_execve, sys_chdir, sys_time, sys_mknod, sys_chmod,
77sys_chown, sys_break, sys_stat, sys_lseek, sys_getpid, sys_mount,
78sys_umount, sys_setuid, sys_getuid, sys_stime, sys_ptrace, sys_alarm,
79sys_fstat, sys_pause, sys_utime, sys_stty, sys_gtty, sys_access,
80sys_nice, sys_ftime, sys_sync, sys_kill, sys_rename, sys_mkdir,
81sys_rmdir, sys_dup, sys_pipe, sys_times, sys_prof, sys_brk, sys_setgid,
82sys_getgid, sys_signal, sys_geteuid, sys_getegid, sys_acct, sys_phys,
83sys_lock, sys_ioctl, sys_fcntl, sys_mpx, sys_setpgid, sys_ulimit,
84sys_uname, sys_umask, sys_chroot, sys_ustat, sys_dup2, sys_getppid,
85sys_getpgrp, sys_setsid, sys_sigaction, sys_sgetmask, sys_ssetmask,
86sys_setreuid,sys_setregid };
diff --git a/src/include/linux/tty.h b/src/include/linux/tty.h
new file mode 100644
index 0000000..ad846b3
--- /dev/null
+++ b/src/include/linux/tty.h
@@ -0,0 +1,77 @@
1/*
2 * 'tty.h' defines some structures used by tty_io.c and some defines.
3 *
4 * NOTE! Don't touch this without checking that nothing in rs_io.s or
5 * con_io.s breaks. Some constants are hardwired into the system (mainly
6 * offsets into 'tty_queue'
7 */
8
9#ifndef _TTY_H
10#define _TTY_H
11
12#include <termios.h>
13
14#define TTY_BUF_SIZE 1024
15
16struct tty_queue {
17 unsigned long data;
18 unsigned long head;
19 unsigned long tail;
20 struct task_struct * proc_list;
21 char buf[TTY_BUF_SIZE];
22};
23
24#define INC(a) ((a) = ((a)+1) & (TTY_BUF_SIZE-1))
25#define DEC(a) ((a) = ((a)-1) & (TTY_BUF_SIZE-1))
26#define EMPTY(a) ((a).head == (a).tail)
27#define LEFT(a) (((a).tail-(a).head-1)&(TTY_BUF_SIZE-1))
28#define LAST(a) ((a).buf[(TTY_BUF_SIZE-1)&((a).head-1)])
29#define FULL(a) (!LEFT(a))
30#define CHARS(a) (((a).head-(a).tail)&(TTY_BUF_SIZE-1))
31#define GETCH(queue,c) \
32(void)({c=(queue).buf[(queue).tail];INC((queue).tail);})
33#define PUTCH(c,queue) \
34(void)({(queue).buf[(queue).head]=(c);INC((queue).head);})
35
36#define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
37#define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
38#define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
39#define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
40#define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
41#define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
42#define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
43#define SUSPEND_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
44
45struct tty_struct {
46 struct termios termios;
47 int pgrp;
48 int stopped;
49 void (*write)(struct tty_struct * tty);
50 struct tty_queue read_q;
51 struct tty_queue write_q;
52 struct tty_queue secondary;
53 };
54
55extern struct tty_struct tty_table[];
56
57/* intr=^C quit=^| erase=del kill=^U
58 eof=^D vtime=\0 vmin=\1 sxtc=\0
59 start=^Q stop=^S susp=^Z eol=\0
60 reprint=^R discard=^U werase=^W lnext=^V
61 eol2=\0
62*/
63#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
64
65void rs_init(void);
66void con_init(void);
67void tty_init(void);
68
69int tty_read(unsigned c, char * buf, int n);
70int tty_write(unsigned c, char * buf, int n);
71
72void rs_write(struct tty_struct * tty);
73void con_write(struct tty_struct * tty);
74
75void copy_to_cooked(struct tty_struct * tty);
76
77#endif