Moved assembly functions ___save_flags and _restore_flags from arch/i86/kernel/irq.c to arch/i86/kernel/irqtab.c. Now, irq.c is an all C file. Updated arch/i86/sibo/irqtab .c to stay in sync with arch/i86/kernel/irqtab.c. Removed garbage from irqtab.c, include/linuxmt/sched.h, fs/minix/inode.c and net/socket.c Small changes in arch/i86/kernel/signal.c, fs/minix/dir.c, fs/minix/file.c, fs/readdir.c, include/arch/irq.h, include/linuxmt/fs.h, include/linuxmt/minix_fs.h, include/linuxmt/mm.h, include/linuxmt/tcpdev.h and net/ipv4/af_inet.c to remove warnings. Code size was reduced by 16 bytes and data size increased by 16 bytes. Juan
diff -Nur elks.orig/arch/i86/kernel/irq.c elks/arch/i86/kernel/irq.c --- elks.orig/arch/i86/kernel/irq.c 2015-04-26 11:39:15.000000000 -0500 +++ elks/arch/i86/kernel/irq.c 2015-05-04 17:43:21.000000000 -0500 @@ -147,40 +147,6 @@ printk("Unexpected interrupt: %u\n", i); } -/* - * Low level IRQ control. - */ - -#ifndef S_SPLINT_S -#asm - .globl ___save_flags - .text - -___save_flags: - pushf - pop ax - ret -#endasm -#endif - -/* this version is smaller than the functionally equivalent C version - * at 7 bytes vs. 21 or thereabouts :-) --Alastair Bridgewater - * - * Further reduced to 5 bytes --Juan Perez - */ -#ifndef S_SPLINT_S -#asm - .globl _restore_flags - .text - -_restore_flags: - pop ax - popf - pushf - jmp ax -#endasm -#endif - int request_irq(int irq, void (*handler)(int,struct pt_regs *,void *), void *dev_id) { register struct irqaction *action; diff -Nur elks.orig/arch/i86/kernel/irqtab.c elks/arch/i86/kernel/irqtab.c --- elks.orig/arch/i86/kernel/irqtab.c 2015-04-26 11:39:15.000000000 -0500 +++ elks/arch/i86/kernel/irqtab.c 2015-05-04 17:51:04.000000000 -0500 @@ -40,6 +40,35 @@ extern void sig_check(void); +/* + * Low level IRQ control. + */ + +#ifndef S_SPLINT_S +#asm + .globl ___save_flags + .globl _restore_flags + .text + +___save_flags: + pushf + pop ax + ret + +! this version is smaller than the functionally equivalent C version +! at 7 bytes vs. 21 or thereabouts :-) --Alastair Bridgewater +! +! Further reduced to 5 bytes --Juan Perez +! + +_restore_flags: + pop ax + popf + pushf + jmp ax +#endasm +#endif + void irqtab_init(void) { #ifndef S_SPLINT_S @@ -114,30 +143,15 @@ ! main code). ! .text - .globl _irq1 -! .globl _irq2 - .globl _irq3 - .globl _irq4 -! .globl _irq5 -! .globl _irq6 -! .globl _irq7 -! .globl _irq8 -! .globl _irq9 -! .globl _irq10 -! .globl _irq11 -! .globl _irq12 -! .globl _irq13 -! .globl _irq14 -! .globl _irq15 .extern _do_IRQ .data .extern _cache_A1 .extern _cache_21 - .text - -_irq1: ;keyboard + .text + +_irq1: ;keyboard push ax mov ax,#1 br _irqit @@ -211,87 +225,73 @@ ! ! Currently not used so removed for space. #if 0 - .globl _div0 _div0: push ax mov ax,#16 jmp _irqit - .globl _dbugtrap _dbugtrap: push ax mov ax,#17 jmp _irqit - .globl _nmi _nmi: push ax mov ax,#18 jmp _irqit - .globl _brkpt _brkpt: push ax mov ax,#19 jmp _irqit - .globl _oflow _oflow: push ax mov ax,#20 jmp _irqit - .globl _bounds _bounds: push ax mov ax,#21 jmp _irqit - - .globl _invop + _invop: push ax mov ax,#22 jmp _irqit - - .globl _devnp + _devnp: push ax mov ax,#23 jmp _irqit - .globl _dfault _dfault: push ax mov ax,#24 jmp _irqit ; ; trap 9 is reserved -; - .globl _itss +; _itss: push ax mov ax,#26 jmp _irqit - .globl _nseg _nseg: push ax mov ax,#27 jmp _irqit - - .globl _stkfault + _stkfault: push ax mov ax,#28 jmp _irqit - .globl _segovr _segovr: push ax mov ax,#29 jmp _irqit - - .globl _pfault + _pfault: push ax mov ax,#30 @@ -299,13 +299,11 @@ ; ; trap 15 is reserved ; - .globl _fpetrap _fpetrap: push ax mov ax,#32 jmp _irqit - .globl _algn _algn: push ax mov ax,#33 @@ -333,11 +331,10 @@ ! Switch to int_stack ! No task switch allowed. ! -! We do all of this to avoid per process interrupt stacks and +! We do all of this to avoid per process interrupt stacks and ! related nonsense. This way we need only one dedicted int stack ! ! - .globl _irq0 _irq0: ! ! Save AX and load it with the IRQ number @@ -487,7 +484,7 @@ orb ch,ch ! Schedule allowed ? je nosched ! No ! mov bx,_need_resched ! Schedule needed -! cmp bx,#0 ! +! cmp bx,#0 ! ! je nosched ! No ! ! This path will return directly to user space diff -Nur elks.orig/arch/i86/kernel/signal.c elks/arch/i86/kernel/signal.c --- elks.orig/arch/i86/kernel/signal.c 2015-04-26 11:39:15.000000000 -0500 +++ elks/arch/i86/kernel/signal.c 2015-05-04 17:43:21.000000000 -0500 @@ -24,7 +24,7 @@ register struct sigaction *sa; unsigned signr; - while ((currentp->signal &= ((1 << NSIG) - 1))) { + while ((currentp->signal &= ((1L << NSIG) - 1))) { signr = find_first_non_zero_bit(¤tp->signal, NSIG); clear_bit(signr, ¤tp->signal); diff -Nur elks.orig/arch/i86/sibo/irqtab.c elks/arch/i86/sibo/irqtab.c --- elks.orig/arch/i86/sibo/irqtab.c 2015-04-26 11:39:15.000000000 -0500 +++ elks/arch/i86/sibo/irqtab.c 2015-05-04 17:43:21.000000000 -0500 @@ -39,6 +39,35 @@ extern void sig_check(void); +/* + * Low level IRQ control. + */ + +#ifndef S_SPLINT_S +#asm + .globl ___save_flags + .globl _restore_flags + .text + +___save_flags: + pushf + pop ax + ret + +! this version is smaller than the functionally equivalent C version +! at 7 bytes vs. 21 or thereabouts :-) --Alastair Bridgewater +! +! Further reduced to 5 bytes --Juan Perez +! + +_restore_flags: + pop ax + popf + pushf + jmp ax +#endasm +#endif + void irqtab_init(void) { #ifndef S_SPLINT_S @@ -143,29 +172,14 @@ ! main code). ! .text - .globl _irq1 -! .globl _irq2 -! .globl _irq3 -! .globl _irq4 -! .globl _irq5 -! .globl _irq6 -! .globl _irq7 -! .globl _irq8 -! .globl _irq9 -! .globl _irq10 -! .globl _irq11 -! .globl _irq12 -! .globl _irq13 -! .globl _irq14 -! .globl _irq15 .extern _do_IRQ .data .extern _cache_A1 .extern _cache_21 - .text - + .text + _irq1: push ax mov ax,#1 @@ -234,55 +248,46 @@ ! ! Currently not used so removed for space. #if 0 - .globl _div0 _div0: push ax mov ax,#16 jmp _irqit - .globl _dbugtrap _dbugtrap: push ax mov ax,#17 jmp _irqit - .globl _nmi _nmi: push ax mov ax,#18 jmp _irqit - .globl _brkpt _brkpt: push ax mov ax,#19 jmp _irqit - .globl _oflow _oflow: push ax mov ax,#20 jmp _irqit - .globl _bounds _bounds: push ax mov ax,#21 jmp _irqit - - .globl _invop + _invop: push ax mov ax,#22 jmp _irqit - - .globl _devnp + _devnp: push ax mov ax,#23 jmp _irqit - .globl _dfault _dfault: push ax mov ax,#24 @@ -290,31 +295,26 @@ ; ; trap 9 is reserved ; - .globl _itss _itss: push ax mov ax,#26 jmp _irqit - .globl _nseg _nseg: push ax mov ax,#27 jmp _irqit - - .globl _stkfault + _stkfault: push ax mov ax,#28 jmp _irqit - .globl _segovr _segovr: push ax mov ax,#29 jmp _irqit - - .globl _pfault + _pfault: push ax mov ax,#30 @@ -322,13 +322,11 @@ ; ; trap 15 is reserved ; - .globl _fpetrap _fpetrap: push ax mov ax,#32 jmp _irqit - .globl _algn _algn: push ax mov ax,#33 @@ -356,11 +354,10 @@ ! Switch to int_stack ! No task switch allowed. ! -! We do all of this to avoid per process interrupt stacks and +! We do all of this to avoid per process interrupt stacks and ! related nonsense. This way we need only one dedicted int stack ! ! - .globl _irq0 _irq0: ! ! Save AX and load it with the IRQ number @@ -481,7 +478,7 @@ orb ch,ch ! Schedule allowed ? je nosched ! No ! mov bx,_need_resched ! Schedule needed -! cmp bx,#0 ! +! cmp bx,#0 ! ! je nosched ! No ! ! This path will return directly to user space diff -Nur elks.orig/fs/minix/dir.c elks/fs/minix/dir.c --- elks.orig/fs/minix/dir.c 2015-04-26 11:39:15.000000000 -0500 +++ elks/fs/minix/dir.c 2015-05-04 17:43:21.000000000 -0500 @@ -16,7 +16,7 @@ #include <arch/segment.h> -static int minix_dir_read(struct inode *inode, struct file *filp, char *buf, int count) +static size_t minix_dir_read(struct inode *inode, struct file *filp, char *buf, int count) { return -EISDIR; } diff -Nur elks.orig/fs/minix/file.c elks/fs/minix/file.c --- elks.orig/fs/minix/file.c 2015-04-26 11:39:15.000000000 -0500 +++ elks/fs/minix/file.c 2015-05-04 17:43:21.000000000 -0500 @@ -22,10 +22,10 @@ #include <linuxmt/fs.h> #include <linuxmt/minix_fs.h> -static int minix_file_read(struct inode *inode, register struct file *filp, +static size_t minix_file_read(struct inode *inode, register struct file *filp, char *buf, size_t count); -static int minix_file_write(register struct inode *inode, struct file *filp, +static size_t minix_file_write(register struct inode *inode, struct file *filp, char *buf, size_t count); /* @@ -77,7 +77,7 @@ static char mode_equal_val[] = "mode = %07o\n"; #endif -static int minix_file_read(struct inode *inode, register struct file *filp, +static size_t minix_file_read(struct inode *inode, register struct file *filp, char *buf, size_t count) { register struct buffer_head *bh; @@ -155,7 +155,7 @@ return read; } -static int minix_file_write(register struct inode *inode, +static size_t minix_file_write(register struct inode *inode, struct file *filp, char *buf, size_t count) { register struct buffer_head *bh; diff -Nur elks.orig/fs/minix/inode.c elks/fs/minix/inode.c --- elks.orig/fs/minix/inode.c 2015-04-26 11:39:15.000000000 -0500 +++ elks/fs/minix/inode.c 2015-05-04 17:43:21.000000000 -0500 @@ -140,8 +140,8 @@ unsigned short block; kdev_t dev = s->s_dev; - if (32 != sizeof(struct minix_inode)) - panic("bad i-node size"); +/* if (32 != sizeof(struct minix_inode)) + panic("bad i-node size");*/ lock_super(s); if (!(bh = bread(dev, (block_t) 1))) { s->s_dev = 0; diff -Nur elks.orig/fs/readdir.c elks/fs/readdir.c --- elks.orig/fs/readdir.c 2015-04-26 11:39:15.000000000 -0500 +++ elks/fs/readdir.c 2015-05-04 17:43:21.000000000 -0500 @@ -42,11 +42,11 @@ return -EINVAL; buf->count++; dirent = buf->dirent; - put_user_long(ino, (__u16) &dirent->d_ino); - put_user_long((__u32) offset, (__u16) &dirent->d_offset); - put_user((__u16) namlen, (__u16) &dirent->d_namlen); + put_user_long((__u32)ino, &dirent->d_ino); + put_user_long((__u32) offset, &dirent->d_offset); + put_user((__u16) namlen, &dirent->d_namlen); memcpy_tofs(dirent->d_name, name, namlen); - put_user_char(0, (__u16) (dirent->d_name + namlen)); + put_user_char(0, dirent->d_name + namlen); return 0; } diff -Nur elks.orig/include/arch/irq.h elks/include/arch/irq.h --- elks.orig/include/arch/irq.h 2015-04-26 11:39:15.000000000 -0500 +++ elks/include/arch/irq.h 2015-05-04 17:43:21.000000000 -0500 @@ -52,8 +52,15 @@ #ifdef __KERNEL__ +#ifdef __BCC__ #define clr_irq() asm("cli") #define set_irq() asm("sti") +#endif + +#ifdef __WATCOMC__ +#define clr_irq() _asm {cli} +#define set_irq() _asm {sti} +#endif #else diff -Nur elks.orig/include/linuxmt/fs.h elks/include/linuxmt/fs.h --- elks.orig/include/linuxmt/fs.h 2015-04-26 11:39:15.000000000 -0500 +++ elks/include/linuxmt/fs.h 2015-05-04 17:43:21.000000000 -0500 @@ -412,7 +412,6 @@ extern struct file_operations rdwr_pipe_fops; extern struct inode_operations pipe_inode_operations; -extern struct file_operations socket_file_ops; extern struct inode_operations sock_inode_operations; extern struct file_system_type *get_fs_type(char *); diff -Nur elks.orig/include/linuxmt/minix_fs.h elks/include/linuxmt/minix_fs.h --- elks.orig/include/linuxmt/minix_fs.h 2015-04-26 11:39:15.000000000 -0500 +++ elks/include/linuxmt/minix_fs.h 2015-05-04 17:43:21.000000000 -0500 @@ -87,7 +87,7 @@ extern int minix_mknod(register struct inode *,char *,size_t,int,int); extern block_t minix_new_block(register struct super_block *); extern struct inode *minix_new_inode(struct inode *,__u16); -extern void minix_put_inode(register struct inode *); +/*extern void minix_put_inode(register struct inode *);*/ extern void minix_put_super(register struct super_block *); /*extern void minix_read_inode(register struct inode *);*/ extern struct super_block *minix_read_super(register struct super_block *, diff -Nur elks.orig/include/linuxmt/mm.h elks/include/linuxmt/mm.h --- elks.orig/include/linuxmt/mm.h 2015-04-26 11:39:15.000000000 -0500 +++ elks/include/linuxmt/mm.h 2015-05-04 17:43:21.000000000 -0500 @@ -55,7 +55,7 @@ extern __u16 peekw(__u16,__u16); extern void fmemcpy(__u16,__u16,__u16,__u16,__u16); -extern void fmemset(__u16,__u16,__u16,__u16); +extern void fmemset(char *,__u16,__u16,size_t); extern void far_memmove(unsigned,unsigned,unsigned,unsigned,unsigned); diff -Nur elks.orig/include/linuxmt/sched.h elks/include/linuxmt/sched.h --- elks.orig/include/linuxmt/sched.h 2015-04-26 11:39:15.000000000 -0500 +++ elks/include/linuxmt/sched.h 2015-05-04 17:43:21.000000000 -0500 @@ -121,11 +121,6 @@ /* We use typedefs to avoid using struct foobar (*) */ typedef struct task_struct __task, *__ptask; -/*@+namechecks@*/ - -extern load_regs(__ptask); -extern save_regs(__ptask); - extern __task task[MAX_TASKS]; extern jiff_t jiffies; diff -Nur elks.orig/include/linuxmt/tcpdev.h elks/include/linuxmt/tcpdev.h --- elks.orig/include/linuxmt/tcpdev.h 2015-04-26 11:39:15.000000000 -0500 +++ elks/include/linuxmt/tcpdev.h 2015-05-04 17:43:21.000000000 -0500 @@ -6,6 +6,7 @@ */ #include <linuxmt/in.h> +#include <linuxmt/net.h> #define TCP_DEVICE_NAME "tcpdev" @@ -24,44 +25,44 @@ struct tdb_release { unsigned char cmd; - unsigned short sock; + struct socket *sock; }; struct tdb_accept { unsigned char cmd; - unsigned short sock; - unsigned short newsock; + struct socket *sock; + struct socket *newsock; int nonblock; }; struct tdb_listen { unsigned char cmd; - unsigned short sock; + struct socket *sock; int backlog; }; struct tdb_bind { unsigned char cmd; - unsigned short sock; + struct socket *sock; struct sockaddr_in addr; }; struct tdb_connect { unsigned char cmd; - unsigned short sock; + struct socket *sock; struct sockaddr_in addr; }; struct tdb_read { unsigned char cmd; - unsigned short sock; + struct socket *sock; int size; int nonblock; }; struct tdb_write { unsigned char cmd; - unsigned short sock; + struct socket *sock; int size; int nonblock; #define TDB_WRITE_MAX 100 @@ -75,7 +76,7 @@ struct tdb_return_data { char type; int ret_value; - unsigned short sock; + struct socket *sock; int size; unsigned char data; }; @@ -83,7 +84,7 @@ struct tdb_accept_ret { char type; int ret_value; - unsigned short sock; + struct socket *sock; __u32 addr_ip; __u16 addr_port; }; diff -Nur elks.orig/net/ipv4/af_inet.c elks/net/ipv4/af_inet.c --- elks.orig/net/ipv4/af_inet.c 2015-04-26 11:39:15.000000000 -0500 +++ elks/net/ipv4/af_inet.c 2015-05-04 17:43:21.000000000 -0500 @@ -34,7 +34,7 @@ r = (struct tdb_return_data *) buf; - sock = (struct socket *) r->sock; + sock = r->sock; switch (r->type) { case TDT_CHG_STATE: @@ -61,7 +61,7 @@ if (protocol != 0 || !tcpdev_inuse) return -EINVAL; - + return 0; } @@ -94,7 +94,7 @@ int ret; debug1("inet_bind(sock: 0x%x)\n", sock); - if (sockaddr_len <= 0 || sockaddr_len > sizeof(struct sockaddr_in)) + if (!sockaddr_len || sockaddr_len > sizeof(struct sockaddr_in)) return -EINVAL; /* TODO : Check if the user has permision to bind the port */ @@ -129,10 +129,10 @@ debug1("inet_connect(sock: 0x%x)\n", sock); - if (sockaddr_len <= 0 || sockaddr_len > sizeof(struct sockaddr_in)) + if (!sockaddr_len || sockaddr_len > sizeof(struct sockaddr_in)) return -EINVAL; - sockin = uservaddr; + sockin = (struct sockaddr_in *)uservaddr; if (sockin->sin_family != AF_INET) return -EINVAL; @@ -346,6 +346,7 @@ } } else if (sel_type == SEL_OUT) return 1; + return 0; } void inet_ioctl(void) diff -Nur elks.orig/net/socket.c elks/net/socket.c --- elks.orig/net/socket.c 2015-04-26 11:39:15.000000000 -0500 +++ elks/net/socket.c 2015-05-04 17:43:21.000000000 -0500 @@ -59,7 +59,7 @@ int move_addr_to_kernel(char *uaddr, size_t ulen, char *kaddr) { - if (ulen < 0 || ulen > MAX_SOCK_ADDR) + if (ulen > MAX_SOCK_ADDR) return -EINVAL; if (ulen == 0) @@ -79,7 +79,7 @@ if (len > klen) len = klen; - if (len < 0 || len > MAX_SOCK_ADDR) + if (len > MAX_SOCK_ADDR) return -EINVAL; if (len) @@ -148,7 +148,7 @@ return socki_lookup(inode); } -static int sock_read(struct inode *inode, struct file *file, +static size_t sock_read(struct inode *inode, struct file *file, register char *ubuf, size_t size) { struct socket *sock; @@ -162,9 +162,6 @@ if (sock->flags & SO_ACCEPTCON) return -EINVAL; - if (size < 0) - return -EINVAL; - if (size == 0) return 0; @@ -174,7 +171,7 @@ return sock->ops->read(sock, ubuf, size, (file->f_flags & O_NONBLOCK)); } -static int sock_write(struct inode *inode, struct file *file, +static size_t sock_write(struct inode *inode, struct file *file, register char *ubuf, size_t size) { struct socket *sock; @@ -188,9 +185,6 @@ if (sock->flags & SO_ACCEPTCON) return -EINVAL; - if (size < 0) - return -EINVAL; - if (size == 0) return 0;