diff -Naur linux-0.01-rm-1.7/boot/head.s linux-0.01-rm-2.0/boot/head.s --- linux-0.01-rm-1.7/boot/head.s 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/boot/head.s 2007-11-26 22:42:44.000000000 +0100 @@ -5,16 +5,17 @@ * the page directory will exist. The startup code will be overwritten by * the page directory. */ +.code32 .text -.globl _idt,_gdt,_pg_dir -_pg_dir: +.globl idt,gdt,pg_dir,startup_32 +pg_dir: startup_32: movl $0x10,%eax mov %ax,%ds mov %ax,%es mov %ax,%fs mov %ax,%gs - lss _stack_start,%esp + lss stack_start,%esp call setup_idt call setup_gdt movl $0x10,%eax # reload all the segment registers @@ -22,7 +23,7 @@ mov %ax,%es # reloaded in 'setup_gdt' mov %ax,%fs mov %ax,%gs - lss _stack_start,%esp + lss stack_start,%esp xorl %eax,%eax 1: incl %eax # check that A20 really IS enabled movl %eax,0x000000 @@ -53,7 +54,7 @@ movw %dx,%ax /* selector = 0x0008 = cs */ movw $0x8E00,%dx /* interrupt gate - dpl=0, present */ - lea _idt,%edi + lea idt,%edi mov $256,%ecx rp_sidt: movl %eax,(%edi) @@ -95,7 +96,7 @@ pushl $0 pushl $0 pushl $L6 # return address for main, if it decides to. - pushl $_main + pushl $main jmp setup_paging L6: jmp L6 # main should never return here, but @@ -139,8 +140,8 @@ xorl %eax,%eax xorl %edi,%edi /* pg_dir is at 0x000 */ cld;rep;stosl - movl $pg0+7,_pg_dir /* set present bit/user r/w */ - movl $pg1+7,_pg_dir+4 /* --------- " " --------- */ + movl $pg0+7,pg_dir /* set present bit/user r/w */ + movl $pg1+7,pg_dir+4 /* --------- " " --------- */ movl $pg1+4092,%edi movl $0x7ff007,%eax /* 8Mb - 4096 + 7 (r/w user,p) */ std @@ -158,17 +159,17 @@ .word 0 idt_descr: .word 256*8-1 # idt contains 256 entries - .long _idt + .long idt .align 2 .word 0 gdt_descr: .word 256*8-1 # so does gdt (not that that's any - .long _gdt # magic number, but it works for me :^) + .long gdt # magic number, but it works for me :^) - .align 3 -_idt: .fill 256,8,0 # idt is uninitialized + .align 8 +idt: .fill 256,8,0 # idt is uninitialized -_gdt: .quad 0x0000000000000000 /* NULL descriptor */ +gdt: .quad 0x0000000000000000 /* NULL descriptor */ .quad 0x00c09a00000007ff /* 8Mb */ .quad 0x00c09200000007ff /* 8Mb */ .quad 0x0000000000000000 /* TEMPORARY - don't use */ diff -Naur linux-0.01-rm-1.7/build_tools linux-0.01-rm-2.0/build_tools --- linux-0.01-rm-1.7/build_tools 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/build_tools 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -#bin/sh! -export PATH=/usr/bin:/usr/local/bin -gcc-4.1 -o tools/build tools/build.c diff -Naur linux-0.01-rm-1.7/fs/bitmap.c linux-0.01-rm-2.0/fs/bitmap.c --- linux-0.01-rm-1.7/fs/bitmap.c 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/fs/bitmap.c 2007-11-26 20:56:34.000000000 +0100 @@ -8,15 +8,15 @@ __asm__("cld\n\t" \ "rep\n\t" \ "stosl" \ - ::"a" (0),"c" (BLOCK_SIZE/4),"D" ((long) (addr)):"cx","di") + ::"a" (0),"c" (BLOCK_SIZE/4),"D" ((long) (addr))/*:"cx","di"*/) #define set_bit(nr,addr) ({\ -register int res __asm__("ax"); \ +register int res;/* __asm__("ax");*/ \ __asm__("btsl %2,%3\n\tsetb %%al":"=a" (res):"0" (0),"r" (nr),"m" (*(addr))); \ res;}) #define clear_bit(nr,addr) ({\ -register int res __asm__("ax"); \ +register int res;/* __asm__("ax");*/ \ __asm__("btrl %2,%3\n\tsetnb %%al":"=a" (res):"0" (0),"r" (nr),"m" (*(addr))); \ res;}) @@ -33,7 +33,7 @@ "cmpl $8192,%%ecx\n\t" \ "jl 1b\n" \ "3:" \ - :"=c" (__res):"c" (0),"S" (addr):"ax","dx","si"); \ + :"=c" (__res):"c" (0),"S" (addr):"ax","dx"/*,"si"*/); \ __res;}) void free_block(int dev, int block) diff -Naur linux-0.01-rm-1.7/fs/exec.c linux-0.01-rm-2.0/fs/exec.c --- linux-0.01-rm-1.7/fs/exec.c 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/fs/exec.c 2007-12-25 10:13:01.000000000 +0100 @@ -18,16 +18,20 @@ */ #define MAX_ARG_PAGES 32 -#define cp_block(from,to) \ -__asm__("pushl $0x10\n\t" \ - "pushl $0x17\n\t" \ - "pop %%es\n\t" \ - "cld\n\t" \ - "rep\n\t" \ - "movsl\n\t" \ - "pop %%es" \ - ::"c" (BLOCK_SIZE/4),"S" (from),"D" (to) \ - :"cx","di","si") +inline void cp_block(const void * from,void * to) +{ +int d0,d1,d2; +__asm__ __volatile("pushl $0x10\n\t" + "pushl $0x17\n\t" + "pop %%es\n\t" + "cld\n\t" + "rep\n\t" + "movsl\n\t" + "pop %%es" + :"=&c" (d0), "=&S" (d1), "=&D" (d2) + :"0" (BLOCK_SIZE/4),"1" (from),"2" (to) + :"memory"); +} /* * read_head() reads blocks 1-6 (not 0). Block 0 has already been diff -Naur linux-0.01-rm-1.7/fs/Makefile linux-0.01-rm-2.0/fs/Makefile --- linux-0.01-rm-1.7/fs/Makefile 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/fs/Makefile 2007-11-26 20:56:55.000000000 +0100 @@ -1,8 +1,8 @@ -AR =gar -AS =gas +AR =ar +AS =as CC =gcc -LD =gld -CFLAGS =-Wall -O -fstrength-reduce -fcombine-regs -fomit-frame-pointer \ +LD =ld +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ -nostdinc -I../include CPP =gcc -E -nostdinc -I../include diff -Naur linux-0.01-rm-1.7/fs/namei.c linux-0.01-rm-2.0/fs/namei.c --- linux-0.01-rm-1.7/fs/namei.c 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/fs/namei.c 2007-11-27 21:13:03.000000000 +0100 @@ -63,7 +63,7 @@ "setz %%al" :"=a" (same) :"0" (0),"S" ((long) name),"D" ((long) de->name),"c" (len) - :"cx","di","si"); + /*:"cx","di","si"*/); return same; } diff -Naur linux-0.01-rm-1.7/fs/super.c linux-0.01-rm-2.0/fs/super.c --- linux-0.01-rm-1.7/fs/super.c 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/fs/super.c 2007-11-26 20:50:42.000000000 +0100 @@ -7,7 +7,7 @@ /* set_bit uses setb, as gas doesn't recognize setc */ #define set_bit(bitnr,addr) ({ \ -register int __res __asm__("ax"); \ +register int __res;/* __asm__("ax");*/ \ __asm__("bt %2,%3;setb %%al":"=a" (__res):"a" (0),"r" (bitnr),"m" (*(addr))); \ __res; }) diff -Naur linux-0.01-rm-1.7/include/linux/kernel.h linux-0.01-rm-2.0/include/linux/kernel.h --- linux-0.01-rm-1.7/include/linux/kernel.h 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/include/linux/kernel.h 2007-11-25 22:35:09.000000000 +0100 @@ -2,7 +2,7 @@ * 'kernel.h' contains some often-used function prototypes etc */ void verify_area(void * addr,int count); -volatile void panic(const char * str); +void panic(const char * str); int printf(const char * fmt, ...); int printk(const char * fmt, ...); int tty_write(unsigned ch,char * buf,int count); diff -Naur linux-0.01-rm-1.7/include/linux/sched.h linux-0.01-rm-2.0/include/linux/sched.h --- linux-0.01-rm-1.7/include/linux/sched.h 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/include/linux/sched.h 2007-12-23 19:33:36.000000000 +0100 @@ -167,64 +167,67 @@ */ #define switch_to(n) {\ struct {long a,b;} __tmp; \ -__asm__("cmpl %%ecx,_current\n\t" \ +__asm__ __volatile__("cmpl %%ecx,current\n\t" \ "je 1f\n\t" \ - "xchgl %%ecx,_current\n\t" \ + "xchgl %%ecx,current\n\t" \ "movw %%dx,%1\n\t" \ - "ljmp %0\n\t" \ + "ljmp *%0\n\t" \ "cmpl %%ecx,%2\n\t" \ "jne 1f\n\t" \ "clts\n" \ - "1:" \ + "1:\n\t" \ ::"m" (*&__tmp.a),"m" (*&__tmp.b), \ "m" (last_task_used_math),"d" _TSS(n),"c" ((long) task[n])); \ } #define PAGE_ALIGN(n) (((n)+0xfff)&0xfffff000) -#define _set_base(addr,base) \ -__asm__("movw %%dx,%0\n\t" \ +#define _set_base(addr,base) do { unsigned long __pr; \ +__asm__ __volatile__ ("movw %%dx,%1\n\t" \ "rorl $16,%%edx\n\t" \ - "movb %%dl,%1\n\t" \ - "movb %%dh,%2" \ - ::"m" (*((addr)+2)), \ - "m" (*((addr)+4)), \ - "m" (*((addr)+7)), \ - "d" (base) \ - :"dx") + "movb %%dl,%2\n\t" \ + "movb %%dh,%3" \ + :"=&d" (__pr) \ + :"m" (*((addr)+2)), \ + "m" (*((addr)+4)), \ + "m" (*((addr)+7)), \ + "0" (base) \ + ); } while(0) -#define _set_limit(addr,limit) \ -__asm__("movw %%dx,%0\n\t" \ +#define _set_limit(addr,limit) do { unsigned long __lr; \ +__asm__ __volatile__ ("movw %%dx,%1\n\t" \ "rorl $16,%%edx\n\t" \ - "movb %1,%%dh\n\t" \ + "movb %2,%%dh\n\t" \ "andb $0xf0,%%dh\n\t" \ "orb %%dh,%%dl\n\t" \ - "movb %%dl,%1" \ - ::"m" (*(addr)), \ - "m" (*((addr)+6)), \ - "d" (limit) \ - :"dx") + "movb %%dl,%2" \ + :"=&d" (__lr) \ + :"m" (*(addr)), \ + "m" (*((addr)+6)), \ + "0" (limit) \ + ); } while(0) #define set_base(ldt,base) _set_base( ((char *)&(ldt)) , base ) #define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , (limit-1)>>12 ) -#define _get_base(addr) ({\ -unsigned long __base; \ -__asm__("movb %3,%%dh\n\t" \ - "movb %2,%%dl\n\t" \ - "shll $16,%%edx\n\t" \ - "movw %1,%%dx" \ - :"=d" (__base) \ - :"m" (*((addr)+2)), \ - "m" (*((addr)+4)), \ - "m" (*((addr)+7))); \ -__base;}) - +static inline unsigned long _get_base(char * addr) +{ + unsigned long __base; + __asm__("movb %3,%%dh\n\t" + "movb %2,%%dl\n\t" + "shll $16,%%edx\n\t" + "movw %1,%%dx" + :"=&d" (__base) + :"m" (*((addr)+2)), + "m" (*((addr)+4)), + "m" (*((addr)+7))); + return __base; +} #define get_base(ldt) _get_base( ((char *)&(ldt)) ) #define get_limit(segment) ({ \ unsigned long __limit; \ -__asm__("lsll %1,%0\n\tincl %0":"=r" (__limit):"r" (segment)); \ +__asm__ __volatile__("lsll %1,%0\n\tincl %0":"=r" (__limit):"r" (segment)); \ __limit;}) #endif diff -Naur linux-0.01-rm-1.7/include/string.h linux-0.01-rm-2.0/include/string.h --- linux-0.01-rm-1.7/include/string.h 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/include/string.h 2007-12-23 11:43:37.000000000 +0100 @@ -26,18 +26,21 @@ extern inline char * strcpy(char * dest,const char *src) { -__asm__("cld\n" +int d0, d1, d2; +__asm__ __volatile__("cld\n\t" "1:\tlodsb\n\t" "stosb\n\t" "testb %%al,%%al\n\t" "jne 1b" - ::"S" (src),"D" (dest):"si","di","ax"); + : "=&S" (d0), "=&D" (d1), "=&a" (d2) + :"0" (src),"1" (dest) : "memory"); return dest; } extern inline char * strncpy(char * dest,const char *src,int count) { -__asm__("cld\n" +int d0, d1, d2, d3; +__asm__ __volatile__("cld\n\t" "1:\tdecl %2\n\t" "js 2f\n\t" "lodsb\n\t" @@ -47,13 +50,15 @@ "rep\n\t" "stosb\n" "2:" - ::"S" (src),"D" (dest),"c" (count):"si","di","ax","cx"); + : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3) + :"0" (src),"1" (dest),"2" (count) : "memory"); return dest; } extern inline char * strcat(char * dest,const char * src) { -__asm__("cld\n\t" +int d0, d1, d2, d3; +__asm__ __volatile__("cld\n\t" "repne\n\t" "scasb\n\t" "decl %1\n" @@ -61,17 +66,19 @@ "stosb\n\t" "testb %%al,%%al\n\t" "jne 1b" - ::"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"si","di","ax","cx"); + : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) + : "0" (src), "1" (dest), "2" (0), "3" (0xffffffffu):"memory"); return dest; } extern inline char * strncat(char * dest,const char * src,int count) { -__asm__("cld\n\t" +int d0, d1, d2, d3; +__asm__ __volatile__("cld\n\t" "repne\n\t" "scasb\n\t" "decl %1\n\t" - "movl %4,%3\n" + "movl %8,%3\n" "1:\tdecl %3\n\t" "js 2f\n\t" "lodsb\n\t" @@ -80,15 +87,17 @@ "jne 1b\n" "2:\txorl %2,%2\n\t" "stosb" - ::"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count) - :"si","di","ax","cx"); + : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) + : "0" (src),"1" (dest),"2" (0),"3" (0xffffffffu), "g" (count) + : "memory"); return dest; } extern inline int strcmp(const char * cs,const char * ct) { -register int __res __asm__("ax"); -__asm__("cld\n" +int d0, d1; +register int __res; +__asm__ __volatile__("cld\n\t" "1:\tlodsb\n\t" "scasb\n\t" "jne 2f\n\t" @@ -96,18 +105,20 @@ "jne 1b\n\t" "xorl %%eax,%%eax\n\t" "jmp 3f\n" - "2:\tmovl $1,%%eax\n\t" - "jl 3f\n\t" - "negl %%eax\n" + "2:\tsbbl %%eax,%%eax\n\t" + "orb $1,%%al\n" "3:" - :"=a" (__res):"D" (cs),"S" (ct):"si","di"); + :"=a" (__res), "=&S" (d0), "=&D" (d1) + :"1" (cs),"2" (ct) + :"memory"); return __res; } extern inline int strncmp(const char * cs,const char * ct,int count) { -register int __res __asm__("ax"); -__asm__("cld\n" +register int __res; +int d0, d1, d2; +__asm__ __volatile__("cld\n\t" "1:\tdecl %3\n\t" "js 2f\n\t" "lodsb\n\t" @@ -117,18 +128,20 @@ "jne 1b\n" "2:\txorl %%eax,%%eax\n\t" "jmp 4f\n" - "3:\tmovl $1,%%eax\n\t" - "jl 4f\n\t" - "negl %%eax\n" + "3:\tsbbl %%eax,%%eax\n\t" + "orb $1,%%al\n" "4:" - :"=a" (__res):"D" (cs),"S" (ct),"c" (count):"si","di","cx"); + :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2) + :"1" (cs),"2" (ct),"3" (count) + :"memory"); return __res; } extern inline char * strchr(const char * s,char c) { -register char * __res __asm__("ax"); -__asm__("cld\n\t" +int d0; +register char * __res; +__asm__ __volatile__( "movb %%al,%%ah\n" "1:\tlodsb\n\t" "cmpb %%ah,%%al\n\t" @@ -138,29 +151,33 @@ "movl $1,%1\n" "2:\tmovl %1,%0\n\t" "decl %0" - :"=a" (__res):"S" (s),"0" (c):"si"); + :"=a" (__res), "=&S" (d0) + :"1" (s),"0" (c) + :"memory"); return __res; } extern inline char * strrchr(const char * s,char c) { -register char * __res __asm__("dx"); -__asm__("cld\n\t" +int d0, d1; +register char * __res; +__asm__ __volatile__("cld\n\t" "movb %%al,%%ah\n" "1:\tlodsb\n\t" "cmpb %%ah,%%al\n\t" "jne 2f\n\t" - "movl %%esi,%0\n\t" - "decl %0\n" + "leal -1(%%esi),%0\n" "2:\ttestb %%al,%%al\n\t" "jne 1b" - :"=d" (__res):"0" (0),"S" (s),"a" (c):"ax","si"); + :"=g" (__res), "=&S" (d0), "=&a" (d1) + :"0" (0),"1" (s),"2" (c) + :"memory"); return __res; } extern inline int strspn(const char * cs, const char * ct) { -register char * __res __asm__("si"); +register char * __res;// __asm__("si"); __asm__("cld\n\t" "movl %4,%%edi\n\t" "repne\n\t" @@ -178,13 +195,13 @@ "je 1b\n" "2:\tdecl %0" :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - :"ax","cx","dx","di"); + :/*"ax","cx",*/"dx","di"); /* TODO : constraint may be wrong*/ return __res-cs; } extern inline int strcspn(const char * cs, const char * ct) { -register char * __res __asm__("si"); +register char * __res;// __asm__("si"); __asm__("cld\n\t" "movl %4,%%edi\n\t" "repne\n\t" @@ -202,13 +219,13 @@ "jne 1b\n" "2:\tdecl %0" :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - :"ax","cx","dx","di"); + :/*"ax","cx",*/"dx","di"); /* TODO : constraint may be wrong*/ return __res-cs; } extern inline char * strpbrk(const char * cs,const char * ct) { -register char * __res __asm__("si"); +register char * __res;// __asm__("si"); __asm__("cld\n\t" "movl %4,%%edi\n\t" "repne\n\t" @@ -229,13 +246,13 @@ "2:\txorl %0,%0\n" "3:" :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) - :"ax","cx","dx","di"); + :/*"ax","cx",*/"dx","di");/* TODO : constraint may be wrong*/ return __res; } extern inline char * strstr(const char * cs,const char * ct) { -register char * __res __asm__("ax"); +register char * __res;// __asm__("ax"); __asm__("cld\n\t" \ "movl %4,%%edi\n\t" "repne\n\t" @@ -256,19 +273,22 @@ "xorl %%eax,%%eax\n\t" "2:" :"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct) - :"cx","dx","di","si"); + :/*"cx",*/"dx","di"/*,"si"*/); /* TODO : constraint may be wrong*/ return __res; } extern inline int strlen(const char * s) { -register int __res __asm__("cx"); -__asm__("cld\n\t" +int d0; +register int __res; +__asm__ __volatile__("cld\n\t" "repne\n\t" "scasb\n\t" "notl %0\n\t" "decl %0" - :"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"di"); + :"=c" (__res), "=&D" (d0) + :"1" (s),"a" (0), "0" (0xffffffffu) + :"memory"); return __res; } @@ -276,7 +296,7 @@ extern inline char * strtok(char * s,const char * ct) { -register char * __res __asm__("si"); +register char * __res;// __asm__("si"); __asm__("testl %1,%1\n\t" "jne 1f\n\t" "testl %0,%0\n\t" @@ -329,40 +349,46 @@ "8:" :"=b" (__res),"=S" (___strtok) :"0" (___strtok),"1" (s),"g" (ct) - :"ax","cx","dx","di"); + :"ax","cx","dx","di"); /* TODO : constraint may be wrong*/ return __res; } extern inline void * memcpy(void * dest,const void * src, int n) { -__asm__("cld\n\t" +int d0,d1,d2; +__asm__ __volatile("cld\n\t" "rep\n\t" "movsb" - ::"c" (n),"S" (src),"D" (dest) - :"cx","si","di"); + :"=&c" (d0), "=&S" (d1), "=&D" (d2) + :"0" (n),"1" (src),"2" (dest) + :"memory"); return dest; } extern inline void * memmove(void * dest,const void * src, int n) { -if (dest %eax xchgl %ebx,(%esp) # &function <-> %ebx @@ -139,19 +139,19 @@ popl %eax iret -_invalid_TSS: - pushl $_do_invalid_TSS +invalid_TSS: + pushl $do_invalid_TSS jmp error_code -_segment_not_present: - pushl $_do_segment_not_present +segment_not_present: + pushl $do_segment_not_present jmp error_code -_stack_segment: - pushl $_do_stack_segment +stack_segment: + pushl $do_stack_segment jmp error_code -_general_protection: - pushl $_do_general_protection +general_protection: + pushl $do_general_protection jmp error_code diff -Naur linux-0.01-rm-1.7/kernel/console.c linux-0.01-rm-2.0/kernel/console.c --- linux-0.01-rm-1.7/kernel/console.c 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/kernel/console.c 2008-01-01 14:07:40.000000000 +0100 @@ -71,59 +71,69 @@ pos += columns<<1; scr_end += columns<<1; if (scr_end>SCREEN_END) { - __asm__("cld\n\t" + + int d0,d1,d2,d3; + __asm__ __volatile("cld\n\t" "rep\n\t" "movsl\n\t" - "movl _columns,%1\n\t" + "movl columns,%1\n\t" "rep\n\t" "stosw" - ::"a" (0x0720), - "c" ((lines-1)*columns>>1), - "D" (SCREEN_START), - "S" (origin) - :"cx","di","si"); + :"=&a" (d0), "=&c" (d1), "=&D" (d2), "=&S" (d3) + :"0" (0x0720), + "1" ((lines-1)*columns>>1), + "2" (SCREEN_START), + "3" (origin) + :"memory"); + scr_end -= origin-SCREEN_START; pos -= origin-SCREEN_START; origin = SCREEN_START; } else { - __asm__("cld\n\t" + int d0,d1,d2; + __asm__ __volatile("cld\n\t" "rep\n\t" "stosl" - ::"a" (0x07200720), - "c" (columns>>1), - "D" (scr_end-(columns<<1)) - :"cx","di"); + :"=&a" (d0), "=&c" (d1), "=&D" (d2) + :"0" (0x07200720), + "1" (columns>>1), + "2" (scr_end-(columns<<1)) + :"memory"); } set_origin(); } else { - __asm__("cld\n\t" + int d0,d1,d2,d3; + __asm__ __volatile__("cld\n\t" "rep\n\t" "movsl\n\t" - "movl _columns,%%ecx\n\t" + "movl columns,%%ecx\n\t" "rep\n\t" "stosw" - ::"a" (0x0720), - "c" ((bottom-top-1)*columns>>1), - "D" (origin+(columns<<1)*top), - "S" (origin+(columns<<1)*(top+1)) - :"cx","di","si"); + :"=&a" (d0), "=&c" (d1), "=&D" (d2), "=&S" (d3) + :"0" (0x0720), + "1" ((bottom-top-1)*columns>>1), + "2" (origin+(columns<<1)*top), + "3" (origin+(columns<<1)*(top+1)) + :"memory"); } } static void scrdown(void) { - __asm__("std\n\t" + int d0,d1,d2,d3; + __asm__ __volatile__("std\n\t" "rep\n\t" "movsl\n\t" "addl $2,%%edi\n\t" /* %edi has been decremented by 4 */ - "movl _columns,%%ecx\n\t" + "movl columns,%%ecx\n\t" "rep\n\t" "stosw" - ::"a" (0x0720), - "c" ((bottom-top-1)*columns>>1), - "D" (origin+(columns<<1)*bottom-4), - "S" (origin+(columns<<1)*(bottom-1)-4) - :"ax","cx","di","si"); + :"=&a" (d0), "=&c" (d1), "=&D" (d2), "=&S" (d3) + :"0" (0x0720), + "1" ((bottom-top-1)*columns>>1), + "2" (origin+(columns<<1)*bottom-4), + "3" (origin+(columns<<1)*(bottom-1)-4) + :"memory"); } static void lf(void) @@ -163,8 +173,8 @@ static void csi_J(int par) { - long count __asm__("cx"); - long start __asm__("di"); + long count; + long start; switch (par) { case 0: /* erase from cursor to end of display */ @@ -182,18 +192,19 @@ default: return; } - __asm__("cld\n\t" + int d0,d1,d2; + __asm__ __volatile__("cld\n\t" "rep\n\t" "stosw\n\t" - ::"c" (count), - "D" (start),"a" (0x0720) - :"cx","di"); + :"=&c" (d0), "=&D" (d1), "=&a" (d2) + :"0" (count),"1" (start),"2" (0x0720) + :"memory"); } static void csi_K(int par) { - long count __asm__("cx"); - long start __asm__("di"); + long count; + long start; switch (par) { case 0: /* erase from cursor to end of line */ @@ -213,12 +224,13 @@ default: return; } - __asm__("cld\n\t" + int d0,d1,d2; + __asm__ __volatile__("cld\n\t" "rep\n\t" "stosw\n\t" - ::"c" (count), - "D" (start),"a" (0x0720) - :"cx","di"); + :"=&c" (d0), "=&D" (d1), "=&a" (d2) + :"0" (count),"1" (start),"2" (0x0720) + :"memory"); } void csi_m(void) @@ -385,10 +397,10 @@ pos -= columns<<1; lf(); } - __asm__("movb _attr,%%ah\n\t" + __asm__("movb attr,%%ah\n\t" "movw %%ax,%1\n\t" ::"a" (c),"m" (*(short *)pos) - :"ax"); + /*:"ax"*/); pos += 2; x++; } else if (c==27) @@ -438,7 +450,7 @@ par[npar]=0; npar=0; state=3; - if (ques=(c=='?')) + if ((ques=(c=='?'))) break; case 3: if (c==';' && npar -volatile void panic(const char * s) +void panic(const char * s) { printk("Kernel panic: %s\n\r",s); for(;;); diff -Naur linux-0.01-rm-1.7/kernel/printk.c linux-0.01-rm-2.0/kernel/printk.c --- linux-0.01-rm-1.7/kernel/printk.c 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/kernel/printk.c 2007-11-26 21:48:24.000000000 +0100 @@ -22,9 +22,9 @@ "push %%ds\n\t" "pop %%fs\n\t" "pushl %0\n\t" - "pushl $_buf\n\t" + "pushl $buf\n\t" "pushl $0\n\t" - "call _tty_write\n\t" + "call tty_write\n\t" "addl $8,%%esp\n\t" "popl %0\n\t" "pop %%fs" diff -Naur linux-0.01-rm-1.7/kernel/rs_io.s linux-0.01-rm-2.0/kernel/rs_io.s --- linux-0.01-rm-1.7/kernel/rs_io.s 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/kernel/rs_io.s 2007-11-26 22:07:38.000000000 +0100 @@ -5,7 +5,7 @@ */ .text -.globl _rs1_interrupt,_rs2_interrupt +.globl rs1_interrupt,rs2_interrupt size = 1024 /* must be power of two ! and must match the value @@ -25,12 +25,12 @@ * the interrupt is coming from, and take appropriate action. */ .align 2 -_rs1_interrupt: - pushl $_table_list+8 +rs1_interrupt: + pushl $table_list+8 jmp rs_int .align 2 -_rs2_interrupt: - pushl $_table_list+16 +rs2_interrupt: + pushl $table_list+16 rs_int: pushl %edx pushl %ecx @@ -56,7 +56,7 @@ movl 24(%esp),%ecx pushl %edx subl $2,%edx - call jmp_table(,%eax,2) /* NOTE! not *4, bit0 is 0 already */ + call *jmp_table(,%eax,2) /* NOTE! not *4, bit0 is 0 already */ popl %edx jmp rep_int end: movb $0x20,%al @@ -89,7 +89,7 @@ read_char: inb %dx,%al movl %ecx,%edx - subl $_table_list,%edx + subl $table_list,%edx shrl $3,%edx movl (%ecx),%ecx # read-queue movl head(%ecx),%ebx @@ -100,7 +100,7 @@ je 1f movl %ebx,head(%ecx) pushl %edx - call _do_tty_interrupt + call do_tty_interrupt addl $4,%esp 1: ret diff -Naur linux-0.01-rm-1.7/kernel/system_call.s linux-0.01-rm-2.0/kernel/system_call.s --- linux-0.01-rm-1.7/kernel/system_call.s 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/kernel/system_call.s 2007-11-26 22:06:58.000000000 +0100 @@ -47,7 +47,7 @@ nr_system_calls = 67 -.globl _system_call,_sys_fork,_timer_interrupt,_hd_interrupt,_sys_execve +.globl system_call,sys_fork,timer_interrupt,hd_interrupt,sys_execve .align 2 bad_sys_call: @@ -56,9 +56,9 @@ .align 2 reschedule: pushl $ret_from_sys_call - jmp _schedule + jmp schedule .align 2 -_system_call: +system_call: cmpl $nr_system_calls-1,%eax ja bad_sys_call push %ds @@ -72,16 +72,16 @@ mov %dx,%es movl $0x17,%edx # fs points to local data space mov %dx,%fs - call _sys_call_table(,%eax,4) + call *sys_call_table(,%eax,4) pushl %eax - movl _current,%eax + movl current,%eax cmpl $0,state(%eax) # state jne reschedule cmpl $0,counter(%eax) # counter je reschedule ret_from_sys_call: - movl _current,%eax # task[0] cannot have signals - cmpl _task,%eax + movl current,%eax # task[0] cannot have signals + cmpl task,%eax je 3f movl CS(%esp),%ebx # was old code segment supervisor testl $3,%ebx # mode? If so - don't check signals @@ -106,7 +106,7 @@ pushl %ecx pushl $28 pushl %edx - call _verify_area + call verify_area popl %edx addl $4,%esp popl %ecx @@ -137,12 +137,12 @@ cmpl $SIG_CHLD,%ecx je 2b pushl %ecx - call _do_exit # remember to set bit 7 when dumping core + call do_exit # remember to set bit 7 when dumping core addl $4,%esp jmp 3b .align 2 -_timer_interrupt: +timer_interrupt: push %ds # save ds,es and put kernel data space push %es # into them. %fs is used by _system_call push %fs @@ -155,27 +155,27 @@ mov %ax,%es movl $0x17,%eax mov %ax,%fs - incl _jiffies + incl jiffies movb $0x20,%al # EOI to interrupt controller #1 outb %al,$0x20 movl CS(%esp),%eax andl $3,%eax # %eax is CPL (0 or 3, 0=supervisor) pushl %eax - call _do_timer # 'do_timer(long CPL)' does everything from + call do_timer # 'do_timer(long CPL)' does everything from addl $4,%esp # task switching to accounting ... jmp ret_from_sys_call .align 2 -_sys_execve: +sys_execve: lea EIP(%esp),%eax pushl %eax - call _do_execve + call do_execve addl $4,%esp ret .align 2 -_sys_fork: - call _find_empty_process +sys_fork: + call find_empty_process testl %eax,%eax js 1f push %gs @@ -183,11 +183,11 @@ pushl %edi pushl %ebp pushl %eax - call _copy_process + call copy_process addl $20,%esp 1: ret -_hd_interrupt: +hd_interrupt: pushl %eax pushl %ecx pushl %edx @@ -204,10 +204,10 @@ jmp 1f # give port chance to breathe 1: jmp 1f 1: outb %al,$0xA0 # same to controller #2 - movl _do_hd,%eax + movl do_hd,%eax testl %eax,%eax jne 1f - movl $_unexpected_hd_interrupt,%eax + movl $unexpected_hd_interrupt,%eax 1: call *%eax # "interesting" way of handling intr. pop %fs pop %es diff -Naur linux-0.01-rm-1.7/lib/Makefile linux-0.01-rm-2.0/lib/Makefile --- linux-0.01-rm-1.7/lib/Makefile 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/lib/Makefile 2007-11-26 21:06:50.000000000 +0100 @@ -6,12 +6,12 @@ # unless it's something special (ie not a .c file). # -AR =gar -AS =gas -LD =gld +AR =ar +AS =as +LD =ld LDFLAGS =-s -x CC =gcc -CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fcombine-regs \ +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ -finline-functions -nostdinc -I../include CPP =gcc -E -nostdinc -I../include @@ -19,7 +19,7 @@ $(CC) $(CFLAGS) \ -S -o $*.s $< .s.o: - $(AS) -c -o $*.o $< + $(AS) -o $*.o $< .c.o: $(CC) $(CFLAGS) \ -c -o $*.o $< diff -Naur linux-0.01-rm-1.7/Makefile linux-0.01-rm-2.0/Makefile --- linux-0.01-rm-1.7/Makefile 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/Makefile 2007-12-23 19:28:48.000000000 +0100 @@ -8,11 +8,11 @@ CC86 =cc86 -0 LD86 =ld86 -0 -AS =gas -LD =gld -LDFLAGS =-s -x -M +AS =as +LD =ld +LDFLAGS =-s -x -M -Ttext 0 -e startup_32 CC =gcc -CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fcombine-regs +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fwritable-strings CPP =gcc -E -nostdinc -Iinclude ARCHIVES=kernel/kernel.o mm/mm.o fs/fs.o @@ -22,7 +22,7 @@ $(CC) $(CFLAGS) \ -nostdinc -Iinclude -S -o $*.s $< .s.o: - $(AS) -c -o $*.o $< + $(AS) -o $*.o $< .c.o: $(CC) $(CFLAGS) \ -nostdinc -Iinclude -c -o $*.o $< @@ -30,13 +30,13 @@ all: Image Image: boot/boot tools/system tools/build - tools/build boot/boot tools/system > Image + objcopy -O binary -R .note -R .comment tools/system tools/system.bin + tools/build boot/boot tools/system.bin > Image # sync tools/build: tools/build.c - sh build_tools -# $(CC) $(CFLAGS) \ -# -o tools/build tools/build.c + $(CC) $(CFLAGS) \ + -o tools/build tools/build.c #chmem +65000 tools/build boot/head.o: boot/head.s @@ -70,7 +70,7 @@ clean: rm -f Image System.map tmp_make boot/boot core - rm -f init/*.o boot/*.o tools/system tools/build + rm -f init/*.o boot/*.o tools/system tools/build tools/system.bin (cd mm;make clean) (cd fs;make clean) (cd kernel;make clean) diff -Naur linux-0.01-rm-1.7/mm/Makefile linux-0.01-rm-2.0/mm/Makefile --- linux-0.01-rm-1.7/mm/Makefile 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/mm/Makefile 2007-11-26 20:39:26.000000000 +0100 @@ -1,9 +1,9 @@ CC =gcc -CFLAGS =-O -Wall -fstrength-reduce -fcombine-regs -fomit-frame-pointer \ +CFLAGS =-O -Wall -fstrength-reduce -fomit-frame-pointer \ -finline-functions -nostdinc -I../include -AS =gas -AR =gar -LD =gld +AS =as +AR =ar +LD =ld CPP =gcc -E -nostdinc -I../include .c.o: diff -Naur linux-0.01-rm-1.7/mm/memory.c linux-0.01-rm-2.0/mm/memory.c --- linux-0.01-rm-1.7/mm/memory.c 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/mm/memory.c 2007-11-26 20:38:54.000000000 +0100 @@ -26,7 +26,7 @@ #endif #define copy_page(from,to) \ -__asm__("cld ; rep ; movsl"::"S" (from),"D" (to),"c" (1024):"cx","di","si") +__asm__("cld ; rep ; movsl"::"S" (from),"D" (to),"c" (1024)/*:"cx","di","si"*/) static unsigned short mem_map [ PAGING_PAGES ] = {0,}; @@ -36,7 +36,7 @@ */ unsigned long get_free_page(void) { -register unsigned long __res asm("ax"); +register unsigned long __res;// asm("ax"); __asm__("std ; repne ; scasw\n\t" "jne 1f\n\t" @@ -52,7 +52,7 @@ :"=a" (__res) :"0" (0),"i" (LOW_MEM),"c" (PAGING_PAGES), "D" (mem_map+PAGING_PAGES-1) - :"di","cx","dx"); + :/*"di","cx",*/"dx"); return __res; } diff -Naur linux-0.01-rm-1.7/mm/page.s linux-0.01-rm-2.0/mm/page.s --- linux-0.01-rm-1.7/mm/page.s 2007-12-23 19:00:53.000000000 +0100 +++ linux-0.01-rm-2.0/mm/page.s 2007-11-26 21:59:33.000000000 +0100 @@ -3,9 +3,9 @@ * the real work is done in mm.c */ -.globl _page_fault +.globl page_fault -_page_fault: +page_fault: xchgl %eax,(%esp) pushl %ecx pushl %edx @@ -21,9 +21,9 @@ pushl %eax testl $1,%eax jne 1f - call _do_no_page + call do_no_page jmp 2f -1: call _do_wp_page +1: call do_wp_page 2: addl $8,%esp pop %fs pop %es diff -Naur linux-0.01-rm-1.7/tools/build.c linux-0.01-rm-2.0/tools/build.c --- linux-0.01-rm-1.7/tools/build.c 2007-12-23 19:16:33.000000000 +0100 +++ linux-0.01-rm-2.0/tools/build.c 2007-12-23 19:26:15.000000000 +0100 @@ -55,10 +55,10 @@ if ((id=open(argv[2],O_RDONLY,0))<0) die("Unable to open 'system'"); - if (read(id,buf,GCC_HEADER) != GCC_HEADER) - die("Unable to read header of 'system'"); - if (((long *) buf)[5] != 0) - die("Non-GCC header of 'system'"); +// if (read(id,buf,GCC_HEADER) != GCC_HEADER) +// die("Unable to read header of 'system'"); +// if (((long *) buf)[5] != 0) +// die("Non-GCC header of 'system'"); for (i=0 ; (c=read(id,buf,sizeof buf))>0 ; i+=c ) if (write(1,buf,c)!=c) die("Write call failed");