diff --git a/一些非必要的资料/Intel手册/IA-32架构软件开发人员指南:卷3 (中文版-部分).pdf b/一些非必要的资料/Intel手册/IA-32架构软件开发人员指南:卷3 (中文版-部分).pdf new file mode 100644 index 0000000..1c13cb9 Binary files /dev/null and b/一些非必要的资料/Intel手册/IA-32架构软件开发人员指南:卷3 (中文版-部分).pdf differ diff --git a/一些非必要的资料/linux-0.11-devel-040329.zip b/一些非必要的资料/linux-0.11-devel-040329.zip deleted file mode 100644 index 7d7e93c..0000000 Binary files a/一些非必要的资料/linux-0.11-devel-040329.zip and /dev/null differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Bochs-2.1.1.exe b/一些非必要的资料/linux-0.11-quickstart/Bochs-2.1.1.exe new file mode 100644 index 0000000..fd66d6d Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Bochs-2.1.1.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/Boot.img b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/Boot.img new file mode 100644 index 0000000..289da87 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/Boot.img differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/Makefile new file mode 100644 index 0000000..8509edf --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/Makefile @@ -0,0 +1,184 @@ +# +# if you want the ram-disk device, define this to be the +# size in blocks. +# +RAMDISK = #-DRAMDISK=512 + +#AS86 =as86 -0 -a +#LD86 =ld86 -0 + +INC=boot +AS86 = nasm +DASM = ndisasm + +AS =as +LD =ld +#LDFLAGS = -m elf_i386 -Ttext 0 -e startup_32 +LDFLAGS = -m i386pe -Ttext 0 -e startup_32 -s -M --image-base 0x0000 +CC =gcc -march=i386 $(RAMDISK) +CFLAGS =-Wall -O2 -fomit-frame-pointer -fno-builtin + + + +CPP =cpp -nostdinc -Iinclude + +# +# ROOT_DEV specifies the default root-device when making the image. +# This can be either FLOPPY, /dev/xxxx or empty, in which case the +# default of /dev/hd6 is used by 'build'. +# +ROOT_DEV= #FLOPPY + +BLK_DRV_SRC = kernel/blk_drv/ll_rw_blk.c kernel/blk_drv/floppy.c \ + kernel/blk_drv/hd.c kernel/blk_drv/ramdisk.c + +CHR_DRV_SRC = kernel/chr_drv/tty_io.c kernel/chr_drv/console.c kernel/chr_drv/keyboard.s \ + kernel/chr_drv/serial.c kernel/chr_drv/rs_io.s \ + kernel/chr_drv/tty_ioctl.s + +KERNEL_SRC = kernel/sched.c kernel/system_call.s kernel/traps.s kernel/asm.s kernel/fork.c \ + kernel/panic.c kernel/printk.c kernel/vsprintf.c kernel/sys.c kernel/exit.c \ + kernel/signal.c kernel/mktime.c + +MM_SRC = mm/memory.c mm/page.s + +FS_SRC= fs/open.c fs/read_write.c fs/inode.c fs/file_table.c fs/buffer.c fs/super.c \ + fs/block_dev.c fs/char_dev.c fs/file_dev.c fs/stat.c fs/exec.c fs/pipe.c fs/namei.c \ + fs/bitmap.c fs/fcntl.c fs/ioctl.c fs/truncate.c + +LIB_SRC = lib/ctype.c lib/_exit.c lib/open.c lib/close.c lib/errno.c lib/write.c lib/dup.c lib/setsid.c \ + lib/execve.c lib/wait.c lib/string.c lib/malloc.c + +ARCHIVES=kernel/kernel.o mm/mm.o fs/fs.o +#ARCHIVES=$(KERNEL_OBJS) mm/mm.o fs/fs.o + +DRIVERS =kernel/blk_drv/blk_drv.a kernel/chr_drv/chr_drv.a + +MATH =kernel/math/math.a +LIBS =lib/lib.a + +.c.s: + $(CC) $(CFLAGS) \ + -nostdinc -Iinclude -S -o $*.s $< +.s.o: + $(AS) -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -nostdinc -Iinclude -c -o $*.o $< + +all: Boot.img + +KERNEL_FILE = tools/system.exe + +tools/system.bin : tools/system.exe + tools/Trans.exe tools/System.exe tools/system.bin + +Boot.img: boot/bootsect.bin boot/setup.bin $(KERNEL_FILE) tools/build.exe Makefile +# objcopy -O binary -R .note -R .comment tools/system tools/kernel + tools\build.exe boot/bootsect.bin boot/setup.bin $(KERNEL_FILE) $(ROOT_DEV) +# rm tools/kernel -f +# sync +# del tools\kernel + +disk: Image + dd bs=8192 if=Image of=/dev/fd0 + +tools/build.exe: tools/build.c + $(CC) $(CFLAGS) -o tools/build tools/build.c + +boot/head.o: boot/head.s + gcc -I./include -traditional -c boot/head.s -o boot/head.o +# move head.o boot/ + +tools/system.exe: boot/head.o init/main.o \ + $(ARCHIVES) $(DRIVERS) $(MATH) $(LIBS) + $(LD) $(LDFLAGS) boot/head.o init/main.o \ + $(ARCHIVES) \ + $(DRIVERS) \ + $(MATH) \ + $(LIBS) \ + -o tools/system.exe >system.map +# nm tools/system | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aU] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)'| sort > System.map + +kernel/math/math.a:kernel/math/math_emulate.o +# (cd kernel/math ; make) + (cd kernel/math & make) + +kernel/blk_drv/blk_drv.a:$(BLK_DRV_SRC) +# (cd kernel/blk_drv ; make) + (cd kernel/blk_drv & make) + +kernel/chr_drv/chr_drv.a:$(CHR_DRV_SRC) +# (cd kernel/chr_drv ; make) + (cd kernel/chr_drv & make) + +kernel/kernel.o:$(KERNEL_SRC) +# (cd kernel; make) + (cd kernel & make) + +mm/mm.o:$(MM_SRC) +# (cd mm; make) + (cd mm & make) + +fs/fs.o:$(FS_SRC) +# (cd fs; make) + (cd fs & make) + +lib/lib.a:$(LIB_SRC) + (cd lib & make) + +boot/setup.bin: boot/setup.asm + $(AS86) -I"$(INC)"\ -o boot/setup.bin boot/setup.asm + $(DASM) -b 16 boot/setup.bin >boot/setup.disasm +# $(LD86) -s -o boot/setup boot/setup.o + +boot/bootsect.bin: boot/bootsect.asm + $(AS86) -I"$(INC)"\ -o boot/bootsect.bin boot/bootsect.asm + $(DASM) -b 16 boot/bootsect.bin >boot/bootsect.disasm +# $(LD86) -s -o boot/bootsect boot/bootsect.o + +tmp.s: boot/bootsect.s tools/system +# (echo -n "SYSSIZE = (";ls -l tools/system | grep system \ +# | cut -c25-31 | tr '\012' ' '; echo "+ 15 ) / 16") > tmp.s + cat boot/bootsect.s >> tmp.s + +clean: +# rm -f Image System.map tmp_make core boot/bootsect boot/setup +# rm -f init/*.o tools/system tools/build boot/*.o +# (cd mm;make clean) +# (cd fs;make clean) +# (cd kernel;make clean) +# (cd lib;make clean) + @del /S /Q *.a *.o system.map tools\system.exe +# del Image System.map tmp_make core boot\bootsect boot\setup +# del init\*.o tools\system tools\build boot\*.o +# (cd mm & make clean) +# (cd fs & make clean) +# (cd kernel & make clean) +# (cd lib &make clean) + + +backup: clean + (cd .. ; tar cf - linux | compress16 - > backup.Z) + sync + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done) >> tmp_make +# cp tmp_make Makefile +# (cd fs; make dep) +# (cd kernel; make dep) +# (cd mm; make dep) + + copy tmp_make Makefile + (cd fs & make dep) + (cd kernel & make dep) + (cd mm & make dep) + +### Dependencies: +init/main.o: init/main.c include/unistd.h include/sys/stat.h \ + include/sys/types.h include/sys/times.h include/sys/utsname.h \ + include/utime.h include/time.h include/linux/tty.h include/termios.h \ + include/linux/sched.h include/linux/head.h include/linux/fs.h \ + include/linux/mm.h include/signal.h include/asm/system.h \ + include/asm/io.h include/stddef.h include/stdarg.h include/fcntl.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/MinGW32.bat.lnk b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/MinGW32.bat.lnk new file mode 100644 index 0000000..e16f2bc Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/MinGW32.bat.lnk differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/bochsout.txt b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/bochsout.txt new file mode 100644 index 0000000..b8b60ec --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/bochsout.txt @@ -0,0 +1,92 @@ +00000000000i[ ] Bochs x86 Emulator 2.1.1 +00000000000i[ ] February 08, 2004 +00000000000i[ ] System configuration +00000000000i[ ] processors: 1 +00000000000i[ ] A20 line support: yes +00000000000i[ ] APIC support: no +00000000000i[ ] CPU configuration +00000000000i[ ] level: 5 +00000000000i[ ] fpu support: yes +00000000000i[ ] paging support: yes, tlb enabled: yes +00000000000i[ ] mmx support: yes +00000000000i[ ] sse support: no +00000000000i[ ] v8086 mode support: yes +00000000000i[ ] 3dnow! support: no +00000000000i[ ] PAE support: no +00000000000i[ ] PGE support: no +00000000000i[ ] PSE support: no +00000000000i[ ] x86-64 support: no +00000000000i[ ] SEP support: no +00000000000i[ ] Optimization configuration +00000000000i[ ] Guest2HostTLB support: yes +00000000000i[ ] RepeatSpeedups support: yes +00000000000i[ ] Icache support: yes +00000000000i[ ] Host Asm support: yes +00000000000i[MEM0 ] allocated memory at 00CC0020. after alignment, vector=00CC1000 +00000000000i[MEM0 ] 32.00MB +00000000000i[MEM0 ] rom at 0xf0000/65536 ('C:\Program Files\Bochs-2.1.1/BIOS-bochs-latest') +00000000000i[MEM0 ] rom at 0xc0000/32768 ('C:\Program Files\Bochs-2.1.1/VGABIOS-elpin-2.40') +00000000000i[CMOS ] Using local time for initial clock +00000000000i[CMOS ] Setting initial clock to: Sat Sep 01 16:44:40 2012 (time0=1346489080) +00000000000i[DMA ] channel 4 used by cascade +00000000000i[DMA ] channel 2 used by Floppy Drive +00000000000i[FDD ] fd0: 'boot.img' ro=0, h=2,t=80,spt=18 +00000000000i[WGUI ] IME disabled +00000000000i[KMAP ] Loading keymap from 'C:\Program Files\Bochs-2.1.1/keymaps/x11-pc-us.map' +00000000000i[KMAP ] Loaded 168 symbols +00000000000i[VGA ] interval=30000 +00000000000i[VGA ] VBE Bochs Display Extension Enabled +00000000000i[ ] init_mem of 'harddrv' plugin device by virtual method +00000000000i[ ] init_mem of 'keyboard' plugin device by virtual method +00000000000i[ ] init_mem of 'serial' plugin device by virtual method +00000000000i[ ] init_mem of 'parallel' plugin device by virtual method +00000000000i[ ] init_mem of 'extfpuirq' plugin device by virtual method +00000000000i[ ] init_mem of 'gameport' plugin device by virtual method +00000000000i[ ] init_dev of 'harddrv' plugin device by virtual method +00000000000i[HD ] Boot device will be 'a' +00000000000i[HD ] Floppy boot signature check is enabled +00000000000i[ ] init_dev of 'keyboard' plugin device by virtual method +00000000000i[KBD ] will paste characters every 1000 keyboard ticks +00000000000i[ ] init_dev of 'serial' plugin device by virtual method +00000000000i[SER ] com1 at 0x03f8 irq 4 +00000000000i[ ] init_dev of 'parallel' plugin device by virtual method +00000000000i[PAR ] parallel port 1 at 0x378 irq 7 +00000000000i[ ] init_dev of 'extfpuirq' plugin device by virtual method +00000000000i[ ] init_dev of 'gameport' plugin device by virtual method +00000000000i[ ] reset of 'harddrv' plugin device by virtual method +00000000000i[ ] reset of 'keyboard' plugin device by virtual method +00000000000i[ ] reset of 'serial' plugin device by virtual method +00000000000i[ ] reset of 'parallel' plugin device by virtual method +00000000000i[ ] reset of 'extfpuirq' plugin device by virtual method +00000000000i[ ] reset of 'gameport' plugin device by virtual method +00000004325i[BIOS ] rombios.c,v 1.103.2.2 2004/02/02 22:39:22 cbothamy Exp $ +00000330074i[KBD ] reset-disable command received +00000390000i[WGUI ] dimension update x=720 y=400 fontheight=16 fontwidth=9 bpp=8 +00002359908e[HD ] device set to 0 which does not exist +00002360201e[HD ] device set to 1 which does not exist +00002625206e[DEV ] write to port 0x03f2 with len 2 ignored +00002629787i[BIOS ] int13_harddisk: function 15, unmapped device for DL=81 +00016270000i[FDD ] fd0: 'boot.img' ro=0, h=2,t=80,spt=18 +00016270000i[FDD ] fd0: 'D:\linux-0.11\Linux-0.11-With-PE-Loader\rootimage-0.11.img' ro=0, h=2,t=80,spt=18 +00016270000i[FDD ] fd0: 'D:\linux-0.11\Linux-0.11-With-PE-Loader\rootimage-0.11.img' ro=0, h=2,t=80,spt=18 +00159822000p[WGUI ] >>PANIC<< POWER button turned off. +00159822000i[SYS ] Last time is 1346489399 +00159822000i[CPU ] protected mode +00159822000i[CPU ] CS.d_b = 32 bit +00159822000i[CPU ] SS.d_b = 32 bit +00159822000i[CPU ] | EAX=00000000 EBX=ffffffff ECX=0001a248 EDX=00000036 +00159822000i[CPU ] | ESP=0001a108 EBP=0000013b ESI=00000000 EDI=0001fca0 +00159822000i[CPU ] | IOPL=0 NV UP EI PL ZR NA PE NC +00159822000i[CPU ] | SEG selector base limit G D +00159822000i[CPU ] | SEG sltr(index|ti|rpl) base limit G D +00159822000i[CPU ] | DS:0010( 0002| 0| 0) 00000000 00000fff 1 1 +00159822000i[CPU ] | ES:0010( 0002| 0| 0) 00000000 00000fff 1 1 +00159822000i[CPU ] | FS:0017( 0002| 1| 3) 00000000 0000009f 1 1 +00159822000i[CPU ] | GS:0017( 0002| 1| 3) 00000000 0000009f 1 1 +00159822000i[CPU ] | SS:0010( 0002| 0| 0) 00000000 00000fff 1 1 +00159822000i[CPU ] | CS:0008( 0001| 0| 0) 00000000 00000fff 1 1 +00159822000i[CPU ] | EIP=00006afb (00006afb) +00159822000i[CPU ] | CR0=0x8000001b CR1=0x00000000 CR2=0x080424cc +00159822000i[CPU ] | CR3=0x00000000 CR4=0x00000000 +00159822000i[ ] restoring default signal behavior +00159822000i[CTRL ] quit_sim called with exit code 1 diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/bochsrc.bxrc b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/bochsrc.bxrc new file mode 100644 index 0000000..c977d97 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/bochsrc.bxrc @@ -0,0 +1,26 @@ +############################################################### +# bochsrc.bxrc file for Tinix. +############################################################### + +# how much memory the emulated machine will have +megs: 32 + +# filename of ROM images +romimage: file=$BXSHARE/BIOS-bochs-latest, address=0xf0000 +vgaromimage: $BXSHARE/VGABIOS-elpin-2.40 + +# what disk images will be used +floppya: 1_44=boot.img, status=inserted +#floppyb: 1_44=rootimage-0.11.img, status=inserted + +# choose the boot disk. +boot: a + +# where do we send log messages? +log: bochsout.txt + +# disable the mouse, since Tinix is text only +mouse: enabled=0 + +# enable key mapping, using US layout as default. +keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-us.map diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.asm b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.asm new file mode 100644 index 0000000..b8ad580 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.asm @@ -0,0 +1,246 @@ +; +; SYS_SIZE is the number of clicks (16 bytes) to be loaded. +; 0x3000 is 0x30000 bytes = 196kB, more than enough for current +; versions of linux +; +SYSSIZE equ 0x3000 +; +; bootsect.s (C) 1991 Linus Torvalds +; +; bootsect.s is loaded at 0x7c00 by the bios-startup routines, and moves +; iself out of the way to address 0x90000, and jumps there. +; +; It then loads 'setup' directly after itself (0x90200), and the system +; at 0x10000, using BIOS interrupts. +; +; NOTE! currently system is at most 8*65536 bytes long. This should be no +; problem, even in the future. I want to keep it simple. This 512 kB +; kernel size should be enough, especially as this doesn't contain the +; buffer cache as in minix +; +; The loader has been made as simple as possible, and continuos +; read errors will result in a unbreakable loop. Reboot by hand. It +; loads pretty fast by getting whole sectors at a time whenever possible. + + +SETUPLEN equ 4 ; nr of setup-sectors +BOOTSEG equ 0x07c0 ; original address of boot-sector +INITSEG equ 0x9000 ; we move boot here - out of the way +SETUPSEG equ 0x9020 ; setup starts here +SYSSEG equ 0x1000 ; system loaded at 0x10000 (65536). +ENDSEG equ SYSSEG + SYSSIZE ; where to stop loading + +; ROOT_DEV: 0x000 - same type of floppy as boot. +; 0x301 - first partition on first drive etc +ROOT_DEV equ 0x306 +[section .s16] +[BITS 16] +_start: + mov ax,BOOTSEG + mov ds,ax + mov ax,INITSEG + mov es,ax + mov cx,256 + sub si,si + sub di,di + rep + movsw + jmp INITSEG:go +go: mov ax,cs + mov ds,ax + mov es,ax +; put stack at 0x9ff00. + mov ss,ax + mov sp,0xFF00 ; arbitrary value >>512 + +; load the setup-sectors directly after the bootblock. +; Note that 'es' is already set up. + +load_setup: + mov dx,0x0000 ; drive 0, head 0 + mov cx,0x0002 ; sector 2, track 0 + mov bx,0x0200 ; address = 512, in INITSEG + mov ax,0x0200+SETUPLEN ; service 2, nr of sectors + int 0x13 ; read it + jnc ok_load_setup ; ok - continue + mov dx,0x0000 + mov ax,0x0000 ; reset the diskette + int 0x13 + jmp load_setup + +ok_load_setup: + +; Get disk drive parameters, specifically nr of sectors/track + + mov dl,0x00 + mov ax,0x0800 ; AH=8 is get drive parameters + int 0x13 + mov ch,0x00 +; seg cs + mov [sectors],cx + mov ax,INITSEG + mov es,ax + +; Print some inane message + + mov ah,0x03 ; read cursor pos + xor bh,bh + int 0x10 + + mov cx,24 + mov bx,0x0007 ; page 0, attribute 7 (normal) + mov bp,msg1 + mov ax,0x1301 ; write string, move cursor + int 0x10 + +; ok, we've written the message, now +; we want to load the system (at 0x10000) + + mov ax,SYSSEG + mov es,ax ; segment of 0x010000 + call read_it + call kill_motor + +; After that we check which root-device to use. If the device is +; defined (;= 0), nothing is done and the given device is used. +; Otherwise, either /dev/PS0 (2,28) or /dev/at0 (2,8), depending +; on the number of sectors that the BIOS reports currently. + +; seg cs + mov ax,[root_dev] + cmp ax,0 + jne root_defined +; seg cs + mov bx,[sectors] + mov ax,0x0208 ; /dev/ps0 - 1.2Mb + cmp bx,15 + je root_defined + mov ax,0x021c ; /dev/PS0 - 1.44Mb + cmp bx,18 + je root_defined +undef_root: + jmp undef_root +root_defined: +; seg cs + mov [root_dev],ax + +; after that (everyting loaded), we jump to +; the setup-routine loaded directly after +; the bootblock: + + jmp SETUPSEG:0 + +; This routine loads the system at address 0x10000, making sure +; no 64kB boundaries are crossed. We try to load it as fast as +; possible, loading whole tracks whenever we can. +; +; in: es - starting address segment (normally 0x1000) +; +sread: dw 1+SETUPLEN ; sectors read of current track +head: dw 0 ; current head +track: dw 0 ; current track + +read_it: + mov ax,es + test ax,0x0fff +die: jne die ; es must be at 64kB boundary + xor bx,bx ; bx is starting address within segment +rp_read: + mov ax,es + cmp ax,ENDSEG ; have we loaded all yet? + jb ok1_read + ret +ok1_read: +; seg cs + mov ax,[sectors] + sub ax,[sread] + mov cx,ax + shl cx,9 + add cx,bx + jnc ok2_read + je ok2_read + xor ax,ax + sub ax,bx + shr ax,9 +ok2_read: + call read_track + mov cx,ax + add ax,[sread] +; seg cs + cmp ax,[sectors] + jne ok3_read + mov ax,1 + sub ax,[head] + jne ok4_read + inc word [track] +ok4_read: + mov [head],ax + xor ax,ax +ok3_read: + mov [sread],ax + shl cx,9 + add bx,cx + jnc rp_read + mov ax,es + add ax,0x1000 + mov es,ax + xor bx,bx + jmp rp_read + +read_track: + push ax + push bx + push cx + push dx + mov dx,[track] + mov cx,[sread] + inc cx + mov ch,dl + mov dx,[head] + mov dh,dl + mov dl,0 + and dx,0x0100 + mov ah,2 + int 0x13 + jc bad_rt + pop dx + pop cx + pop bx + pop ax + ret +bad_rt: mov ax,0 + mov dx,0 + int 0x13 + pop dx + pop cx + pop bx + pop ax + jmp read_track + +;/* +; * This procedure turns off the floppy drive motor, so +; * that we enter the kernel in a known state, and +; * don't have to worry about it later. +; */ +kill_motor: + push dx + mov dx,0x3f2 + mov al,0 + out dx,ax + pop dx + ret + +sectors: + dw 0 + +msg1: + db 13,10 + db "Loading System ..." + db 13,10,13,10 + +times 508-($-$$) db 0 +root_dev: + dw ROOT_DEV +boot_flag: + dw 0xAA55 + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.asm.bak b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.asm.bak new file mode 100644 index 0000000..5d88e06 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.asm.bak @@ -0,0 +1,246 @@ +; +; SYS_SIZE is the number of clicks (16 bytes) to be loaded. +; 0x3000 is 0x30000 bytes = 196kB, more than enough for current +; versions of linux +; +SYSSIZE equ 0x3000 +; +; bootsect.s (C) 1991 Linus Torvalds +; +; bootsect.s is loaded at 0x7c00 by the bios-startup routines, and moves +; iself out of the way to address 0x90000, and jumps there. +; +; It then loads 'setup' directly after itself (0x90200), and the system +; at 0x10000, using BIOS interrupts. +; +; NOTE! currently system is at most 8*65536 bytes long. This should be no +; problem, even in the future. I want to keep it simple. This 512 kB +; kernel size should be enough, especially as this doesn't contain the +; buffer cache as in minix +; +; The loader has been made as simple as possible, and continuos +; read errors will result in a unbreakable loop. Reboot by hand. It +; loads pretty fast by getting whole sectors at a time whenever possible. + + +SETUPLEN equ 4 ; nr of setup-sectors +BOOTSEG equ 0x07c0 ; original address of boot-sector +INITSEG equ 0x9000 ; we move boot here - out of the way +SETUPSEG equ 0x9020 ; setup starts here +SYSSEG equ 0x1000 ; system loaded at 0x10000 (65536). +ENDSEG equ SYSSEG + SYSSIZE ; where to stop loading + +; ROOT_DEV: 0x000 - same type of floppy as boot. +; 0x301 - first partition on first drive etc +ROOT_DEV equ 0x306 +[section .s16] +[BITS 16] +_start: + mov ax,BOOTSEG + mov ds,ax + mov ax,INITSEG + mov es,ax + mov cx,256 + sub si,si + sub di,di + rep + movsw + jmp INITSEG:go +go: mov ax,cs + mov ds,ax + mov es,ax +; put stack at 0x9ff00. + mov ss,ax + mov sp,0xFF00 ; arbitrary value >>512 + +; load the setup-sectors directly after the bootblock. +; Note that 'es' is already set up. + +load_setup: + mov dx,0x0000 ; drive 0, head 0 + mov cx,0x0002 ; sector 2, track 0 + mov bx,0x0200 ; address = 512, in INITSEG + mov ax,0x0200+SETUPLEN ; service 2, nr of sectors + int 0x13 ; read it + jnc ok_load_setup ; ok - continue + mov dx,0x0000 + mov ax,0x0000 ; reset the diskette + int 0x13 + jmp load_setup + +ok_load_setup: + +; Get disk drive parameters, specifically nr of sectors/track + + mov dl,0x00 + mov ax,0x0800 ; AH=8 is get drive parameters + int 0x13 + mov ch,0x00 +; seg cs + mov [sectors],cx + mov ax,INITSEG + mov es,ax + +; Print some inane message + + mov ah,0x03 ; read cursor pos + xor bh,bh + int 0x10 + + mov cx,24 + mov bx,0x0007 ; page 0, attribute 7 (normal) + mov bp,msg1 + mov ax,0x1301 ; write string, move cursor + int 0x10 + +; ok, we've written the message, now +; we want to load the system (at 0x10000) + + mov ax,SYSSEG + mov es,ax ; segment of 0x010000 + call read_it + call kill_motor + +; After that we check which root-device to use. If the device is +; defined (;= 0), nothing is done and the given device is used. +; Otherwise, either /dev/PS0 (2,28) or /dev/at0 (2,8), depending +; on the number of sectors that the BIOS reports currently. + +; seg cs + mov ax,[root_dev] + cmp ax,0 + jne root_defined +; seg cs + mov bx,[sectors] + mov ax,0x0208 ; /dev/ps0 - 1.2Mb + cmp bx,15 + je root_defined + mov ax,0x021c ; /dev/PS0 - 1.44Mb + cmp bx,18 + je root_defined +undef_root: + jmp undef_root +root_defined: +; seg cs + mov [root_dev],ax + +; after that (everyting loaded), we jump to +; the setup-routine loaded directly after +; the bootblock: + + jmp SETUPSEG:0 + +; This routine loads the system at address 0x10000, making sure +; no 64kB boundaries are crossed. We try to load it as fast as +; possible, loading whole tracks whenever we can. +; +; in: es - starting address segment (normally 0x1000) +; +sread: dw 1+SETUPLEN ; sectors read of current track +head: dw 0 ; current head +track: dw 0 ; current track + +read_it: + mov ax,es + test ax,0x0fff +die: jne die ; es must be at 64kB boundary + xor bx,bx ; bx is starting address within segment +rp_read: + mov ax,es + cmp ax,ENDSEG ; have we loaded all yet? + jb ok1_read + ret +ok1_read: +; seg cs + mov ax,[sectors] + sub ax,[sread] + mov cx,ax + shl cx,9 + add cx,bx + jnc ok2_read + je ok2_read + xor ax,ax + sub ax,bx + shr ax,9 +ok2_read: + call read_track + mov cx,ax + add ax,[sread] +; seg cs + cmp ax,[sectors] + jne ok3_read + mov ax,1 + sub ax,[head] + jne ok4_read + inc word [track] +ok4_read: + mov [head],ax + xor ax,ax +ok3_read: + mov [sread],ax + shl cx,9 + add bx,cx + jnc rp_read + mov ax,es + add ax,0x1000 + mov es,ax + xor bx,bx + jmp rp_read + +read_track: + push ax + push bx + push cx + push dx + mov dx,[track] + mov cx,[sread] + inc cx + mov ch,dl + mov dx,[head] + mov dh,dl + mov dl,0 + and dx,0x0100 + mov ah,2 + int 0x13 + jc bad_rt + pop dx + pop cx + pop bx + pop ax + ret +bad_rt: mov ax,0 + mov dx,0 + int 0x13 + pop dx + pop cx + pop bx + pop ax + jmp read_track + +;/* +; * This procedure turns off the floppy drive motor, so +; * that we enter the kernel in a known state, and +; * don't have to worry about it later. +; */ +kill_motor: + push dx + mov dx,0x3f2 + mov al,0 + out dx,ax + pop dx + ret + +sectors: + dw 0 + +msg1: + db 13,10 + db "Loading system ..." + db 13,10,13,10 + +times 508-($-$$) db 0 +root_dev: + dw ROOT_DEV +boot_flag: + dw 0xAA55 + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.bin b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.bin new file mode 100644 index 0000000..4961e58 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.bin differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.disasm b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.disasm new file mode 100644 index 0000000..bf81a4f --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/bootsect.disasm @@ -0,0 +1,227 @@ +00000000 B8C007 mov ax,0x7c0 +00000003 8ED8 mov ds,ax +00000005 B80090 mov ax,0x9000 +00000008 8EC0 mov es,ax +0000000A B90001 mov cx,0x100 +0000000D 29F6 sub si,si +0000000F 29FF sub di,di +00000011 F3A5 rep movsw +00000013 EA18000090 jmp word 0x9000:0x18 +00000018 8CC8 mov ax,cs +0000001A 8ED8 mov ds,ax +0000001C 8EC0 mov es,ax +0000001E 8ED0 mov ss,ax +00000020 BC00FF mov sp,0xff00 +00000023 BA0000 mov dx,0x0 +00000026 B90200 mov cx,0x2 +00000029 BB0002 mov bx,0x200 +0000002C B80402 mov ax,0x204 +0000002F CD13 int 0x13 +00000031 730A jnc 0x3d +00000033 BA0000 mov dx,0x0 +00000036 B80000 mov ax,0x0 +00000039 CD13 int 0x13 +0000003B EBE6 jmp short 0x23 +0000003D B200 mov dl,0x0 +0000003F B80008 mov ax,0x800 +00000042 CD13 int 0x13 +00000044 B500 mov ch,0x0 +00000046 890E3901 mov [0x139],cx +0000004A B80090 mov ax,0x9000 +0000004D 8EC0 mov es,ax +0000004F B403 mov ah,0x3 +00000051 30FF xor bh,bh +00000053 CD10 int 0x10 +00000055 B91800 mov cx,0x18 +00000058 BB0700 mov bx,0x7 +0000005B BD3B01 mov bp,0x13b +0000005E B80113 mov ax,0x1301 +00000061 CD10 int 0x10 +00000063 B80010 mov ax,0x1000 +00000066 8EC0 mov es,ax +00000068 E83100 call word 0x9c +0000006B E8C200 call word 0x130 +0000006E A1FC01 mov ax,[0x1fc] +00000071 3D0000 cmp ax,0x0 +00000074 7518 jnz 0x8e +00000076 8B1E3901 mov bx,[0x139] +0000007A B80802 mov ax,0x208 +0000007D 81FB0F00 cmp bx,0xf +00000081 740B jz 0x8e +00000083 B81C02 mov ax,0x21c +00000086 81FB1200 cmp bx,0x12 +0000008A 7402 jz 0x8e +0000008C EBFE jmp short 0x8c +0000008E A3FC01 mov [0x1fc],ax +00000091 EA00002090 jmp word 0x9020:0x0 +00000096 050000 add ax,0x0 +00000099 0000 add [bx+si],al +0000009B 008CC0A9 add [si-0x5640],cl +0000009F FF0F dec word [bx] +000000A1 75FE jnz 0xa1 +000000A3 31DB xor bx,bx +000000A5 8CC0 mov ax,es +000000A7 3D0040 cmp ax,0x4000 +000000AA 7201 jc 0xad +000000AC C3 ret +000000AD A13901 mov ax,[0x139] +000000B0 2B069600 sub ax,[0x96] +000000B4 89C1 mov cx,ax +000000B6 C1E109 shl cx,0x9 +000000B9 01D9 add cx,bx +000000BB 7309 jnc 0xc6 +000000BD 7407 jz 0xc6 +000000BF 31C0 xor ax,ax +000000C1 29D8 sub ax,bx +000000C3 C1E809 shr ax,0x9 +000000C6 E83300 call word 0xfc +000000C9 89C1 mov cx,ax +000000CB 03069600 add ax,[0x96] +000000CF 3B063901 cmp ax,[0x139] +000000D3 7512 jnz 0xe7 +000000D5 B80100 mov ax,0x1 +000000D8 2B069800 sub ax,[0x98] +000000DC 7504 jnz 0xe2 +000000DE FF069A00 inc word [0x9a] +000000E2 A39800 mov [0x98],ax +000000E5 31C0 xor ax,ax +000000E7 A39600 mov [0x96],ax +000000EA C1E109 shl cx,0x9 +000000ED 01CB add bx,cx +000000EF 73B4 jnc 0xa5 +000000F1 8CC0 mov ax,es +000000F3 050010 add ax,0x1000 +000000F6 8EC0 mov es,ax +000000F8 31DB xor bx,bx +000000FA EBA9 jmp short 0xa5 +000000FC 50 push ax +000000FD 53 push bx +000000FE 51 push cx +000000FF 52 push dx +00000100 8B169A00 mov dx,[0x9a] +00000104 8B0E9600 mov cx,[0x96] +00000108 41 inc cx +00000109 88D5 mov ch,dl +0000010B 8B169800 mov dx,[0x98] +0000010F 88D6 mov dh,dl +00000111 B200 mov dl,0x0 +00000113 81E20001 and dx,0x100 +00000117 B402 mov ah,0x2 +00000119 CD13 int 0x13 +0000011B 7205 jc 0x122 +0000011D 5A pop dx +0000011E 59 pop cx +0000011F 5B pop bx +00000120 58 pop ax +00000121 C3 ret +00000122 B80000 mov ax,0x0 +00000125 BA0000 mov dx,0x0 +00000128 CD13 int 0x13 +0000012A 5A pop dx +0000012B 59 pop cx +0000012C 5B pop bx +0000012D 58 pop ax +0000012E EBCC jmp short 0xfc +00000130 52 push dx +00000131 BAF203 mov dx,0x3f2 +00000134 B000 mov al,0x0 +00000136 EF out dx,ax +00000137 5A pop dx +00000138 C3 ret +00000139 0000 add [bx+si],al +0000013B 0D0A4C or ax,0x4c0a +0000013E 6F outsw +0000013F 61 popaw +00000140 64696E672053 imul bp,[fs:bp+0x67],word 0x5320 +00000146 7973 jns 0x1bb +00000148 7465 jz 0x1af +0000014A 6D insw +0000014B 202E2E2E and [0x2e2e],ch +0000014F 0D0A0D or ax,0xd0a +00000152 0A00 or al,[bx+si] +00000154 0000 add [bx+si],al +00000156 0000 add [bx+si],al +00000158 0000 add [bx+si],al +0000015A 0000 add [bx+si],al +0000015C 0000 add [bx+si],al +0000015E 0000 add [bx+si],al +00000160 0000 add [bx+si],al +00000162 0000 add [bx+si],al +00000164 0000 add [bx+si],al +00000166 0000 add [bx+si],al +00000168 0000 add [bx+si],al +0000016A 0000 add [bx+si],al +0000016C 0000 add [bx+si],al +0000016E 0000 add [bx+si],al +00000170 0000 add [bx+si],al +00000172 0000 add [bx+si],al +00000174 0000 add [bx+si],al +00000176 0000 add [bx+si],al +00000178 0000 add [bx+si],al +0000017A 0000 add [bx+si],al +0000017C 0000 add [bx+si],al +0000017E 0000 add [bx+si],al +00000180 0000 add [bx+si],al +00000182 0000 add [bx+si],al +00000184 0000 add [bx+si],al +00000186 0000 add [bx+si],al +00000188 0000 add [bx+si],al +0000018A 0000 add [bx+si],al +0000018C 0000 add [bx+si],al +0000018E 0000 add [bx+si],al +00000190 0000 add [bx+si],al +00000192 0000 add [bx+si],al +00000194 0000 add [bx+si],al +00000196 0000 add [bx+si],al +00000198 0000 add [bx+si],al +0000019A 0000 add [bx+si],al +0000019C 0000 add [bx+si],al +0000019E 0000 add [bx+si],al +000001A0 0000 add [bx+si],al +000001A2 0000 add [bx+si],al +000001A4 0000 add [bx+si],al +000001A6 0000 add [bx+si],al +000001A8 0000 add [bx+si],al +000001AA 0000 add [bx+si],al +000001AC 0000 add [bx+si],al +000001AE 0000 add [bx+si],al +000001B0 0000 add [bx+si],al +000001B2 0000 add [bx+si],al +000001B4 0000 add [bx+si],al +000001B6 0000 add [bx+si],al +000001B8 0000 add [bx+si],al +000001BA 0000 add [bx+si],al +000001BC 0000 add [bx+si],al +000001BE 0000 add [bx+si],al +000001C0 0000 add [bx+si],al +000001C2 0000 add [bx+si],al +000001C4 0000 add [bx+si],al +000001C6 0000 add [bx+si],al +000001C8 0000 add [bx+si],al +000001CA 0000 add [bx+si],al +000001CC 0000 add [bx+si],al +000001CE 0000 add [bx+si],al +000001D0 0000 add [bx+si],al +000001D2 0000 add [bx+si],al +000001D4 0000 add [bx+si],al +000001D6 0000 add [bx+si],al +000001D8 0000 add [bx+si],al +000001DA 0000 add [bx+si],al +000001DC 0000 add [bx+si],al +000001DE 0000 add [bx+si],al +000001E0 0000 add [bx+si],al +000001E2 0000 add [bx+si],al +000001E4 0000 add [bx+si],al +000001E6 0000 add [bx+si],al +000001E8 0000 add [bx+si],al +000001EA 0000 add [bx+si],al +000001EC 0000 add [bx+si],al +000001EE 0000 add [bx+si],al +000001F0 0000 add [bx+si],al +000001F2 0000 add [bx+si],al +000001F4 0000 add [bx+si],al +000001F6 0000 add [bx+si],al +000001F8 0000 add [bx+si],al +000001FA 0000 add [bx+si],al +000001FC 06 push es +000001FD 0355AA add dx,[di-0x56] diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/head.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/head.s new file mode 100644 index 0000000..7c534d8 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/head.s @@ -0,0 +1,240 @@ +/* + * linux/boot/head.s + * + * (C) 1991 Linus Torvalds + */ + +/* + * head.s contains the 32-bit startup code. + * + * NOTE!!! Startup happens at absolute address 0x00000000, which is also where + * the page directory will exist. The startup code will be overwritten by + * the page directory. + */ +.text +.globl _idt,_gdt,_pg_dir,_tmp_floppy_area +_pg_dir: +.globl startup_32 +startup_32: + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + mov %ax,%fs + mov %ax,%gs + lss _stack_start,%esp + call _setup_idt + call _setup_gdt + movl $0x10,%eax # reload all the segment registers + mov %ax,%ds # after changing gdt. CS was already + mov %ax,%es # reloaded in 'setup_gdt' + mov %ax,%fs + mov %ax,%gs + lss _stack_start,%esp + xorl %eax,%eax +1: incl %eax # check that A20 really IS enabled + movl %eax,0x000000 # loop forever if it isn't + cmpl %eax,0x100000 + je 1b + +/* + * NOTE! 486 should set bit 16, to check for write-protect in supervisor + * mode. Then it would be unnecessary with the "verify_area()"-calls. + * 486 users probably want to set the NE (#5) bit also, so as to use + * int 16 for math errors. + */ + movl %cr0,%eax # check math chip + andl $0x80000011,%eax # Save PG,PE,ET +/* "orl $0x10020,%eax" here for 486 might be good */ + orl $2,%eax # set MP + movl %eax,%cr0 + call check_x87 + jmp after_page_tables + +/* + * We depend on ET to be correct. This checks for 287/387. + */ +check_x87: + fninit + fstsw %ax + cmpb $0,%al + je 1f /* no coprocessor: have to set bits */ + movl %cr0,%eax + xorl $6,%eax /* reset MP, set EM */ + movl %eax,%cr0 + ret +.align 2 +1: .byte 0xDB,0xE4 /* fsetpm for 287, ignored by 387 */ + ret + +/* + * setup_idt + * + * sets up a idt with 256 entries pointing to + * ignore_int, interrupt gates. It then loads + * idt. Everything that wants to install itself + * in the idt-table may do so themselves. Interrupts + * are enabled elsewhere, when we can be relatively + * sure everything is ok. This routine will be over- + * written by the page tables. + */ +_setup_idt: + lea ignore_int,%edx + movl $0x00080000,%eax + movw %dx,%ax /* selector = 0x0008 = cs */ + movw $0x8E00,%dx /* interrupt gate - dpl=0, present */ + + lea _idt,%edi + mov $256,%ecx +rp_sidt: + movl %eax,(%edi) + movl %edx,4(%edi) + addl $8,%edi + dec %ecx + jne rp_sidt + lidt idt_descr + ret + +/* + * setup_gdt + * + * This routines sets up a new gdt and loads it. + * Only two entries are currently built, the same + * ones that were built in init.s. The routine + * is VERY complicated at two whole lines, so this + * rather long comment is certainly needed :-). + * This routine will beoverwritten by the page tables. + */ +_setup_gdt: + lgdt gdt_descr + ret + +/* + * I put the kernel page tables right after the page directory, + * using 4 of them to span 16 Mb of physical memory. People with + * more than 16MB will have to expand this. + */ +.org 0x1000 +pg0: + +.org 0x2000 +pg1: + +.org 0x3000 +pg2: + +.org 0x4000 +pg3: + +.org 0x5000 +/* + * tmp_floppy_area is used by the floppy-driver when DMA cannot + * reach to a buffer-block. It needs to be aligned, so that it isn't + * on a 64kB border. + */ +_tmp_floppy_area: + .fill 1024,1,0 + +after_page_tables: + pushl $0 # These are the parameters to main :-) + pushl $0 + pushl $0 + pushl $L6 # return address for main, if it decides to. + pushl $_start + jmp setup_paging +L6: + jmp L6 # main should never return here, but + # just in case, we know what happens. + +/* This is the default interrupt "handler" :-) */ +int_msg: + .asciz "Unknown interrupt\n\r" +.align 2 +ignore_int: + pushl %eax + pushl %ecx + pushl %edx + push %ds + push %es + push %fs + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + mov %ax,%fs + pushl $int_msg + call _printk + popl %eax + pop %fs + pop %es + pop %ds + popl %edx + popl %ecx + popl %eax + iret + + +/* + * Setup_paging + * + * This routine sets up paging by setting the page bit + * in cr0. The page tables are set up, identity-mapping + * the first 16MB. The pager assumes that no illegal + * addresses are produced (ie >4Mb on a 4Mb machine). + * + * NOTE! Although all physical memory should be identity + * mapped by this routine, only the kernel page functions + * use the >1Mb addresses directly. All "normal" functions + * use just the lower 1Mb, or the local data space, which + * will be mapped to some other place - mm keeps track of + * that. + * + * For those with more memory than 16 Mb - tough luck. I've + * not got it, why should you :-) The source is here. Change + * it. (Seriously - it shouldn't be too difficult. Mostly + * change some constants etc. I left it at 16Mb, as my machine + * even cannot be extended past that (ok, but it was cheap :-) + * I've tried to show which constants to change by having + * some kind of marker at them (search for "16Mb"), but I + * won't guarantee that's all :-( ) + */ +.align 2 +setup_paging: + movl $1024*5,%ecx /* 5 pages - pg_dir+4 page tables */ + 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 $pg2+7,_pg_dir+8 /* --------- " " --------- */ + movl $pg3+7,_pg_dir+12 /* --------- " " --------- */ + movl $pg3+4092,%edi + movl $0xfff007,%eax /* 16Mb - 4096 + 7 (r/w user,p) */ + std +1: stosl /* fill pages backwards - more efficient :-) */ + subl $0x1000,%eax + jge 1b + xorl %eax,%eax /* pg_dir is at 0x0000 */ + movl %eax,%cr3 /* cr3 - page directory start */ + movl %cr0,%eax + orl $0x80000000,%eax + movl %eax,%cr0 /* set paging (PG) bit */ + ret /* this also flushes prefetch-queue */ + +.align 2 +.word 0 +idt_descr: + .word 256*8-1 # idt contains 256 entries + .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 :^) + + .align 8 +_idt: .fill 256,8,0 # idt is uninitialized + +_gdt: .quad 0x0000000000000000 /* NULL descriptor */ + .quad 0x00c09a0000000fff /* 16Mb */ + .quad 0x00c0920000000fff /* 16Mb */ + .quad 0x0000000000000000 /* TEMPORARY - don't use */ + .fill 252,8,0 /* space for LDT's and TSS's etc */ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/pestruc.inc b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/pestruc.inc new file mode 100644 index 0000000..2961e1b --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/pestruc.inc @@ -0,0 +1,93 @@ +IMAGE_NUMBEROF_DIRECTORY_ENTRIES equ 16 +IMAGE_SIZEOF_SHORT_NAME equ 8 + + +STRUC IMAGE_FILE_HEADER +.Machine RESW 1 +.NumberOfSections RESW 1 +.TimeDateStamp RESD 1 +.PointerToSymbolTable RESD 1 +.NumberOfSymbols RESD 1 +.SizeOfOptionalHeader RESW 1 +.Characteristics RESW 1 +ENDSTRUC + +STRUC IMAGE_DATA_DIRECTORY +.VirtualAddress RESD 1 +.isize RESD 1 +ENDSTRUC + +STRUC IMAGE_OPTIONAL_HEADER32 + .Magic RESW 1 + .MajorLinkerVersion RESB 1 + .MinorLinkerVersion RESB 1 + .SizeOfCode RESD 1 + .SizeOfInitializedData RESD 1 + .SizeOfUninitializedData RESD 1 + .AddressOfEntryPoint RESD 1 + .BaseOfCode RESD 1 + .BaseOfData RESD 1 + .ImageBase RESD 1 + .SectionAlignment RESD 1 + .FileAlignment RESD 1 + .MajorOperatingSystemVersion RESW 1 + .MinorOperatingSystemVersion RESW 1 + .MajorImageVersion RESW 1 + .MinorImageVersion RESW 1 + .MajorSubsystemVersion RESW 1 + .MinorSubsystemVersion RESW 1 + .Win32VersionValue RESD 1 + .SizeOfImage RESD 1 + .SizeOfHeaders RESD 1 + .CheckSum RESD 1 + .Subsystem RESW 1 + .DllCharacteristics RESW 1 + .SizeOfStackReserve RESD 1 + .SizeOfStackCommit RESD 1 + .SizeOfHeapReserve RESD 1 + .SizeOfHeapCommit RESD 1 + .LoaderFlags RESD 1 + .NumberOfRvaAndSizes RESD 1 + .DataDirectory RESB IMAGE_DATA_DIRECTORY_size*16 + ENDSTRUC + +STRUC IMAGE_SECTION_HEADER + .Name1 RESB 8 + .VirtualSize RESD 1 + .VirtualAddress RESD 1 + .SizeOfRawData RESD 1 + .PointerToRawData RESD 1 + .PointerToRelocations RESD 1 + .PointerToLinenumbers RESD 1 + .NumberOfRelocations RESW 1 + .NumberOfLinenumbers RESW 1 + .Characteristics RESD 1 +ENDSTRUC + +STRUC IMAGE_NT_HEADERS + .Signature RESD 1 + .FileHeader RESB IMAGE_FILE_HEADER_size + .OptionalHeader RESB IMAGE_OPTIONAL_HEADER32_size +ENDSTRUC + +STRUC IMAGE_DOS_HEADER + .e_magic RESW 1 + .e_cblp RESW 1 + .e_cp RESW 1 + .e_crlc RESW 1 + .e_cparhdr RESW 1 + .e_minalloc RESW 1 + .e_maxalloc RESW 1 + .e_ss RESW 1 + .e_sp RESW 1 + .e_csum RESW 1 + .e_ip RESW 1 + .e_cs RESW 1 + .e_lfarlc RESW 1 + .e_ovno RESW 1 + .e_res4 RESW 4 + .e_oemid RESW 1 + .e_oeminfo RESW 1 + .e_res2 RESW 10 + .e_lfanew RESD 1 +ENDSTRUC \ No newline at end of file diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/pm.inc b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/pm.inc new file mode 100644 index 0000000..672a244 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/pm.inc @@ -0,0 +1,250 @@ + + +; ͼʾ + +; ߵַ͵ַ + +; | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +; |7654321076543210765432107654321076543210765432107654321076543210| <- 8 ֽ +; |--------========--------========--------========--------========| +; ששש +; 31..24 (ͼ) λַ(23..0) ν(15..0) +; +; ַ2۩ک ٩ַ1b ַ1a ν1 +; ǩ贈ש贈贈 +; %6 %5 %4 %3 %2 %1 +; ߩߩߩߩߩ +; \_________ +; \__________________ +; \________________________________________________ +; \ +; ששששששששששששששש +; 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 +; ǩ贈贈贈贈ߩߩߩ贈贈ߩ贈贈ߩߩߩ +; G D 0 AVL ν 2 (19..16) P DPL S TYPE +; ǩߩߩߩ贈贈ߩߩߩ +; : 2 : ν 2 : 1 +; ߩߩ +; ߵַ ͵ַ +; +; + +; ˵: +; +; (1) P: (Present)λ +; P=1 ʾԵַתЧģ˵ĶδڣڴУ +; P=0 ʾԵַתЧöβڡʹøڴʱ쳣 +; +; (2) DPL: ʾȨ(Descriptor Privilege level)2λ涨εȨȨ飬ԾԸöܷʡ +; +; (3) S: ˵͡ +; ڴ洢ԣS=1ϵͳ(S=0) +; +; (4) TYPE: ˵洢Ĵ洢εľԡ +; +; +; ݶ ֵ ˵ +; ---------------------------------- +; 0 ֻ +; 1 ֻѷ +; 2 /д +; 3 /дѷ +; 4 ֻչ +; 5 ֻչѷ +; 6 /дչ +; 7 /дչѷ +; +; +; ֵ ˵ +; ---------------------------------- +; 8 ִֻ +; 9 ִֻСѷ +; A ִ/ +; B ִ/ѷ +; C ִֻСһ +; D ִֻСһΡѷ +; E ִ/һ +; F ִ/һΡѷ +; +; +; ϵͳ ͱ ˵ +; ---------------------------------- +; 0 <δ> +; 1 286TSS +; 2 LDT +; 3 æ286TSS +; 4 286 +; 5 +; 6 286ж +; 7 286 +; 8 δ +; 9 386TSS +; A <δ> +; B æ386TSS +; C 386 +; D <δ> +; E 386ж +; F 386 +; +; (5) G: ν(Granularity)λ +; G=0 ʾΪֽڣ +; G=1 ʾΪ4K ֽڡ +; ע⣬ֻԶνЧԶλַЧλַֽΪλ +; +; (6) D: DλһλִжΡչݶλSSĴѰַĶ(ͨǶջ)еͬ +; ִжεУDλָʹõĵַĬϵĴС +; D=1ʾĬָʹ32λַ32λ8λĴҲΪ32λΣ +; D=0 ʾĬ£ʹ16λַ16λ8λĴҲΪ16λΣ80286ݡʹõַСǰ׺ͲСǰ׺ֱıĬϵĵַĴС +; չݶεУDλεϲ߽硣 +; D=1ʾεϲΪ4G +; D=0ʾεϲΪ64KΪ80286ݡ +; SSĴѰַĶУDλʽĶջָ(PUSHPOPָ)ʹúֶջָĴ +; D=1ʾʹ32λջָĴESP +; D=0ʾʹ16λջָĴSP80286ݡ +; +; (7) AVL: λ80386Ըλʹδ涨Intel˾Ҳ֤󿪷ĴֻҪ80386ݣͲԸλʹκζ涨 +; + + +;---------------------------------------------------------------------------- +; ֵ˵ +; : +; DA_ : Descriptor Attribute +; D : ݶ +; C : +; S : ϵͳ +; R : ֻ +; RW : д +; A : ѷ +; : ɰ˼ +;---------------------------------------------------------------------------- +DA_32 EQU 4000h ; 32 λ +DA_LIMIT_4K EQU 8000h ; νΪ 4K ֽ + +DA_DPL0 EQU 00h ; DPL = 0 +DA_DPL1 EQU 20h ; DPL = 1 +DA_DPL2 EQU 40h ; DPL = 2 +DA_DPL3 EQU 60h ; DPL = 3 +;---------------------------------------------------------------------------- +; 洢ֵ˵ +;---------------------------------------------------------------------------- +DA_DR EQU 90h ; ڵֻݶֵ +DA_DRW EQU 92h ; ڵĿɶдݶֵ +DA_DRWA EQU 93h ; ڵѷʿɶдݶֵ +DA_C EQU 98h ; ڵִֻдֵ +DA_CR EQU 9Ah ; ڵĿִпɶֵ +DA_CCO EQU 9Ch ; ڵִֻһ´ֵ +DA_CCOR EQU 9Eh ; ڵĿִпɶһ´ֵ +;---------------------------------------------------------------------------- +; ϵͳֵ˵ +;---------------------------------------------------------------------------- +DA_LDT EQU 82h ; ֲֵ +DA_TaskGate EQU 85h ; ֵ +DA_386TSS EQU 89h ; 386 ״ֵ̬ +DA_386CGate EQU 8Ch ; 386 ֵ +DA_386IGate EQU 8Eh ; 386 жֵ +DA_386TGate EQU 8Fh ; 386 ֵ +;---------------------------------------------------------------------------- + + +; ѡͼʾ: +; ששששששששששששששש +; 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +; ǩߩߩߩߩߩߩߩߩߩߩߩߩ贈贈ߩ +; TI RPL +; ߩߩ +; +; RPL(Requested Privilege Level): ȨȨ顣 +; +; TI(Table Indicator): ָʾλ +; TI=0 ָʾȫGDTжȡ +; TI=1 ָʾӾֲLDTжȡ +; + +;---------------------------------------------------------------------------- +; ѡֵ˵ +; : +; SA_ : Selector Attribute + +SA_RPL0 EQU 0 ; +SA_RPL1 EQU 1 ; RPL +SA_RPL2 EQU 2 ; +SA_RPL3 EQU 3 ; + +SA_TIG EQU 0 ; TI +SA_TIL EQU 4 ; +;---------------------------------------------------------------------------- + + +;---------------------------------------------------------------------------- +; ҳʹõij˵ +;---------------------------------------------------------------------------- +PG_P EQU 1 ; ҳλ +PG_RWR EQU 0 ; R/W λֵ, /ִ +PG_RWW EQU 2 ; R/W λֵ, /д/ִ +PG_USS EQU 0 ; U/S λֵ, ϵͳ +PG_USU EQU 4 ; U/S λֵ, û +;---------------------------------------------------------------------------- + + + + +; ========================================= +; FLAGS - Intel 8086 Family Flags Register +; ========================================= +; +; |11|10|F|E|D|C|B|A|9|8|7|6|5|4|3|2|1|0| +; | | | | | | | | | | | | | | | | | '--- CFCarry Flag +; | | | | | | | | | | | | | | | | '--- 1 +; | | | | | | | | | | | | | | | '--- PFParity Flag +; | | | | | | | | | | | | | | '--- 0 +; | | | | | | | | | | | | | '--- AFAuxiliary Flag +; | | | | | | | | | | | | '--- 0 +; | | | | | | | | | | | '--- ZFZero Flag +; | | | | | | | | | | '--- SFSign Flag +; | | | | | | | | | '--- TFTrap Flag (Single Step) +; | | | | | | | | '--- IFInterrupt Flag +; | | | | | | | '--- DFDirection Flag +; | | | | | | '--- OFOverflow flag +; | | | | '----- IOPLI/O Privilege Level (286+ only) +; | | | '----- NTNested Task Flag (286+ only) +; | | '----- 0 +; | '----- RFResume Flag (386+ only) +; '------ VMVirtual Mode Flag (386+ only) +; +; ע: see PUSHF POPF STI CLI STD CLD +; + + +; ------------------------------------------------------------------------------------------------------ +; +; +; usage: Descriptor Base, Limit, Attr +; Base: dd +; Limit: dd (low 20 bits available) +; Attr: dw (lower 4 bits of higher byte are always 0) +%macro Descriptor 3 + dw %2 & 0FFFFh ; ν 0--15 (2 ֽ) + dw %1 & 0FFFFh ; λַ 0--15 (2 ֽ) + db (%1 >> 16) & 0FFh ; λַ 16--23 (1 ֽ) + db %3 & 0xFF ;Եĵ8λ 0--7 + db ((%2 >> 16) & 0Fh) | (%3 >> 8) ; ν16--19λ 1 + ν 2 + 2 (2 ֽ) + db (%1 >> 24) & 0FFh ; λַ 3 (1 ֽ) +%endmacro ; 8 ֽ + +; +; +; usage: Gate Selector, Offset, DCount, Attr +; Selector: dw +; Offset: dd +; DCount: db +; Attr: db +%macro Gate 4 + dw (%2 & 0FFFFh) ; ƫ 1 (2 ֽ) + dw %1 ; ѡ (2 ֽ) + dw (%3 & 1Fh) | ((%4 << 8) & 0FF00h) ; (2 ֽ) + dw ((%2 >> 16) & 0FFFFh) ; ƫ 2 (2 ֽ) +%endmacro ; 8 ֽ + + +; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/protect.inc b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/protect.inc new file mode 100644 index 0000000..e593723 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/protect.inc @@ -0,0 +1,50 @@ + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +struc SegmentDescriptor + .wLimitLow RESW 1 ;ν޵16λ + .wBaseLow RESW 1 ;ַ16λ + .bBaseMiddle RESB 1 ;ַм8λ + .bAttrib RESB 1 ; + .bLimitHight4Bit_AttribHight4Bit RESB 1 ;ν޵ĸ4λͶԵĸ4λ + .bBaseHigh RESB 1 ;ַĸ8λ +endstruc + +; varaible ,offset,Base +%macro SetDescriptor_Base_Offset 3 + xor eax, eax + mov ax, %3 + shl eax, 4 + add eax, %2 + mov word [%1 + SegmentDescriptor.wBaseLow], ax + shr eax, 16 + mov byte [%1 + SegmentDescriptor.bBaseMiddle], al + mov byte [%1 + SegmentDescriptor.bBaseHigh], ah +%endmacro + +; varaible , Base +%macro SetDescriptor_Base 2 + mov eax,%2 + mov word [%1 + SegmentDescriptor.wBaseLow], ax + shr eax, 16 + mov byte [%1 + SegmentDescriptor.bBaseMiddle], al + mov byte [%1 + SegmentDescriptor.bBaseHigh], ah +%endmacro + +; %1 new descriptor name +; %2 base : 32 bit +; %3 limit : 20 bit +; %4 attribute ; 12 bit +%macro NewDescriptor 4 +%1: + istruc SegmentDescriptor + at SegmentDescriptor.wLimitLow , dw %3 & 0xffff + at SegmentDescriptor.wBaseLow , dw %2 & 0xffff + at SegmentDescriptor.bBaseMiddle, db (%2>>16) & 0xff + at SegmentDescriptor.bAttrib , db %4 & 0xff + at SegmentDescriptor.bLimitHight4Bit_AttribHight4Bit, db ( (%3>>16) & 0x0F) | (%4 >> 8) + at SegmentDescriptor.bBaseHigh , db (%2 >> 24) & 0xff + iend +%endmacro + + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/setup.asm b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/setup.asm new file mode 100644 index 0000000..96d0f86 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/setup.asm @@ -0,0 +1,373 @@ +; +; setup.s (C) 1991 Linus Torvalds +; +; setup.s is responsible for getting the system data from the BIOS, +; and putting them into the appropriate places in system memory. +; both setup.s and system has been loaded by the bootblock. +; +; This code asks the bios for memory/disk/other parameters, and +; puts them in a "safe" place: 0x90000-0x901FF, ie where the +; boot-block used to be. It is then up to the protected mode +; system to read them from there before the area is overwritten +; for buffer-blocks. +; + +; NOTE; These had better be the same as in bootsect.s; + +INITSEG equ 0x9000 ; we move boot here - out of the way +SYSSEG equ 0x1000 ; system loaded at 0x10000 (65536). +SETUPSEG equ 0x9020 ; this is the current segment + +SYSTEM_ADDRESS equ 0x50000 +DESTINATION_ADDRESS equ 0x0000 + + +%include "pm.inc" +%include "protect.inc" +%include "pestruc.inc" + +start: +; ok, the read went well so we get current cursor position and save it for +; posterity. + mov ax,INITSEG ; this is done in bootsect already, but... + mov ds,ax + mov ah,0x03 ; read cursor pos + xor bh,bh + int 0x10 ; save it in known place, con_init fetches + mov [0],dx ; it from 0x90000. +; Get memory size (extended mem, kB) + + mov ah,0x88 + int 0x15 + mov [2],ax + +; Get video-card data: + + mov ah,0x0f + int 0x10 + mov [4],bx ; bh = display page + mov [6],ax ; al = video mode, ah = window width + +; check for EGA/VGA and some config parameters + + mov ah,0x12 + mov bl,0x10 + int 0x10 + mov [8],ax + mov [10],bx + mov [12],cx + +; Get hd0 data + + mov ax,0x0000 + mov ds,ax + lds si,[4*0x41] + mov ax,INITSEG + mov es,ax + mov di,0x0080 + mov cx,0x10 + rep + movsb + +; Get hd1 data + + mov ax,0x0000 + mov ds,ax + lds si,[4*0x46] + mov ax,INITSEG + mov es,ax + mov di,0x0090 + mov cx,0x10 + rep + movsb + +; Check that there IS a hd1 :-) + + mov ax,0x01500 + mov dl,0x81 + int 0x13 + jc no_disk1 + cmp ah,3 + je is_disk1 +no_disk1: + mov ax,INITSEG + mov es,ax + mov di,0x0090 + mov cx,0x10 + mov ax,0x00 + rep + stosb +is_disk1: + +; now we want to move to protected mode ... + + cli ; no interrupts allowed ; + +; first we move the system to it's rightful place + +;--System ģ0x10000Ƶ0x50000λ,ĬSystemģ鲻ᳬ256KB +;--ΪPEʽSystemģнеĴݿܻḲǵ0x10000Ĵ,ʹʹݻûȫVirtual Addressź +;--ԭݾѾƻ + mov ax,0x1000 + mov ds,ax + mov ax,0x5000 + mov es,ax + cld ; 'direction'=0, movs moves forward +do_move: + sub di,di + sub si,si + mov cx,0x8000 + rep + movsw + + mov ax,ds + add ax,0x1000 + cmp ax,0x5000 + jz end_move + + mov ds,ax + + mov ax,es + add ax,0x1000 + mov es,ax + jmp do_move + +; then we load the segment descriptors + +end_move: + mov ax,SETUPSEG ; right, forgot this at first. didn't work :-) + mov ds,ax + + mov eax,0x9000 + mov es,ax + + mov ax,0x800 + mov [es:gdt_48_offset],ax + mov eax,0x90200 +gdt + mov dword [es:gdt_48_offset+2],0x90200+gdt + + xor eax,eax + mov word [es:idt_48_offset],ax + mov dword [idt_48_offset+2],eax + +; lidt [idt_48] ; load idt with 0,0 +; lgdt [gdt_48] ; load gdt with whatever appropriate + lgdt [gdt_ptr] +; that was painless, now we enable A20 + + call empty_8042 + mov al,0xD1 ; command write + out 0x64,al + call empty_8042 + mov al,0xDF ; A20 on + out 0x60,al + call empty_8042 + +; well, that went ok, I hope. Now we have to reprogram the interrupts :-( +; we put them right after the intel-reserved hardware interrupts, at +; int 0x20-0x2F. There they won't mess up anything. Sadly IBM really +; messed this up with the original PC, and they haven't been able to +; rectify it afterwards. Thus the bios puts interrupts at 0x08-0x0f, +; which is used for the internal hardware interrupts as well. We just +; have to reprogram the 8259's, and it isn't fun. + + mov al,0x11 ; initialization sequence + out 0x20,al ; send it to 8259A-1 + dw 0x00eb,0x00eb ; jmp $+2, jmp $+2 + out 0xA0,al ; and to 8259A-2 + dw 0x00eb,0x00eb + mov al,0x20 ; start of hardware int's (0x20) + out 0x21,al + dw 0x00eb,0x00eb + mov al,0x28 ; start of hardware int's 2 (0x28) + out 0xA1,al + dw 0x00eb,0x00eb + mov al,0x04 ; 8259-1 is master + out 0x21,al + dw 0x00eb,0x00eb + mov al,0x02 ; 8259-2 is slave + out 0xA1,al + dw 0x00eb,0x00eb + mov al,0x01 ; 8086 mode for both + out 0x21,al + dw 0x00eb,0x00eb + out 0xA1,al + dw 0x00eb,0x00eb + mov al,0xFF ; mask off all interrupts for now + out 0x21,al + dw 0x00eb,0x00eb + out 0xA1,al + +; well, that certainly wasn't fun :-(. Hopefully it works, and we don't +; need no steenking BIOS anyway (except for the initial loading :-). +; The BIOS-routine wants lots of unnecessary data, and it's less +; "interesting" anyway. This is how REAL programmers do it. +; +; Well, now's the time to actually move into protected mode. To make +; things as simple as possible, we do no register set-up or anything, +; we let the gnu-compiled 32-bit programs do that. We just jump to +; absolute address 0x00000, in 32-bit protected mode. + + + +; mov ax,0x0001 ; protected mode (PE) bit +; lmsw ax ; This is it; +; jmp 8:0 ; jmp offset 0 of segment 8 (cs) + + +;--ôĻַ + SetDescriptor_Base Code32Desc ,InitKernel + SETUPSEG * 16 + +;-- 򿪵ַA20 + in al, 92h + or al, 00000010b + out 92h, al + + ; ׼лģʽ + mov eax, cr0 + or eax, 1 + mov cr0, eax +;--뱣ģʽ,ʼڱģʽִInitKernel + jmp dword SelectorCode:0 + +; This routine checks that the keyboard command queue is empty +; No timeout is used - if this hangs there is something wrong with +; the machine, and we probably couldn't proceed anyway. +empty_8042: + dw 0x00eb,0x00eb + in al,0x64 ; 8042 status port + test al,2 ; is input buffer full? + jnz empty_8042 ; yes - loop + ret + +gdt: + dw 0,0,0,0 ; dummy + + dw 0x07FF ; 8Mb - limit=2047 (2048*4096=8Mb) + dw 0x0000 ; base address=0 + dw 0x9A00 ; code read/exec + dw 0x00C0 ; granularity=4096, 386 + + dw 0x07FF ; 8Mb - limit=2047 (2048*4096=8Mb) + dw 0x0000 ; base address=0 + dw 0x9200 ; data read/write + dw 0x00C0 ; granularity=4096, 386 +_idt_48: + dw 0 ; idt limit=0 + dw 0,0 ; idt base=0L +_gdt_48: + dw 0x800 ; gdt limit=2048, 256 GDT entries + dw 512+gdt,0x9 ; gdt base = 0X9xxxx + + +[SECTION .s32] +ALIGN 32 +[BITS 32] +InitKernel: + mov ax, SelectorVideo + mov gs, ax + mov ax, SelectorSystemData + mov ds, ax + mov es, ax + mov fs, ax + +;--ں˳ʼ + xor eax,eax + mov [sectionHeader],eax + mov [counter],eax + mov [numberOfSection],eax + + mov eax, SYSTEM_ADDRESS + add eax, [eax+IMAGE_DOS_HEADER.e_lfanew] ;-- õIMAGE_NT_HEADERSṹĻַ + +;--IMAGE_NT_HEADER.FileHeader.NumberOfSections + movzx edx,WORD [eax+IMAGE_NT_HEADERS.FileHeader+IMAGE_FILE_HEADER.NumberOfSections] + mov [numberOfSection],edx + +;--ȡַ + mov edx,[eax+IMAGE_NT_HEADERS.OptionalHeader + IMAGE_OPTIONAL_HEADER32.ImageBase]; + mov [imageBase],edx + + ;--ȡڵַ,ڵַ=imageBase + EntryPoint,ѾһԵַ + mov edx,[eax+IMAGE_NT_HEADERS.OptionalHeader + IMAGE_OPTIONAL_HEADER32.AddressOfEntryPoint]; + add edx,[imageBase] + mov [addressOfEntryPoint],edx + + add eax,IMAGE_NT_HEADERS_size ; + mov [sectionHeader],eax ;IMAGE_SECTION_HEADERĻַ + +LoadData: + mov eax,[counter] + cmp eax, [numberOfSection] + jge SHORT finish + + mov edx,[sectionHeader] + +;--ƶֽ + mov eax,[edx+IMAGE_SECTION_HEADER.SizeOfRawData] + jz next + mov ecx,eax + add [systemSize],ecx + +;--Դַ + mov eax,[edx+IMAGE_SECTION_HEADER.PointerToRawData] + add eax,SYSTEM_ADDRESS + mov esi,eax +;--Ŀַ + mov eax,[edx+IMAGE_SECTION_HEADER.VirtualAddress] + add eax,[imageBase] + mov edi,eax + rep movsb + + mov eax,[sectionHeader] + add eax,IMAGE_SECTION_HEADER_size + mov [sectionHeader],eax + +next: + mov eax, [counter] + inc eax + mov [counter],eax + jmp SHORT LoadData + +finish: + + lgdt [gdt_48]; + lidt [idt_48] + +;--ں!!Ѿ,ʣµľͽLinux-0.11ȥ:) + jmp 8:0 + +SEG_CODE_LEN equ $-InitKernel +[SECTION .data] +[BITS 32] +; λַ , ν , +GDT_TABEL: + dw 0,0,0,0 +NewDescriptor Code32Desc, 0, SEG_CODE_LEN - 1, DA_CR | DA_32 ; +NewDescriptor SystemDesc, 0, 0x90200, DA_DRW | DA_32 ;ݶ +NewDescriptor VideoDesc , 0xB8000, 0x0ffff, DA_DRW | DA_DPL3 ; Դ׵ַ + +gdt_ptr dw gdt_len - 1 ; ν + dd 0x90200 + GDT_TABEL ; ַ + +SelectorCode equ Code32Desc - GDT_TABEL +SelectorSystemData equ SystemDesc - GDT_TABEL +SelectorVideo equ VideoDesc - GDT_TABEL +gdt_len equ $ - GDT_TABEL + +;======================================================== +;ں˳ʼҪõı +numberOfSection equ 0x90100 ;SECTION +sectionHeader equ 0x90104 ;IMAGE_SECTION_HEADER ָ +counter equ 0x90108 ; +addressOfEntryPoint equ 0x9010C ;ں˿ʼִеڵַ +imageBase equ 0x90110 ;ں˼صĻַ +systemSize equ 0x90114 ;ں˼صĻַ + + +gdt_48_offset equ 0x118 +idt_48_offset equ 0x120 + +gdt_48 equ 0x90118 +idt_48 equ 0x90120 + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/setup.bin b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/setup.bin new file mode 100644 index 0000000..5f7b796 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/setup.bin differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/setup.disasm b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/setup.disasm new file mode 100644 index 0000000..8bb7f86 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/boot/setup.disasm @@ -0,0 +1,253 @@ +00000000 B80090 mov ax,0x9000 +00000003 8ED8 mov ds,ax +00000005 B403 mov ah,0x3 +00000007 30FF xor bh,bh +00000009 CD10 int 0x10 +0000000B 89160000 mov [0x0],dx +0000000F B488 mov ah,0x88 +00000011 CD15 int 0x15 +00000013 A30200 mov [0x2],ax +00000016 B40F mov ah,0xf +00000018 CD10 int 0x10 +0000001A 891E0400 mov [0x4],bx +0000001E A30600 mov [0x6],ax +00000021 B412 mov ah,0x12 +00000023 B310 mov bl,0x10 +00000025 CD10 int 0x10 +00000027 A30800 mov [0x8],ax +0000002A 891E0A00 mov [0xa],bx +0000002E 890E0C00 mov [0xc],cx +00000032 B80000 mov ax,0x0 +00000035 8ED8 mov ds,ax +00000037 C5360401 lds si,[0x104] +0000003B B80090 mov ax,0x9000 +0000003E 8EC0 mov es,ax +00000040 BF8000 mov di,0x80 +00000043 B91000 mov cx,0x10 +00000046 F3A4 rep movsb +00000048 B80000 mov ax,0x0 +0000004B 8ED8 mov ds,ax +0000004D C5361801 lds si,[0x118] +00000051 B80090 mov ax,0x9000 +00000054 8EC0 mov es,ax +00000056 BF9000 mov di,0x90 +00000059 B91000 mov cx,0x10 +0000005C F3A4 rep movsb +0000005E B80015 mov ax,0x1500 +00000061 B281 mov dl,0x81 +00000063 CD13 int 0x13 +00000065 7205 jc 0x6c +00000067 80FC03 cmp ah,0x3 +0000006A 7410 jz 0x7c +0000006C B80090 mov ax,0x9000 +0000006F 8EC0 mov es,ax +00000071 BF9000 mov di,0x90 +00000074 B91000 mov cx,0x10 +00000077 B80000 mov ax,0x0 +0000007A F3AA rep stosb +0000007C FA cli +0000007D B80010 mov ax,0x1000 +00000080 8ED8 mov ds,ax +00000082 B80050 mov ax,0x5000 +00000085 8EC0 mov es,ax +00000087 FC cld +00000088 29FF sub di,di +0000008A 29F6 sub si,si +0000008C B90080 mov cx,0x8000 +0000008F F3A5 rep movsw +00000091 8CD8 mov ax,ds +00000093 050010 add ax,0x1000 +00000096 3D0050 cmp ax,0x5000 +00000099 740B jz 0xa6 +0000009B 8ED8 mov ds,ax +0000009D 8CC0 mov ax,es +0000009F 050010 add ax,0x1000 +000000A2 8EC0 mov es,ax +000000A4 EBE2 jmp short 0x88 +000000A6 B82090 mov ax,0x9020 +000000A9 8ED8 mov ds,ax +000000AB 66B800900000 mov eax,0x9000 +000000B1 8EC0 mov es,ax +000000B3 B80008 mov ax,0x800 +000000B6 26A31801 mov [es:0x118],ax +000000BA 66B86A030900 mov eax,0x9036a +000000C0 2666C7061A016A03 mov dword [es:0x11a],0x9036a + -0900 +000000CA 6631C0 xor eax,eax +000000CD 26A32001 mov [es:0x120],ax +000000D1 66A32201 mov [0x122],eax +000000D5 0F01167002 lgdt [0x270] +000000DA E88200 call word 0x15f +000000DD B0D1 mov al,0xd1 +000000DF E664 out 0x64,al +000000E1 E87B00 call word 0x15f +000000E4 B0DF mov al,0xdf +000000E6 E660 out 0x60,al +000000E8 E87400 call word 0x15f +000000EB B011 mov al,0x11 +000000ED E620 out 0x20,al +000000EF EB00 jmp short 0xf1 +000000F1 EB00 jmp short 0xf3 +000000F3 E6A0 out 0xa0,al +000000F5 EB00 jmp short 0xf7 +000000F7 EB00 jmp short 0xf9 +000000F9 B020 mov al,0x20 +000000FB E621 out 0x21,al +000000FD EB00 jmp short 0xff +000000FF EB00 jmp short 0x101 +00000101 B028 mov al,0x28 +00000103 E6A1 out 0xa1,al +00000105 EB00 jmp short 0x107 +00000107 EB00 jmp short 0x109 +00000109 B004 mov al,0x4 +0000010B E621 out 0x21,al +0000010D EB00 jmp short 0x10f +0000010F EB00 jmp short 0x111 +00000111 B002 mov al,0x2 +00000113 E6A1 out 0xa1,al +00000115 EB00 jmp short 0x117 +00000117 EB00 jmp short 0x119 +00000119 B001 mov al,0x1 +0000011B E621 out 0x21,al +0000011D EB00 jmp short 0x11f +0000011F EB00 jmp short 0x121 +00000121 E6A1 out 0xa1,al +00000123 EB00 jmp short 0x125 +00000125 EB00 jmp short 0x127 +00000127 B0FF mov al,0xff +00000129 E621 out 0x21,al +0000012B EB00 jmp short 0x12d +0000012D EB00 jmp short 0x12f +0000012F E6A1 out 0xa1,al +00000131 66B890030900 mov eax,0x90390 +00000137 A35A02 mov [0x25a],ax +0000013A 66C1E810 shr eax,0x10 +0000013E A25C02 mov [0x25c],al +00000141 88265F02 mov [0x25f],ah +00000145 E492 in al,0x92 +00000147 0C02 or al,0x2 +00000149 E692 out 0x92,al +0000014B 0F20C0 mov eax,cr0 +0000014E 660D01000000 or eax,0x1 +00000154 0F22C0 mov cr0,eax +00000157 66EA000000000800 jmp dword 0x8:0x0 +0000015F EB00 jmp short 0x161 +00000161 EB00 jmp short 0x163 +00000163 E464 in al,0x64 +00000165 A802 test al,0x2 +00000167 75F6 jnz 0x15f +00000169 C3 ret +0000016A 0000 add [bx+si],al +0000016C 0000 add [bx+si],al +0000016E 0000 add [bx+si],al +00000170 0000 add [bx+si],al +00000172 FF07 inc word [bx] +00000174 0000 add [bx+si],al +00000176 009AC000 add [bp+si+0xc0],bl +0000017A FF07 inc word [bx] +0000017C 0000 add [bx+si],al +0000017E 0092C000 add [bp+si+0xc0],dl +00000182 0000 add [bx+si],al +00000184 0000 add [bx+si],al +00000186 0000 add [bx+si],al +00000188 0008 add [bx+si],cl +0000018A 6A03 push byte +0x3 +0000018C 0900 or [bx+si],ax +0000018E 0000 add [bx+si],al +00000190 66B818008EE8 mov eax,0xe88e0018 +00000196 66B810008ED8 mov eax,0xd88e0010 +0000019C 8EC0 mov es,ax +0000019E 8EE0 mov fs,ax +000001A0 31C0 xor ax,ax +000001A2 A30401 mov [0x104],ax +000001A5 0900 or [bx+si],ax +000001A7 A30801 mov [0x108],ax +000001AA 0900 or [bx+si],ax +000001AC A30001 mov [0x100],ax +000001AF 0900 or [bx+si],ax +000001B1 B80000 mov ax,0x0 +000001B4 050003 add ax,0x300 +000001B7 40 inc ax +000001B8 3C0F cmp al,0xf +000001BA B750 mov bh,0x50 +000001BC 06 push es +000001BD 8915 mov [di],dx +000001BF 0001 add [bx+di],al +000001C1 0900 or [bx+si],ax +000001C3 8B5034 mov dx,[bx+si+0x34] +000001C6 8915 mov [di],dx +000001C8 1001 adc [bx+di],al +000001CA 0900 or [bx+si],ax +000001CC 8B5028 mov dx,[bx+si+0x28] +000001CF 0315 add dx,[di] +000001D1 1001 adc [bx+di],al +000001D3 0900 or [bx+si],ax +000001D5 8915 mov [di],dx +000001D7 0C01 or al,0x1 +000001D9 0900 or [bx+si],ax +000001DB 05F800 add ax,0xf8 +000001DE 0000 add [bx+si],al +000001E0 A30401 mov [0x104],ax +000001E3 0900 or [bx+si],ax +000001E5 A10801 mov ax,[0x108] +000001E8 0900 or [bx+si],ax +000001EA 3B05 cmp ax,[di] +000001EC 0001 add [bx+di],al +000001EE 0900 or [bx+si],ax +000001F0 7D46 jnl 0x238 +000001F2 8B15 mov dx,[di] +000001F4 0401 add al,0x1 +000001F6 0900 or [bx+si],ax +000001F8 8B4210 mov ax,[bp+si+0x10] +000001FB 742E jz 0x22b +000001FD 89C1 mov cx,ax +000001FF 010D add [di],cx +00000201 1401 adc al,0x1 +00000203 0900 or [bx+si],ax +00000205 8B4214 mov ax,[bp+si+0x14] +00000208 050000 add ax,0x0 +0000020B 050089 add ax,0x8900 +0000020E C6 db 0xC6 +0000020F 8B420C mov ax,[bp+si+0xc] +00000212 0305 add ax,[di] +00000214 1001 adc [bx+di],al +00000216 0900 or [bx+si],ax +00000218 89C7 mov di,ax +0000021A F3A4 rep movsb +0000021C A10401 mov ax,[0x104] +0000021F 0900 or [bx+si],ax +00000221 052800 add ax,0x28 +00000224 0000 add [bx+si],al +00000226 A30401 mov [0x104],ax +00000229 0900 or [bx+si],ax +0000022B A10801 mov ax,[0x108] +0000022E 0900 or [bx+si],ax +00000230 40 inc ax +00000231 A30801 mov [0x108],ax +00000234 0900 or [bx+si],ax +00000236 EBAD jmp short 0x1e5 +00000238 0F0115 lgdt [di] +0000023B 1801 sbb [bx+di],al +0000023D 0900 or [bx+si],ax +0000023F 0F011D lidt [di] +00000242 2001 and [bx+di],al +00000244 0900 or [bx+si],ax +00000246 EA00000000 jmp word 0x0:0x0 +0000024B 0800 or [bx+si],al +0000024D 0000 add [bx+si],al +0000024F 0000 add [bx+si],al +00000251 0000 add [bx+si],al +00000253 0000 add [bx+si],al +00000255 0000 add [bx+si],al +00000257 00BC0000 add [si+0x0],bh +0000025B 0000 add [bx+si],al +0000025D 9ADA000002 call word 0x200:0xda +00000262 0000 add [bx+si],al +00000264 0092DB00 add [bp+si+0xdb],dl +00000268 FF db 0xFF +00000269 FF00 inc word [bx+si] +0000026B 800BF2 or byte [bp+di],0xf2 +0000026E 92 xchg ax,dx +0000026F 0025 add [di],ah +00000271 005004 add [bx+si+0x4],dl +00000274 0900 or [bx+si],ax diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/Makefile new file mode 100644 index 0000000..593a922 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/Makefile @@ -0,0 +1,100 @@ +AR =ar +AS =as +CC =gcc -mcpu=i386 +LD =ld +CFLAGS =-Wall -fstrength-reduce -fomit-frame-pointer \ + -nostdinc -I../include +CPP =gcc -E -nostdinc -I../include + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< +.s.o: + $(AS) -o $*.o $< + +OBJS= open.o read_write.o inode.o file_table.o buffer.o super.o \ + block_dev.o char_dev.o file_dev.o stat.o exec.o pipe.o namei.o \ + bitmap.o fcntl.o ioctl.o truncate.o + +fs.o: $(OBJS) + $(LD) -r -o fs.o $(OBJS) + +clean: + rm -f core *.o *.a tmp_make + for i in *.c;do rm -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: +bitmap.o: bitmap.c ../include/string.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h +block_dev.o: block_dev.c ../include/errno.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ + ../include/asm/segment.h ../include/asm/system.h +buffer.o: buffer.c ../include/stdarg.h ../include/linux/config.h \ + ../include/linux/sched.h ../include/linux/head.h ../include/linux/fs.h \ + ../include/sys/types.h ../include/linux/mm.h ../include/signal.h \ + ../include/linux/kernel.h ../include/asm/system.h ../include/asm/io.h +char_dev.o: char_dev.c ../include/errno.h ../include/sys/types.h \ + ../include/linux/sched.h ../include/linux/head.h ../include/linux/fs.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ + ../include/asm/segment.h ../include/asm/io.h +exec.o: exec.c ../include/errno.h ../include/string.h \ + ../include/sys/stat.h ../include/sys/types.h ../include/a.out.h \ + ../include/linux/fs.h ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ + ../include/asm/segment.h +fcntl.o: fcntl.c ../include/string.h ../include/errno.h \ + ../include/linux/sched.h ../include/linux/head.h ../include/linux/fs.h \ + ../include/sys/types.h ../include/linux/mm.h ../include/signal.h \ + ../include/linux/kernel.h ../include/asm/segment.h ../include/fcntl.h \ + ../include/sys/stat.h +file_dev.o: file_dev.c ../include/errno.h ../include/fcntl.h \ + ../include/sys/types.h ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/linux/mm.h ../include/signal.h \ + ../include/linux/kernel.h ../include/asm/segment.h +file_table.o: file_table.c ../include/linux/fs.h ../include/sys/types.h +inode.o: inode.c ../include/string.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/linux/mm.h ../include/signal.h \ + ../include/linux/kernel.h ../include/asm/system.h +ioctl.o: ioctl.c ../include/string.h ../include/errno.h \ + ../include/sys/stat.h ../include/sys/types.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \ + ../include/signal.h +namei.o: namei.c ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \ + ../include/signal.h ../include/linux/kernel.h ../include/asm/segment.h \ + ../include/string.h ../include/fcntl.h ../include/errno.h \ + ../include/const.h ../include/sys/stat.h +open.o: open.c ../include/string.h ../include/errno.h ../include/fcntl.h \ + ../include/sys/types.h ../include/utime.h ../include/sys/stat.h \ + ../include/linux/sched.h ../include/linux/head.h ../include/linux/fs.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/tty.h \ + ../include/termios.h ../include/linux/kernel.h ../include/asm/segment.h +pipe.o: pipe.c ../include/signal.h ../include/sys/types.h \ + ../include/linux/sched.h ../include/linux/head.h ../include/linux/fs.h \ + ../include/linux/mm.h ../include/asm/segment.h +read_write.o: read_write.c ../include/sys/stat.h ../include/sys/types.h \ + ../include/errno.h ../include/linux/kernel.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \ + ../include/signal.h ../include/asm/segment.h +stat.o: stat.c ../include/errno.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/linux/fs.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/mm.h ../include/signal.h \ + ../include/linux/kernel.h ../include/asm/segment.h +super.o: super.c ../include/linux/config.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ + ../include/asm/system.h ../include/errno.h ../include/sys/stat.h +truncate.o: truncate.c ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \ + ../include/signal.h ../include/sys/stat.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/bitmap.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/bitmap.c new file mode 100644 index 0000000..fb0741d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/bitmap.c @@ -0,0 +1,168 @@ +/* + * linux/fs/bitmap.c + * + * (C) 1991 Linus Torvalds + */ + +/* bitmap.c contains the code that handles the inode and block bitmaps */ +#include + +#include +#include + +#define clear_block(addr) \ +__asm__ __volatile__ ("cld\n\t" \ + "rep\n\t" \ + "stosl" \ + ::"a" (0),"c" (BLOCK_SIZE/4),"D" ((long) (addr))) + +#define set_bit(nr,addr) ({\ +register int res ; \ +__asm__ __volatile__("btsl %2,%3\n\tsetb %%al": \ +"=a" (res):"0" (0),"r" (nr),"m" (*(addr))); \ +res;}) + +#define clear_bit(nr,addr) ({\ +register int res ; \ +__asm__ __volatile__("btrl %2,%3\n\tsetnb %%al": \ +"=a" (res):"0" (0),"r" (nr),"m" (*(addr))); \ +res;}) + +#define find_first_zero(addr) ({ \ +int __res; \ +__asm__ __volatile__ ("cld\n" \ + "1:\tlodsl\n\t" \ + "notl %%eax\n\t" \ + "bsfl %%eax,%%edx\n\t" \ + "je 2f\n\t" \ + "addl %%edx,%%ecx\n\t" \ + "jmp 3f\n" \ + "2:\taddl $32,%%ecx\n\t" \ + "cmpl $8192,%%ecx\n\t" \ + "jl 1b\n" \ + "3:" \ + :"=c" (__res):"c" (0),"S" (addr)); \ +__res;}) + +void free_block(int dev, int block) +{ + struct super_block * sb; + struct buffer_head * bh; + + if (!(sb = get_super(dev))) + panic("trying to free block on nonexistent device"); + if (block < sb->s_firstdatazone || block >= sb->s_nzones) + panic("trying to free block not in datazone"); + bh = get_hash_table(dev,block); + if (bh) { + if (bh->b_count != 1) { + printk("trying to free block (%04x:%d), count=%d\n", + dev,block,bh->b_count); + return; + } + bh->b_dirt=0; + bh->b_uptodate=0; + brelse(bh); + } + block -= sb->s_firstdatazone - 1 ; + if (clear_bit(block&8191,sb->s_zmap[block/8192]->b_data)) { + printk("block (%04x:%d) ",dev,block+sb->s_firstdatazone-1); + panic("free_block: bit already cleared"); + } + sb->s_zmap[block/8192]->b_dirt = 1; +} + +int new_block(int dev) +{ + struct buffer_head * bh; + struct super_block * sb; + int i,j; + + if (!(sb = get_super(dev))) + panic("trying to get new block from nonexistant device"); + j = 8192; + for (i=0 ; i<8 ; i++) + if ((bh=sb->s_zmap[i])) + if ((j=find_first_zero(bh->b_data))<8192) + break; + if (i>=8 || !bh || j>=8192) + return 0; + if (set_bit(j,bh->b_data)) + panic("new_block: bit already set"); + bh->b_dirt = 1; + j += i*8192 + sb->s_firstdatazone-1; + if (j >= sb->s_nzones) + return 0; + if (!(bh=getblk(dev,j))) + panic("new_block: cannot get block"); + if (bh->b_count != 1) + panic("new block: count is != 1"); + clear_block(bh->b_data); + bh->b_uptodate = 1; + bh->b_dirt = 1; + brelse(bh); + return j; +} + +void free_inode(struct m_inode * inode) +{ + struct super_block * sb; + struct buffer_head * bh; + + if (!inode) + return; + if (!inode->i_dev) { + memset(inode,0,sizeof(*inode)); + return; + } + if (inode->i_count>1) { + printk("trying to free inode with count=%d\n",inode->i_count); + panic("free_inode"); + } + if (inode->i_nlinks) + panic("trying to free inode with links"); + if (!(sb = get_super(inode->i_dev))) + panic("trying to free inode on nonexistent device"); + if (inode->i_num < 1 || inode->i_num > sb->s_ninodes) + panic("trying to free inode 0 or nonexistant inode"); + if (!(bh=sb->s_imap[inode->i_num>>13])) + panic("nonexistent imap in superblock"); + if (clear_bit(inode->i_num&8191,bh->b_data)) + printk("free_inode: bit already cleared.\n\r"); + bh->b_dirt = 1; + memset(inode,0,sizeof(*inode)); +} + +struct m_inode * new_inode(int dev) +{ + struct m_inode * inode; + struct super_block * sb; + struct buffer_head * bh; + int i,j; + + if (!(inode=get_empty_inode())) + return NULL; + if (!(sb = get_super(dev))) + panic("new_inode with unknown device"); + j = 8192; + for (i=0 ; i<8 ; i++) + if ((bh=sb->s_imap[i])) + if ((j=find_first_zero(bh->b_data))<8192) + break; + if (!bh || j >= 8192 || j+i*8192 > sb->s_ninodes) { + iput(inode); + return NULL; + } + if (set_bit(j,bh->b_data)) + panic("new_inode: bit already set"); + bh->b_dirt = 1; + inode->i_count=1; + inode->i_nlinks=1; + inode->i_dev=dev; + inode->i_uid=current->euid; + inode->i_gid=current->egid; + inode->i_dirt=1; + inode->i_num = j + i*8192; + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; + return inode; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/block_dev.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/block_dev.c new file mode 100644 index 0000000..a50ae3f --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/block_dev.c @@ -0,0 +1,73 @@ +/* + * linux/fs/block_dev.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +#include +#include +#include +#include + +int block_write(int dev, long * pos, char * buf, int count) +{ + int block = *pos >> BLOCK_SIZE_BITS; + int offset = *pos & (BLOCK_SIZE-1); + int chars; + int written = 0; + struct buffer_head * bh; + register char * p; + + while (count>0) { + chars = BLOCK_SIZE - offset; + if (chars > count) + chars=count; + if (chars == BLOCK_SIZE) + bh = getblk(dev,block); + else + bh = breada(dev,block,block+1,block+2,-1); + block++; + if (!bh) + return written?written:-EIO; + p = offset + bh->b_data; + offset = 0; + *pos += chars; + written += chars; + count -= chars; + while (chars-->0) + *(p++) = get_fs_byte(buf++); + bh->b_dirt = 1; + brelse(bh); + } + return written; +} + +int block_read(int dev, unsigned long * pos, char * buf, int count) +{ + int block = *pos >> BLOCK_SIZE_BITS; + int offset = *pos & (BLOCK_SIZE-1); + int chars; + int read = 0; + struct buffer_head * bh; + register char * p; + + while (count>0) { + chars = BLOCK_SIZE-offset; + if (chars > count) + chars = count; + if (!(bh = breada(dev,block,block+1,block+2,-1))) + return read?read:-EIO; + block++; + p = offset + bh->b_data; + offset = 0; + *pos += chars; + read += chars; + count -= chars; + while (chars-->0) + put_fs_byte(*(p++),buf++); + brelse(bh); + } + return read; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/buffer.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/buffer.c new file mode 100644 index 0000000..47c5a4d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/buffer.c @@ -0,0 +1,384 @@ +/* + * linux/fs/buffer.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 'buffer.c' implements the buffer-cache functions. Race-conditions have + * been avoided by NEVER letting a interrupt change a buffer (except for the + * data, of course), but instead letting the caller do it. NOTE! As interrupts + * can wake up a caller, some cli-sti sequences are needed to check for + * sleep-on-calls. These should be extremely quick, though (I hope). + */ + +/* + * NOTE! There is one discordant note here: checking floppies for + * disk change. This is where it fits best, I think, as it should + * invalidate changed floppy-disk-caches. + */ + +#include + +#include +#include +#include +#include +#include + +extern int end; +extern void put_super(int); +extern void invalidate_inodes(int); + +struct buffer_head * start_buffer = (struct buffer_head *) &end; +struct buffer_head * hash_table[NR_HASH]; +static struct buffer_head * free_list; +static struct task_struct * buffer_wait = NULL; +int NR_BUFFERS = 0; + +static inline void wait_on_buffer(struct buffer_head * bh) +{ + cli(); + while (bh->b_lock) + sleep_on(&bh->b_wait); + sti(); +} + +int sys_sync(void) +{ + int i; + struct buffer_head * bh; + + sync_inodes(); /* write out inodes into buffers */ + bh = start_buffer; + for (i=0 ; ib_dirt) + ll_rw_block(WRITE,bh); + } + return 0; +} + +int sync_dev(int dev) +{ + int i; + struct buffer_head * bh; + + bh = start_buffer; + for (i=0 ; ib_dev != dev) + continue; + wait_on_buffer(bh); + if (bh->b_dev == dev && bh->b_dirt) + ll_rw_block(WRITE,bh); + } + sync_inodes(); + bh = start_buffer; + for (i=0 ; ib_dev != dev) + continue; + wait_on_buffer(bh); + if (bh->b_dev == dev && bh->b_dirt) + ll_rw_block(WRITE,bh); + } + return 0; +} + +void inline invalidate_buffers(int dev) +{ + int i; + struct buffer_head * bh; + + bh = start_buffer; + for (i=0 ; ib_dev != dev) + continue; + wait_on_buffer(bh); + if (bh->b_dev == dev) + bh->b_uptodate = bh->b_dirt = 0; + } +} + +/* + * This routine checks whether a floppy has been changed, and + * invalidates all buffer-cache-entries in that case. This + * is a relatively slow routine, so we have to try to minimize using + * it. Thus it is called only upon a 'mount' or 'open'. This + * is the best way of combining speed and utility, I think. + * People changing diskettes in the middle of an operation deserve + * to loose :-) + * + * NOTE! Although currently this is only for floppies, the idea is + * that any additional removable block-device will use this routine, + * and that mount/open needn't know that floppies/whatever are + * special. + */ +void check_disk_change(int dev) +{ + int i; + + if (MAJOR(dev) != 2) + return; + if (!floppy_change(dev & 0x03)) + return; + for (i=0 ; ib_next) + bh->b_next->b_prev = bh->b_prev; + if (bh->b_prev) + bh->b_prev->b_next = bh->b_next; + if (hash(bh->b_dev,bh->b_blocknr) == bh) + hash(bh->b_dev,bh->b_blocknr) = bh->b_next; +/* remove from free list */ + if (!(bh->b_prev_free) || !(bh->b_next_free)) + panic("Free block list corrupted"); + bh->b_prev_free->b_next_free = bh->b_next_free; + bh->b_next_free->b_prev_free = bh->b_prev_free; + if (free_list == bh) + free_list = bh->b_next_free; +} + +static inline void insert_into_queues(struct buffer_head * bh) +{ +/* put at end of free list */ + bh->b_next_free = free_list; + bh->b_prev_free = free_list->b_prev_free; + free_list->b_prev_free->b_next_free = bh; + free_list->b_prev_free = bh; +/* put the buffer in new hash-queue if it has a device */ + bh->b_prev = NULL; + bh->b_next = NULL; + if (!bh->b_dev) + return; + bh->b_next = hash(bh->b_dev,bh->b_blocknr); + hash(bh->b_dev,bh->b_blocknr) = bh; + bh->b_next->b_prev = bh; +} + +static struct buffer_head * find_buffer(int dev, int block) +{ + struct buffer_head * tmp; + + for (tmp = hash(dev,block) ; tmp != NULL ; tmp = tmp->b_next) + if (tmp->b_dev==dev && tmp->b_blocknr==block) + return tmp; + return NULL; +} + +/* + * Why like this, I hear you say... The reason is race-conditions. + * As we don't lock buffers (unless we are readint them, that is), + * something might happen to it while we sleep (ie a read-error + * will force it bad). This shouldn't really happen currently, but + * the code is ready. + */ +struct buffer_head * get_hash_table(int dev, int block) +{ + struct buffer_head * bh; + + for (;;) { + if (!(bh=find_buffer(dev,block))) + return NULL; + bh->b_count++; + wait_on_buffer(bh); + if (bh->b_dev == dev && bh->b_blocknr == block) + return bh; + bh->b_count--; + } +} + +/* + * Ok, this is getblk, and it isn't very clear, again to hinder + * race-conditions. Most of the code is seldom used, (ie repeating), + * so it should be much more efficient than it looks. + * + * The algoritm is changed: hopefully better, and an elusive bug removed. + */ +#define BADNESS(bh) (((bh)->b_dirt<<1)+(bh)->b_lock) +struct buffer_head * getblk(int dev,int block) +{ + struct buffer_head * tmp, * bh; + +repeat: + if ((bh = get_hash_table(dev,block))) + return bh; + tmp = free_list; + do { + if (tmp->b_count) + continue; + if (!bh || BADNESS(tmp)b_next_free) != free_list); + if (!bh) { + sleep_on(&buffer_wait); + goto repeat; + } + wait_on_buffer(bh); + if (bh->b_count) + goto repeat; + while (bh->b_dirt) { + sync_dev(bh->b_dev); + wait_on_buffer(bh); + if (bh->b_count) + goto repeat; + } +/* NOTE!! While we slept waiting for this block, somebody else might */ +/* already have added "this" block to the cache. check it */ + if (find_buffer(dev,block)) + goto repeat; +/* OK, FINALLY we know that this buffer is the only one of it's kind, */ +/* and that it's unused (b_count=0), unlocked (b_lock=0), and clean */ + bh->b_count=1; + bh->b_dirt=0; + bh->b_uptodate=0; + remove_from_queues(bh); + bh->b_dev=dev; + bh->b_blocknr=block; + insert_into_queues(bh); + return bh; +} + +void brelse(struct buffer_head * buf) +{ + if (!buf) + return; + wait_on_buffer(buf); + if (!(buf->b_count--)) + panic("Trying to free free buffer"); + wake_up(&buffer_wait); +} + +/* + * bread() reads a specified block and returns the buffer that contains + * it. It returns NULL if the block was unreadable. + */ +struct buffer_head * bread(int dev,int block) +{ + struct buffer_head * bh; + + if (!(bh=getblk(dev,block))) + panic("bread: getblk returned NULL\n"); + if (bh->b_uptodate) + return bh; + ll_rw_block(READ,bh); + wait_on_buffer(bh); + if (bh->b_uptodate) + return bh; + brelse(bh); + return NULL; +} + +#define COPYBLK(from,to) \ +__asm__("cld\n\t" \ + "rep\n\t" \ + "movsl\n\t" \ + ::"c" (BLOCK_SIZE/4),"S" (from),"D" (to) \ + ) + +/* + * bread_page reads four buffers into memory at the desired address. It's + * a function of its own, as there is some speed to be got by reading them + * all at the same time, not waiting for one to be read, and then another + * etc. + */ +void bread_page(unsigned long address,int dev,int b[4]) +{ + struct buffer_head * bh[4]; + int i; + + for (i=0 ; i<4 ; i++) + if (b[i]) { + if ((bh[i] = getblk(dev,b[i]))) + if (!bh[i]->b_uptodate) + ll_rw_block(READ,bh[i]); + } else + bh[i] = NULL; + for (i=0 ; i<4 ; i++,address += BLOCK_SIZE) + if (bh[i]) { + wait_on_buffer(bh[i]); + if (bh[i]->b_uptodate) + COPYBLK((unsigned long) bh[i]->b_data,address); + brelse(bh[i]); + } +} + +/* + * Ok, breada can be used as bread, but additionally to mark other + * blocks for reading as well. End the argument list with a negative + * number. + */ +struct buffer_head * breada(int dev,int first, ...) +{ + va_list args; + struct buffer_head * bh, *tmp; + + va_start(args,first); + if (!(bh=getblk(dev,first))) + panic("bread: getblk returned NULL\n"); + if (!bh->b_uptodate) + ll_rw_block(READ,bh); + while ((first=va_arg(args,int))>=0) { + tmp=getblk(dev,first); + if (tmp) { + if (!tmp->b_uptodate) + ll_rw_block(READA,bh); + tmp->b_count--; + } + } + va_end(args); + wait_on_buffer(bh); + if (bh->b_uptodate) + return bh; + brelse(bh); + return (NULL); +} + +void buffer_init(long buffer_end) +{ + struct buffer_head * h = start_buffer; + void * b; + int i; + + if (buffer_end == 1<<20) + b = (void *) (640*1024); + else + b = (void *) buffer_end; + while ( (b -= BLOCK_SIZE) >= ((void *) (h+1)) ) { + h->b_dev = 0; + h->b_dirt = 0; + h->b_count = 0; + h->b_lock = 0; + h->b_uptodate = 0; + h->b_wait = NULL; + h->b_next = NULL; + h->b_prev = NULL; + h->b_data = (char *) b; + h->b_prev_free = h-1; + h->b_next_free = h+1; + h++; + NR_BUFFERS++; + if (b == (void *) 0x100000) + b = (void *) 0xA0000; + } + h--; + free_list = start_buffer; + free_list->b_prev_free = h; + h->b_next_free = free_list; + for (i=0;i +#include + +#include +#include + +#include +#include + +extern int tty_read(unsigned minor,char * buf,int count); +extern int tty_write(unsigned minor,char * buf,int count); + +typedef int (*crw_ptr)(int rw,unsigned minor,char * buf,int count,off_t * pos); + +static int rw_ttyx(int rw,unsigned minor,char * buf,int count,off_t * pos) +{ + return ((rw==READ)?tty_read(minor,buf,count): + tty_write(minor,buf,count)); +} + +static int rw_tty(int rw,unsigned minor,char * buf,int count, off_t * pos) +{ + if (current->tty<0) + return -EPERM; + return rw_ttyx(rw,current->tty,buf,count,pos); +} + +static int rw_ram(int rw,char * buf, int count, off_t *pos) +{ + return -EIO; +} + +static int rw_mem(int rw,char * buf, int count, off_t * pos) +{ + return -EIO; +} + +static int rw_kmem(int rw,char * buf, int count, off_t * pos) +{ + return -EIO; +} + +static int rw_port(int rw,char * buf, int count, off_t * pos) +{ + int i=*pos; + + while (count-->0 && i<65536) { + if (rw==READ) + put_fs_byte(inb(i),buf++); + else + outb(get_fs_byte(buf++),i); + i++; + } + i -= *pos; + *pos += i; + return i; +} + +static int rw_memory(int rw, unsigned minor, char * buf, int count, off_t * pos) +{ + switch(minor) { + case 0: + return rw_ram(rw,buf,count,pos); + case 1: + return rw_mem(rw,buf,count,pos); + case 2: + return rw_kmem(rw,buf,count,pos); + case 3: + return (rw==READ)?0:count; /* rw_null */ + case 4: + return rw_port(rw,buf,count,pos); + default: + return -EIO; + } +} + +#define NRDEVS ((sizeof (crw_table))/(sizeof (crw_ptr))) + +static crw_ptr crw_table[]={ + NULL, /* nodev */ + rw_memory, /* /dev/mem etc */ + NULL, /* /dev/fd */ + NULL, /* /dev/hd */ + rw_ttyx, /* /dev/ttyx */ + rw_tty, /* /dev/tty */ + NULL, /* /dev/lp */ + NULL}; /* unnamed pipes */ + +int rw_char(int rw,int dev, char * buf, int count, off_t * pos) +{ + crw_ptr call_addr; + + if (MAJOR(dev)>=NRDEVS) + return -ENODEV; + if (!(call_addr=crw_table[MAJOR(dev)])) + return -ENODEV; + return call_addr(rw,MINOR(dev),buf,count,pos); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/exec.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/exec.c new file mode 100644 index 0000000..c1b6a29 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/exec.c @@ -0,0 +1,353 @@ +/* + * linux/fs/exec.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * #!-checking implemented by tytso. + */ + +/* + * Demand-loading implemented 01.12.91 - no need to read anything but + * the header into memory. The inode of the executable is put into + * "current->executable", and page faults do the actual loading. Clean. + * + * Once more I can proudly say that linux stood up to being changed: it + * was less than 2 hours work to get demand-loading completely implemented. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +extern int sys_exit(int exit_code); +extern int sys_close(int fd); + +/* + * MAX_ARG_PAGES defines the number of pages allocated for arguments + * and envelope for the new program. 32 should suffice, this gives + * a maximum env+arg of 128kB ! + */ +#define MAX_ARG_PAGES 32 + +/* + * create_tables() parses the env- and arg-strings in new user + * memory and creates the pointer tables from them, and puts their + * addresses on the "stack", returning the new stack pointer value. + */ +static unsigned long * create_tables(char * p,int argc,int envc) +{ + unsigned long *argv,*envp; + unsigned long * sp; + + sp = (unsigned long *) (0xfffffffc & (unsigned long) p); + sp -= envc+1; + envp = sp; + sp -= argc+1; + argv = sp; + put_fs_long((unsigned long)envp,--sp); + put_fs_long((unsigned long)argv,--sp); + put_fs_long((unsigned long)argc,--sp); + while (argc-->0) { + put_fs_long((unsigned long) p,argv++); + while (get_fs_byte(p++)) /* nothing */ ; + } + put_fs_long(0,argv); + while (envc-->0) { + put_fs_long((unsigned long) p,envp++); + while (get_fs_byte(p++)) /* nothing */ ; + } + put_fs_long(0,envp); + return sp; +} + +/* + * count() counts the number of arguments/envelopes + */ +static int count(char ** argv) +{ + int i=0; + char ** tmp; + + if ((tmp = argv)) + while (get_fs_long((unsigned long *) (tmp++))) + i++; + + return i; +} + +/* + * 'copy_string()' copies argument/envelope strings from user + * memory to free pages in kernel mem. These are in a format ready + * to be put directly into the top of new user memory. + * + * Modified by TYT, 11/24/91 to add the from_kmem argument, which specifies + * whether the string and the string array are from user or kernel segments: + * + * from_kmem argv * argv ** + * 0 user space user space + * 1 kernel space user space + * 2 kernel space kernel space + * + * We do this by playing games with the fs segment register. Since it + * it is expensive to load a segment register, we try to avoid calling + * set_fs() unless we absolutely have to. + */ +static unsigned long copy_strings(int argc,char ** argv,unsigned long *page, + unsigned long p, int from_kmem) +{ + char *tmp, *pag=NULL; + int len, offset = 0; + unsigned long old_fs, new_fs; + + if (!p) + return 0; /* bullet-proofing */ + new_fs = get_ds(); + old_fs = get_fs(); + if (from_kmem==2) + set_fs(new_fs); + while (argc-- > 0) { + if (from_kmem == 1) + set_fs(new_fs); + if (!(tmp = (char *)get_fs_long(((unsigned long *)argv)+argc))) + panic("argc is wrong"); + if (from_kmem == 1) + set_fs(old_fs); + len=0; /* remember zero-padding */ + do { + len++; + } while (get_fs_byte(tmp++)); + if (p-len < 0) { /* this shouldn't happen - 128kB */ + set_fs(old_fs); + return 0; + } + while (len) { + --p; --tmp; --len; + if (--offset < 0) { + offset = p % PAGE_SIZE; + if (from_kmem==2) + set_fs(old_fs); + if (!(pag = (char *) page[p/PAGE_SIZE]) && + !(pag = (char *) page[p/PAGE_SIZE] = + (unsigned long *) get_free_page())) + return 0; + if (from_kmem==2) + set_fs(new_fs); + + } + *(pag + offset) = get_fs_byte(tmp); + } + } + if (from_kmem==2) + set_fs(old_fs); + return p; +} + +static unsigned long change_ldt(unsigned long text_size,unsigned long * page) +{ + unsigned long code_limit,data_limit,code_base,data_base; + int i; + + code_limit = text_size+PAGE_SIZE -1; + code_limit &= 0xFFFFF000; + data_limit = 0x4000000; + code_base = get_base(current->ldt[1]); + data_base = code_base; + set_base(current->ldt[1],code_base); + set_limit(current->ldt[1],code_limit); + set_base(current->ldt[2],data_base); + set_limit(current->ldt[2],data_limit); +/* make sure fs points to the NEW data segment */ + __asm__("pushl $0x17\n\tpop %%fs"::); + data_base += data_limit; + for (i=MAX_ARG_PAGES-1 ; i>=0 ; i--) { + data_base -= PAGE_SIZE; + if (page[i]) + put_page(page[i],data_base); + } + return data_limit; +} + +/* + * 'do_execve()' executes a new program. + */ +int do_execve(unsigned long * eip,long tmp,char * filename, + char ** argv, char ** envp) +{ + struct m_inode * inode; + struct buffer_head * bh; + struct exec ex; + unsigned long page[MAX_ARG_PAGES]; + int i,argc,envc; + int e_uid, e_gid; + int retval; + int sh_bang = 0; + unsigned long p=PAGE_SIZE*MAX_ARG_PAGES-4; + + if ((0xffff & eip[1]) != 0x000f) + panic("execve called from supervisor mode"); + for (i=0 ; ii_mode)) { /* must be regular file */ + retval = -EACCES; + goto exec_error2; + } + i = inode->i_mode; + e_uid = (i & S_ISUID) ? inode->i_uid : current->euid; + e_gid = (i & S_ISGID) ? inode->i_gid : current->egid; + if (current->euid == inode->i_uid) + i >>= 6; + else if (current->egid == inode->i_gid) + i >>= 3; + if (!(i & 1) && + !((inode->i_mode & 0111) && suser())) { + retval = -ENOEXEC; + goto exec_error2; + } + if (!(bh = bread(inode->i_dev,inode->i_zone[0]))) { + retval = -EACCES; + goto exec_error2; + } + ex = *((struct exec *) bh->b_data); /* read exec-header */ + if ((bh->b_data[0] == '#') && (bh->b_data[1] == '!') && (!sh_bang)) { + /* + * This section does the #! interpretation. + * Sorta complicated, but hopefully it will work. -TYT + */ + + char buf[1023], *cp, *interp, *i_name, *i_arg; + unsigned long old_fs; + + strncpy(buf, bh->b_data+2, 1022); + brelse(bh); + iput(inode); + buf[1022] = '\0'; + if ((cp = strchr(buf, '\n'))) { + *cp = '\0'; + for (cp = buf; (*cp == ' ') || (*cp == '\t'); cp++); + } + if (!cp || *cp == '\0') { + retval = -ENOEXEC; /* No interpreter name found */ + goto exec_error1; + } + interp = i_name = cp; + i_arg = 0; + for ( ; *cp && (*cp != ' ') && (*cp != '\t'); cp++) { + if (*cp == '/') + i_name = cp+1; + } + if (*cp) { + *cp++ = '\0'; + i_arg = cp; + } + /* + * OK, we've parsed out the interpreter name and + * (optional) argument. + */ + if (sh_bang++ == 0) { + p = copy_strings(envc, envp, page, p, 0); + p = copy_strings(--argc, argv+1, page, p, 0); + } + /* + * Splice in (1) the interpreter's name for argv[0] + * (2) (optional) argument to interpreter + * (3) filename of shell script + * + * This is done in reverse order, because of how the + * user environment and arguments are stored. + */ + p = copy_strings(1, &filename, page, p, 1); + argc++; + if (i_arg) { + p = copy_strings(1, &i_arg, page, p, 2); + argc++; + } + p = copy_strings(1, &i_name, page, p, 2); + argc++; + if (!p) { + retval = -ENOMEM; + goto exec_error1; + } + /* + * OK, now restart the process with the interpreter's inode. + */ + old_fs = get_fs(); + set_fs(get_ds()); + if (!(inode=namei(interp))) { /* get executables inode */ + set_fs(old_fs); + retval = -ENOENT; + goto exec_error1; + } + set_fs(old_fs); + goto restart_interp; + } + brelse(bh); + if (N_MAGIC(ex) != ZMAGIC || ex.a_trsize || ex.a_drsize || + ex.a_text+ex.a_data+ex.a_bss>0x3000000 || + inode->i_size < ex.a_text+ex.a_data+ex.a_syms+N_TXTOFF(ex)) { + retval = -ENOEXEC; + goto exec_error2; + } + if (N_TXTOFF(ex) != BLOCK_SIZE) { + printk("%s: N_TXTOFF != BLOCK_SIZE. See a.out.h.", filename); + retval = -ENOEXEC; + goto exec_error2; + } + if (!sh_bang) { + p = copy_strings(envc,envp,page,p,0); + p = copy_strings(argc,argv,page,p,0); + if (!p) { + retval = -ENOMEM; + goto exec_error2; + } + } +/* OK, This is the point of no return */ + if (current->executable) + iput(current->executable); + current->executable = inode; + for (i=0 ; i<32 ; i++) + current->sigaction[i].sa_handler = NULL; + for (i=0 ; iclose_on_exec>>i)&1) + sys_close(i); + current->close_on_exec = 0; + free_page_tables(get_base(current->ldt[1]),get_limit(0x0f)); + free_page_tables(get_base(current->ldt[2]),get_limit(0x17)); + if (last_task_used_math == current) + last_task_used_math = NULL; + current->used_math = 0; + p += change_ldt(ex.a_text,page)-MAX_ARG_PAGES*PAGE_SIZE; + p = (unsigned long) create_tables((char *)p,argc,envc); + current->brk = ex.a_bss + + (current->end_data = ex.a_data + + (current->end_code = ex.a_text)); + current->start_stack = p & 0xfffff000; + current->euid = e_uid; + current->egid = e_gid; + i = ex.a_text+ex.a_data; + while (i&0xfff) + put_fs_byte(0,(char *) (i++)); + eip[0] = ex.a_entry; /* eip, magic happens :-) */ + eip[3] = p; /* stack pointer */ + return 0; +exec_error2: + iput(inode); +exec_error1: + for (i=0 ; i */ +#include +#include +#include +#include + +#include +#include + +extern int sys_close(int fd); + +static int dupfd(unsigned int fd, unsigned int arg) +{ + if (fd >= NR_OPEN || !current->filp[fd]) + return -EBADF; + if (arg >= NR_OPEN) + return -EINVAL; + while (arg < NR_OPEN) + if (current->filp[arg]) + arg++; + else + break; + if (arg >= NR_OPEN) + return -EMFILE; + current->close_on_exec &= ~(1<filp[arg] = current->filp[fd])->f_count++; + return arg; +} + +int sys_dup2(unsigned int oldfd, unsigned int newfd) +{ + sys_close(newfd); + return dupfd(oldfd,newfd); +} + +int sys_dup(unsigned int fildes) +{ + return dupfd(fildes,0); +} + +int sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg) +{ + struct file * filp; + + if (fd >= NR_OPEN || !(filp = current->filp[fd])) + return -EBADF; + switch (cmd) { + case F_DUPFD: + return dupfd(fd,arg); + case F_GETFD: + return (current->close_on_exec>>fd)&1; + case F_SETFD: + if (arg&1) + current->close_on_exec |= (1<close_on_exec &= ~(1<f_flags; + case F_SETFL: + filp->f_flags &= ~(O_APPEND | O_NONBLOCK); + filp->f_flags |= arg & (O_APPEND | O_NONBLOCK); + return 0; + case F_GETLK: case F_SETLK: case F_SETLKW: + return -1; + default: + return -1; + } +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/file_dev.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/file_dev.c new file mode 100644 index 0000000..4661b6f --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/file_dev.c @@ -0,0 +1,90 @@ +/* + * linux/fs/file_dev.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include + +#include +#include +#include + +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + +int file_read(struct m_inode * inode, struct file * filp, char * buf, int count) +{ + int left,chars,nr; + struct buffer_head * bh; + + if ((left=count)<=0) + return 0; + while (left) { + if ((nr = bmap(inode,(filp->f_pos)/BLOCK_SIZE))) { + if (!(bh=bread(inode->i_dev,nr))) + break; + } else + bh = NULL; + nr = filp->f_pos % BLOCK_SIZE; + chars = MIN( BLOCK_SIZE-nr , left ); + filp->f_pos += chars; + left -= chars; + if (bh) { + char * p = nr + bh->b_data; + while (chars-->0) + put_fs_byte(*(p++),buf++); + brelse(bh); + } else { + while (chars-->0) + put_fs_byte(0,buf++); + } + } + inode->i_atime = CURRENT_TIME; + return (count-left)?(count-left):-ERROR; +} + +int file_write(struct m_inode * inode, struct file * filp, char * buf, int count) +{ + off_t pos; + int block,c; + struct buffer_head * bh; + char * p; + int i=0; + +/* + * ok, append may not work when many processes are writing at the same time + * but so what. That way leads to madness anyway. + */ + if (filp->f_flags & O_APPEND) + pos = inode->i_size; + else + pos = filp->f_pos; + while (ii_dev,block))) + break; + c = pos % BLOCK_SIZE; + p = c + bh->b_data; + bh->b_dirt = 1; + c = BLOCK_SIZE-c; + if (c > count-i) c = count-i; + pos += c; + if (pos > inode->i_size) { + inode->i_size = pos; + inode->i_dirt = 1; + } + i += c; + while (c-->0) + *(p++) = get_fs_byte(buf++); + brelse(bh); + } + inode->i_mtime = CURRENT_TIME; + if (!(filp->f_flags & O_APPEND)) { + filp->f_pos = pos; + inode->i_ctime = CURRENT_TIME; + } + return (i?i:-1); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/file_table.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/file_table.c new file mode 100644 index 0000000..e0589ac --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/file_table.c @@ -0,0 +1,9 @@ +/* + * linux/fs/file_table.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +struct file file_table[NR_FILE]; diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/inode.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/inode.c new file mode 100644 index 0000000..d0b1c32 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/inode.c @@ -0,0 +1,338 @@ +/* + * linux/fs/inode.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include + +#include +#include +#include +#include + +struct m_inode inode_table[NR_INODE]={{0,},}; + +static void read_inode(struct m_inode * inode); +static void write_inode(struct m_inode * inode); + +static inline void wait_on_inode(struct m_inode * inode) +{ + cli(); + while (inode->i_lock) + sleep_on(&inode->i_wait); + sti(); +} + +static inline void lock_inode(struct m_inode * inode) +{ + cli(); + while (inode->i_lock) + sleep_on(&inode->i_wait); + inode->i_lock=1; + sti(); +} + +static inline void unlock_inode(struct m_inode * inode) +{ + inode->i_lock=0; + wake_up(&inode->i_wait); +} + +void invalidate_inodes(int dev) +{ + int i; + struct m_inode * inode; + + inode = 0+inode_table; + for(i=0 ; ii_dev == dev) { + if (inode->i_count) + printk("inode in use on removed disk\n\r"); + inode->i_dev = inode->i_dirt = 0; + } + } +} + +void sync_inodes(void) +{ + int i; + struct m_inode * inode; + + inode = 0+inode_table; + for(i=0 ; ii_dirt && !inode->i_pipe) + write_inode(inode); + } +} + +static int _bmap(struct m_inode * inode,int block,int create) +{ + struct buffer_head * bh; + int i; + + if (block<0) + panic("_bmap: block<0"); + if (block >= 7+512+512*512) + panic("_bmap: block>big"); + if (block<7) { + if (create && !inode->i_zone[block]) + if ((inode->i_zone[block]=new_block(inode->i_dev))) { + inode->i_ctime=CURRENT_TIME; + inode->i_dirt=1; + } + return inode->i_zone[block]; + } + block -= 7; + if (block<512) { + if (create && !inode->i_zone[7]) + if ((inode->i_zone[7]=new_block(inode->i_dev))) { + inode->i_dirt=1; + inode->i_ctime=CURRENT_TIME; + } + if (!inode->i_zone[7]) + return 0; + if (!(bh = bread(inode->i_dev,inode->i_zone[7]))) + return 0; + i = ((unsigned short *) (bh->b_data))[block]; + if (create && !i) + if ((i=new_block(inode->i_dev))) { + ((unsigned short *) (bh->b_data))[block]=i; + bh->b_dirt=1; + } + brelse(bh); + return i; + } + block -= 512; + if (create && !inode->i_zone[8]) + if ((inode->i_zone[8]=new_block(inode->i_dev))) { + inode->i_dirt=1; + inode->i_ctime=CURRENT_TIME; + } + if (!inode->i_zone[8]) + return 0; + if (!(bh=bread(inode->i_dev,inode->i_zone[8]))) + return 0; + i = ((unsigned short *)bh->b_data)[block>>9]; + if (create && !i) + if ((i=new_block(inode->i_dev))) { + ((unsigned short *) (bh->b_data))[block>>9]=i; + bh->b_dirt=1; + } + brelse(bh); + if (!i) + return 0; + if (!(bh=bread(inode->i_dev,i))) + return 0; + i = ((unsigned short *)bh->b_data)[block&511]; + if (create && !i) + if ((i=new_block(inode->i_dev))) { + ((unsigned short *) (bh->b_data))[block&511]=i; + bh->b_dirt=1; + } + brelse(bh); + return i; +} + +int bmap(struct m_inode * inode,int block) +{ + return _bmap(inode,block,0); +} + +int create_block(struct m_inode * inode, int block) +{ + return _bmap(inode,block,1); +} + +void iput(struct m_inode * inode) +{ + if (!inode) + return; + wait_on_inode(inode); + if (!inode->i_count) + panic("iput: trying to free free inode"); + if (inode->i_pipe) { + wake_up(&inode->i_wait); + if (--inode->i_count) + return; + free_page(inode->i_size); + inode->i_count=0; + inode->i_dirt=0; + inode->i_pipe=0; + return; + } + if (!inode->i_dev) { + inode->i_count--; + return; + } + if (S_ISBLK(inode->i_mode)) { + sync_dev(inode->i_zone[0]); + wait_on_inode(inode); + } +repeat: + if (inode->i_count>1) { + inode->i_count--; + return; + } + if (!inode->i_nlinks) { + truncate(inode); + free_inode(inode); + return; + } + if (inode->i_dirt) { + write_inode(inode); /* we can sleep - so do again */ + wait_on_inode(inode); + goto repeat; + } + inode->i_count--; + return; +} + +struct m_inode * get_empty_inode(void) +{ + struct m_inode * inode; + static struct m_inode * last_inode = inode_table; + int i; + + do { + inode = NULL; + for (i = NR_INODE; i ; i--) { + if (++last_inode >= inode_table + NR_INODE) + last_inode = inode_table; + if (!last_inode->i_count) { + inode = last_inode; + if (!inode->i_dirt && !inode->i_lock) + break; + } + } + if (!inode) { + for (i=0 ; ii_dirt) { + write_inode(inode); + wait_on_inode(inode); + } + } while (inode->i_count); + memset(inode,0,sizeof(*inode)); + inode->i_count = 1; + return inode; +} + +struct m_inode * get_pipe_inode(void) +{ + struct m_inode * inode; + + if (!(inode = get_empty_inode())) + return NULL; + if (!(inode->i_size=get_free_page())) { + inode->i_count = 0; + return NULL; + } + inode->i_count = 2; /* sum of readers/writers */ + PIPE_HEAD(*inode) = PIPE_TAIL(*inode) = 0; + inode->i_pipe = 1; + return inode; +} + +struct m_inode * iget(int dev,int nr) +{ + struct m_inode * inode, * empty; + + if (!dev) + panic("iget with dev==0"); + empty = get_empty_inode(); + inode = inode_table; + while (inode < NR_INODE+inode_table) { + if (inode->i_dev != dev || inode->i_num != nr) { + inode++; + continue; + } + wait_on_inode(inode); + if (inode->i_dev != dev || inode->i_num != nr) { + inode = inode_table; + continue; + } + inode->i_count++; + if (inode->i_mount) { + int i; + + for (i = 0 ; i= NR_SUPER) { + printk("Mounted inode hasn't got sb\n"); + if (empty) + iput(empty); + return inode; + } + iput(inode); + dev = super_block[i].s_dev; + nr = ROOT_INO; + inode = inode_table; + continue; + } + if (empty) + iput(empty); + return inode; + } + if (!empty) + return (NULL); + inode=empty; + inode->i_dev = dev; + inode->i_num = nr; + read_inode(inode); + return inode; +} + +static void read_inode(struct m_inode * inode) +{ + struct super_block * sb; + struct buffer_head * bh; + int block; + + lock_inode(inode); + if (!(sb=get_super(inode->i_dev))) + panic("trying to read inode without dev"); + block = 2 + sb->s_imap_blocks + sb->s_zmap_blocks + + (inode->i_num-1)/INODES_PER_BLOCK; + if (!(bh=bread(inode->i_dev,block))) + panic("unable to read i-node block"); + *(struct d_inode *)inode = + ((struct d_inode *)bh->b_data) + [(inode->i_num-1)%INODES_PER_BLOCK]; + brelse(bh); + unlock_inode(inode); +} + +static void write_inode(struct m_inode * inode) +{ + struct super_block * sb; + struct buffer_head * bh; + int block; + + lock_inode(inode); + if (!inode->i_dirt || !inode->i_dev) { + unlock_inode(inode); + return; + } + if (!(sb=get_super(inode->i_dev))) + panic("trying to write inode without device"); + block = 2 + sb->s_imap_blocks + sb->s_zmap_blocks + + (inode->i_num-1)/INODES_PER_BLOCK; + if (!(bh=bread(inode->i_dev,block))) + panic("unable to read i-node block"); + ((struct d_inode *)bh->b_data) + [(inode->i_num-1)%INODES_PER_BLOCK] = + *(struct d_inode *)inode; + bh->b_dirt=1; + inode->i_dirt=0; + brelse(bh); + unlock_inode(inode); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/ioctl.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/ioctl.c new file mode 100644 index 0000000..47ce3cb --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/ioctl.c @@ -0,0 +1,46 @@ +/* + * linux/fs/ioctl.c + * + * (C) 1991 Linus Torvalds + */ + +/* #include */ +#include +#include + +#include + +extern int tty_ioctl(int dev, int cmd, int arg); + +typedef int (*ioctl_ptr)(int dev,int cmd,int arg); + +#define NRDEVS ((sizeof (ioctl_table))/(sizeof (ioctl_ptr))) + +static ioctl_ptr ioctl_table[]={ + NULL, /* nodev */ + NULL, /* /dev/mem */ + NULL, /* /dev/fd */ + NULL, /* /dev/hd */ + tty_ioctl, /* /dev/ttyx */ + tty_ioctl, /* /dev/tty */ + NULL, /* /dev/lp */ + NULL}; /* named pipes */ + + +int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) +{ + struct file * filp; + int dev,mode; + + if (fd >= NR_OPEN || !(filp = current->filp[fd])) + return -EBADF; + mode=filp->f_inode->i_mode; + if (!S_ISCHR(mode) && !S_ISBLK(mode)) + return -EINVAL; + dev = filp->f_inode->i_zone[0]; + if (MAJOR(dev) >= NRDEVS) + return -ENODEV; + if (!ioctl_table[MAJOR(dev)]) + return -ENOTTY; + return ioctl_table[MAJOR(dev)](dev,cmd,arg); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/namei.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/namei.c new file mode 100644 index 0000000..97d0de4 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/namei.c @@ -0,0 +1,778 @@ +/* + * linux/fs/namei.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * Some corrections by tytso. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#define ACC_MODE(x) ("\004\002\006\377"[(x)&O_ACCMODE]) + +/* + * comment out this line if you want names > NAME_LEN chars to be + * truncated. Else they will be disallowed. + */ +/* #define NO_TRUNCATE */ + +#define MAY_EXEC 1 +#define MAY_WRITE 2 +#define MAY_READ 4 + +/* + * permission() + * + * is used to check for read/write/execute permissions on a file. + * I don't know if we should look at just the euid or both euid and + * uid, but that should be easily changed. + */ +static int permission(struct m_inode * inode,int mask) +{ + int mode = inode->i_mode; + +/* special case: not even root can read/write a deleted file */ + if (inode->i_dev && !inode->i_nlinks) + return 0; + else if (current->euid==inode->i_uid) + mode >>= 6; + else if (current->egid==inode->i_gid) + mode >>= 3; + if (((mode & mask & 0007) == mask) || suser()) + return 1; + return 0; +} + +/* + * ok, we cannot use strncmp, as the name is not in our data space. + * Thus we'll have to use match. No big problem. Match also makes + * some sanity tests. + * + * NOTE! unlike strncmp, match returns 1 for success, 0 for failure. + */ +static int match(int len,const char * name,struct dir_entry * de) +{ + register int same ; + + if (!de || !de->inode || len > NAME_LEN) + return 0; + if (len < NAME_LEN && de->name[len]) + return 0; + __asm__("cld\n\t" + "fs ; repe ; cmpsb\n\t" + "setz %%al" + :"=a" (same) + :"0" (0),"S" ((long) name),"D" ((long) de->name),"c" (len) + ); + return same; +} + +/* + * find_entry() + * + * finds an entry in the specified directory with the wanted name. It + * returns the cache buffer in which the entry was found, and the entry + * itself (as a parameter - res_dir). It does NOT read the inode of the + * entry - you'll have to do that yourself if you want to. + * + * This also takes care of the few special cases due to '..'-traversal + * over a pseudo-root and a mount point. + */ +static struct buffer_head * find_entry(struct m_inode ** dir, + const char * name, int namelen, struct dir_entry ** res_dir) +{ + int entries; + int block,i; + struct buffer_head * bh; + struct dir_entry * de; + struct super_block * sb; + +#ifdef NO_TRUNCATE + if (namelen > NAME_LEN) + return NULL; +#else + if (namelen > NAME_LEN) + namelen = NAME_LEN; +#endif + entries = (*dir)->i_size / (sizeof (struct dir_entry)); + *res_dir = NULL; + if (!namelen) + return NULL; +/* check for '..', as we might have to do some "magic" for it */ + if (namelen==2 && get_fs_byte(name)=='.' && get_fs_byte(name+1)=='.') { +/* '..' in a pseudo-root results in a faked '.' (just change namelen) */ + if ((*dir) == current->root) + namelen=1; + else if ((*dir)->i_num == ROOT_INO) { +/* '..' over a mount-point results in 'dir' being exchanged for the mounted + directory-inode. NOTE! We set mounted, so that we can iput the new dir */ + sb=get_super((*dir)->i_dev); + if (sb->s_imount) { + iput(*dir); + (*dir)=sb->s_imount; + (*dir)->i_count++; + } + } + } + if (!(block = (*dir)->i_zone[0])) + return NULL; + if (!(bh = bread((*dir)->i_dev,block))) + return NULL; + i = 0; + de = (struct dir_entry *) bh->b_data; + while (i < entries) { + if ((char *)de >= BLOCK_SIZE+bh->b_data) { + brelse(bh); + bh = NULL; + if (!(block = bmap(*dir,i/DIR_ENTRIES_PER_BLOCK)) || + !(bh = bread((*dir)->i_dev,block))) { + i += DIR_ENTRIES_PER_BLOCK; + continue; + } + de = (struct dir_entry *) bh->b_data; + } + if (match(namelen,name,de)) { + *res_dir = de; + return bh; + } + de++; + i++; + } + brelse(bh); + return NULL; +} + +/* + * add_entry() + * + * adds a file entry to the specified directory, using the same + * semantics as find_entry(). It returns NULL if it failed. + * + * NOTE!! The inode part of 'de' is left at 0 - which means you + * may not sleep between calling this and putting something into + * the entry, as someone else might have used it while you slept. + */ +static struct buffer_head * add_entry(struct m_inode * dir, + const char * name, int namelen, struct dir_entry ** res_dir) +{ + int block,i; + struct buffer_head * bh; + struct dir_entry * de; + + *res_dir = NULL; +#ifdef NO_TRUNCATE + if (namelen > NAME_LEN) + return NULL; +#else + if (namelen > NAME_LEN) + namelen = NAME_LEN; +#endif + if (!namelen) + return NULL; + if (!(block = dir->i_zone[0])) + return NULL; + if (!(bh = bread(dir->i_dev,block))) + return NULL; + i = 0; + de = (struct dir_entry *) bh->b_data; + while (1) { + if ((char *)de >= BLOCK_SIZE+bh->b_data) { + brelse(bh); + bh = NULL; + block = create_block(dir,i/DIR_ENTRIES_PER_BLOCK); + if (!block) + return NULL; + if (!(bh = bread(dir->i_dev,block))) { + i += DIR_ENTRIES_PER_BLOCK; + continue; + } + de = (struct dir_entry *) bh->b_data; + } + if (i*sizeof(struct dir_entry) >= dir->i_size) { + de->inode=0; + dir->i_size = (i+1)*sizeof(struct dir_entry); + dir->i_dirt = 1; + dir->i_ctime = CURRENT_TIME; + } + if (!de->inode) { + dir->i_mtime = CURRENT_TIME; + for (i=0; i < NAME_LEN ; i++) + de->name[i]=(ib_dirt = 1; + *res_dir = de; + return bh; + } + de++; + i++; + } + brelse(bh); + return NULL; +} + +/* + * get_dir() + * + * Getdir traverses the pathname until it hits the topmost directory. + * It returns NULL on failure. + */ +static struct m_inode * get_dir(const char * pathname) +{ + char c; + const char * thisname; + struct m_inode * inode; + struct buffer_head * bh; + int namelen,inr,idev; + struct dir_entry * de; + + if (!current->root || !current->root->i_count) + panic("No root inode"); + if (!current->pwd || !current->pwd->i_count) + panic("No cwd inode"); + if ((c=get_fs_byte(pathname))=='/') { + inode = current->root; + pathname++; + } else if (c) + inode = current->pwd; + else + return NULL; /* empty name is bad */ + inode->i_count++; + while (1) { + thisname = pathname; + if (!S_ISDIR(inode->i_mode) || !permission(inode,MAY_EXEC)) { + iput(inode); + return NULL; + } + for(namelen=0;(c=get_fs_byte(pathname++))&&(c!='/');namelen++) + /* nothing */ ; + if (!c) + return inode; + if (!(bh = find_entry(&inode,thisname,namelen,&de))) { + iput(inode); + return NULL; + } + inr = de->inode; + idev = inode->i_dev; + brelse(bh); + iput(inode); + if (!(inode = iget(idev,inr))) + return NULL; + } +} + +/* + * dir_namei() + * + * dir_namei() returns the inode of the directory of the + * specified name, and the name within that directory. + */ +static struct m_inode * dir_namei(const char * pathname, + int * namelen, const char ** name) +{ + char c; + const char * basename; + struct m_inode * dir; + + if (!(dir = get_dir(pathname))) + return NULL; + basename = pathname; + while ((c=get_fs_byte(pathname++))) + if (c=='/') + basename=pathname; + *namelen = pathname-basename-1; + *name = basename; + return dir; +} + +/* + * namei() + * + * is used by most simple commands to get the inode of a specified name. + * Open, link etc use their own routines, but this is enough for things + * like 'chmod' etc. + */ +struct m_inode * namei(const char * pathname) +{ + const char * basename; + int inr,dev,namelen; + struct m_inode * dir; + struct buffer_head * bh; + struct dir_entry * de; + + if (!(dir = dir_namei(pathname,&namelen,&basename))) + return NULL; + if (!namelen) /* special case: '/usr/' etc */ + return dir; + bh = find_entry(&dir,basename,namelen,&de); + if (!bh) { + iput(dir); + return NULL; + } + inr = de->inode; + dev = dir->i_dev; + brelse(bh); + iput(dir); + dir=iget(dev,inr); + if (dir) { + dir->i_atime=CURRENT_TIME; + dir->i_dirt=1; + } + return dir; +} + +/* + * open_namei() + * + * namei for open - this is in fact almost the whole open-routine. + */ +int open_namei(const char * pathname, int flag, int mode, + struct m_inode ** res_inode) +{ + const char * basename; + int inr,dev,namelen; + struct m_inode * dir, *inode; + struct buffer_head * bh; + struct dir_entry * de; + + if ((flag & O_TRUNC) && !(flag & O_ACCMODE)) + flag |= O_WRONLY; + mode &= 0777 & ~current->umask; + mode |= I_REGULAR; + if (!(dir = dir_namei(pathname,&namelen,&basename))) + return -ENOENT; + if (!namelen) { /* special case: '/usr/' etc */ + if (!(flag & (O_ACCMODE|O_CREAT|O_TRUNC))) { + *res_inode=dir; + return 0; + } + iput(dir); + return -EISDIR; + } + bh = find_entry(&dir,basename,namelen,&de); + if (!bh) { + if (!(flag & O_CREAT)) { + iput(dir); + return -ENOENT; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + return -EACCES; + } + inode = new_inode(dir->i_dev); + if (!inode) { + iput(dir); + return -ENOSPC; + } + inode->i_uid = current->euid; + inode->i_mode = mode; + inode->i_dirt = 1; + bh = add_entry(dir,basename,namelen,&de); + if (!bh) { + inode->i_nlinks--; + iput(inode); + iput(dir); + return -ENOSPC; + } + de->inode = inode->i_num; + bh->b_dirt = 1; + brelse(bh); + iput(dir); + *res_inode = inode; + return 0; + } + inr = de->inode; + dev = dir->i_dev; + brelse(bh); + iput(dir); + if (flag & O_EXCL) + return -EEXIST; + if (!(inode=iget(dev,inr))) + return -EACCES; + if ((S_ISDIR(inode->i_mode) && (flag & O_ACCMODE)) || + !permission(inode,ACC_MODE(flag))) { + iput(inode); + return -EPERM; + } + inode->i_atime = CURRENT_TIME; + if (flag & O_TRUNC) + truncate(inode); + *res_inode = inode; + return 0; +} + +int sys_mknod(const char * filename, int mode, int dev) +{ + const char * basename; + int namelen; + struct m_inode * dir, * inode; + struct buffer_head * bh; + struct dir_entry * de; + + if (!suser()) + return -EPERM; + if (!(dir = dir_namei(filename,&namelen,&basename))) + return -ENOENT; + if (!namelen) { + iput(dir); + return -ENOENT; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + return -EPERM; + } + bh = find_entry(&dir,basename,namelen,&de); + if (bh) { + brelse(bh); + iput(dir); + return -EEXIST; + } + inode = new_inode(dir->i_dev); + if (!inode) { + iput(dir); + return -ENOSPC; + } + inode->i_mode = mode; + if (S_ISBLK(mode) || S_ISCHR(mode)) + inode->i_zone[0] = dev; + inode->i_mtime = inode->i_atime = CURRENT_TIME; + inode->i_dirt = 1; + bh = add_entry(dir,basename,namelen,&de); + if (!bh) { + iput(dir); + inode->i_nlinks=0; + iput(inode); + return -ENOSPC; + } + de->inode = inode->i_num; + bh->b_dirt = 1; + iput(dir); + iput(inode); + brelse(bh); + return 0; +} + +int sys_mkdir(const char * pathname, int mode) +{ + const char * basename; + int namelen; + struct m_inode * dir, * inode; + struct buffer_head * bh, *dir_block; + struct dir_entry * de; + + if (!suser()) + return -EPERM; + if (!(dir = dir_namei(pathname,&namelen,&basename))) + return -ENOENT; + if (!namelen) { + iput(dir); + return -ENOENT; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + return -EPERM; + } + bh = find_entry(&dir,basename,namelen,&de); + if (bh) { + brelse(bh); + iput(dir); + return -EEXIST; + } + inode = new_inode(dir->i_dev); + if (!inode) { + iput(dir); + return -ENOSPC; + } + inode->i_size = 32; + inode->i_dirt = 1; + inode->i_mtime = inode->i_atime = CURRENT_TIME; + if (!(inode->i_zone[0]=new_block(inode->i_dev))) { + iput(dir); + inode->i_nlinks--; + iput(inode); + return -ENOSPC; + } + inode->i_dirt = 1; + if (!(dir_block=bread(inode->i_dev,inode->i_zone[0]))) { + iput(dir); + free_block(inode->i_dev,inode->i_zone[0]); + inode->i_nlinks--; + iput(inode); + return -ERROR; + } + de = (struct dir_entry *) dir_block->b_data; + de->inode=inode->i_num; + strcpy(de->name,"."); + de++; + de->inode = dir->i_num; + strcpy(de->name,".."); + inode->i_nlinks = 2; + dir_block->b_dirt = 1; + brelse(dir_block); + inode->i_mode = I_DIRECTORY | (mode & 0777 & ~current->umask); + inode->i_dirt = 1; + bh = add_entry(dir,basename,namelen,&de); + if (!bh) { + iput(dir); + free_block(inode->i_dev,inode->i_zone[0]); + inode->i_nlinks=0; + iput(inode); + return -ENOSPC; + } + de->inode = inode->i_num; + bh->b_dirt = 1; + dir->i_nlinks++; + dir->i_dirt = 1; + iput(dir); + iput(inode); + brelse(bh); + return 0; +} + +/* + * routine to check that the specified directory is empty (for rmdir) + */ +static int empty_dir(struct m_inode * inode) +{ + int nr,block; + int len; + struct buffer_head * bh; + struct dir_entry * de; + + len = inode->i_size / sizeof (struct dir_entry); + if (len<2 || !inode->i_zone[0] || + !(bh=bread(inode->i_dev,inode->i_zone[0]))) { + printk("warning - bad directory on dev %04x\n",inode->i_dev); + return 0; + } + de = (struct dir_entry *) bh->b_data; + if (de[0].inode != inode->i_num || !de[1].inode || + strcmp(".",de[0].name) || strcmp("..",de[1].name)) { + printk("warning - bad directory on dev %04x\n",inode->i_dev); + return 0; + } + nr = 2; + de += 2; + while (nr= (void *) (bh->b_data+BLOCK_SIZE)) { + brelse(bh); + block=bmap(inode,nr/DIR_ENTRIES_PER_BLOCK); + if (!block) { + nr += DIR_ENTRIES_PER_BLOCK; + continue; + } + if (!(bh=bread(inode->i_dev,block))) + return 0; + de = (struct dir_entry *) bh->b_data; + } + if (de->inode) { + brelse(bh); + return 0; + } + de++; + nr++; + } + brelse(bh); + return 1; +} + +int sys_rmdir(const char * name) +{ + const char * basename; + int namelen; + struct m_inode * dir, * inode; + struct buffer_head * bh; + struct dir_entry * de; + + if (!suser()) + return -EPERM; + if (!(dir = dir_namei(name,&namelen,&basename))) + return -ENOENT; + if (!namelen) { + iput(dir); + return -ENOENT; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + return -EPERM; + } + bh = find_entry(&dir,basename,namelen,&de); + if (!bh) { + iput(dir); + return -ENOENT; + } + if (!(inode = iget(dir->i_dev, de->inode))) { + iput(dir); + brelse(bh); + return -EPERM; + } + if ((dir->i_mode & S_ISVTX) && current->euid && + inode->i_uid != current->euid) { + iput(dir); + iput(inode); + brelse(bh); + return -EPERM; + } + if (inode->i_dev != dir->i_dev || inode->i_count>1) { + iput(dir); + iput(inode); + brelse(bh); + return -EPERM; + } + if (inode == dir) { /* we may not delete ".", but "../dir" is ok */ + iput(inode); + iput(dir); + brelse(bh); + return -EPERM; + } + if (!S_ISDIR(inode->i_mode)) { + iput(inode); + iput(dir); + brelse(bh); + return -ENOTDIR; + } + if (!empty_dir(inode)) { + iput(inode); + iput(dir); + brelse(bh); + return -ENOTEMPTY; + } + if (inode->i_nlinks != 2) + printk("empty directory has nlink!=2 (%d)",inode->i_nlinks); + de->inode = 0; + bh->b_dirt = 1; + brelse(bh); + inode->i_nlinks=0; + inode->i_dirt=1; + dir->i_nlinks--; + dir->i_ctime = dir->i_mtime = CURRENT_TIME; + dir->i_dirt=1; + iput(dir); + iput(inode); + return 0; +} + +int sys_unlink(const char * name) +{ + const char * basename; + int namelen; + struct m_inode * dir, * inode; + struct buffer_head * bh; + struct dir_entry * de; + + if (!(dir = dir_namei(name,&namelen,&basename))) + return -ENOENT; + if (!namelen) { + iput(dir); + return -ENOENT; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + return -EPERM; + } + bh = find_entry(&dir,basename,namelen,&de); + if (!bh) { + iput(dir); + return -ENOENT; + } + if (!(inode = iget(dir->i_dev, de->inode))) { + iput(dir); + brelse(bh); + return -ENOENT; + } + if ((dir->i_mode & S_ISVTX) && !suser() && + current->euid != inode->i_uid && + current->euid != dir->i_uid) { + iput(dir); + iput(inode); + brelse(bh); + return -EPERM; + } + if (S_ISDIR(inode->i_mode)) { + iput(inode); + iput(dir); + brelse(bh); + return -EPERM; + } + if (!inode->i_nlinks) { + printk("Deleting nonexistent file (%04x:%d), %d\n", + inode->i_dev,inode->i_num,inode->i_nlinks); + inode->i_nlinks=1; + } + de->inode = 0; + bh->b_dirt = 1; + brelse(bh); + inode->i_nlinks--; + inode->i_dirt = 1; + inode->i_ctime = CURRENT_TIME; + iput(inode); + iput(dir); + return 0; +} + +int sys_link(const char * oldname, const char * newname) +{ + struct dir_entry * de; + struct m_inode * oldinode, * dir; + struct buffer_head * bh; + const char * basename; + int namelen; + + oldinode=namei(oldname); + if (!oldinode) + return -ENOENT; + if (S_ISDIR(oldinode->i_mode)) { + iput(oldinode); + return -EPERM; + } + dir = dir_namei(newname,&namelen,&basename); + if (!dir) { + iput(oldinode); + return -EACCES; + } + if (!namelen) { + iput(oldinode); + iput(dir); + return -EPERM; + } + if (dir->i_dev != oldinode->i_dev) { + iput(dir); + iput(oldinode); + return -EXDEV; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + iput(oldinode); + return -EACCES; + } + bh = find_entry(&dir,basename,namelen,&de); + if (bh) { + brelse(bh); + iput(dir); + iput(oldinode); + return -EEXIST; + } + bh = add_entry(dir,basename,namelen,&de); + if (!bh) { + iput(dir); + iput(oldinode); + return -ENOSPC; + } + de->inode = oldinode->i_num; + bh->b_dirt = 1; + brelse(bh); + iput(dir); + oldinode->i_nlinks++; + oldinode->i_ctime = CURRENT_TIME; + oldinode->i_dirt = 1; + iput(oldinode); + return 0; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/open.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/open.c new file mode 100644 index 0000000..cac0082 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/open.c @@ -0,0 +1,209 @@ +/* + * linux/fs/open.c + * + * (C) 1991 Linus Torvalds + */ + +/* #include */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +int sys_ustat(int dev, struct ustat * ubuf) +{ + return -ENOSYS; +} + +int sys_utime(char * filename, struct utimbuf * times) +{ + struct m_inode * inode; + long actime,modtime; + + if (!(inode=namei(filename))) + return -ENOENT; + if (times) { + actime = get_fs_long((unsigned long *) ×->actime); + modtime = get_fs_long((unsigned long *) ×->modtime); + } else + actime = modtime = CURRENT_TIME; + inode->i_atime = actime; + inode->i_mtime = modtime; + inode->i_dirt = 1; + iput(inode); + return 0; +} + +/* + * XXX should we use the real or effective uid? BSD uses the real uid, + * so as to make this call useful to setuid programs. + */ +int sys_access(const char * filename,int mode) +{ + struct m_inode * inode; + int res, i_mode; + + mode &= 0007; + if (!(inode=namei(filename))) + return -EACCES; + i_mode = res = inode->i_mode & 0777; + iput(inode); + if (current->uid == inode->i_uid) + res >>= 6; + else if (current->gid == inode->i_gid) + res >>= 6; + if ((res & 0007 & mode) == mode) + return 0; + /* + * XXX we are doing this test last because we really should be + * swapping the effective with the real user id (temporarily), + * and then calling suser() routine. If we do call the + * suser() routine, it needs to be called last. + */ + if ((!current->uid) && + (!(mode & 1) || (i_mode & 0111))) + return 0; + return -EACCES; +} + +int sys_chdir(const char * filename) +{ + struct m_inode * inode; + + if (!(inode = namei(filename))) + return -ENOENT; + if (!S_ISDIR(inode->i_mode)) { + iput(inode); + return -ENOTDIR; + } + iput(current->pwd); + current->pwd = inode; + return (0); +} + +int sys_chroot(const char * filename) +{ + struct m_inode * inode; + + if (!(inode=namei(filename))) + return -ENOENT; + if (!S_ISDIR(inode->i_mode)) { + iput(inode); + return -ENOTDIR; + } + iput(current->root); + current->root = inode; + return (0); +} + +int sys_chmod(const char * filename,int mode) +{ + struct m_inode * inode; + + if (!(inode=namei(filename))) + return -ENOENT; + if ((current->euid != inode->i_uid) && !suser()) { + iput(inode); + return -EACCES; + } + inode->i_mode = (mode & 07777) | (inode->i_mode & ~07777); + inode->i_dirt = 1; + iput(inode); + return 0; +} + +int sys_chown(const char * filename,int uid,int gid) +{ + struct m_inode * inode; + + if (!(inode=namei(filename))) + return -ENOENT; + if (!suser()) { + iput(inode); + return -EACCES; + } + inode->i_uid=uid; + inode->i_gid=gid; + inode->i_dirt=1; + iput(inode); + return 0; +} + +int sys_open(const char * filename,int flag,int mode) +{ + struct m_inode * inode; + struct file * f; + int i,fd; + + mode &= 0777 & ~current->umask; + for(fd=0 ; fdfilp[fd]) + break; + if (fd>=NR_OPEN) + return -EINVAL; + current->close_on_exec &= ~(1<f_count) break; + if (i>=NR_FILE) + return -EINVAL; + (current->filp[fd]=f)->f_count++; + if ((i=open_namei(filename,flag,mode,&inode))<0) { + current->filp[fd]=NULL; + f->f_count=0; + return i; + } +/* ttys are somewhat special (ttyxx major==4, tty major==5) */ + if (S_ISCHR(inode->i_mode)) { + if (MAJOR(inode->i_zone[0])==4) { + if (current->leader && current->tty<0) { + current->tty = MINOR(inode->i_zone[0]); + tty_table[current->tty].pgrp = current->pgrp; + } + } else if (MAJOR(inode->i_zone[0])==5) + if (current->tty<0) { + iput(inode); + current->filp[fd]=NULL; + f->f_count=0; + return -EPERM; + } + } +/* Likewise with block-devices: check for floppy_change */ + if (S_ISBLK(inode->i_mode)) + check_disk_change(inode->i_zone[0]); + f->f_mode = inode->i_mode; + f->f_flags = flag; + f->f_count = 1; + f->f_inode = inode; + f->f_pos = 0; + return (fd); +} + +int sys_creat(const char * pathname, int mode) +{ + return sys_open(pathname, O_CREAT | O_TRUNC, mode); +} + +int sys_close(unsigned int fd) +{ + struct file * filp; + + if (fd >= NR_OPEN) + return -EINVAL; + current->close_on_exec &= ~(1<filp[fd])) + return -EINVAL; + current->filp[fd] = NULL; + if (filp->f_count == 0) + panic("Close: file count is 0"); + if (--filp->f_count) + return (0); + iput(filp->f_inode); + return (0); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/pipe.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/pipe.c new file mode 100644 index 0000000..dfc4480 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/pipe.c @@ -0,0 +1,111 @@ +/* + * linux/fs/pipe.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +#include +#include /* for get_free_page */ +#include + +int read_pipe(struct m_inode * inode, char * buf, int count) +{ + int chars, size, read = 0; + + while (count>0) { + while (!(size=PIPE_SIZE(*inode))) { + wake_up(&inode->i_wait); + if (inode->i_count != 2) /* are there any writers? */ + return read; + sleep_on(&inode->i_wait); + } + chars = PAGE_SIZE-PIPE_TAIL(*inode); + if (chars > count) + chars = count; + if (chars > size) + chars = size; + count -= chars; + read += chars; + size = PIPE_TAIL(*inode); + PIPE_TAIL(*inode) += chars; + PIPE_TAIL(*inode) &= (PAGE_SIZE-1); + while (chars-->0) + put_fs_byte(((char *)inode->i_size)[size++],buf++); + } + wake_up(&inode->i_wait); + return read; +} + +int write_pipe(struct m_inode * inode, char * buf, int count) +{ + int chars, size, written = 0; + + while (count>0) { + while (!(size=(PAGE_SIZE-1)-PIPE_SIZE(*inode))) { + wake_up(&inode->i_wait); + if (inode->i_count != 2) { /* no readers */ + current->signal |= (1<<(SIGPIPE-1)); + return written?written:-1; + } + sleep_on(&inode->i_wait); + } + chars = PAGE_SIZE-PIPE_HEAD(*inode); + if (chars > count) + chars = count; + if (chars > size) + chars = size; + count -= chars; + written += chars; + size = PIPE_HEAD(*inode); + PIPE_HEAD(*inode) += chars; + PIPE_HEAD(*inode) &= (PAGE_SIZE-1); + while (chars-->0) + ((char *)inode->i_size)[size++]=get_fs_byte(buf++); + } + wake_up(&inode->i_wait); + return written; +} + +int sys_pipe(unsigned long * fildes) +{ + struct m_inode * inode; + struct file * f[2]; + int fd[2]; + int i,j; + + j=0; + for(i=0;j<2 && if_count++; + if (j==1) + f[0]->f_count=0; + if (j<2) + return -1; + j=0; + for(i=0;j<2 && ifilp[i]) { + current->filp[ fd[j]=i ] = f[j]; + j++; + } + if (j==1) + current->filp[fd[0]]=NULL; + if (j<2) { + f[0]->f_count=f[1]->f_count=0; + return -1; + } + if (!(inode=get_pipe_inode())) { + current->filp[fd[0]] = + current->filp[fd[1]] = NULL; + f[0]->f_count = f[1]->f_count = 0; + return -1; + } + f[0]->f_inode = f[1]->f_inode = inode; + f[0]->f_pos = f[1]->f_pos = 0; + f[0]->f_mode = 1; /* read */ + f[1]->f_mode = 2; /* write */ + put_fs_long(fd[0],0+fildes); + put_fs_long(fd[1],1+fildes); + return 0; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/read_write.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/read_write.c new file mode 100644 index 0000000..341274a --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/read_write.c @@ -0,0 +1,103 @@ +/* + * linux/fs/read_write.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include +#include + +#include +#include +#include + +extern int rw_char(int rw,int dev, char * buf, int count, off_t * pos); +extern int read_pipe(struct m_inode * inode, char * buf, int count); +extern int write_pipe(struct m_inode * inode, char * buf, int count); +extern int block_read(int dev, off_t * pos, char * buf, int count); +extern int block_write(int dev, off_t * pos, char * buf, int count); +extern int file_read(struct m_inode * inode, struct file * filp, + char * buf, int count); +extern int file_write(struct m_inode * inode, struct file * filp, + char * buf, int count); + +int sys_lseek(unsigned int fd,off_t offset, int origin) +{ + struct file * file; + int tmp; + + if (fd >= NR_OPEN || !(file=current->filp[fd]) || !(file->f_inode) + || !IS_SEEKABLE(MAJOR(file->f_inode->i_dev))) + return -EBADF; + if (file->f_inode->i_pipe) + return -ESPIPE; + switch (origin) { + case 0: + if (offset<0) return -EINVAL; + file->f_pos=offset; + break; + case 1: + if (file->f_pos+offset<0) return -EINVAL; + file->f_pos += offset; + break; + case 2: + if ((tmp=file->f_inode->i_size+offset) < 0) + return -EINVAL; + file->f_pos = tmp; + break; + default: + return -EINVAL; + } + return file->f_pos; +} + +int sys_read(unsigned int fd,char * buf,int count) +{ + struct file * file; + struct m_inode * inode; + + if (fd>=NR_OPEN || count<0 || !(file=current->filp[fd])) + return -EINVAL; + if (!count) + return 0; + verify_area(buf,count); + inode = file->f_inode; + if (inode->i_pipe) + return (file->f_mode&1)?read_pipe(inode,buf,count):-EIO; + if (S_ISCHR(inode->i_mode)) + return rw_char(READ,inode->i_zone[0],buf,count,&file->f_pos); + if (S_ISBLK(inode->i_mode)) + return block_read(inode->i_zone[0],&file->f_pos,buf,count); + if (S_ISDIR(inode->i_mode) || S_ISREG(inode->i_mode)) { + if (count+file->f_pos > inode->i_size) + count = inode->i_size - file->f_pos; + if (count<=0) + return 0; + return file_read(inode,file,buf,count); + } + printk("(Read)inode->i_mode=%06o\n\r",inode->i_mode); + return -EINVAL; +} + +int sys_write(unsigned int fd,char * buf,int count) +{ + struct file * file; + struct m_inode * inode; + + if (fd>=NR_OPEN || count <0 || !(file=current->filp[fd])) + return -EINVAL; + if (!count) + return 0; + inode=file->f_inode; + if (inode->i_pipe) + return (file->f_mode&2)?write_pipe(inode,buf,count):-EIO; + if (S_ISCHR(inode->i_mode)) + return rw_char(WRITE,inode->i_zone[0],buf,count,&file->f_pos); + if (S_ISBLK(inode->i_mode)) + return block_write(inode->i_zone[0],&file->f_pos,buf,count); + if (S_ISREG(inode->i_mode)) + return file_write(inode,file,buf,count); + printk("(Write)inode->i_mode=%06o\n\r",inode->i_mode); + return -EINVAL; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/stat.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/stat.c new file mode 100644 index 0000000..61a4ceb --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/stat.c @@ -0,0 +1,56 @@ +/* + * linux/fs/stat.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include + +#include +#include +#include +#include + +static void cp_stat(struct m_inode * inode, struct stat * statbuf) +{ + struct stat tmp; + int i; + + verify_area(statbuf,sizeof (* statbuf)); + tmp.st_dev = inode->i_dev; + tmp.st_ino = inode->i_num; + tmp.st_mode = inode->i_mode; + tmp.st_nlink = inode->i_nlinks; + tmp.st_uid = inode->i_uid; + tmp.st_gid = inode->i_gid; + tmp.st_rdev = inode->i_zone[0]; + tmp.st_size = inode->i_size; + tmp.st_atime = inode->i_atime; + tmp.st_mtime = inode->i_mtime; + tmp.st_ctime = inode->i_ctime; + for (i=0 ; i= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode)) + return -EBADF; + cp_stat(inode,statbuf); + return 0; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/super.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/super.c new file mode 100644 index 0000000..39c4089 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/super.c @@ -0,0 +1,281 @@ +/* + * linux/fs/super.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * super.c contains code to handle the super-block tables. + */ +#include +#include +#include +#include + +#include +#include + +int sync_dev(int dev); +void wait_for_keypress(void); + +/* set_bit uses setb, as gas doesn't recognize setc */ +#define set_bit(bitnr,addr) ({ \ +register int __res ; \ +__asm__("bt %2,%3;setb %%al":"=a" (__res):"a" (0),"r" (bitnr),"m" (*(addr))); \ +__res; }) + +struct super_block super_block[NR_SUPER]; +/* this is initialized in init/main.c */ +int ROOT_DEV = 0; + +static void lock_super(struct super_block * sb) +{ + cli(); + while (sb->s_lock) + sleep_on(&(sb->s_wait)); + sb->s_lock = 1; + sti(); +} + +static void free_super(struct super_block * sb) +{ + cli(); + sb->s_lock = 0; + wake_up(&(sb->s_wait)); + sti(); +} + +static void wait_on_super(struct super_block * sb) +{ + cli(); + while (sb->s_lock) + sleep_on(&(sb->s_wait)); + sti(); +} + +struct super_block * get_super(int dev) +{ + struct super_block * s; + + if (!dev) + return NULL; + s = 0+super_block; + while (s < NR_SUPER+super_block) + if (s->s_dev == dev) { + wait_on_super(s); + if (s->s_dev == dev) + return s; + s = 0+super_block; + } else + s++; + return NULL; +} + +void put_super(int dev) +{ + struct super_block * sb; + /* struct m_inode * inode;*/ + int i; + + if (dev == ROOT_DEV) { + printk("root diskette changed: prepare for armageddon\n\r"); + return; + } + if (!(sb = get_super(dev))) + return; + if (sb->s_imount) { + printk("Mounted disk changed - tssk, tssk\n\r"); + return; + } + lock_super(sb); + sb->s_dev = 0; + for(i=0;is_imap[i]); + for(i=0;is_zmap[i]); + free_super(sb); + return; +} + +static struct super_block * read_super(int dev) +{ + struct super_block * s; + struct buffer_head * bh; + int i,block; + + if (!dev) + return NULL; + check_disk_change(dev); + if ((s = get_super(dev))) + return s; + for (s = 0+super_block ;; s++) { + if (s >= NR_SUPER+super_block) + return NULL; + if (!s->s_dev) + break; + } + s->s_dev = dev; + s->s_isup = NULL; + s->s_imount = NULL; + s->s_time = 0; + s->s_rd_only = 0; + s->s_dirt = 0; + lock_super(s); + if (!(bh = bread(dev,1))) { + s->s_dev=0; + free_super(s); + return NULL; + } + *((struct d_super_block *) s) = + *((struct d_super_block *) bh->b_data); + brelse(bh); + if (s->s_magic != SUPER_MAGIC) { + s->s_dev = 0; + free_super(s); + return NULL; + } + for (i=0;is_imap[i] = NULL; + for (i=0;is_zmap[i] = NULL; + block=2; + for (i=0 ; i < s->s_imap_blocks ; i++) + if ((s->s_imap[i]=bread(dev,block))) + block++; + else + break; + for (i=0 ; i < s->s_zmap_blocks ; i++) + if ((s->s_zmap[i]=bread(dev,block))) + block++; + else + break; + if (block != 2+s->s_imap_blocks+s->s_zmap_blocks) { + for(i=0;is_imap[i]); + for(i=0;is_zmap[i]); + s->s_dev=0; + free_super(s); + return NULL; + } + s->s_imap[0]->b_data[0] |= 1; + s->s_zmap[0]->b_data[0] |= 1; + free_super(s); + return s; +} + +int sys_umount(char * dev_name) +{ + struct m_inode * inode; + struct super_block * sb; + int dev; + + if (!(inode=namei(dev_name))) + return -ENOENT; + dev = inode->i_zone[0]; + if (!S_ISBLK(inode->i_mode)) { + iput(inode); + return -ENOTBLK; + } + iput(inode); + if (dev==ROOT_DEV) + return -EBUSY; + if (!(sb=get_super(dev)) || !(sb->s_imount)) + return -ENOENT; + if (!sb->s_imount->i_mount) + printk("Mounted inode has i_mount=0\n"); + for (inode=inode_table+0 ; inodei_dev==dev && inode->i_count) + return -EBUSY; + sb->s_imount->i_mount=0; + iput(sb->s_imount); + sb->s_imount = NULL; + iput(sb->s_isup); + sb->s_isup = NULL; + put_super(dev); + sync_dev(dev); + return 0; +} + +int sys_mount(char * dev_name, char * dir_name, int rw_flag) +{ + struct m_inode * dev_i, * dir_i; + struct super_block * sb; + int dev; + + if (!(dev_i=namei(dev_name))) + return -ENOENT; + dev = dev_i->i_zone[0]; + if (!S_ISBLK(dev_i->i_mode)) { + iput(dev_i); + return -EPERM; + } + iput(dev_i); + if (!(dir_i=namei(dir_name))) + return -ENOENT; + if (dir_i->i_count != 1 || dir_i->i_num == ROOT_INO) { + iput(dir_i); + return -EBUSY; + } + if (!S_ISDIR(dir_i->i_mode)) { + iput(dir_i); + return -EPERM; + } + if (!(sb=read_super(dev))) { + iput(dir_i); + return -EBUSY; + } + if (sb->s_imount) { + iput(dir_i); + return -EBUSY; + } + if (dir_i->i_mount) { + iput(dir_i); + return -EPERM; + } + sb->s_imount=dir_i; + dir_i->i_mount=1; + dir_i->i_dirt=1; /* NOTE! we don't iput(dir_i) */ + return 0; /* we do that in umount */ +} + +void mount_root(void) +{ + int i,free; + struct super_block * p; + struct m_inode * mi; + + if (32 != sizeof (struct d_inode)) + panic("bad i-node size"); + for(i=0;is_dev = 0; + p->s_lock = 0; + p->s_wait = NULL; + } + if (!(p=read_super(ROOT_DEV))) + panic("Unable to mount root"); + if (!(mi=iget(ROOT_DEV,ROOT_INO))) + panic("Unable to read root i-node"); + mi->i_count += 3 ; /* NOTE! it is logically used 4 times, not 1 */ + p->s_isup = p->s_imount = mi; + current->pwd = mi; + current->root = mi; + free=0; + i=p->s_nzones; + while (-- i >= 0) + if (!set_bit(i&8191,p->s_zmap[i>>13]->b_data)) + free++; + printk("%d/%d free blocks\n\r",free,p->s_nzones); + free=0; + i=p->s_ninodes+1; + while (-- i >= 0) + if (!set_bit(i&8191,p->s_imap[i>>13]->b_data)) + free++; + printk("%d/%d free inodes\n\r",free,p->s_ninodes); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/truncate.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/truncate.c new file mode 100644 index 0000000..cb22d5f --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/fs/truncate.c @@ -0,0 +1,65 @@ +/* + * linux/fs/truncate.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +#include + +static void free_ind(int dev,int block) +{ + struct buffer_head * bh; + unsigned short * p; + int i; + + if (!block) + return; + if ((bh=bread(dev,block))) { + p = (unsigned short *) bh->b_data; + for (i=0;i<512;i++,p++) + if (*p) + free_block(dev,*p); + brelse(bh); + } + free_block(dev,block); +} + +static void free_dind(int dev,int block) +{ + struct buffer_head * bh; + unsigned short * p; + int i; + + if (!block) + return; + if ((bh=bread(dev,block))) { + p = (unsigned short *) bh->b_data; + for (i=0;i<512;i++,p++) + if (*p) + free_ind(dev,*p); + brelse(bh); + } + free_block(dev,block); +} + +void truncate(struct m_inode * inode) +{ + int i; + + if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) + return; + for (i=0;i<7;i++) + if (inode->i_zone[i]) { + free_block(inode->i_dev,inode->i_zone[i]); + inode->i_zone[i]=0; + } + free_ind(inode->i_dev,inode->i_zone[7]); + free_dind(inode->i_dev,inode->i_zone[8]); + inode->i_zone[7] = inode->i_zone[8] = 0; + inode->i_size = 0; + inode->i_dirt = 1; + inode->i_mtime = inode->i_ctime = CURRENT_TIME; +} + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/a.out.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/a.out.h new file mode 100644 index 0000000..3e67974 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/a.out.h @@ -0,0 +1,220 @@ +#ifndef _A_OUT_H +#define _A_OUT_H + +#define __GNU_EXEC_MACROS__ + +struct exec { + unsigned long a_magic; /* Use macros N_MAGIC, etc for access */ + unsigned a_text; /* length of text, in bytes */ + unsigned a_data; /* length of data, in bytes */ + unsigned a_bss; /* length of uninitialized data area for file, in bytes */ + unsigned a_syms; /* length of symbol table data in file, in bytes */ + unsigned a_entry; /* start address */ + unsigned a_trsize; /* length of relocation info for text, in bytes */ + unsigned a_drsize; /* length of relocation info for data, in bytes */ +}; + +#ifndef N_MAGIC +#define N_MAGIC(exec) ((exec).a_magic) +#endif + +#ifndef OMAGIC +/* Code indicating object file or impure executable. */ +#define OMAGIC 0407 +/* Code indicating pure executable. */ +#define NMAGIC 0410 +/* Code indicating demand-paged executable. */ +#define ZMAGIC 0413 +#endif /* not OMAGIC */ + +#ifndef N_BADMAG +#define N_BADMAG(x) \ + (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC) +#endif + +#define _N_BADMAG(x) \ + (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC) + +#define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec)) + +#ifndef N_TXTOFF +#define N_TXTOFF(x) \ + (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec)) +#endif + +#ifndef N_DATOFF +#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text) +#endif + +#ifndef N_TRELOFF +#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data) +#endif + +#ifndef N_DRELOFF +#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize) +#endif + +#ifndef N_SYMOFF +#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize) +#endif + +#ifndef N_STROFF +#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms) +#endif + +/* Address of text segment in memory after it is loaded. */ +#ifndef N_TXTADDR +#define N_TXTADDR(x) 0 +#endif + +/* Address of data segment in memory after it is loaded. + Note that it is up to you to define SEGMENT_SIZE + on machines not listed here. */ +#if defined(vax) || defined(hp300) || defined(pyr) +#define SEGMENT_SIZE PAGE_SIZE +#endif +#ifdef hp300 +#define PAGE_SIZE 4096 +#endif +#ifdef sony +#define SEGMENT_SIZE 0x2000 +#endif /* Sony. */ +#ifdef is68k +#define SEGMENT_SIZE 0x20000 +#endif +#if defined(m68k) && defined(PORTAR) +#define PAGE_SIZE 0x400 +#define SEGMENT_SIZE PAGE_SIZE +#endif + +#define PAGE_SIZE 4096 +#define SEGMENT_SIZE 1024 + +#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1)) + +#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text) + +#ifndef N_DATADDR +#define N_DATADDR(x) \ + (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \ + : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x)))) +#endif + +/* Address of bss segment in memory after it is loaded. */ +#ifndef N_BSSADDR +#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) +#endif + +#ifndef N_NLIST_DECLARED +struct nlist { + union { + char *n_name; + struct nlist *n_next; + long n_strx; + } n_un; + unsigned char n_type; + char n_other; + short n_desc; + unsigned long n_value; +}; +#endif + +#ifndef N_UNDF +#define N_UNDF 0 +#endif +#ifndef N_ABS +#define N_ABS 2 +#endif +#ifndef N_TEXT +#define N_TEXT 4 +#endif +#ifndef N_DATA +#define N_DATA 6 +#endif +#ifndef N_BSS +#define N_BSS 8 +#endif +#ifndef N_COMM +#define N_COMM 18 +#endif +#ifndef N_FN +#define N_FN 15 +#endif + +#ifndef N_EXT +#define N_EXT 1 +#endif +#ifndef N_TYPE +#define N_TYPE 036 +#endif +#ifndef N_STAB +#define N_STAB 0340 +#endif + +/* The following type indicates the definition of a symbol as being + an indirect reference to another symbol. The other symbol + appears as an undefined reference, immediately following this symbol. + + Indirection is asymmetrical. The other symbol's value will be used + to satisfy requests for the indirect symbol, but not vice versa. + If the other symbol does not have a definition, libraries will + be searched to find a definition. */ +#define N_INDR 0xa + +/* The following symbols refer to set elements. + All the N_SET[ATDB] symbols with the same name form one set. + Space is allocated for the set in the text section, and each set + element's value is stored into one word of the space. + The first word of the space is the length of the set (number of elements). + + The address of the set is made into an N_SETV symbol + whose name is the same as the name of the set. + This symbol acts like a N_DATA global symbol + in that it can satisfy undefined external references. */ + +/* These appear as input to LD, in a .o file. */ +#define N_SETA 0x14 /* Absolute set element symbol */ +#define N_SETT 0x16 /* Text set element symbol */ +#define N_SETD 0x18 /* Data set element symbol */ +#define N_SETB 0x1A /* Bss set element symbol */ + +/* This is output from LD. */ +#define N_SETV 0x1C /* Pointer to set vector in data area. */ + +#ifndef N_RELOCATION_INFO_DECLARED + +/* This structure describes a single relocation to be performed. + The text-relocation section of the file is a vector of these structures, + all of which apply to the text section. + Likewise, the data-relocation section applies to the data section. */ + +struct relocation_info +{ + /* Address (within segment) to be relocated. */ + int r_address; + /* The meaning of r_symbolnum depends on r_extern. */ + unsigned int r_symbolnum:24; + /* Nonzero means value is a pc-relative offset + and it should be relocated for changes in its own address + as well as for changes in the symbol or section specified. */ + unsigned int r_pcrel:1; + /* Length (as exponent of 2) of the field to be relocated. + Thus, a value of 2 indicates 1<<2 bytes. */ + unsigned int r_length:2; + /* 1 => relocate with value of symbol. + r_symbolnum is the index of the symbol + in file's the symbol table. + 0 => relocate with the address of a segment. + r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS + (the N_EXT bit may be set also, but signifies nothing). */ + unsigned int r_extern:1; + /* Four bits that aren't used, but when writing an object file + it is desirable to clear them. */ + unsigned int r_pad:4; +}; +#endif /* no N_RELOCATION_INFO_DECLARED. */ + + +#endif /* __A_OUT_GNU_H__ */ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/io.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/io.h new file mode 100644 index 0000000..d5cc42a --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/io.h @@ -0,0 +1,24 @@ +#define outb(value,port) \ +__asm__ ("outb %%al,%%dx"::"a" (value),"d" (port)) + + +#define inb(port) ({ \ +unsigned char _v; \ +__asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \ +_v; \ +}) + +#define outb_p(value,port) \ +__asm__ ("outb %%al,%%dx\n" \ + "\tjmp 1f\n" \ + "1:\tjmp 1f\n" \ + "1:"::"a" (value),"d" (port)) + +#define inb_p(port) ({ \ +unsigned char _v; \ +__asm__ volatile ("inb %%dx,%%al\n" \ + "\tjmp 1f\n" \ + "1:\tjmp 1f\n" \ + "1:":"=a" (_v):"d" (port)); \ +_v; \ +}) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/memory.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/memory.h new file mode 100644 index 0000000..4457420 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/memory.h @@ -0,0 +1,14 @@ +/* + * NOTE!!! memcpy(dest,src,n) assumes ds=es=normal data segment. This + * goes for all kernel functions (ds=es=kernel space, fs=local data, + * gs=null), as well as for all well-behaving user programs (ds=es= + * user data space). This is NOT a bug, as any user program that changes + * es deserves to die if it isn't careful. + */ +#define memcpy(dest,src,n) ({ \ +void * _res = dest; \ +__asm__ ("cld;rep;movsb" \ + ::"D" ((long)(_res)),"S" ((long)(src)),"c" ((long) (n)) \ + ); \ +_res; \ +}) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/segment.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/segment.h new file mode 100644 index 0000000..94dd102 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/segment.h @@ -0,0 +1,65 @@ +static inline unsigned char get_fs_byte(const char * addr) +{ + unsigned register char _v; + + __asm__ ("movb %%fs:%1,%0":"=r" (_v):"m" (*addr)); + return _v; +} + +static inline unsigned short get_fs_word(const unsigned short *addr) +{ + unsigned short _v; + + __asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr)); + return _v; +} + +static inline unsigned long get_fs_long(const unsigned long *addr) +{ + unsigned long _v; + + __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \ + return _v; +} + +static inline void put_fs_byte(char val,char *addr) +{ +__asm__ ("movb %0,%%fs:%1"::"r" (val),"m" (*addr)); +} + +static inline void put_fs_word(short val,short * addr) +{ +__asm__ ("movw %0,%%fs:%1"::"r" (val),"m" (*addr)); +} + +static inline void put_fs_long(unsigned long val,unsigned long * addr) +{ +__asm__ ("movl %0,%%fs:%1"::"r" (val),"m" (*addr)); +} + +/* + * Someone who knows GNU asm better than I should double check the followig. + * It seems to work, but I don't know if I'm doing something subtly wrong. + * --- TYT, 11/24/91 + * [ nothing wrong here, Linus ] + */ + +static inline unsigned long get_fs() +{ + unsigned short _v; + __asm__("mov %%fs,%%ax":"=a" (_v):); + return _v; +} + +static inline unsigned long get_ds() +{ + unsigned short _v; + __asm__("mov %%ds,%%ax":"=a" (_v):); + return _v; +} + +static inline void set_fs(unsigned long val) +{ + __asm__("mov %0,%%fs"::"a" ((unsigned short) val)); +} + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/system.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/system.h new file mode 100644 index 0000000..9bc027a --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/asm/system.h @@ -0,0 +1,67 @@ +#define move_to_user_mode() \ +__asm__ ("movl %%esp,%%eax\n\t" \ + "pushl $0x17\n\t" \ + "pushl %%eax\n\t" \ + "pushfl\n\t" \ + "pushl $0x0f\n\t" \ + "pushl $1f\n\t" \ + "iret\n" \ + "1:\tmovl $0x17,%%eax\n\t" \ + "movw %%ax,%%ds\n\t" \ + "movw %%ax,%%es\n\t" \ + "movw %%ax,%%fs\n\t" \ + "movw %%ax,%%gs" \ + :::"ax") + +#define sti() __asm__ ("sti"::) +#define cli() __asm__ ("cli"::) +#define nop() __asm__ ("nop"::) + +#define iret() __asm__ ("iret"::) + +#define _set_gate(gate_addr,type,dpl,addr) \ +__asm__ ("movw %%dx,%%ax\n\t" \ + "movw %0,%%dx\n\t" \ + "movl %%eax,%1\n\t" \ + "movl %%edx,%2" \ + : \ + : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), \ + "o" (*((char *) (gate_addr))), \ + "o" (*(4+(char *) (gate_addr))), \ + "d" ((char *) (addr)),"a" (0x00080000)) + +#define set_intr_gate(n,addr) \ + _set_gate(&idt[n],14,0,addr) + +#define set_trap_gate(n,addr) \ + _set_gate(&idt[n],15,0,addr) + +#define set_system_gate(n,addr) \ + _set_gate(&idt[n],15,3,addr) + +#define _set_seg_desc(gate_addr,type,dpl,base,limit) {\ + *(gate_addr) = ((base) & 0xff000000) | \ + (((base) & 0x00ff0000)>>16) | \ + ((limit) & 0xf0000) | \ + ((dpl)<<13) | \ + (0x00408000) | \ + ((type)<<8); \ + *((gate_addr)+1) = (((base) & 0x0000ffff)<<16) | \ + ((limit) & 0x0ffff); } + +#define _set_tssldt_desc(n,addr,type) \ +__asm__ ("movw $104,%1\n\t" \ + "movw %%ax,%2\n\t" \ + "rorl $16,%%eax\n\t" \ + "movb %%al,%3\n\t" \ + "movb $" type ",%4\n\t" \ + "movb $0x00,%5\n\t" \ + "movb %%ah,%6\n\t" \ + "rorl $16,%%eax" \ + ::"a" (addr), "m" (*(n)), "m" (*(n+2)), "m" (*(n+4)), \ + "m" (*(n+5)), "m" (*(n+6)), "m" (*(n+7)) \ + ) + +#define set_tss_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),"0x89") +#define set_ldt_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),"0x82") + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/const.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/const.h new file mode 100644 index 0000000..7828e61 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/const.h @@ -0,0 +1,15 @@ +#ifndef _CONST_H +#define _CONST_H + +#define BUFFER_END 0x200000 + +#define I_TYPE 0170000 +#define I_DIRECTORY 0040000 +#define I_REGULAR 0100000 +#define I_BLOCK_SPECIAL 0060000 +#define I_CHAR_SPECIAL 0020000 +#define I_NAMED_PIPE 0010000 +#define I_SET_UID_BIT 0004000 +#define I_SET_GID_BIT 0002000 + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/ctype.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/ctype.h new file mode 100644 index 0000000..7acf55d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/ctype.h @@ -0,0 +1,34 @@ +#ifndef _CTYPE_H +#define _CTYPE_H + +#define _U 0x01 /* upper */ +#define _L 0x02 /* lower */ +#define _D 0x04 /* digit */ +#define _C 0x08 /* cntrl */ +#define _P 0x10 /* punct */ +#define _S 0x20 /* white space (space/lf/tab) */ +#define _X 0x40 /* hex digit */ +#define _SP 0x80 /* hard space (0x20) */ + +extern unsigned char _ctype[]; +extern char _ctmp; + +#define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D)) +#define isalpha(c) ((_ctype+1)[c]&(_U|_L)) +#define iscntrl(c) ((_ctype+1)[c]&(_C)) +#define isdigit(c) ((_ctype+1)[c]&(_D)) +#define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D)) +#define islower(c) ((_ctype+1)[c]&(_L)) +#define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP)) +#define ispunct(c) ((_ctype+1)[c]&(_P)) +#define isspace(c) ((_ctype+1)[c]&(_S)) +#define isupper(c) ((_ctype+1)[c]&(_U)) +#define isxdigit(c) ((_ctype+1)[c]&(_D|_X)) + +#define isascii(c) (((unsigned) c)<=0x7f) +#define toascii(c) (((unsigned) c)&0x7f) + +#define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp) +#define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp) + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/errno.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/errno.h new file mode 100644 index 0000000..c282f69 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/errno.h @@ -0,0 +1,60 @@ +#ifndef _ERRNO_H +#define _ERRNO_H + +/* + * ok, as I hadn't got any other source of information about + * possible error numbers, I was forced to use the same numbers + * as minix. + * Hopefully these are posix or something. I wouldn't know (and posix + * isn't telling me - they want $$$ for their f***ing standard). + * + * We don't use the _SIGN cludge of minix, so kernel returns must + * see to the sign by themselves. + * + * NOTE! Remember to change strerror() if you change this file! + */ + +extern int errno; + +#define ERROR 99 +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define ENOTBLK 15 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define ETXTBSY 26 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define EDOM 33 +#define ERANGE 34 +#define EDEADLK 35 +#define ENAMETOOLONG 36 +#define ENOLCK 37 +#define ENOSYS 38 +#define ENOTEMPTY 39 + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/fcntl.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/fcntl.h new file mode 100644 index 0000000..a5bf9af --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/fcntl.h @@ -0,0 +1,55 @@ +#ifndef _FCNTL_H +#define _FCNTL_H + +#include + +/* open/fcntl - NOCTTY, NDELAY isn't implemented yet */ +#define O_ACCMODE 00003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 00100 /* not fcntl */ +#define O_EXCL 00200 /* not fcntl */ +#define O_NOCTTY 00400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 /* not fcntl */ +#define O_NDELAY O_NONBLOCK + +/* Defines for fcntl-commands. Note that currently + * locking isn't supported, and other things aren't really + * tested. + */ +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 /* not implemented */ +#define F_SETLK 6 +#define F_SETLKW 7 + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* Ok, these are locking features, and aren't implemented at any + * level. POSIX wants them. + */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* Once again - not implemented, but ... */ +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +extern int creat(const char * filename,mode_t mode); +extern int fcntl(int fildes,int cmd, ...); +extern int open(const char * filename, int flags, ...); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/config.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/config.h new file mode 100644 index 0000000..819b525 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/config.h @@ -0,0 +1,48 @@ +#ifndef _CONFIG_H +#define _CONFIG_H + +/* + * The root-device is no longer hard-coded. You can change the default + * root-device by changing the line ROOT_DEV = XXX in boot/bootsect.s + */ + +/* + * define your keyboard here - + * KBD_FINNISH for Finnish keyboards + * KBD_US for US-type + * KBD_GR for German keyboards + * KBD_FR for Frech keyboard + */ +#define KBD_US +/*#define KBD_GR */ +/*#define KBD_FR */ +/*#define KBD_FINNISH */ + +/* + * Normally, Linux can get the drive parameters from the BIOS at + * startup, but if this for some unfathomable reason fails, you'd + * be left stranded. For this case, you can define HD_TYPE, which + * contains all necessary info on your harddisk. + * + * The HD_TYPE macro should look like this: + * + * #define HD_TYPE { head, sect, cyl, wpcom, lzone, ctl} + * + * In case of two harddisks, the info should be sepatated by + * commas: + * + * #define HD_TYPE { h,s,c,wpcom,lz,ctl },{ h,s,c,wpcom,lz,ctl } + */ +/* + This is an example, two drives, first is type 2, second is type 3: + +#define HD_TYPE { 4,17,615,300,615,8 }, { 6,17,615,300,615,0 } + + NOTE: ctl is 0 for all drives with heads<=8, and ctl=8 for drives + with more than 8 heads. + + If you want the BIOS to tell what kind of drive you have, just + leave HD_TYPE undefined. This is the normal thing to do. +*/ + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/fdreg.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/fdreg.h new file mode 100644 index 0000000..01355af --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/fdreg.h @@ -0,0 +1,71 @@ +/* + * This file contains some defines for the floppy disk controller. + * Various sources. Mostly "IBM Microcomputers: A Programmers + * Handbook", Sanches and Canton. + */ +#ifndef _FDREG_H +#define _FDREG_H + +extern int ticks_to_floppy_on(unsigned int nr); +extern void floppy_on(unsigned int nr); +extern void floppy_off(unsigned int nr); +extern void floppy_select(unsigned int nr); +extern void floppy_deselect(unsigned int nr); + +/* Fd controller regs. S&C, about page 340 */ +#define FD_STATUS 0x3f4 +#define FD_DATA 0x3f5 +#define FD_DOR 0x3f2 /* Digital Output Register */ +#define FD_DIR 0x3f7 /* Digital Input Register (read) */ +#define FD_DCR 0x3f7 /* Diskette Control Register (write)*/ + +/* Bits of main status register */ +#define STATUS_BUSYMASK 0x0F /* drive busy mask */ +#define STATUS_BUSY 0x10 /* FDC busy */ +#define STATUS_DMA 0x20 /* 0- DMA mode */ +#define STATUS_DIR 0x40 /* 0- cpu->fdc */ +#define STATUS_READY 0x80 /* Data reg ready */ + +/* Bits of FD_ST0 */ +#define ST0_DS 0x03 /* drive select mask */ +#define ST0_HA 0x04 /* Head (Address) */ +#define ST0_NR 0x08 /* Not Ready */ +#define ST0_ECE 0x10 /* Equipment chech error */ +#define ST0_SE 0x20 /* Seek end */ +#define ST0_INTR 0xC0 /* Interrupt code mask */ + +/* Bits of FD_ST1 */ +#define ST1_MAM 0x01 /* Missing Address Mark */ +#define ST1_WP 0x02 /* Write Protect */ +#define ST1_ND 0x04 /* No Data - unreadable */ +#define ST1_OR 0x10 /* OverRun */ +#define ST1_CRC 0x20 /* CRC error in data or addr */ +#define ST1_EOC 0x80 /* End Of Cylinder */ + +/* Bits of FD_ST2 */ +#define ST2_MAM 0x01 /* Missing Addess Mark (again) */ +#define ST2_BC 0x02 /* Bad Cylinder */ +#define ST2_SNS 0x04 /* Scan Not Satisfied */ +#define ST2_SEH 0x08 /* Scan Equal Hit */ +#define ST2_WC 0x10 /* Wrong Cylinder */ +#define ST2_CRC 0x20 /* CRC error in data field */ +#define ST2_CM 0x40 /* Control Mark = deleted */ + +/* Bits of FD_ST3 */ +#define ST3_HA 0x04 /* Head (Address) */ +#define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */ +#define ST3_WP 0x40 /* Write Protect */ + +/* Values for FD_COMMAND */ +#define FD_RECALIBRATE 0x07 /* move to track 0 */ +#define FD_SEEK 0x0F /* seek track */ +#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */ +#define FD_WRITE 0xC5 /* write with MT, MFM */ +#define FD_SENSEI 0x08 /* Sense Interrupt Status */ +#define FD_SPECIFY 0x03 /* specify HUT etc */ + +/* DMA commands */ +#define DMA_READ 0x46 +#define DMA_WRITE 0x4A + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/fs.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/fs.h new file mode 100644 index 0000000..7a90b10 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/fs.h @@ -0,0 +1,202 @@ +/* + * This file has definitions for some important file table + * structures etc. + */ + +#ifndef _FS_H +#define _FS_H + +#include + +/* devices are as follows: (same as minix, so we can use the minix + * file system. These are major numbers.) + * + * 0 - unused (nodev) + * 1 - /dev/mem + * 2 - /dev/fd + * 3 - /dev/hd + * 4 - /dev/ttyx + * 5 - /dev/tty + * 6 - /dev/lp + * 7 - unnamed pipes + */ + +#define IS_SEEKABLE(x) ((x)>=1 && (x)<=3) + +#define READ 0 +#define WRITE 1 +#define READA 2 /* read-ahead - don't pause */ +#define WRITEA 3 /* "write-ahead" - silly, but somewhat useful */ + +void buffer_init(long buffer_end); + +#define MAJOR(a) (((unsigned)(a))>>8) +#define MINOR(a) ((a)&0xff) + +#define NAME_LEN 14 +#define ROOT_INO 1 + +#define I_MAP_SLOTS 8 +#define Z_MAP_SLOTS 8 +#define SUPER_MAGIC 0x137F + +#define NR_OPEN 20 +#define NR_INODE 32 +#define NR_FILE 64 +#define NR_SUPER 8 +#define NR_HASH 307 +#define NR_BUFFERS nr_buffers +#define BLOCK_SIZE 1024 +#define BLOCK_SIZE_BITS 10 +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#define INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct d_inode))) +#define DIR_ENTRIES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct dir_entry))) + +#define PIPE_HEAD(inode) ((inode).i_zone[0]) +#define PIPE_TAIL(inode) ((inode).i_zone[1]) +#define PIPE_SIZE(inode) ((PIPE_HEAD(inode)-PIPE_TAIL(inode))&(PAGE_SIZE-1)) +#define PIPE_EMPTY(inode) (PIPE_HEAD(inode)==PIPE_TAIL(inode)) +#define PIPE_FULL(inode) (PIPE_SIZE(inode)==(PAGE_SIZE-1)) +#define INC_PIPE(head) \ +__asm__("incl %0\n\tandl $4095,%0"::"m" (head)) + +typedef char buffer_block[BLOCK_SIZE]; + +struct buffer_head { + char * b_data; /* pointer to data block (1024 bytes) */ + unsigned long b_blocknr; /* block number */ + unsigned short b_dev; /* device (0 = free) */ + unsigned char b_uptodate; + unsigned char b_dirt; /* 0-clean,1-dirty */ + unsigned char b_count; /* users using this block */ + unsigned char b_lock; /* 0 - ok, 1 -locked */ + struct task_struct * b_wait; + struct buffer_head * b_prev; + struct buffer_head * b_next; + struct buffer_head * b_prev_free; + struct buffer_head * b_next_free; +}; + +struct d_inode { + unsigned short i_mode; + unsigned short i_uid; + unsigned long i_size; + unsigned long i_time; + unsigned char i_gid; + unsigned char i_nlinks; + unsigned short i_zone[9]; +}; + +struct m_inode { + unsigned short i_mode; + unsigned short i_uid; + unsigned long i_size; + unsigned long i_mtime; + unsigned char i_gid; + unsigned char i_nlinks; + unsigned short i_zone[9]; +/* these are in memory also */ + struct task_struct * i_wait; + unsigned long i_atime; + unsigned long i_ctime; + unsigned short i_dev; + unsigned short i_num; + unsigned short i_count; + unsigned char i_lock; + unsigned char i_dirt; + unsigned char i_pipe; + unsigned char i_mount; + unsigned char i_seek; + unsigned char i_update; +}; + +struct file { + unsigned short f_mode; + unsigned short f_flags; + unsigned short f_count; + struct m_inode * f_inode; + off_t f_pos; +}; + +struct super_block { + unsigned short s_ninodes; + unsigned short s_nzones; + unsigned short s_imap_blocks; + unsigned short s_zmap_blocks; + unsigned short s_firstdatazone; + unsigned short s_log_zone_size; + unsigned long s_max_size; + unsigned short s_magic; +/* These are only in memory */ + struct buffer_head * s_imap[8]; + struct buffer_head * s_zmap[8]; + unsigned short s_dev; + struct m_inode * s_isup; + struct m_inode * s_imount; + unsigned long s_time; + struct task_struct * s_wait; + unsigned char s_lock; + unsigned char s_rd_only; + unsigned char s_dirt; +}; + +struct d_super_block { + unsigned short s_ninodes; + unsigned short s_nzones; + unsigned short s_imap_blocks; + unsigned short s_zmap_blocks; + unsigned short s_firstdatazone; + unsigned short s_log_zone_size; + unsigned long s_max_size; + unsigned short s_magic; +}; + +struct dir_entry { + unsigned short inode; + char name[NAME_LEN]; +}; + +extern struct m_inode inode_table[NR_INODE]; +extern struct file file_table[NR_FILE]; +extern struct super_block super_block[NR_SUPER]; +extern struct buffer_head * start_buffer; +extern int nr_buffers; + +extern void check_disk_change(int dev); +extern int floppy_change(unsigned int nr); +extern int ticks_to_floppy_on(unsigned int dev); +extern void floppy_on(unsigned int dev); +extern void floppy_off(unsigned int dev); +extern void truncate(struct m_inode * inode); +extern void sync_inodes(void); +extern void wait_on(struct m_inode * inode); +extern int bmap(struct m_inode * inode,int block); +extern int create_block(struct m_inode * inode,int block); +extern struct m_inode * namei(const char * pathname); +extern int open_namei(const char * pathname, int flag, int mode, + struct m_inode ** res_inode); +extern void iput(struct m_inode * inode); +extern struct m_inode * iget(int dev,int nr); +extern struct m_inode * get_empty_inode(void); +extern struct m_inode * get_pipe_inode(void); +extern struct buffer_head * get_hash_table(int dev, int block); +extern struct buffer_head * getblk(int dev, int block); +extern void ll_rw_block(int rw, struct buffer_head * bh); +extern void brelse(struct buffer_head * buf); +extern struct buffer_head * bread(int dev,int block); +extern void bread_page(unsigned long addr,int dev,int b[4]); +extern struct buffer_head * breada(int dev,int block,...); +extern int new_block(int dev); +extern void free_block(int dev, int block); +extern struct m_inode * new_inode(int dev); +extern void free_inode(struct m_inode * inode); +extern int sync_dev(int dev); +extern struct super_block * get_super(int dev); +extern int ROOT_DEV; + +extern void mount_root(void); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/hdreg.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/hdreg.h new file mode 100644 index 0000000..e6c593f --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/hdreg.h @@ -0,0 +1,65 @@ +/* + * This file contains some defines for the AT-hd-controller. + * Various sources. Check out some definitions (see comments with + * a ques). + */ +#ifndef _HDREG_H +#define _HDREG_H + +/* Hd controller regs. Ref: IBM AT Bios-listing */ +#define HD_DATA 0x1f0 /* _CTL when writing */ +#define HD_ERROR 0x1f1 /* see err-bits */ +#define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */ +#define HD_SECTOR 0x1f3 /* starting sector */ +#define HD_LCYL 0x1f4 /* starting cylinder */ +#define HD_HCYL 0x1f5 /* high byte of starting cyl */ +#define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */ +#define HD_STATUS 0x1f7 /* see status-bits */ +#define HD_PRECOMP HD_ERROR /* same io address, read=error, write=precomp */ +#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */ + +#define HD_CMD 0x3f6 + +/* Bits of HD_STATUS */ +#define ERR_STAT 0x01 +#define INDEX_STAT 0x02 +#define ECC_STAT 0x04 /* Corrected error */ +#define DRQ_STAT 0x08 +#define SEEK_STAT 0x10 +#define WRERR_STAT 0x20 +#define READY_STAT 0x40 +#define BUSY_STAT 0x80 + +/* Values for HD_COMMAND */ +#define WIN_RESTORE 0x10 +#define WIN_READ 0x20 +#define WIN_WRITE 0x30 +#define WIN_VERIFY 0x40 +#define WIN_FORMAT 0x50 +#define WIN_INIT 0x60 +#define WIN_SEEK 0x70 +#define WIN_DIAGNOSE 0x90 +#define WIN_SPECIFY 0x91 + +/* Bits for HD_ERROR */ +#define MARK_ERR 0x01 /* Bad address mark ? */ +#define TRK0_ERR 0x02 /* couldn't find track 0 */ +#define ABRT_ERR 0x04 /* ? */ +#define ID_ERR 0x10 /* ? */ +#define ECC_ERR 0x40 /* ? */ +#define BBD_ERR 0x80 /* ? */ + +struct partition { + unsigned char boot_ind; /* 0x80 - active (unused) */ + unsigned char head; /* ? */ + unsigned char sector; /* ? */ + unsigned char cyl; /* ? */ + unsigned char sys_ind; /* ? */ + unsigned char end_head; /* ? */ + unsigned char end_sector; /* ? */ + unsigned char end_cyl; /* ? */ + unsigned int start_sect; /* starting sector counting from 0 */ + unsigned int nr_sects; /* nr of sectors in partition */ +}; + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/head.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/head.h new file mode 100644 index 0000000..db3dda2 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/head.h @@ -0,0 +1,20 @@ +#ifndef _HEAD_H +#define _HEAD_H + +typedef struct desc_struct { + unsigned long a,b; +} desc_table[256]; + +extern unsigned long pg_dir[1024]; +extern desc_table idt,gdt; + +#define GDT_NUL 0 +#define GDT_CODE 1 +#define GDT_DATA 2 +#define GDT_TMP 3 + +#define LDT_NUL 0 +#define LDT_CODE 1 +#define LDT_DATA 2 + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/kernel.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/kernel.h new file mode 100644 index 0000000..cb40dd5 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/kernel.h @@ -0,0 +1,22 @@ +/* + * 'kernel.h' contains some often-used function prototypes etc + */ +void verify_area(void * addr,int count); +volatile void panic(const char * str); +int printf(const char * fmt, ...); +int printk(const char * fmt, ...); +int tty_write(unsigned ch,char * buf,int count); +void * malloc(unsigned int size); +void free_s(void * obj, int size); + +#define free(x) free_s((x), 0) + +/* + * This is defined as a macro, but at some point this might become a + * real subroutine that sets a flag if it returns true (to do + * BSD-style accounting where the process is flagged if it uses root + * privs). The implication of this is that you should do normal + * permissions checks first, and check suser() last. + */ +#define suser() (current->euid == 0) + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/mm.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/mm.h new file mode 100644 index 0000000..5a160f3 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/mm.h @@ -0,0 +1,10 @@ +#ifndef _MM_H +#define _MM_H + +#define PAGE_SIZE 4096 + +extern unsigned long get_free_page(void); +extern unsigned long put_page(unsigned long page,unsigned long address); +extern void free_page(unsigned long addr); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sched.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sched.h new file mode 100644 index 0000000..53ffbe8 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sched.h @@ -0,0 +1,256 @@ +#ifndef _SCHED_H +#define _SCHED_H + +#define NR_TASKS 64 +#define HZ 100 + +#define FIRST_TASK task[0] +#define LAST_TASK task[NR_TASKS-1] + +#include +#include +#include +#include + +#if (NR_OPEN > 32) +#error "Currently the close-on-exec-flags are in one word, max 32 files/proc" +#endif + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_ZOMBIE 3 +#define TASK_STOPPED 4 + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +extern int copy_page_tables(unsigned long from, unsigned long to, long size); +extern int free_page_tables(unsigned long from, unsigned long size); + +extern void sched_init(void); +extern void schedule(void); +extern void trap_init(void); +#ifndef PANIC +volatile void panic(const char * str); +#endif +extern int tty_write(unsigned minor,char * buf,int count); + +typedef int (*fn_ptr)(); + +struct i387_struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ +}; + +struct tss_struct { + long back_link; /* 16 high bits zero */ + long esp0; + long ss0; /* 16 high bits zero */ + long esp1; + long ss1; /* 16 high bits zero */ + long esp2; + long ss2; /* 16 high bits zero */ + long cr3; + long eip; + long eflags; + long eax,ecx,edx,ebx; + long esp; + long ebp; + long esi; + long edi; + long es; /* 16 high bits zero */ + long cs; /* 16 high bits zero */ + long ss; /* 16 high bits zero */ + long ds; /* 16 high bits zero */ + long fs; /* 16 high bits zero */ + long gs; /* 16 high bits zero */ + long ldt; /* 16 high bits zero */ + long trace_bitmap; /* bits: trace 0, bitmap 16-31 */ + struct i387_struct i387; +}; + +struct task_struct { +/* these are hardcoded - don't touch */ + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + long counter; + long priority; + long signal; + struct sigaction sigaction[32]; + long blocked; /* bitmap of masked signals */ +/* various fields */ + int exit_code; + unsigned long start_code,end_code,end_data,brk,start_stack; + long pid,father,pgrp,session,leader; + unsigned short uid,euid,suid; + unsigned short gid,egid,sgid; + long alarm; + long utime,stime,cutime,cstime,start_time; + unsigned short used_math; +/* file system info */ + int tty; /* -1 if no tty, so it must be signed */ + unsigned short umask; + struct m_inode * pwd; + struct m_inode * root; + struct m_inode * executable; + unsigned long close_on_exec; + struct file * filp[NR_OPEN]; +/* ldt for this task 0 - zero 1 - cs 2 - ds&ss */ + struct desc_struct ldt[3]; +/* tss for this task */ + struct tss_struct tss; +}; + +/* + * INIT_TASK is used to set up the first task table, touch at + * your own risk!. Base=0, limit=0x9ffff (=640kB) + */ +#define INIT_TASK \ +/* state etc */ { 0,15,15, \ +/* signals */ 0,{{},},0, \ +/* ec,brk... */ 0,0,0,0,0,0, \ +/* pid etc.. */ 0,-1,0,0,0, \ +/* uid etc */ 0,0,0,0,0,0, \ +/* alarm */ 0,0,0,0,0,0, \ +/* math */ 0, \ +/* fs info */ -1,0022,NULL,NULL,NULL,0, \ +/* filp */ {NULL,}, \ + { \ + {0,0}, \ +/* ldt */ {0x9f,0xc0fa00}, \ + {0x9f,0xc0f200}, \ + }, \ +/*tss*/ {0,PAGE_SIZE+(long)&init_task,0x10,0,0,0,0,(long)&pg_dir,\ + 0,0,0,0,0,0,0,0, \ + 0,0,0x17,0x17,0x17,0x17,0x17,0x17, \ + _LDT(0),0x80000000, \ + {} \ + }, \ +} + +extern struct task_struct *task[NR_TASKS]; +extern struct task_struct *last_task_used_math; +extern struct task_struct *current; +extern long volatile jiffies; +extern long startup_time; + +#define CURRENT_TIME (startup_time+jiffies/HZ) + +extern void add_timer(long jiffies, void (*fn)(void)); +extern void sleep_on(struct task_struct ** p); +extern void interruptible_sleep_on(struct task_struct ** p); +extern void wake_up(struct task_struct ** p); + +/* + * Entry into gdt where to find first TSS. 0-nul, 1-cs, 2-ds, 3-syscall + * 4-TSS0, 5-LDT0, 6-TSS1 etc ... + */ +#define FIRST_TSS_ENTRY 4 +#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1) +#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3)) +#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3)) +#define ltr(n) __asm__("ltr %%ax"::"a" (_TSS(n))) +#define lldt(n) __asm__("lldt %%ax"::"a" (_LDT(n))) +#define str(n) \ +__asm__("str %%ax\n\t" \ + "subl %2,%%eax\n\t" \ + "shrl $4,%%eax" \ + :"=a" (n) \ + :"a" (0),"i" (FIRST_TSS_ENTRY<<3)) +/* + * switch_to(n) should switch tasks to task nr n, first + * checking that n isn't the current task, in which case it does nothing. + * This also clears the TS-flag if the task we switched to has used + * tha math co-processor latest. + */ +#define switch_to(n) {\ +struct {long a,b;} __tmp; \ +__asm__("cmpl %%ecx,_current\n\t" \ + "je 1f\n\t" \ + "movw %%dx,%1\n\t" \ + "xchgl %%ecx,_current\n\t" \ + "ljmp *%0\n\t" \ + "cmpl %%ecx,_last_task_used_math\n\t" \ + "jne 1f\n\t" \ + "clts\n" \ + "1:" \ + ::"m" (*&__tmp.a),"m" (*&__tmp.b), \ + "d" (_TSS(n)),"c" ((long) task[n])); \ +} + +#define PAGE_ALIGN(n) (((n)+0xfff)&0xfffff000) + +#define _set_base(addr,base) \ +__asm__ ("push %%edx\n\t" \ + "movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %%dl,%1\n\t" \ + "movb %%dh,%2\n\t" \ + "pop %%edx" \ + ::"m" (*((addr)+2)), \ + "m" (*((addr)+4)), \ + "m" (*((addr)+7)), \ + "d" (base) \ + ) + +#define _set_limit(addr,limit) \ +__asm__ ("push %%edx\n\t" \ + "movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %1,%%dh\n\t" \ + "andb $0xf0,%%dh\n\t" \ + "orb %%dh,%%dl\n\t" \ + "movb %%dl,%1\n\t" \ + "pop %%edx" \ + ::"m" (*(addr)), \ + "m" (*((addr)+6)), \ + "d" (limit) \ + ) + +#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)) \ + :"memory"); \ +__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)); \ +__limit;}) + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sched.h.cur1 b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sched.h.cur1 new file mode 100644 index 0000000..20b05ce --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sched.h.cur1 @@ -0,0 +1,235 @@ +#ifndef _SCHED_H +#define _SCHED_H + +#define NR_TASKS 64 +#define HZ 100 + +#define FIRST_TASK task[0] +#define LAST_TASK task[NR_TASKS-1] + +#include +#include +#include +#include + +#if (NR_OPEN > 32) +#error "Currently the close-on-exec-flags are in one word, max 32 files/proc" +#endif + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_ZOMBIE 3 +#define TASK_STOPPED 4 + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +extern int copy_page_tables(unsigned long from, unsigned long to, long size); +extern int free_page_tables(unsigned long from, unsigned long size); + +extern void sched_init(void); +extern void schedule(void); +extern void trap_init(void); +#ifndef PANIC +volatile void panic(const char * str); +#endif +extern int tty_write(unsigned minor,char * buf,int count); + +typedef int (*fn_ptr)(); + +struct i387_struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ +}; + +struct tss_struct { + long back_link; /* 16 high bits zero */ + long esp0; + long ss0; /* 16 high bits zero */ + long esp1; + long ss1; /* 16 high bits zero */ + long esp2; + long ss2; /* 16 high bits zero */ + long cr3; + long eip; + long eflags; + long eax,ecx,edx,ebx; + long esp; + long ebp; + long esi; + long edi; + long es; /* 16 high bits zero */ + long cs; /* 16 high bits zero */ + long ss; /* 16 high bits zero */ + long ds; /* 16 high bits zero */ + long fs; /* 16 high bits zero */ + long gs; /* 16 high bits zero */ + long ldt; /* 16 high bits zero */ + long trace_bitmap; /* bits: trace 0, bitmap 16-31 */ + struct i387_struct i387; +}; + +struct task_struct { +/* these are hardcoded - don't touch */ + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + long counter; + long priority; + long signal; + struct sigaction sigaction[32]; + long blocked; /* bitmap of masked signals */ +/* various fields */ + int exit_code; + unsigned long start_code,end_code,end_data,brk,start_stack; + long pid,father,pgrp,session,leader; + unsigned short uid,euid,suid; + unsigned short gid,egid,sgid; + long alarm; + long utime,stime,cutime,cstime,start_time; + unsigned short used_math; +/* file system info */ + int tty; /* -1 if no tty, so it must be signed */ + unsigned short umask; + struct m_inode * pwd; + struct m_inode * root; + struct m_inode * executable; + unsigned long close_on_exec; + struct file * filp[NR_OPEN]; +/* ldt for this task 0 - zero 1 - cs 2 - ds&ss */ + struct desc_struct ldt[3]; +/* tss for this task */ + struct tss_struct tss; +}; + +/* + * INIT_TASK is used to set up the first task table, touch at + * your own risk!. Base=0, limit=0x9ffff (=640kB) + */ +#define INIT_TASK \ +/* state etc */ { 0,15,15, \ +/* signals */ 0,{{},},0, \ +/* ec,brk... */ 0,0,0,0,0,0, \ +/* pid etc.. */ 0,-1,0,0,0, \ +/* uid etc */ 0,0,0,0,0,0, \ +/* alarm */ 0,0,0,0,0,0, \ +/* math */ 0, \ +/* fs info */ -1,0022,NULL,NULL,NULL,0, \ +/* filp */ {NULL,}, \ + { \ + {0,0}, \ +/* ldt */ {0x9f,0xc0fa00}, \ + {0x9f,0xc0f200}, \ + }, \ +/*tss*/ {0,PAGE_SIZE+(long)&init_task,0x10,0,0,0,0,(long)&pg_dir,\ + 0,0,0,0,0,0,0,0, \ + 0,0,0x17,0x17,0x17,0x17,0x17,0x17, \ + _LDT(0),0x80000000, \ + {} \ + }, \ +} + +extern struct task_struct *task[NR_TASKS]; +extern struct task_struct *last_task_used_math; +extern struct task_struct *current; +extern long volatile jiffies; +extern long startup_time; + +#define CURRENT_TIME (startup_time+jiffies/HZ) + +extern void add_timer(long jiffies, void (*fn)(void)); +extern void sleep_on(struct task_struct ** p); +extern void interruptible_sleep_on(struct task_struct ** p); +extern void wake_up(struct task_struct ** p); + +/* + * Entry into gdt where to find first TSS. 0-nul, 1-cs, 2-ds, 3-syscall + * 4-TSS0, 5-LDT0, 6-TSS1 etc ... + */ +#define FIRST_TSS_ENTRY 4 +#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1) +#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3)) +#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3)) +#define ltr(n) __asm__("ltr %%ax"::"a" (_TSS(n))) +#define lldt(n) __asm__("lldt %%ax"::"a" (_LDT(n))) +#define str(n) \ +__asm__("str %%ax\n\t" \ + "subl %2,%%eax\n\t" \ + "shrl $4,%%eax" \ + :"=a" (n) \ + :"a" (0),"i" (FIRST_TSS_ENTRY<<3)) +/* + * switch_to(n) should switch tasks to task nr n, first + * checking that n isn't the current task, in which case it does nothing. + * This also clears the TS-flag if the task we switched to has used + * tha math co-processor latest. + */ +#define switch_to(n) {\ +struct {long a,b;} __tmp; \ +__asm__("cmpl %%ecx,current\n\t" \ + "je 1f\n\t" \ + "movw %%dx,%1\n\t" \ + "xchgl %%ecx,current\n\t" \ + "ljmp *%0\n\t" \ + "cmpl %%ecx,last_task_used_math\n\t" \ + "jne 1f\n\t" \ + "clts\n" \ + "1:" \ + ::"m" (*&__tmp.a),"m" (*&__tmp.b), \ + "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" \ + "rorl $16,%%edx\n\t" \ + "movb %%dl,%1\n\t" \ + "movb %%dh,%2\n\t" \ + ::"m" (*((addr)+2)), \ + "m" (*((addr)+4)), \ + "m" (*((addr)+7)), \ + "d" (base) \ + ) + +#define _set_limit(addr,limit) \ +__asm__ ("movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %1,%%dh\n\t" \ + "andb $0xf0,%%dh\n\t" \ + "orb %%dh,%%dl\n\t" \ + "movb %%dl,%1\n\t" \ + ::"m" (*(addr)), \ + "m" (*((addr)+6)), \ + "d" (limit) \ + ) + +#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;}) + +#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)); \ +__limit;}) + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sched.h.old b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sched.h.old new file mode 100644 index 0000000..c6e4deb --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sched.h.old @@ -0,0 +1,239 @@ +#ifndef _SCHED_H +#define _SCHED_H + +#define NR_TASKS 64 +#define HZ 100 + +#define FIRST_TASK task[0] +#define LAST_TASK task[NR_TASKS-1] + +#include +#include +#include +#include + +#if (NR_OPEN > 32) +#error "Currently the close-on-exec-flags are in one word, max 32 files/proc" +#endif + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_ZOMBIE 3 +#define TASK_STOPPED 4 + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +extern int copy_page_tables(unsigned long from, unsigned long to, long size); +extern int free_page_tables(unsigned long from, unsigned long size); + +extern void sched_init(void); +extern void schedule(void); +extern void trap_init(void); +#ifndef PANIC +extern void panic(const char * str); +#endif +extern int tty_write(unsigned minor,char * buf,int count); + +typedef int (*fn_ptr)(); + +struct i387_struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ +}; + +struct tss_struct { + long back_link; /* 16 high bits zero */ + long esp0; + long ss0; /* 16 high bits zero */ + long esp1; + long ss1; /* 16 high bits zero */ + long esp2; + long ss2; /* 16 high bits zero */ + long cr3; + long eip; + long eflags; + long eax,ecx,edx,ebx; + long esp; + long ebp; + long esi; + long edi; + long es; /* 16 high bits zero */ + long cs; /* 16 high bits zero */ + long ss; /* 16 high bits zero */ + long ds; /* 16 high bits zero */ + long fs; /* 16 high bits zero */ + long gs; /* 16 high bits zero */ + long ldt; /* 16 high bits zero */ + long trace_bitmap; /* bits: trace 0, bitmap 16-31 */ + struct i387_struct i387; +}; + +struct task_struct { +/* these are hardcoded - don't touch */ + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + long counter; + long priority; + long signal; + struct sigaction sigaction[32]; + long blocked; /* bitmap of masked signals */ +/* various fields */ + int exit_code; + unsigned long start_code,end_code,end_data,brk,start_stack; + long pid,father,pgrp,session,leader; + unsigned short uid,euid,suid; + unsigned short gid,egid,sgid; + long alarm; + long utime,stime,cutime,cstime,start_time; + unsigned short used_math; +/* file system info */ + int tty; /* -1 if no tty, so it must be signed */ + unsigned short umask; + struct m_inode * pwd; + struct m_inode * root; + struct m_inode * executable; + unsigned long close_on_exec; + struct file * filp[NR_OPEN]; +/* ldt for this task 0 - zero 1 - cs 2 - ds&ss */ + struct desc_struct ldt[3]; +/* tss for this task */ + struct tss_struct tss; +}; + +/* + * INIT_TASK is used to set up the first task table, touch at + * your own risk!. Base=0, limit=0x9ffff (=640kB) + */ +#define INIT_TASK \ +/* state etc */ { 0,15,15, \ +/* signals */ 0,{{},},0, \ +/* ec,brk... */ 0,0,0,0,0,0, \ +/* pid etc.. */ 0,-1,0,0,0, \ +/* uid etc */ 0,0,0,0,0,0, \ +/* alarm */ 0,0,0,0,0,0, \ +/* math */ 0, \ +/* fs info */ -1,0022,NULL,NULL,NULL,0, \ +/* filp */ {NULL,}, \ + { \ + {0,0}, \ +/* ldt */ {0x9f,0xc0fa00}, \ + {0x9f,0xc0f200}, \ + }, \ +/*tss*/ {0,PAGE_SIZE+(long)&init_task,0x10,0,0,0,0,(long)&pg_dir,\ + 0,0,0,0,0,0,0,0, \ + 0,0,0x17,0x17,0x17,0x17,0x17,0x17, \ + _LDT(0),0x80000000, \ + {} \ + }, \ +} + +extern struct task_struct *task[NR_TASKS]; +extern struct task_struct *last_task_used_math; +extern struct task_struct *current; +extern long volatile jiffies; +extern long startup_time; + +#define CURRENT_TIME (startup_time+jiffies/HZ) + +extern void add_timer(long jiffies, void (*fn)(void)); +extern void sleep_on(struct task_struct ** p); +extern void interruptible_sleep_on(struct task_struct ** p); +extern void wake_up(struct task_struct ** p); + +/* + * Entry into gdt where to find first TSS. 0-nul, 1-cs, 2-ds, 3-syscall + * 4-TSS0, 5-LDT0, 6-TSS1 etc ... + */ +#define FIRST_TSS_ENTRY 4 +#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1) +#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3)) +#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3)) +#define ltr(n) __asm__("ltr %%ax"::"a" (_TSS(n))) +#define lldt(n) __asm__("lldt %%ax"::"a" (_LDT(n))) +#define str(n) \ +__asm__("str %%ax\n\t" \ + "subl %2,%%eax\n\t" \ + "shrl $4,%%eax" \ + :"=a" (n) \ + :"a" (0),"i" (FIRST_TSS_ENTRY<<3)) +/* + * switch_to(n) should switch tasks to task nr n, first + * checking that n isn't the current task, in which case it does nothing. + * This also clears the TS-flag if the task we switched to has used + * tha math co-processor latest. + */ +#define switch_to(n) {\ +struct {long a,b;} __tmp; \ +__asm__("cmpl %%ecx,current\n\t" \ + "je 1f\n\t" \ + "movw %%dx,%1\n\t" \ + "xchgl %%ecx,current\n\t" \ + "ljmp *%0\n\t" \ + "cmpl %%ecx,last_task_used_math\n\t" \ + "jne 1f\n\t" \ + "clts\n" \ + "1:" \ + ::"m" (*&__tmp.a),"m" (*&__tmp.b), \ + "d" (_TSS(n)),"c" ((long) task[n])); \ +} + +#define PAGE_ALIGN(n) (((n)+0xfff)&0xfffff000) + +#define _set_base(addr,base) \ +__asm__ ("push %%edx\n\t" \ + "movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %%dl,%1\n\t" \ + "movb %%dh,%2\n\t" \ + "pop %%edx" \ + ::"m" (*((addr)+2)), \ + "m" (*((addr)+4)), \ + "m" (*((addr)+7)), \ + "d" (base) \ + ) + +#define _set_limit(addr,limit) \ +__asm__ ("push %%edx\n\t" \ + "movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %1,%%dh\n\t" \ + "andb $0xf0,%%dh\n\t" \ + "orb %%dh,%%dl\n\t" \ + "movb %%dl,%1\n\t" \ + "pop %%edx" \ + ::"m" (*(addr)), \ + "m" (*((addr)+6)), \ + "d" (limit) \ + ) + +#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;}) + +#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)); \ +__limit;}) + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sys.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sys.h new file mode 100644 index 0000000..c538fc1 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/sys.h @@ -0,0 +1,86 @@ +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(); + +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 }; diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/tty.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/tty.h new file mode 100644 index 0000000..ad846b3 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/linux/tty.h @@ -0,0 +1,77 @@ +/* + * '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 + +#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[]; + +/* 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 diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/signal.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/signal.h new file mode 100644 index 0000000..0eea9a3 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/signal.h @@ -0,0 +1,68 @@ +#ifndef _SIGNAL_H +#define _SIGNAL_H + +#include + +typedef int sig_atomic_t; +typedef unsigned int sigset_t; /* 32 bits */ + +#define _NSIG 32 +#define NSIG _NSIG + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGUNUSED 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 + +/* Ok, I haven't implemented sigactions, but trying to keep headers POSIX */ +#define SA_NOCLDSTOP 1 +#define SA_NOMASK 0x40000000 +#define SA_ONESHOT 0x80000000 + +#define SIG_BLOCK 0 /* for blocking signals */ +#define SIG_UNBLOCK 1 /* for unblocking signals */ +#define SIG_SETMASK 2 /* for setting the signal mask */ + +#define SIG_DFL ((void (*)(int))0) /* default signal handling */ +#define SIG_IGN ((void (*)(int))1) /* ignore signal */ + +struct sigaction { + void (*sa_handler)(int); + sigset_t sa_mask; + int sa_flags; + void (*sa_restorer)(void); +}; + +void (*signal(int _sig, void (*_func)(int)))(int); +int raise(int sig); +int kill(pid_t pid, int sig); +int sigaddset(sigset_t *mask, int signo); +int sigdelset(sigset_t *mask, int signo); +int sigemptyset(sigset_t *mask); +int sigfillset(sigset_t *mask); +int sigismember(sigset_t *mask, int signo); /* 1 - is, 0 - not, -1 error */ +int sigpending(sigset_t *set); +int sigprocmask(int how, sigset_t *set, sigset_t *oldset); +int sigsuspend(sigset_t *sigmask); +int sigaction(int sig, struct sigaction *act, struct sigaction *oldact); + +#endif /* _SIGNAL_H */ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/stdarg.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/stdarg.h new file mode 100644 index 0000000..fd79ec0 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/stdarg.h @@ -0,0 +1,28 @@ +#ifndef _STDARG_H +#define _STDARG_H + +typedef char *va_list; + +/* Amount of space required in an argument list for an arg of type TYPE. + TYPE may alternatively be an expression whose type is used. */ + +#define __va_rounded_size(TYPE) \ + (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) + +#ifndef __sparc__ +#define va_start(AP, LASTARG) \ + (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) +#else +#define va_start(AP, LASTARG) \ + (__builtin_saveregs (), \ + AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) +#endif + +void va_end (va_list); /* Defined in gnulib */ +#define va_end(AP) + +#define va_arg(AP, TYPE) \ + (AP += __va_rounded_size (TYPE), \ + *((TYPE *) (AP - __va_rounded_size (TYPE)))) + +#endif /* _STDARG_H */ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/stddef.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/stddef.h new file mode 100644 index 0000000..97f72ff --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/stddef.h @@ -0,0 +1,19 @@ +#ifndef _STDDEF_H +#define _STDDEF_H + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef long ptrdiff_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned long size_t; +#endif + +#undef NULL +#define NULL ((void *)0) + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/string.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/string.h new file mode 100644 index 0000000..608e86f --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/string.h @@ -0,0 +1,405 @@ +#ifndef _STRING_H_ +#define _STRING_H_ + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +extern char * strerror(int errno); + +/* + * This string-include defines all string functions as inline + * functions. Use gcc. It also assumes ds=es=data space, this should be + * normal. Most of the string-functions are rather heavily hand-optimized, + * see especially strtok,strstr,str[c]spn. They should work, but are not + * very easy to understand. Everything is done entirely within the register + * set, making the functions fast and clean. String instructions have been + * used through-out, making for "slightly" unclear code :-) + * + * (C) 1991 Linus Torvalds + */ + +extern inline char * strcpy(char * dest,const char *src) +{ +__asm__("cld\n" + "1:\tlodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + ::"S" (src),"D" (dest)); +return dest; +} + +static inline char * strncpy(char * dest,const char *src,int count) +{ +__asm__("cld\n" + "1:\tdecl %2\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "rep\n\t" + "stosb\n" + "2:" + ::"S" (src),"D" (dest),"c" (count)); +return dest; +} + +extern inline char * strcat(char * dest,const char * src) +{ +__asm__("cld\n\t" + "repne\n\t" + "scasb\n\t" + "decl %1\n" + "1:\tlodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + ::"S" (src),"D" (dest),"a" (0),"c" (0xffffffff)); +return dest; +} + +static inline char * strncat(char * dest,const char * src,int count) +{ +__asm__("cld\n\t" + "repne\n\t" + "scasb\n\t" + "decl %1\n\t" + "movl %4,%3\n" + "1:\tdecl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n" + "2:\txorl %2,%2\n\t" + "stosb" + ::"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count) + ); +return dest; +} + +extern inline int strcmp(const char * cs,const char * ct) +{ +register int __res ; +__asm__("cld\n" + "1:\tlodsb\n\t" + "scasb\n\t" + "jne 2f\n\t" + "testb %%al,%%al\n\t" + "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" + "3:" + :"=a" (__res):"D" (cs),"S" (ct)); +return __res; +} + +static inline int strncmp(const char * cs,const char * ct,int count) +{ +register int __res ; +__asm__("cld\n" + "1:\tdecl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "scasb\n\t" + "jne 3f\n\t" + "testb %%al,%%al\n\t" + "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" + "4:" + :"=a" (__res):"D" (cs),"S" (ct),"c" (count)); +return __res; +} + +static inline char * strchr(const char * s,char c) +{ +register char * __res ; +__asm__("cld\n\t" + "movb %%al,%%ah\n" + "1:\tlodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "movl $1,%1\n" + "2:\tmovl %1,%0\n\t" + "decl %0" + :"=a" (__res):"S" (s),"0" (c)); +return __res; +} + +static inline char * strrchr(const char * s,char c) +{ +register char * __res; +__asm__("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" + "2:\ttestb %%al,%%al\n\t" + "jne 1b" + :"=d" (__res):"0" (0),"S" (s),"a" (c)); +return __res; +} + +extern inline int strspn(const char * cs, const char * ct) +{ +register char * __res; +__asm__("cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "je 1b\n" + "2:\tdecl %0" + :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) + ); +return __res-cs; +} + +extern inline int strcspn(const char * cs, const char * ct) +{ +register char * __res; +__asm__("cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "jne 1b\n" + "2:\tdecl %0" + :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) + ); +return __res-cs; +} + +extern inline char * strpbrk(const char * cs,const char * ct) +{ +register char * __res ; +__asm__("cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "jne 1b\n\t" + "decl %0\n\t" + "jmp 3f\n" + "2:\txorl %0,%0\n" + "3:" + :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) + ); +return __res; +} + +extern inline char * strstr(const char * cs,const char * ct) +{ +register char * __res ; +__asm__("cld\n\t" \ + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ + "movl %%ecx,%%edx\n" + "1:\tmovl %4,%%edi\n\t" + "movl %%esi,%%eax\n\t" + "movl %%edx,%%ecx\n\t" + "repe\n\t" + "cmpsb\n\t" + "je 2f\n\t" /* also works for empty string, see above */ + "xchgl %%eax,%%esi\n\t" + "incl %%esi\n\t" + "cmpb $0,-1(%%eax)\n\t" + "jne 1b\n\t" + "xorl %%eax,%%eax\n\t" + "2:" + :"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct) + ); +return __res; +} + +extern inline int strlen(const char * s) +{ +register int __res ; +__asm__("cld\n\t" + "repne\n\t" + "scasb\n\t" + "notl %0\n\t" + "decl %0" + :"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff)); +return __res; +} + +extern char * ___strtok; + +extern inline char * strtok(char * s,const char * ct) +{ +register char * __res ; +__asm__("testl %1,%1\n\t" + "jne 1f\n\t" + "testl %0,%0\n\t" + "je 8f\n\t" + "movl %0,%1\n" + "1:\txorl %0,%0\n\t" + "movl $-1,%%ecx\n\t" + "xorl %%eax,%%eax\n\t" + "cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "je 7f\n\t" /* empty delimeter-string */ + "movl %%ecx,%%edx\n" + "2:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 7f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "je 2b\n\t" + "decl %1\n\t" + "cmpb $0,(%1)\n\t" + "je 7f\n\t" + "movl %1,%0\n" + "3:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 5f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "jne 3b\n\t" + "decl %1\n\t" + "cmpb $0,(%1)\n\t" + "je 5f\n\t" + "movb $0,(%1)\n\t" + "incl %1\n\t" + "jmp 6f\n" + "5:\txorl %1,%1\n" + "6:\tcmpb $0,(%0)\n\t" + "jne 7f\n\t" + "xorl %0,%0\n" + "7:\ttestl %0,%0\n\t" + "jne 8f\n\t" + "movl %0,%1\n" + "8:" + :"=b" (__res),"=S" (___strtok) + :"0" (___strtok),"1" (s),"g" (ct) + ); +return __res; +} + +static inline void * memcpy(void * dest,const void * src, int n) +{ +__asm__("cld\n\t" + "rep\n\t" + "movsb" + ::"c" (n),"S" (src),"D" (dest) + ); +return dest; +} + +extern inline void * memmove(void * dest,const void * src, int n) +{ +if (dest + +struct stat { + dev_t st_dev; + ino_t st_ino; + umode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + time_t st_atime; + time_t st_mtime; + time_t st_ctime; +}; + +#define S_IFMT 00170000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +extern int chmod(const char *_path, mode_t mode); +extern int fstat(int fildes, struct stat *stat_buf); +extern int mkdir(const char *_path, mode_t mode); +extern int mkfifo(const char *_path, mode_t mode); +extern int stat(const char *filename, struct stat *stat_buf); +extern mode_t umask(mode_t mask); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/times.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/times.h new file mode 100644 index 0000000..68d5bfb --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/times.h @@ -0,0 +1,15 @@ +#ifndef _TIMES_H +#define _TIMES_H + +#include + +struct tms { + time_t tms_utime; + time_t tms_stime; + time_t tms_cutime; + time_t tms_cstime; +}; + +extern time_t times(struct tms * tp); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/types.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/types.h new file mode 100644 index 0000000..557aa31 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/types.h @@ -0,0 +1,46 @@ +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef long ptrdiff_t; +#endif + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +typedef int pid_t; +typedef unsigned short uid_t; +typedef unsigned char gid_t; +typedef unsigned short dev_t; +typedef unsigned short ino_t; +typedef unsigned short mode_t; +typedef unsigned short umode_t; +typedef unsigned char nlink_t; +typedef int daddr_t; +typedef long off_t; +typedef unsigned char u_char; +typedef unsigned short ushort; + +typedef struct { int quot,rem; } div_t; +typedef struct { long quot,rem; } ldiv_t; + +struct ustat { + daddr_t f_tfree; + ino_t f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/utsname.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/utsname.h new file mode 100644 index 0000000..0a1c5a0 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/utsname.h @@ -0,0 +1,16 @@ +#ifndef _SYS_UTSNAME_H +#define _SYS_UTSNAME_H + +#include + +struct utsname { + char sysname[9]; + char nodename[9]; + char release[9]; + char version[9]; + char machine[9]; +}; + +extern int uname(struct utsname * utsbuf); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/wait.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/wait.h new file mode 100644 index 0000000..53190c2 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/sys/wait.h @@ -0,0 +1,23 @@ +#ifndef _SYS_WAIT_H +#define _SYS_WAIT_H + +#include + +#define _LOW(v) ( (v) & 0377) +#define _HIGH(v) ( ((v) >> 8) & 0377) + +/* options for waitpid, WUNTRACED not supported */ +#define WNOHANG 1 +#define WUNTRACED 2 + +#define WIFEXITED(s) (!((s)&0xFF) +#define WIFSTOPPED(s) (((s)&0xFF)==0x7F) +#define WEXITSTATUS(s) (((s)>>8)&0xFF) +#define WTERMSIG(s) ((s)&0x7F) +#define WSTOPSIG(s) (((s)>>8)&0xFF) +#define WIFSIGNALED(s) (((unsigned int)(s)-1 & 0xFFFF) < 0xFF) + +pid_t wait(int *stat_loc); +pid_t waitpid(pid_t pid, int *stat_loc, int options); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/termios.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/termios.h new file mode 100644 index 0000000..2b7b913 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/termios.h @@ -0,0 +1,228 @@ +#ifndef _TERMIOS_H +#define _TERMIOS_H + +#define TTY_BUF_SIZE 1024 + +/* 0x54 is just a magic number to make these relatively uniqe ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define TIOCINQ 0x541B + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +#define NCCS 17 +struct termios { + unsigned long c_iflag; /* input mode flags */ + unsigned long c_oflag; /* output mode flags */ + unsigned long c_cflag; /* control mode flags */ + unsigned long c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCCS]; /* control characters */ +}; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define XTABS 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 +#define FFDLY 0040000 +#define FF0 0000000 +#define FF1 0040000 + +/* c_cflag bit meaning */ +#define CBAUD 0000017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define EXTA B19200 +#define EXTB B38400 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define CPARENB 0000400 +#define CPARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#define CIBAUD 03600000 /* input baud rate (not used) */ +#define CRTSCTS 020000000000 /* flow control */ + +#define PARENB CPARENB +#define PARODD CPARODD + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#define XCASE 0000004 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define IEXTEN 0100000 + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG + +/* tcflow() and TCXONC use these */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +typedef int speed_t; + +extern speed_t cfgetispeed(struct termios *termios_p); +extern speed_t cfgetospeed(struct termios *termios_p); +extern int cfsetispeed(struct termios *termios_p, speed_t speed); +extern int cfsetospeed(struct termios *termios_p, speed_t speed); +extern int tcdrain(int fildes); +extern int tcflow(int fildes, int action); +extern int tcflush(int fildes, int queue_selector); +extern int tcgetattr(int fildes, struct termios *termios_p); +extern int tcsendbreak(int fildes, int duration); +extern int tcsetattr(int fildes, int optional_actions, + struct termios *termios_p); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/time.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/time.h new file mode 100644 index 0000000..d0a765d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/time.h @@ -0,0 +1,42 @@ +#ifndef _TIME_H +#define _TIME_H + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#define CLOCKS_PER_SEC 100 + +typedef long clock_t; + +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + +clock_t clock(void); +time_t time(time_t * tp); +double difftime(time_t time2, time_t time1); +time_t mktime(struct tm * tp); + +char * asctime(const struct tm * tp); +char * ctime(const time_t * tp); +struct tm * gmtime(const time_t *tp); +struct tm *localtime(const time_t * tp); +size_t strftime(char * s, size_t smax, const char * fmt, const struct tm * tp); +void tzset(void); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/unistd.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/unistd.h new file mode 100644 index 0000000..bf71dcb --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/unistd.h @@ -0,0 +1,253 @@ +#ifndef _UNISTD_H +#define _UNISTD_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 +#include +#include +#include + +#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 _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); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/utime.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/utime.h new file mode 100644 index 0000000..83f07c7 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/include/utime.h @@ -0,0 +1,13 @@ +#ifndef _UTIME_H +#define _UTIME_H + +#include /* I know - shouldn't do this, but .. */ + +struct utimbuf { + time_t actime; + time_t modtime; +}; + +extern int utime(const char *filename, struct utimbuf *times); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/init/main.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/init/main.c new file mode 100644 index 0000000..c304d06 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/init/main.c @@ -0,0 +1,209 @@ +/* + * linux/init/main.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include +#include + +/* + * we need this inline - forking from kernel space will result + * in NO COPY ON WRITE (!!!), until an execve is executed. This + * is no problem, but for the stack. This is handled by not letting + * main() use the stack at all after fork(). Thus, no function + * calls - which means inline code for fork too, as otherwise we + * would use the stack upon exit from 'fork()'. + * + * Actually only pause and fork are needed inline, so that there + * won't be any messing with the stack from main(), but we define + * some others too. + */ +static inline _syscall0(int,fork) +static inline _syscall0(int,pause) +static inline _syscall1(int,setup,void *,BIOS) +static inline _syscall0(int,sync) + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +static char printbuf[1024]; + +extern int vsprintf(); +extern void init(void); +extern void blk_dev_init(void); +extern void chr_dev_init(void); +extern void hd_init(void); +extern void floppy_init(void); +extern void mem_init(long start, long end); +extern long rd_init(long mem_start, int length); +extern long kernel_mktime(struct tm * tm); +extern long startup_time; + +/* + * This is set up by the setup-routine at boot-time + */ +#define EXT_MEM_K (*(unsigned short *)0x90002) +#define DRIVE_INFO (*(struct drive_info *)0x90080) +#define ORIG_ROOT_DEV (*(unsigned short *)0x901FC) + +/* + * Yeah, yeah, it's ugly, but I cannot find how to do this correctly + * and this seems to work. I anybody has more info on the real-time + * clock I'd be interested. Most of this was trial and error, and some + * bios-listing reading. Urghh. + */ + +#define CMOS_READ(addr) ({ \ +outb_p(0x80|addr,0x70); \ +inb_p(0x71); \ +}) + +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) + +static void time_init(void) +{ + struct tm time; + + do { + time.tm_sec = CMOS_READ(0); + time.tm_min = CMOS_READ(2); + time.tm_hour = CMOS_READ(4); + time.tm_mday = CMOS_READ(7); + time.tm_mon = CMOS_READ(8); + time.tm_year = CMOS_READ(9); + } while (time.tm_sec != CMOS_READ(0)); + BCD_TO_BIN(time.tm_sec); + BCD_TO_BIN(time.tm_min); + BCD_TO_BIN(time.tm_hour); + BCD_TO_BIN(time.tm_mday); + BCD_TO_BIN(time.tm_mon); + BCD_TO_BIN(time.tm_year); + time.tm_mon--; + startup_time = kernel_mktime(&time); +} + +static long memory_end = 0; +static long buffer_memory_end = 0; +static long main_memory_start = 0; + +struct drive_info { char dummy[32]; } drive_info; + +void start(void) /* This really IS void, no error here. */ +{ /* The startup routine assumes (well, ...) this */ +/* + * Interrupts are still disabled. Do necessary setups, then + * enable them + */ + ROOT_DEV = ORIG_ROOT_DEV; + drive_info = DRIVE_INFO; + memory_end = (1<<20) + (EXT_MEM_K<<10); + memory_end &= 0xfffff000; + if (memory_end > 16*1024*1024) + memory_end = 16*1024*1024; + if (memory_end > 12*1024*1024) + buffer_memory_end = 4*1024*1024; + else if (memory_end > 6*1024*1024) + buffer_memory_end = 2*1024*1024; + else + buffer_memory_end = 1*1024*1024; + main_memory_start = buffer_memory_end; +#ifdef RAMDISK + main_memory_start += rd_init(main_memory_start, RAMDISK*1024); +#endif + mem_init(main_memory_start,memory_end); + trap_init(); + blk_dev_init(); + chr_dev_init(); + tty_init(); + time_init(); + sched_init(); + buffer_init(buffer_memory_end); + hd_init(); + floppy_init(); + sti(); + move_to_user_mode(); + if (!fork()) { /* we count on this going ok */ + init(); + } +/* + * NOTE!! For any other task 'pause()' would mean we have to get a + * signal to awaken, but task0 is the sole exception (see 'schedule()') + * as task 0 gets activated at every idle moment (when no other tasks + * can run). For task0 'pause()' just means we go check if some other + * task can run, and if not we return here. + */ + for(;;) pause(); +} + +static int printf(const char *fmt, ...) +{ + va_list args; + int i; + + va_start(args, fmt); + write(1,printbuf,i=vsprintf(printbuf, fmt, args)); + va_end(args); + return i; +} + +static char * argv_rc[] = { "/bin/sh", NULL }; +static char * envp_rc[] = { "HOME=/", NULL }; + +static char * argv[] = { "-/bin/sh",NULL }; +static char * envp[] = { "HOME=/usr/root", NULL }; + +void init(void) +{ + int pid,i; + + setup((void *) &drive_info); + (void) open("/dev/tty0",O_RDWR,0); + (void) dup(0); + (void) dup(0); + printf("%d buffers = %d bytes buffer space\n\r",NR_BUFFERS, + NR_BUFFERS*BLOCK_SIZE); + printf("Free mem: %d bytes\n\r",memory_end-main_memory_start); + if (!(pid=fork())) { + close(0); + if (open("/etc/rc",O_RDONLY,0)) + _exit(1); + execve("/bin/sh",argv_rc,envp_rc); + _exit(2); + } + if (pid>0) + while (pid != wait(&i)) + /* nothing */; + while (1) { + if ((pid=fork())<0) { + printf("Fork failed in init\r\n"); + continue; + } + if (!pid) { + close(0);close(1);close(2); + setsid(); + (void) open("/dev/tty0",O_RDWR,0); + (void) dup(0); + (void) dup(0); + _exit(execve("/bin/sh",argv,envp)); + } + while (1) + if (pid == wait(&i)) + break; + printf("\n\rchild %d died with code %04x\n\r",pid,i); + sync(); + } + _exit(0); /* NOTE! _exit, not exit() */ +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/Makefile new file mode 100644 index 0000000..fbd0d43 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/Makefile @@ -0,0 +1,83 @@ +# +# Makefile for the FREAX-kernel. +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (ie not a .c file). +# + +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =gcc -mcpu=i386 +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions -nostdinc -I../include +CPP =gcc -E -nostdinc -I../include + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(AS) -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = sched.o system_call.o traps.o asm.o fork.o \ + panic.o printk.o vsprintf.o sys.o exit.o \ + signal.o mktime.o + +kernel.o: $(OBJS) + $(LD) -r -o kernel.o $(OBJS) + sync + +clean: + rm -f core *.o *.a tmp_make keyboard.s + for i in *.c;do rm -f `basename $$i .c`.s;done + (cd chr_drv; make clean) + (cd blk_drv; make clean) + (cd math; make clean) + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + (cd chr_drv; make dep) + (cd blk_drv; make dep) + +### Dependencies: +exit.s exit.o: exit.c ../include/errno.h ../include/signal.h \ + ../include/sys/types.h ../include/sys/wait.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \ + ../include/linux/kernel.h ../include/linux/tty.h ../include/termios.h \ + ../include/asm/segment.h +fork.s fork.o: fork.c ../include/errno.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ + ../include/asm/segment.h ../include/asm/system.h +mktime.s mktime.o: mktime.c ../include/time.h +panic.s panic.o: panic.c ../include/linux/kernel.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h +printk.s printk.o: printk.c ../include/stdarg.h ../include/stddef.h \ + ../include/linux/kernel.h +sched.s sched.o: sched.c ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \ + ../include/signal.h ../include/linux/kernel.h ../include/linux/sys.h \ + ../include/linux/fdreg.h ../include/asm/system.h ../include/asm/io.h \ + ../include/asm/segment.h +signal.s signal.o: signal.c ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \ + ../include/signal.h ../include/linux/kernel.h ../include/asm/segment.h +sys.s sys.o: sys.c ../include/errno.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/tty.h \ + ../include/termios.h ../include/linux/kernel.h ../include/asm/segment.h \ + ../include/sys/times.h ../include/sys/utsname.h +traps.s traps.o: traps.c ../include/string.h ../include/linux/head.h \ + ../include/linux/sched.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.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 diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/asm.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/asm.s new file mode 100644 index 0000000..34f9b20 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/asm.s @@ -0,0 +1,146 @@ +/* + * linux/kernel/asm.s + * + * (C) 1991 Linus Torvalds + */ + +/* + * asm.s contains the low-level code for most hardware faults. + * page_exception is handled by the mm, so that isn't here. This + * file also handles (hopefully) fpu-exceptions due to TS-bit, as + * the fpu must be properly saved/resored. This hasn't been tested. + */ + +.globl _divide_error, _debug, _nmi, _int3, _overflow,_bounds,_invalid_op +.globl _double_fault, _coprocessor_segment_overrun +.globl _invalid_TSS, _segment_not_present, _stack_segment +.globl _general_protection, _coprocessor_error,_irq13, _reserved + +_divide_error: + pushl $_do_divide_error +no_error_code: + xchgl %eax,(%esp) + pushl %ebx + pushl %ecx + pushl %edx + pushl %edi + pushl %esi + pushl %ebp + push %ds + push %es + push %fs + pushl $0 # "error code" + lea 44(%esp),%edx + pushl %edx + movl $0x10,%edx + mov %dx,%ds + mov %dx,%es + mov %dx,%fs + call *%eax + addl $8,%esp + pop %fs + pop %es + pop %ds + popl %ebp + popl %esi + popl %edi + popl %edx + popl %ecx + popl %ebx + popl %eax + iret + +_debug: + pushl $_do_int3 # _do_debug + jmp no_error_code + +_nmi: + pushl $_do_nmi + jmp no_error_code + +_int3: + pushl $_do_int3 + jmp no_error_code + +_overflow: + pushl $_do_overflow + jmp no_error_code + +_bounds: + pushl $_do_bounds + jmp no_error_code + +_invalid_op: + pushl $_do_invalid_op + jmp no_error_code + +_coprocessor_segment_overrun: + pushl $_do_coprocessor_segment_overrun + jmp no_error_code + +_reserved: + pushl $_do_reserved + jmp no_error_code + +_irq13: + pushl %eax + xorb %al,%al + outb %al,$0xF0 + movb $0x20,%al + outb %al,$0x20 + jmp 1f +1: jmp 1f +1: outb %al,$0xA0 + popl %eax + jmp _coprocessor_error + +_double_fault: + pushl $_do_double_fault +error_code: + xchgl %eax,4(%esp) # error code <-> %eax + xchgl %ebx,(%esp) # &function <-> %ebx + pushl %ecx + pushl %edx + pushl %edi + pushl %esi + pushl %ebp + push %ds + push %es + push %fs + pushl %eax # error code + lea 44(%esp),%eax # offset + pushl %eax + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + mov %ax,%fs + call *%ebx + addl $8,%esp + pop %fs + pop %es + pop %ds + popl %ebp + popl %esi + popl %edi + popl %edx + popl %ecx + popl %ebx + popl %eax + iret + +_invalid_TSS: + pushl $_do_invalid_TSS + jmp error_code + +_segment_not_present: + pushl $_do_segment_not_present + jmp error_code + +_stack_segment: + pushl $_do_stack_segment + jmp error_code + +_general_protection: + pushl $_do_general_protection + jmp error_code + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/Makefile new file mode 100644 index 0000000..14074c2 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/Makefile @@ -0,0 +1,66 @@ +# +# Makefile for the FREAX-kernel block device drivers. +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (ie not a .c file). +# + +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =gcc -mcpu=i386 +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions -nostdinc -I../../include +CPP =gcc -E -nostdinc -I../../include + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(AS) -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = ll_rw_blk.o floppy.o hd.o ramdisk.o + +blk_drv.a: $(OBJS) + $(AR) rcs blk_drv.a $(OBJS) + sync + +clean: + rm -f core *.o *.a tmp_make + for i in *.c;do rm -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: +floppy.s floppy.o: floppy.c ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/sys/types.h \ + ../../include/linux/mm.h ../../include/signal.h \ + ../../include/linux/kernel.h ../../include/linux/fdreg.h \ + ../../include/asm/system.h ../../include/asm/io.h \ + ../../include/asm/segment.h blk.h +hd.s hd.o: hd.c ../../include/linux/config.h ../../include/linux/sched.h \ + ../../include/linux/head.h ../../include/linux/fs.h \ + ../../include/sys/types.h ../../include/linux/mm.h \ + ../../include/signal.h ../../include/linux/kernel.h \ + ../../include/linux/hdreg.h ../../include/asm/system.h \ + ../../include/asm/io.h ../../include/asm/segment.h blk.h +ll_rw_blk.s ll_rw_blk.o: ll_rw_blk.c ../../include/errno.h \ + ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/sys/types.h \ + ../../include/linux/mm.h ../../include/signal.h \ + ../../include/linux/kernel.h ../../include/asm/system.h blk.h +ramdisk.s ramdisk.o: ramdisk.c ../../include/string.h ../../include/linux/config.h \ + ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/sys/types.h \ + ../../include/linux/mm.h ../../include/signal.h \ + ../../include/linux/kernel.h ../../include/asm/system.h \ + ../../include/asm/segment.h ../../include/asm/memory.h blk.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/blk.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/blk.h new file mode 100644 index 0000000..9ee7591 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/blk.h @@ -0,0 +1,140 @@ +#ifndef _BLK_H +#define _BLK_H + +#define NR_BLK_DEV 7 +/* + * NR_REQUEST is the number of entries in the request-queue. + * NOTE that writes may use only the low 2/3 of these: reads + * take precedence. + * + * 32 seems to be a reasonable number: enough to get some benefit + * from the elevator-mechanism, but not so much as to lock a lot of + * buffers when they are in the queue. 64 seems to be too many (easily + * long pauses in reading when heavy writing/syncing is going on) + */ +#define NR_REQUEST 32 + +/* + * Ok, this is an expanded form so that we can use the same + * request for paging requests when that is implemented. In + * paging, 'bh' is NULL, and 'waiting' is used to wait for + * read/write completion. + */ +struct request { + int dev; /* -1 if no request */ + int cmd; /* READ or WRITE */ + int errors; + unsigned long sector; + unsigned long nr_sectors; + char * buffer; + struct task_struct * waiting; + struct buffer_head * bh; + struct request * next; +}; + +/* + * This is used in the elevator algorithm: Note that + * reads always go before writes. This is natural: reads + * are much more time-critical than writes. + */ +#define IN_ORDER(s1,s2) \ +((s1)->cmd<(s2)->cmd || ((s1)->cmd==(s2)->cmd && \ +((s1)->dev < (s2)->dev || ((s1)->dev == (s2)->dev && \ +(s1)->sector < (s2)->sector)))) + +struct blk_dev_struct { + void (*request_fn)(void); + struct request * current_request; +}; + +extern struct blk_dev_struct blk_dev[NR_BLK_DEV]; +extern struct request request[NR_REQUEST]; +extern struct task_struct * wait_for_request; + +#ifdef MAJOR_NR + +/* + * Add entries as needed. Currently the only block devices + * supported are hard-disks and floppies. + */ + +#if (MAJOR_NR == 1) +/* ram disk */ +#define DEVICE_NAME "ramdisk" +#define DEVICE_REQUEST do_rd_request +#define DEVICE_NR(device) ((device) & 7) +#define DEVICE_ON(device) +#define DEVICE_OFF(device) + +#elif (MAJOR_NR == 2) +/* floppy */ +#define DEVICE_NAME "floppy" +#define DEVICE_INTR do_floppy +#define DEVICE_REQUEST do_fd_request +#define DEVICE_NR(device) ((device) & 3) +#define DEVICE_ON(device) floppy_on(DEVICE_NR(device)) +#define DEVICE_OFF(device) floppy_off(DEVICE_NR(device)) + +#elif (MAJOR_NR == 3) +/* harddisk */ +#define DEVICE_NAME "harddisk" +#define DEVICE_INTR do_hd +#define DEVICE_REQUEST do_hd_request +#define DEVICE_NR(device) (MINOR(device)/5) +#define DEVICE_ON(device) +#define DEVICE_OFF(device) + +#elif +/* unknown blk device */ +#error "unknown blk device" + +#endif + +#define CURRENT (blk_dev[MAJOR_NR].current_request) +#define CURRENT_DEV DEVICE_NR(CURRENT->dev) + +#ifdef DEVICE_INTR +void (*DEVICE_INTR)(void) = NULL; +#endif +static void (DEVICE_REQUEST)(void); + +static inline void unlock_buffer(struct buffer_head * bh) +{ + if (!bh->b_lock) + printk(DEVICE_NAME ": free buffer being unlocked\n"); + bh->b_lock=0; + wake_up(&bh->b_wait); +} + +static inline void end_request(int uptodate) +{ + DEVICE_OFF(CURRENT->dev); + if (CURRENT->bh) { + CURRENT->bh->b_uptodate = uptodate; + unlock_buffer(CURRENT->bh); + } + if (!uptodate) { + printk(DEVICE_NAME " I/O error\n\r"); + printk("dev %04x, block %d\n\r",CURRENT->dev, + CURRENT->bh->b_blocknr); + } + wake_up(&CURRENT->waiting); + wake_up(&wait_for_request); + CURRENT->dev = -1; + CURRENT = CURRENT->next; +} + +#define INIT_REQUEST \ +repeat: \ + if (!CURRENT) \ + return; \ + if (MAJOR(CURRENT->dev) != MAJOR_NR) \ + panic(DEVICE_NAME ": request list destroyed"); \ + if (CURRENT->bh) { \ + if (!CURRENT->bh->b_lock) \ + panic(DEVICE_NAME ": block not locked"); \ + } + +#endif + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/floppy.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/floppy.c new file mode 100644 index 0000000..6ca6401 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/floppy.c @@ -0,0 +1,462 @@ +/* + * linux/kernel/floppy.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 02.12.91 - Changed to static variables to indicate need for reset + * and recalibrate. This makes some things easier (output_byte reset + * checking etc), and means less interrupt jumping in case of errors, + * so the code is hopefully easier to understand. + */ + +/* + * This file is certainly a mess. I've tried my best to get it working, + * but I don't like programming floppies, and I have only one anyway. + * Urgel. I should check for more errors, and do more graceful error + * recovery. Seems there are problems with several drives. I've tried to + * correct them. No promises. + */ + +/* + * As with hd.c, all routines within this file can (and will) be called + * by interrupts, so extreme caution is needed. A hardware interrupt + * handler may not sleep, or a kernel panic will happen. Thus I cannot + * call "floppy-on" directly, but have to set a special timer interrupt + * etc. + * + * Also, I'm not certain this works on more than 1 floppy. Bugs may + * abund. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MAJOR_NR 2 +#include "blk.h" + +static int recalibrate = 0; +static int reset = 0; +static int seek = 0; + +extern unsigned char current_DOR; + +#define immoutb_p(val,port) \ +__asm__("outb %0,%1\n\tjmp 1f\n1:\tjmp 1f\n1:"::"a" ((char) (val)),"i" (port)) + +#define TYPE(x) ((x)>>2) +#define DRIVE(x) ((x)&0x03) +/* + * Note that MAX_ERRORS=8 doesn't imply that we retry every bad read + * max 8 times - some types of errors increase the errorcount by 2, + * so we might actually retry only 5-6 times before giving up. + */ +#define MAX_ERRORS 8 + +/* + * globals used by 'result()' + */ +#define MAX_REPLIES 7 +static unsigned char reply_buffer[MAX_REPLIES]; +#define ST0 (reply_buffer[0]) +#define ST1 (reply_buffer[1]) +#define ST2 (reply_buffer[2]) +#define ST3 (reply_buffer[3]) + +/* + * This struct defines the different floppy types. Unlike minix + * linux doesn't have a "search for right type"-type, as the code + * for that is convoluted and weird. I've got enough problems with + * this driver as it is. + * + * The 'stretch' tells if the tracks need to be boubled for some + * types (ie 360kB diskette in 1.2MB drive etc). Others should + * be self-explanatory. + */ +static struct floppy_struct { + unsigned int size, sect, head, track, stretch; + unsigned char gap,rate,spec1; +} floppy_type[] = { + { 0, 0,0, 0,0,0x00,0x00,0x00 }, /* no testing */ + { 720, 9,2,40,0,0x2A,0x02,0xDF }, /* 360kB PC diskettes */ + { 2400,15,2,80,0,0x1B,0x00,0xDF }, /* 1.2 MB AT-diskettes */ + { 720, 9,2,40,1,0x2A,0x02,0xDF }, /* 360kB in 720kB drive */ + { 1440, 9,2,80,0,0x2A,0x02,0xDF }, /* 3.5" 720kB diskette */ + { 720, 9,2,40,1,0x23,0x01,0xDF }, /* 360kB in 1.2MB drive */ + { 1440, 9,2,80,0,0x23,0x01,0xDF }, /* 720kB in 1.2MB drive */ + { 2880,18,2,80,0,0x1B,0x00,0xCF }, /* 1.44MB diskette */ +}; +/* + * Rate is 0 for 500kb/s, 2 for 300kbps, 1 for 250kbps + * Spec1 is 0xSH, where S is stepping rate (F=1ms, E=2ms, D=3ms etc), + * H is head unload time (1=16ms, 2=32ms, etc) + * + * Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms etc) + * and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). + */ + +extern void floppy_interrupt(void); +extern char tmp_floppy_area[1024]; + +/* + * These are global variables, as that's the easiest way to give + * information to interrupts. They are the data used for the current + * request. + */ +static int cur_spec1 = -1; +static int cur_rate = -1; +static struct floppy_struct * floppy = floppy_type; +static unsigned char current_drive = 0; +static unsigned char sector = 0; +static unsigned char head = 0; +static unsigned char track = 0; +static unsigned char seek_track = 0; +static unsigned char current_track = 255; +static unsigned char command = 0; +unsigned char selected = 0; +struct task_struct * wait_on_floppy_select = NULL; + +void floppy_deselect(unsigned int nr) +{ + if (nr != (current_DOR & 3)) + printk("floppy_deselect: drive not selected\n\r"); + selected = 0; + wake_up(&wait_on_floppy_select); +} + +/* + * floppy-change is never called from an interrupt, so we can relax a bit + * here, sleep etc. Note that floppy-on tries to set current_DOR to point + * to the desired drive, but it will probably not survive the sleep if + * several floppies are used at the same time: thus the loop. + */ +int floppy_change(unsigned int nr) +{ +repeat: + floppy_on(nr); + while ((current_DOR & 3) != nr && selected) + interruptible_sleep_on(&wait_on_floppy_select); + if ((current_DOR & 3) != nr) + goto repeat; + if (inb(FD_DIR) & 0x80) { + floppy_off(nr); + return 1; + } + floppy_off(nr); + return 0; +} + +#define copy_buffer(from,to) \ +__asm__("cld ; rep ; movsl" \ + ::"c" (BLOCK_SIZE/4),"S" ((long)(from)),"D" ((long)(to)) \ + ) + +static void setup_DMA(void) +{ + long addr = (long) CURRENT->buffer; + + cli(); + if (addr >= 0x100000) { + addr = (long) tmp_floppy_area; + if (command == FD_WRITE) + copy_buffer(CURRENT->buffer,tmp_floppy_area); + } +/* mask DMA 2 */ + immoutb_p(4|2,10); +/* output command byte. I don't know why, but everyone (minix, */ +/* sanches & canton) output this twice, first to 12 then to 11 */ + __asm__("outb %%al,$12\n\tjmp 1f\n1:\tjmp 1f\n1:\t" + "outb %%al,$11\n\tjmp 1f\n1:\tjmp 1f\n1:":: + "a" ((char) ((command == FD_READ)?DMA_READ:DMA_WRITE))); +/* 8 low bits of addr */ + immoutb_p(addr,4); + addr >>= 8; +/* bits 8-15 of addr */ + immoutb_p(addr,4); + addr >>= 8; +/* bits 16-19 of addr */ + immoutb_p(addr,0x81); +/* low 8 bits of count-1 (1024-1=0x3ff) */ + immoutb_p(0xff,5); +/* high 8 bits of count-1 */ + immoutb_p(3,5); +/* activate DMA 2 */ + immoutb_p(0|2,10); + sti(); +} + +static void output_byte(char byte) +{ + int counter; + unsigned char status; + + if (reset) + return; + for(counter = 0 ; counter < 10000 ; counter++) { + status = inb_p(FD_STATUS) & (STATUS_READY | STATUS_DIR); + if (status == STATUS_READY) { + outb(byte,FD_DATA); + return; + } + } + reset = 1; + printk("Unable to send byte to FDC\n\r"); +} + +static int result(void) +{ + int i = 0, counter, status; + + if (reset) + return -1; + for (counter = 0 ; counter < 10000 ; counter++) { + status = inb_p(FD_STATUS)&(STATUS_DIR|STATUS_READY|STATUS_BUSY); + if (status == STATUS_READY) + return i; + if (status == (STATUS_DIR|STATUS_READY|STATUS_BUSY)) { + if (i >= MAX_REPLIES) + break; + reply_buffer[i++] = inb_p(FD_DATA); + } + } + reset = 1; + printk("Getstatus times out\n\r"); + return -1; +} + +static void bad_flp_intr(void) +{ + CURRENT->errors++; + if (CURRENT->errors > MAX_ERRORS) { + floppy_deselect(current_drive); + end_request(0); + } + if (CURRENT->errors > MAX_ERRORS/2) + reset = 1; + else + recalibrate = 1; +} + +/* + * Ok, this interrupt is called after a DMA read/write has succeeded, + * so we check the results, and copy any buffers. + */ +static void rw_interrupt(void) +{ + if (result() != 7 || (ST0 & 0xf8) || (ST1 & 0xbf) || (ST2 & 0x73)) { + if (ST1 & 0x02) { + printk("Drive %d is write protected\n\r",current_drive); + floppy_deselect(current_drive); + end_request(0); + } else + bad_flp_intr(); + do_fd_request(); + return; + } + if (command == FD_READ && (unsigned long)(CURRENT->buffer) >= 0x100000) + copy_buffer(tmp_floppy_area,CURRENT->buffer); + floppy_deselect(current_drive); + end_request(1); + do_fd_request(); +} + +inline void setup_rw_floppy(void) +{ + setup_DMA(); + do_floppy = rw_interrupt; + output_byte(command); + output_byte(head<<2 | current_drive); + output_byte(track); + output_byte(head); + output_byte(sector); + output_byte(2); /* sector size = 512 */ + output_byte(floppy->sect); + output_byte(floppy->gap); + output_byte(0xFF); /* sector size (0xff when n!=0 ?) */ + if (reset) + do_fd_request(); +} + +/* + * This is the routine called after every seek (or recalibrate) interrupt + * from the floppy controller. Note that the "unexpected interrupt" routine + * also does a recalibrate, but doesn't come here. + */ +static void seek_interrupt(void) +{ +/* sense drive status */ + output_byte(FD_SENSEI); + if (result() != 2 || (ST0 & 0xF8) != 0x20 || ST1 != seek_track) { + bad_flp_intr(); + do_fd_request(); + return; + } + current_track = ST1; + setup_rw_floppy(); +} + +/* + * This routine is called when everything should be correctly set up + * for the transfer (ie floppy motor is on and the correct floppy is + * selected). + */ +static void transfer(void) +{ + if (cur_spec1 != floppy->spec1) { + cur_spec1 = floppy->spec1; + output_byte(FD_SPECIFY); + output_byte(cur_spec1); /* hut etc */ + output_byte(6); /* Head load time =6ms, DMA */ + } + if (cur_rate != floppy->rate) + outb_p(cur_rate = floppy->rate,FD_DCR); + if (reset) { + do_fd_request(); + return; + } + if (!seek) { + setup_rw_floppy(); + return; + } + do_floppy = seek_interrupt; + if (seek_track) { + output_byte(FD_SEEK); + output_byte(head<<2 | current_drive); + output_byte(seek_track); + } else { + output_byte(FD_RECALIBRATE); + output_byte(head<<2 | current_drive); + } + if (reset) + do_fd_request(); +} + +/* + * Special case - used after a unexpected interrupt (or reset) + */ +static void recal_interrupt(void) +{ + output_byte(FD_SENSEI); + if (result()!=2 || (ST0 & 0xE0) == 0x60) + reset = 1; + else + recalibrate = 0; + do_fd_request(); +} + +void unexpected_floppy_interrupt(void) +{ + output_byte(FD_SENSEI); + if (result()!=2 || (ST0 & 0xE0) == 0x60) + reset = 1; + else + recalibrate = 1; +} + +static void recalibrate_floppy(void) +{ + recalibrate = 0; + current_track = 0; + do_floppy = recal_interrupt; + output_byte(FD_RECALIBRATE); + output_byte(head<<2 | current_drive); + if (reset) + do_fd_request(); +} + +static void reset_interrupt(void) +{ + output_byte(FD_SENSEI); + (void) result(); + output_byte(FD_SPECIFY); + output_byte(cur_spec1); /* hut etc */ + output_byte(6); /* Head load time =6ms, DMA */ + do_fd_request(); +} + +/* + * reset is done by pulling bit 2 of DOR low for a while. + */ +static void reset_floppy(void) +{ + int i; + + reset = 0; + cur_spec1 = -1; + cur_rate = -1; + recalibrate = 1; + printk("Reset-floppy called\n\r"); + cli(); + do_floppy = reset_interrupt; + outb_p(current_DOR & ~0x04,FD_DOR); + for (i=0 ; i<100 ; i++) + __asm__("nop"); + outb(current_DOR,FD_DOR); + sti(); +} + +static void floppy_on_interrupt(void) +{ +/* We cannot do a floppy-select, as that might sleep. We just force it */ + selected = 1; + if (current_drive != (current_DOR & 3)) { + current_DOR &= 0xFC; + current_DOR |= current_drive; + outb(current_DOR,FD_DOR); + add_timer(2,&transfer); + } else + transfer(); +} + +void do_fd_request(void) +{ + unsigned int block; + + seek = 0; + if (reset) { + reset_floppy(); + return; + } + if (recalibrate) { + recalibrate_floppy(); + return; + } + INIT_REQUEST; + floppy = (MINOR(CURRENT->dev)>>2) + floppy_type; + if (current_drive != CURRENT_DEV) + seek = 1; + current_drive = CURRENT_DEV; + block = CURRENT->sector; + if (block+2 > floppy->size) { + end_request(0); + goto repeat; + } + sector = block % floppy->sect; + block /= floppy->sect; + head = block % floppy->head; + track = block / floppy->head; + seek_track = track << floppy->stretch; + if (seek_track != current_track) + seek = 1; + sector++; + if (CURRENT->cmd == READ) + command = FD_READ; + else if (CURRENT->cmd == WRITE) + command = FD_WRITE; + else + panic("do_fd_request: unknown command"); + add_timer(ticks_to_floppy_on(current_drive),&floppy_on_interrupt); +} + +void floppy_init(void) +{ + blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST; + set_trap_gate(0x26,&floppy_interrupt); + outb(inb_p(0x21)&~0x40,0x21); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/hd.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/hd.c new file mode 100644 index 0000000..3e176f7 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/hd.c @@ -0,0 +1,349 @@ +/* + * linux/kernel/hd.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * This is the low-level hd interrupt support. It traverses the + * request-list, using interrupts to jump between functions. As + * all the functions are called within interrupts, we may not + * sleep. Special care is recommended. + * + * modified by Drew Eckhardt to check nr of hd's from the CMOS. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAJOR_NR 3 +#include "blk.h" + +#define CMOS_READ(addr) ({ \ +outb_p(0x80|addr,0x70); \ +inb_p(0x71); \ +}) + +/* Max read/write errors/sector */ +#define MAX_ERRORS 7 +#define MAX_HD 2 + +static void recal_intr(void); + +static int recalibrate = 1; +static int reset = 1; + +/* + * This struct defines the HD's and their types. + */ +struct hd_i_struct { + int head,sect,cyl,wpcom,lzone,ctl; + }; +#ifdef HD_TYPE +struct hd_i_struct hd_info[] = { HD_TYPE }; +#define NR_HD ((sizeof (hd_info))/(sizeof (struct hd_i_struct))) +#else +struct hd_i_struct hd_info[] = { {0,0,0,0,0,0},{0,0,0,0,0,0} }; +static int NR_HD = 0; +#endif + +static struct hd_struct { + long start_sect; + long nr_sects; +} hd[5*MAX_HD]={{0,0},}; + +#define port_read(port,buf,nr) \ +__asm__("cld;rep;insw"::"d" (port),"D" (buf),"c" (nr)) + +#define port_write(port,buf,nr) \ +__asm__("cld;rep;outsw"::"d" (port),"S" (buf),"c" (nr)) + +extern void hd_interrupt(void); +extern void rd_load(void); + +/* This may be used only once, enforced by 'static int callable' */ +int sys_setup(void * BIOS) +{ + static int callable = 1; + int i,drive; + unsigned char cmos_disks; + struct partition *p; + struct buffer_head * bh; + + if (!callable) + return -1; + callable = 0; +#ifndef HD_TYPE + for (drive=0 ; drive<2 ; drive++) { + hd_info[drive].cyl = *(unsigned short *) BIOS; + hd_info[drive].head = *(unsigned char *) (2+BIOS); + hd_info[drive].wpcom = *(unsigned short *) (5+BIOS); + hd_info[drive].ctl = *(unsigned char *) (8+BIOS); + hd_info[drive].lzone = *(unsigned short *) (12+BIOS); + hd_info[drive].sect = *(unsigned char *) (14+BIOS); + BIOS += 16; + } + if (hd_info[1].cyl) + NR_HD=2; + else + NR_HD=1; +#endif + for (i=0 ; i are the primary drives in the system, and + the ones reflected as drive 1 or 2. + + The first drive is stored in the high nibble of CMOS + byte 0x12, the second in the low nibble. This will be + either a 4 bit drive type or 0xf indicating use byte 0x19 + for an 8 bit type, drive 1, 0x1a for drive 2 in CMOS. + + Needless to say, a non-zero value means we have + an AT controller hard disk for that drive. + + + */ + + if ((cmos_disks = CMOS_READ(0x12)) & 0xf0) + if (cmos_disks & 0x0f) + NR_HD = 2; + else + NR_HD = 1; + else + NR_HD = 0; + for (i = NR_HD ; i < 2 ; i++) { + hd[i*5].start_sect = 0; + hd[i*5].nr_sects = 0; + } + for (drive=0 ; driveb_data[510] != 0x55 || (unsigned char) + bh->b_data[511] != 0xAA) { + printk("Bad partition table on drive %d\n\r",drive); + panic(""); + } + p = 0x1BE + (void *)bh->b_data; + for (i=1;i<5;i++,p++) { + hd[i+5*drive].start_sect = p->start_sect; + hd[i+5*drive].nr_sects = p->nr_sects; + } + brelse(bh); + } + if (NR_HD) + printk("Partition table%s ok.\n\r",(NR_HD>1)?"s":""); + rd_load(); + mount_root(); + return (0); +} + +static int controller_ready(void) +{ + int retries=10000; + + while (--retries && (inb_p(HD_STATUS)&0xc0)!=0x40); + return (retries); +} + +static int win_result(void) +{ + int i=inb_p(HD_STATUS); + + if ((i & (BUSY_STAT | READY_STAT | WRERR_STAT | SEEK_STAT | ERR_STAT)) + == (READY_STAT | SEEK_STAT)) + return(0); /* ok */ + if (i&1) i=inb(HD_ERROR); + return (1); +} + +static void hd_out(unsigned int drive,unsigned int nsect,unsigned int sect, + unsigned int head,unsigned int cyl,unsigned int cmd, + void (*intr_addr)(void)) +{ + register int port asm("dx"); + + if (drive>1 || head>15) + panic("Trying to write bad sector"); + if (!controller_ready()) + panic("HD controller not ready"); + do_hd = intr_addr; + outb_p(hd_info[drive].ctl,HD_CMD); + port=HD_DATA; + outb_p(hd_info[drive].wpcom>>2,++port); + outb_p(nsect,++port); + outb_p(sect,++port); + outb_p(cyl,++port); + outb_p(cyl>>8,++port); + outb_p(0xA0|(drive<<4)|head,++port); + outb(cmd,++port); +} + +static int drive_busy(void) +{ + unsigned int i; + + for (i = 0; i < 10000; i++) + if (READY_STAT == (inb_p(HD_STATUS) & (BUSY_STAT|READY_STAT))) + break; + i = inb(HD_STATUS); + i &= BUSY_STAT | READY_STAT | SEEK_STAT; + if (i == (READY_STAT | SEEK_STAT)) + return(0); + printk("HD controller times out\n\r"); + return(1); +} + +static void reset_controller(void) +{ + int i; + + outb(4,HD_CMD); + for(i = 0; i < 100; i++) nop(); + outb(hd_info[0].ctl & 0x0f ,HD_CMD); + if (drive_busy()) + printk("HD-controller still busy\n\r"); + if ((i = inb(HD_ERROR)) != 1) + printk("HD-controller reset failed: %02x\n\r",i); +} + +static void reset_hd(int nr) +{ + reset_controller(); + hd_out(nr,hd_info[nr].sect,hd_info[nr].sect,hd_info[nr].head-1, + hd_info[nr].cyl,WIN_SPECIFY,&recal_intr); +} + +void unexpected_hd_interrupt(void) +{ + printk("Unexpected HD interrupt\n\r"); +} + +static void bad_rw_intr(void) +{ + if (++CURRENT->errors >= MAX_ERRORS) + end_request(0); + if (CURRENT->errors > MAX_ERRORS/2) + reset = 1; +} + +static void read_intr(void) +{ + if (win_result()) { + bad_rw_intr(); + do_hd_request(); + return; + } + port_read(HD_DATA,CURRENT->buffer,256); + CURRENT->errors = 0; + CURRENT->buffer += 512; + CURRENT->sector++; + if (--CURRENT->nr_sectors) { + do_hd = &read_intr; + return; + } + end_request(1); + do_hd_request(); +} + +static void write_intr(void) +{ + if (win_result()) { + bad_rw_intr(); + do_hd_request(); + return; + } + if (--CURRENT->nr_sectors) { + CURRENT->sector++; + CURRENT->buffer += 512; + do_hd = &write_intr; + port_write(HD_DATA,CURRENT->buffer,256); + return; + } + end_request(1); + do_hd_request(); +} + +static void recal_intr(void) +{ + if (win_result()) + bad_rw_intr(); + do_hd_request(); +} + +void do_hd_request(void) +{ + int i,r = 0; + unsigned int block,dev; + unsigned int sec,head,cyl; + unsigned int nsect; + + INIT_REQUEST; + dev = MINOR(CURRENT->dev); + block = CURRENT->sector; + if (dev >= 5*NR_HD || block+2 > hd[dev].nr_sects) { + end_request(0); + goto repeat; + } + block += hd[dev].start_sect; + dev /= 5; + __asm__("divl %4":"=a" (block),"=d" (sec):"0" (block),"1" (0), + "r" (hd_info[dev].sect)); + __asm__("divl %4":"=a" (cyl),"=d" (head):"0" (block),"1" (0), + "r" (hd_info[dev].head)); + sec++; + nsect = CURRENT->nr_sectors; + if (reset) { + reset = 0; + recalibrate = 1; + reset_hd(CURRENT_DEV); + return; + } + if (recalibrate) { + recalibrate = 0; + hd_out(dev,hd_info[CURRENT_DEV].sect,0,0,0, + WIN_RESTORE,&recal_intr); + return; + } + if (CURRENT->cmd == WRITE) { + hd_out(dev,nsect,sec,head,cyl,WIN_WRITE,&write_intr); + for(i=0 ; i<3000 && !(r=inb_p(HD_STATUS)&DRQ_STAT) ; i++) + /* nothing */ ; + if (!r) { + bad_rw_intr(); + goto repeat; + } + port_write(HD_DATA,CURRENT->buffer,256); + } else if (CURRENT->cmd == READ) { + hd_out(dev,nsect,sec,head,cyl,WIN_READ,&read_intr); + } else + panic("unknown hd-command"); +} + +void hd_init(void) +{ + blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST; + set_intr_gate(0x2E,&hd_interrupt); + outb_p(inb_p(0x21)&0xfb,0x21); + outb(inb_p(0xA1)&0xbf,0xA1); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/ll_rw_blk.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/ll_rw_blk.c new file mode 100644 index 0000000..8931a81 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/blk_drv/ll_rw_blk.c @@ -0,0 +1,165 @@ +/* + * linux/kernel/blk_dev/ll_rw.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * This handles all read/write requests to block devices + */ +#include +#include +#include +#include + +#include "blk.h" + +/* + * The request-struct contains all necessary data + * to load a nr of sectors into memory + */ +struct request request[NR_REQUEST]; + +/* + * used to wait on when there are no free requests + */ +struct task_struct * wait_for_request = NULL; + +/* blk_dev_struct is: + * do_request-address + * next-request + */ +struct blk_dev_struct blk_dev[NR_BLK_DEV] = { + { NULL, NULL }, /* no_dev */ + { NULL, NULL }, /* dev mem */ + { NULL, NULL }, /* dev fd */ + { NULL, NULL }, /* dev hd */ + { NULL, NULL }, /* dev ttyx */ + { NULL, NULL }, /* dev tty */ + { NULL, NULL } /* dev lp */ +}; + +static inline void lock_buffer(struct buffer_head * bh) +{ + cli(); + while (bh->b_lock) + sleep_on(&bh->b_wait); + bh->b_lock=1; + sti(); +} + +static inline void unlock_buffer(struct buffer_head * bh) +{ + if (!bh->b_lock) + printk("ll_rw_block.c: buffer not locked\n\r"); + bh->b_lock = 0; + wake_up(&bh->b_wait); +} + +/* + * add-request adds a request to the linked list. + * It disables interrupts so that it can muck with the + * request-lists in peace. + */ +static void add_request(struct blk_dev_struct * dev, struct request * req) +{ + struct request * tmp; + + req->next = NULL; + cli(); + if (req->bh) + req->bh->b_dirt = 0; + if (!(tmp = dev->current_request)) { + dev->current_request = req; + sti(); + (dev->request_fn)(); + return; + } + for ( ; tmp->next ; tmp=tmp->next) + if ((IN_ORDER(tmp,req) || + !IN_ORDER(tmp,tmp->next)) && + IN_ORDER(req,tmp->next)) + break; + req->next=tmp->next; + tmp->next=req; + sti(); +} + +static void make_request(int major,int rw, struct buffer_head * bh) +{ + struct request * req; + int rw_ahead; + +/* WRITEA/READA is special case - it is not really needed, so if the */ +/* buffer is locked, we just forget about it, else it's a normal read */ + if ((rw_ahead = (rw == READA || rw == WRITEA))) { + if (bh->b_lock) + return; + if (rw == READA) + rw = READ; + else + rw = WRITE; + } + if (rw!=READ && rw!=WRITE) + panic("Bad block dev command, must be R/W/RA/WA"); + lock_buffer(bh); + if ((rw == WRITE && !bh->b_dirt) || (rw == READ && bh->b_uptodate)) { + unlock_buffer(bh); + return; + } +repeat: +/* we don't allow the write-requests to fill up the queue completely: + * we want some room for reads: they take precedence. The last third + * of the requests are only for reads. + */ + if (rw == READ) + req = request+NR_REQUEST; + else + req = request+((NR_REQUEST*2)/3); +/* find an empty request */ + while (--req >= request) + if (req->dev<0) + break; +/* if none found, sleep on new requests: check for rw_ahead */ + if (req < request) { + if (rw_ahead) { + unlock_buffer(bh); + return; + } + sleep_on(&wait_for_request); + goto repeat; + } +/* fill up the request-info, and add it to the queue */ + req->dev = bh->b_dev; + req->cmd = rw; + req->errors=0; + req->sector = bh->b_blocknr<<1; + req->nr_sectors = 2; + req->buffer = bh->b_data; + req->waiting = NULL; + req->bh = bh; + req->next = NULL; + add_request(major+blk_dev,req); +} + +void ll_rw_block(int rw, struct buffer_head * bh) +{ + unsigned int major; + + if ((major=MAJOR(bh->b_dev)) >= NR_BLK_DEV || + !(blk_dev[major].request_fn)) { + printk("Trying to read nonexistent block-device\n\r"); + return; + } + make_request(major,rw,bh); +} + +void blk_dev_init(void) +{ + int i; + + for (i=0 ; i + +#include +#include +#include +#include +#include +#include +#include + +#define MAJOR_NR 1 +#include "blk.h" + +char *rd_start; +int rd_length = 0; + +void do_rd_request(void) +{ + int len; + char *addr; + + INIT_REQUEST; + addr = rd_start + (CURRENT->sector << 9); + len = CURRENT->nr_sectors << 9; + if ((MINOR(CURRENT->dev) != 1) || (addr+len > rd_start+rd_length)) { + end_request(0); + goto repeat; + } + if (CURRENT-> cmd == WRITE) { + (void ) memcpy(addr, + CURRENT->buffer, + len); + } else if (CURRENT->cmd == READ) { + (void) memcpy(CURRENT->buffer, + addr, + len); + } else + panic("unknown ramdisk-command"); + end_request(1); + goto repeat; +} + +/* + * Returns amount of memory which needs to be reserved. + */ +long rd_init(long mem_start, int length) +{ + int i; + char *cp; + + blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST; + rd_start = (char *) mem_start; + rd_length = length; + cp = rd_start; + for (i=0; i < length; i++) + *cp++ = '\0'; + return(length); +} + +/* + * If the root device is the ram disk, try to load it. + * In order to do this, the root device is originally set to the + * floppy, and we later change it to be ram disk. + */ +void rd_load(void) +{ + struct buffer_head *bh; + struct super_block s; + int block = 256; /* Start at block 256 */ + int i = 1; + int nblocks; + char *cp; /* Move pointer */ + + if (!rd_length) + return; + printk("Ram disk: %d bytes, starting at 0x%x\n", rd_length, + (int) rd_start); + if (MAJOR(ROOT_DEV) != 2) + return; + bh = breada(ROOT_DEV,block+1,block,block+2,-1); + if (!bh) { + printk("Disk error while looking for ramdisk!\n"); + return; + } + *((struct d_super_block *) &s) = *((struct d_super_block *) bh->b_data); + brelse(bh); + if (s.s_magic != SUPER_MAGIC) + /* No ram disk image present, assume normal floppy boot */ + return; + nblocks = s.s_nzones << s.s_log_zone_size; + if (nblocks > (rd_length >> BLOCK_SIZE_BITS)) { + printk("Ram disk image too big! (%d blocks, %d avail)\n", + nblocks, rd_length >> BLOCK_SIZE_BITS); + return; + } + printk("Loading %d bytes into ram disk... 0000k", + nblocks << BLOCK_SIZE_BITS); + cp = rd_start; + while (nblocks) { + if (nblocks > 2) + bh = breada(ROOT_DEV, block, block+1, block+2, -1); + else + bh = bread(ROOT_DEV, block); + if (!bh) { + printk("I/O error on block %d, aborting load\n", + block); + return; + } + (void) memcpy(cp, bh->b_data, BLOCK_SIZE); + brelse(bh); + printk("\010\010\010\010\010%4dk",i); + cp += BLOCK_SIZE; + block++; + nblocks--; + i++; + } + printk("\010\010\010\010\010done \n"); + ROOT_DEV=0x0101; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/Makefile new file mode 100644 index 0000000..76d9cdd --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/Makefile @@ -0,0 +1,71 @@ +# +# Makefile for the FREAX-kernel character device drivers. +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (ie not a .c file). +# + +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =gcc -mcpu=i386 +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions -nostdinc -I../../include +CPP =gcc -E -nostdinc -I../../include + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(AS) -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = tty_io.o console.o keyboard.o serial.o rs_io.o \ + tty_ioctl.o + +chr_drv.a: $(OBJS) + $(AR) rcs chr_drv.a $(OBJS) + sync + +keyboard.s: keyboard.S ../../include/linux/config.h + $(CPP) -traditional keyboard.S -o keyboard.s + +clean: + rm -f core *.o *.a tmp_make keyboard.s + for i in *.c;do rm -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: +console.s console.o: console.c ../../include/linux/sched.h \ + ../../include/linux/head.h ../../include/linux/fs.h \ + ../../include/sys/types.h ../../include/linux/mm.h \ + ../../include/signal.h ../../include/linux/tty.h \ + ../../include/termios.h ../../include/asm/io.h \ + ../../include/asm/system.h +serial.s serial.o: serial.c ../../include/linux/tty.h ../../include/termios.h \ + ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/sys/types.h \ + ../../include/linux/mm.h ../../include/signal.h \ + ../../include/asm/system.h ../../include/asm/io.h +tty_io.s tty_io.o: tty_io.c ../../include/ctype.h ../../include/errno.h \ + ../../include/signal.h ../../include/sys/types.h \ + ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/linux/mm.h \ + ../../include/linux/tty.h ../../include/termios.h \ + ../../include/asm/segment.h ../../include/asm/system.h +tty_ioctl.s tty_ioctl.o: tty_ioctl.c ../../include/errno.h ../../include/termios.h \ + ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/sys/types.h \ + ../../include/linux/mm.h ../../include/signal.h \ + ../../include/linux/kernel.h ../../include/linux/tty.h \ + ../../include/asm/io.h ../../include/asm/segment.h \ + ../../include/asm/system.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/console.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/console.c new file mode 100644 index 0000000..3f76f61 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/console.c @@ -0,0 +1,710 @@ +/* + * linux/kernel/console.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * console.c + * + * This module implements the console io functions + * 'void con_init(void)' + * 'void con_write(struct tty_queue * queue)' + * Hopefully this will be a rather complete VT102 implementation. + * + * Beeping thanks to John T Kohl. + */ + +/* + * NOTE!!! We sometimes disable and enable interrupts for a short while + * (to put a word in video IO), but this will work even for keyboard + * interrupts. We know interrupts aren't enabled when getting a keyboard + * interrupt, as we use trap-gates. Hopefully all is well. + */ + +/* + * Code to check for different video-cards mostly by Galen Hunt, + * + */ + +#include +#include +#include +#include + +/* + * These are set up by the setup-routine at boot-time: + */ + +#define ORIG_X (*(unsigned char *)0x90000) +#define ORIG_Y (*(unsigned char *)0x90001) +#define ORIG_VIDEO_PAGE (*(unsigned short *)0x90004) +#define ORIG_VIDEO_MODE ((*(unsigned short *)0x90006) & 0xff) +#define ORIG_VIDEO_COLS (((*(unsigned short *)0x90006) & 0xff00) >> 8) +#define ORIG_VIDEO_LINES (25) +#define ORIG_VIDEO_EGA_AX (*(unsigned short *)0x90008) +#define ORIG_VIDEO_EGA_BX (*(unsigned short *)0x9000a) +#define ORIG_VIDEO_EGA_CX (*(unsigned short *)0x9000c) + +#define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */ +#define VIDEO_TYPE_CGA 0x11 /* CGA Display */ +#define VIDEO_TYPE_EGAM 0x20 /* EGA/VGA in Monochrome Mode */ +#define VIDEO_TYPE_EGAC 0x21 /* EGA/VGA in Color Mode */ + +#define NPAR 16 + +extern void keyboard_interrupt(void); + +static unsigned char video_type; /* Type of display being used */ +static unsigned long video_num_columns; /* Number of text columns */ +static unsigned long video_size_row; /* Bytes per row */ +static unsigned long video_num_lines; /* Number of test lines */ +static unsigned char video_page; /* Initial video page */ +static unsigned long video_mem_start; /* Start of video RAM */ +static unsigned long video_mem_end; /* End of video RAM (sort of) */ +static unsigned short video_port_reg; /* Video register select port */ +static unsigned short video_port_val; /* Video register value port */ +static unsigned short video_erase_char; /* Char+Attrib to erase with */ + +static unsigned long origin; /* Used for EGA/VGA fast scroll */ +static unsigned long scr_end; /* Used for EGA/VGA fast scroll */ +static unsigned long pos; +static unsigned long x,y; +static unsigned long top,bottom; +static unsigned long state=0; +static unsigned long npar,par[NPAR]; +static unsigned long ques=0; +static unsigned char attr=0x07; + +static void sysbeep(void); + +/* + * this is what the terminal answers to a ESC-Z or csi0c + * query (= vt100 response). + */ +#define RESPONSE "\033[?1;2c" + +/* NOTE! gotoxy thinks x==video_num_columns is ok */ +static inline void gotoxy(unsigned int new_x,unsigned int new_y) +{ + if (new_x > video_num_columns || new_y >= video_num_lines) + return; + x=new_x; + y=new_y; + pos=origin + y*video_size_row + (x<<1); +} + +static inline void set_origin(void) +{ + cli(); + outb_p(12, video_port_reg); + outb_p(0xff&((origin-video_mem_start)>>9), video_port_val); + outb_p(13, video_port_reg); + outb_p(0xff&((origin-video_mem_start)>>1), video_port_val); + sti(); +} + +static void scrup(void) +{ + if (video_type == VIDEO_TYPE_EGAC || video_type == VIDEO_TYPE_EGAM) + { + if (!top && bottom == video_num_lines) { + origin += video_size_row; + pos += video_size_row; + scr_end += video_size_row; + if (scr_end > video_mem_end) { + __asm__("cld\n\t" + "rep\n\t" + "movsl\n\t" + "movl _video_num_columns,%1\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((video_num_lines-1)*video_num_columns>>1), + "D" (video_mem_start), + "S" (origin) + ); + scr_end -= origin-video_mem_start; + pos -= origin-video_mem_start; + origin = video_mem_start; + } else { + __asm__("cld\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" (video_num_columns), + "D" (scr_end-video_size_row) + ); + } + set_origin(); + } else { + __asm__("cld\n\t" + "rep\n\t" + "movsl\n\t" + "movl _video_num_columns,%%ecx\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((bottom-top-1)*video_num_columns>>1), + "D" (origin+video_size_row*top), + "S" (origin+video_size_row*(top+1)) + ); + } + } + else /* Not EGA/VGA */ + { + __asm__("cld\n\t" + "rep\n\t" + "movsl\n\t" + "movl _video_num_columns,%%ecx\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((bottom-top-1)*video_num_columns>>1), + "D" (origin+video_size_row*top), + "S" (origin+video_size_row*(top+1)) + ); + } +} + +static void scrdown(void) +{ + if (video_type == VIDEO_TYPE_EGAC || video_type == VIDEO_TYPE_EGAM) + { + __asm__("std\n\t" + "rep\n\t" + "movsl\n\t" + "addl $2,%%edi\n\t" /* %edi has been decremented by 4 */ + "movl _video_num_columns,%%ecx\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((bottom-top-1)*video_num_columns>>1), + "D" (origin+video_size_row*bottom-4), + "S" (origin+video_size_row*(bottom-1)-4) + ); + } + else /* Not EGA/VGA */ + { + __asm__("std\n\t" + "rep\n\t" + "movsl\n\t" + "addl $2,%%edi\n\t" /* %edi has been decremented by 4 */ + "movl _video_num_columns,%%ecx\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((bottom-top-1)*video_num_columns>>1), + "D" (origin+video_size_row*bottom-4), + "S" (origin+video_size_row*(bottom-1)-4) + ); + } +} + +static void lf(void) +{ + if (y+1top) { + y--; + pos -= video_size_row; + return; + } + scrdown(); +} + +static void cr(void) +{ + pos -= x<<1; + x=0; +} + +static void del(void) +{ + if (x) { + pos -= 2; + x--; + *(unsigned short *)pos = video_erase_char; + } +} + +static void csi_J(int par) +{ + long count; + long start; + + switch (par) { + case 0: /* erase from cursor to end of display */ + count = (scr_end-pos)>>1; + start = pos; + break; + case 1: /* erase from start to cursor */ + count = (pos-origin)>>1; + start = origin; + break; + case 2: /* erase whole display */ + count = video_num_columns * video_num_lines; + start = origin; + break; + default: + return; + } + __asm__("cld\n\t" + "rep\n\t" + "stosw\n\t" + ::"c" (count), + "D" (start),"a" (video_erase_char) + ); +} + +static void csi_K(int par) +{ + long count; + long start; + + switch (par) { + case 0: /* erase from cursor to end of line */ + if (x>=video_num_columns) + return; + count = video_num_columns-x; + start = pos; + break; + case 1: /* erase from start of line to cursor */ + start = pos - (x<<1); + count = (x>9), video_port_val); + outb_p(15, video_port_reg); + outb_p(0xff&((pos-video_mem_start)>>1), video_port_val); + sti(); +} + +static void respond(struct tty_struct * tty) +{ + char * p = RESPONSE; + + cli(); + while (*p) { + PUTCH(*p,tty->read_q); + p++; + } + sti(); + copy_to_cooked(tty); +} + +static void insert_char(void) +{ + int i=x; + unsigned short tmp, old = video_erase_char; + unsigned short * p = (unsigned short *) pos; + + while (i++=video_num_columns) + return; + i = x; + while (++i < video_num_columns) { + *p = *(p+1); + p++; + } + *p = video_erase_char; +} + +static void delete_line(void) +{ + int oldtop,oldbottom; + + oldtop=top; + oldbottom=bottom; + top=y; + bottom = video_num_lines; + scrup(); + top=oldtop; + bottom=oldbottom; +} + +static void csi_at(unsigned int nr) +{ + if (nr > video_num_columns) + nr = video_num_columns; + else if (!nr) + nr = 1; + while (nr--) + insert_char(); +} + +static void csi_L(unsigned int nr) +{ + if (nr > video_num_lines) + nr = video_num_lines; + else if (!nr) + nr = 1; + while (nr--) + insert_line(); +} + +static void csi_P(unsigned int nr) +{ + if (nr > video_num_columns) + nr = video_num_columns; + else if (!nr) + nr = 1; + while (nr--) + delete_char(); +} + +static void csi_M(unsigned int nr) +{ + if (nr > video_num_lines) + nr = video_num_lines; + else if (!nr) + nr=1; + while (nr--) + delete_line(); +} + +static int saved_x=0; +static int saved_y=0; + +static void save_cur(void) +{ + saved_x=x; + saved_y=y; +} + +static void restore_cur(void) +{ + gotoxy(saved_x, saved_y); +} + +void con_write(struct tty_struct * tty) +{ + int nr; + char c; + + nr = CHARS(tty->write_q); + while (nr--) { + GETCH(tty->write_q,c); + switch(state) { + case 0: + if (c>31 && c<127) { + if (x>=video_num_columns) { + x -= video_num_columns; + pos -= video_size_row; + lf(); + } + __asm__("movb _attr,%%ah\n\t" + "movw %%ax,%1\n\t" + ::"a" (c),"m" (*(short *)pos) + ); + pos += 2; + x++; + } else if (c==27) + state=1; + else if (c==10 || c==11 || c==12) + lf(); + else if (c==13) + cr(); + else if (c==ERASE_CHAR(tty)) + del(); + else if (c==8) { + if (x) { + x--; + pos -= 2; + } + } else if (c==9) { + c=8-(x&7); + x += c; + pos += c<<1; + if (x>video_num_columns) { + x -= video_num_columns; + pos -= video_size_row; + lf(); + } + c=9; + } else if (c==7) + sysbeep(); + break; + case 1: + state=0; + if (c=='[') + state=2; + else if (c=='E') + gotoxy(0,y+1); + else if (c=='M') + ri(); + else if (c=='D') + lf(); + else if (c=='Z') + respond(tty); + else if (x=='7') + save_cur(); + else if (x=='8') + restore_cur(); + break; + case 2: + for(npar=0;npar='0' && c<='9') { + par[npar]=10*par[npar]+c-'0'; + break; + } else state=4; + case 4: + state=0; + switch(c) { + case 'G': case '`': + if (par[0]) par[0]--; + gotoxy(par[0],y); + break; + case 'A': + if (!par[0]) par[0]++; + gotoxy(x,y-par[0]); + break; + case 'B': case 'e': + if (!par[0]) par[0]++; + gotoxy(x,y+par[0]); + break; + case 'C': case 'a': + if (!par[0]) par[0]++; + gotoxy(x+par[0],y); + break; + case 'D': + if (!par[0]) par[0]++; + gotoxy(x-par[0],y); + break; + case 'E': + if (!par[0]) par[0]++; + gotoxy(0,y+par[0]); + break; + case 'F': + if (!par[0]) par[0]++; + gotoxy(0,y-par[0]); + break; + case 'd': + if (par[0]) par[0]--; + gotoxy(x,par[0]); + break; + case 'H': case 'f': + if (par[0]) par[0]--; + if (par[1]) par[1]--; + gotoxy(par[1],par[0]); + break; + case 'J': + csi_J(par[0]); + break; + case 'K': + csi_K(par[0]); + break; + case 'L': + csi_L(par[0]); + break; + case 'M': + csi_M(par[0]); + break; + case 'P': + csi_P(par[0]); + break; + case '@': + csi_at(par[0]); + break; + case 'm': + csi_m(); + break; + case 'r': + if (par[0]) par[0]--; + if (!par[1]) par[1] = video_num_lines; + if (par[0] < par[1] && + par[1] <= video_num_lines) { + top=par[0]; + bottom=par[1]; + } + break; + case 's': + save_cur(); + break; + case 'u': + restore_cur(); + break; + } + } + } + set_cursor(); +} + +/* + * void con_init(void); + * + * This routine initalizes console interrupts, and does nothing + * else. If you want the screen to clear, call tty_write with + * the appropriate escape-sequece. + * + * Reads the information preserved by setup.s to determine the current display + * type and sets everything accordingly. + */ +void con_init(void) +{ + register unsigned char a; + char *display_desc = "????"; + char *display_ptr; + + video_num_columns = ORIG_VIDEO_COLS; + video_size_row = video_num_columns * 2; + video_num_lines = ORIG_VIDEO_LINES; + video_page = ORIG_VIDEO_PAGE; + video_erase_char = 0x0720; + + if (ORIG_VIDEO_MODE == 7) /* Is this a monochrome display? */ + { + video_mem_start = 0xb0000; + video_port_reg = 0x3b4; + video_port_val = 0x3b5; + if ((ORIG_VIDEO_EGA_BX & 0xff) != 0x10) + { + video_type = VIDEO_TYPE_EGAM; + video_mem_end = 0xb8000; + display_desc = "EGAm"; + } + else + { + video_type = VIDEO_TYPE_MDA; + video_mem_end = 0xb2000; + display_desc = "*MDA"; + } + } + else /* If not, it is color. */ + { + video_mem_start = 0xb8000; + video_port_reg = 0x3d4; + video_port_val = 0x3d5; + if ((ORIG_VIDEO_EGA_BX & 0xff) != 0x10) + { + video_type = VIDEO_TYPE_EGAC; + video_mem_end = 0xbc000; + display_desc = "EGAc"; + } + else + { + video_type = VIDEO_TYPE_CGA; + video_mem_end = 0xba000; + display_desc = "*CGA"; + } + } + + /* Let the user known what kind of display driver we are using */ + + display_ptr = ((char *)video_mem_start) + video_size_row - 8; + while (*display_desc) + { + *display_ptr++ = *display_desc++; + display_ptr++; + } + + /* Initialize the variables used for scrolling (mostly EGA/VGA) */ + + origin = video_mem_start; + scr_end = video_mem_start + video_num_lines * video_size_row; + top = 0; + bottom = video_num_lines; + + gotoxy(ORIG_X,ORIG_Y); + set_trap_gate(0x21,&keyboard_interrupt); + outb_p(inb_p(0x21)&0xfd,0x21); + a=inb_p(0x61); + outb_p(a|0x80,0x61); + outb(a,0x61); +} +/* from bsd-net-2: */ + +void sysbeepstop(void) +{ + /* disable counter 2 */ + outb(inb_p(0x61)&0xFC, 0x61); +} + +int beepcount = 0; + +static void sysbeep(void) +{ + /* enable counter 2 */ + outb_p(inb_p(0x61)|3, 0x61); + /* set command for counter 2, 2 byte write */ + outb_p(0xB6, 0x43); + /* send 0x637 for 750 HZ */ + outb_p(0x37, 0x42); + outb(0x06, 0x42); + /* 1/8 second */ + beepcount = HZ/8; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/keyboard.S b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/keyboard.S new file mode 100644 index 0000000..91f327b --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/keyboard.S @@ -0,0 +1,433 @@ +/* + * linux/kernel/keyboard.S + * + * (C) 1991 Linus Torvalds + */ + +/* + * Thanks to Alfred Leung for US keyboard patches + * Wolfgang Thiel for German keyboard patches + * Marc Corsini for the French keyboard + */ + +#include + +.text +.globl _keyboard_interrupt + +/* + * these are for the keyboard read functions + */ +size = 1024 /* must be a power of two ! And MUST be the same + as in tty_io.c !!!! */ +head = 4 +tail = 8 +proc_list = 12 +buf = 16 + +mode: .byte 0 /* caps, alt, ctrl and shift mode */ +leds: .byte 2 /* num-lock, caps, scroll-lock mode (nom-lock on) */ +e0: .byte 0 + +/* + * con_int is the real interrupt routine that reads the + * keyboard scan-code and converts it into the appropriate + * ascii character(s). + */ +_keyboard_interrupt: + pushl %eax + pushl %ebx + pushl %ecx + pushl %edx + push %ds + push %es + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + xor %al,%al /* %eax is scan code */ + inb $0x60,%al + cmpb $0xe0,%al + je set_e0 + cmpb $0xe1,%al + je set_e1 + call key_table(,%eax,4) + movb $0,e0 +e0_e1: inb $0x61,%al + jmp 1f +1: jmp 1f +1: orb $0x80,%al + jmp 1f +1: jmp 1f +1: outb %al,$0x61 + jmp 1f +1: jmp 1f +1: andb $0x7F,%al + outb %al,$0x61 + movb $0x20,%al + outb %al,$0x20 + pushl $0 + call _do_tty_interrupt + addl $4,%esp + pop %es + pop %ds + popl %edx + popl %ecx + popl %ebx + popl %eax + iret +set_e0: movb $1,e0 + jmp e0_e1 +set_e1: movb $2,e0 + jmp e0_e1 + +/* + * This routine fills the buffer with max 8 bytes, taken from + * %ebx:%eax. (%edx is high). The bytes are written in the + * order %al,%ah,%eal,%eah,%bl,%bh ... until %eax is zero. + */ +put_queue: + pushl %ecx + pushl %edx + movl _table_list,%edx # read-queue for console + movl head(%edx),%ecx +1: movb %al,buf(%edx,%ecx) + incl %ecx + andl $size-1,%ecx + cmpl tail(%edx),%ecx # buffer full - discard everything + je 3f + shrdl $8,%ebx,%eax + je 2f + shrl $8,%ebx + jmp 1b +2: movl %ecx,head(%edx) + movl proc_list(%edx),%ecx + testl %ecx,%ecx + je 3f + movl $0,(%ecx) +3: popl %edx + popl %ecx + ret + +ctrl: movb $0x04,%al + jmp 1f +alt: movb $0x10,%al +1: cmpb $0,e0 + je 2f + addb %al,%al +2: orb %al,mode + ret +unctrl: movb $0x04,%al + jmp 1f +unalt: movb $0x10,%al +1: cmpb $0,e0 + je 2f + addb %al,%al +2: notb %al + andb %al,mode + ret + +lshift: + orb $0x01,mode + ret +unlshift: + andb $0xfe,mode + ret +rshift: + orb $0x02,mode + ret +unrshift: + andb $0xfd,mode + ret + +caps: testb $0x80,mode + jne 1f + xorb $4,leds + xorb $0x40,mode + orb $0x80,mode +set_leds: + call kb_wait + movb $0xed,%al /* set leds command */ + outb %al,$0x60 + call kb_wait + movb leds,%al + outb %al,$0x60 + ret +uncaps: andb $0x7f,mode + ret +scroll: + xorb $1,leds + jmp set_leds +num: xorb $2,leds + jmp set_leds + +/* + * curosr-key/numeric keypad cursor keys are handled here. + * checking for numeric keypad etc. + */ +cursor: + subb $0x47,%al + jb 1f + cmpb $12,%al + ja 1f + jne cur2 /* check for ctrl-alt-del */ + testb $0x0c,mode + je cur2 + testb $0x30,mode + jne reboot +cur2: cmpb $0x01,e0 /* e0 forces cursor movement */ + je cur + testb $0x02,leds /* not num-lock forces cursor */ + je cur + testb $0x03,mode /* shift forces cursor */ + jne cur + xorl %ebx,%ebx + movb num_table(%eax),%al + jmp put_queue +1: ret + +cur: movb cur_table(%eax),%al + cmpb $'9,%al + ja ok_cur + movb $'~,%ah +ok_cur: shll $16,%eax + movw $0x5b1b,%ax + xorl %ebx,%ebx + jmp put_queue + + +num_table: + .ascii "789 456 1230," +cur_table: + .ascii "HA5 DGC YB623" + +/* + * this routine handles function keys + */ +func: + pushl %eax + pushl %ecx + pushl %edx + call _show_stat + popl %edx + popl %ecx + popl %eax + subb $0x3B,%al + jb end_func + cmpb $9,%al + jbe ok_func + subb $18,%al + cmpb $10,%al + jb end_func + cmpb $11,%al + ja end_func +ok_func: + cmpl $4,%ecx /* check that there is enough room */ + jl end_func + movl func_table(,%eax,4),%eax + xorl %ebx,%ebx + jmp put_queue +end_func: + ret + +/* + * function keys send F1:'esc [ [ A' F2:'esc [ [ B' etc. + */ +func_table: + .long 0x415b5b1b,0x425b5b1b,0x435b5b1b,0x445b5b1b + .long 0x455b5b1b,0x465b5b1b,0x475b5b1b,0x485b5b1b + .long 0x495b5b1b,0x4a5b5b1b,0x4b5b5b1b,0x4c5b5b1b + + +#if defined(KBD_US) + +key_map: + .byte 0,27 + .ascii "1234567890-=" + .byte 127,9 + .ascii "qwertyuiop[]" + .byte 13,0 + .ascii "asdfghjkl;'" + .byte '`,0 + .ascii "\\zxcvbnm,./" + .byte 0,'*,0,32 /* 36-39 */ + .fill 16,1,0 /* 3A-49 */ + .byte '-,0,0,0,'+ /* 4A-4E */ + .byte 0,0,0,0,0,0,0 /* 4F-55 */ + .byte '< + .fill 10,1,0 + + +shift_map: + .byte 0,27 + .ascii "!@#$%^&*()_+" + .byte 127,9 + .ascii "QWERTYUIOP{}" + .byte 13,0 + .ascii "ASDFGHJKL:\"" + .byte '~,0 + .ascii "|ZXCVBNM<>?" + .byte 0,'*,0,32 /* 36-39 */ + .fill 16,1,0 /* 3A-49 */ + .byte '-,0,0,0,'+ /* 4A-4E */ + .byte 0,0,0,0,0,0,0 /* 4F-55 */ + .byte '> + .fill 10,1,0 + +alt_map: + .byte 0,0 + .ascii "\0@\0$\0\0{[]}\\\0" + .byte 0,0 + .byte 0,0,0,0,0,0,0,0,0,0,0 + .byte '~,13,0 + .byte 0,0,0,0,0,0,0,0,0,0,0 + .byte 0,0 + .byte 0,0,0,0,0,0,0,0,0,0,0 + .byte 0,0,0,0 /* 36-39 */ + .fill 16,1,0 /* 3A-49 */ + .byte 0,0,0,0,0 /* 4A-4E */ + .byte 0,0,0,0,0,0,0 /* 4F-55 */ + .byte '| + .fill 10,1,0 +#else +#error "KBD-type not defined" +#endif +/* + * do_self handles "normal" keys, ie keys that don't change meaning + * and which have just one character returns. + */ +do_self: + lea alt_map,%ebx + testb $0x20,mode /* alt-gr */ + jne 1f + lea shift_map,%ebx + testb $0x03,mode + jne 1f + lea key_map,%ebx +1: movb (%ebx,%eax),%al + orb %al,%al + je none + testb $0x4c,mode /* ctrl or caps */ + je 2f + cmpb $'a,%al + jb 2f + cmpb $'},%al + ja 2f + subb $32,%al +2: testb $0x0c,mode /* ctrl */ + je 3f + cmpb $64,%al + jb 3f + cmpb $64+32,%al + jae 3f + subb $64,%al +3: testb $0x10,mode /* left alt */ + je 4f + orb $0x80,%al +4: andl $0xff,%eax + xorl %ebx,%ebx + call put_queue +none: ret + +/* + * minus has a routine of it's own, as a 'E0h' before + * the scan code for minus means that the numeric keypad + * slash was pushed. + */ +minus: cmpb $1,e0 + jne do_self + movl $'/,%eax + xorl %ebx,%ebx + jmp put_queue + +/* + * This table decides which routine to call when a scan-code has been + * gotten. Most routines just call do_self, or none, depending if + * they are make or break. + */ +key_table: + .long none,do_self,do_self,do_self /* 00-03 s0 esc 1 2 */ + .long do_self,do_self,do_self,do_self /* 04-07 3 4 5 6 */ + .long do_self,do_self,do_self,do_self /* 08-0B 7 8 9 0 */ + .long do_self,do_self,do_self,do_self /* 0C-0F + ' bs tab */ + .long do_self,do_self,do_self,do_self /* 10-13 q w e r */ + .long do_self,do_self,do_self,do_self /* 14-17 t y u i */ + .long do_self,do_self,do_self,do_self /* 18-1B o p } ^ */ + .long do_self,ctrl,do_self,do_self /* 1C-1F enter ctrl a s */ + .long do_self,do_self,do_self,do_self /* 20-23 d f g h */ + .long do_self,do_self,do_self,do_self /* 24-27 j k l | */ + .long do_self,do_self,lshift,do_self /* 28-2B { para lshift , */ + .long do_self,do_self,do_self,do_self /* 2C-2F z x c v */ + .long do_self,do_self,do_self,do_self /* 30-33 b n m , */ + .long do_self,minus,rshift,do_self /* 34-37 . - rshift * */ + .long alt,do_self,caps,func /* 38-3B alt sp caps f1 */ + .long func,func,func,func /* 3C-3F f2 f3 f4 f5 */ + .long func,func,func,func /* 40-43 f6 f7 f8 f9 */ + .long func,num,scroll,cursor /* 44-47 f10 num scr home */ + .long cursor,cursor,do_self,cursor /* 48-4B up pgup - left */ + .long cursor,cursor,do_self,cursor /* 4C-4F n5 right + end */ + .long cursor,cursor,cursor,cursor /* 50-53 dn pgdn ins del */ + .long none,none,do_self,func /* 54-57 sysreq ? < f11 */ + .long func,none,none,none /* 58-5B f12 ? ? ? */ + .long none,none,none,none /* 5C-5F ? ? ? ? */ + .long none,none,none,none /* 60-63 ? ? ? ? */ + .long none,none,none,none /* 64-67 ? ? ? ? */ + .long none,none,none,none /* 68-6B ? ? ? ? */ + .long none,none,none,none /* 6C-6F ? ? ? ? */ + .long none,none,none,none /* 70-73 ? ? ? ? */ + .long none,none,none,none /* 74-77 ? ? ? ? */ + .long none,none,none,none /* 78-7B ? ? ? ? */ + .long none,none,none,none /* 7C-7F ? ? ? ? */ + .long none,none,none,none /* 80-83 ? br br br */ + .long none,none,none,none /* 84-87 br br br br */ + .long none,none,none,none /* 88-8B br br br br */ + .long none,none,none,none /* 8C-8F br br br br */ + .long none,none,none,none /* 90-93 br br br br */ + .long none,none,none,none /* 94-97 br br br br */ + .long none,none,none,none /* 98-9B br br br br */ + .long none,unctrl,none,none /* 9C-9F br unctrl br br */ + .long none,none,none,none /* A0-A3 br br br br */ + .long none,none,none,none /* A4-A7 br br br br */ + .long none,none,unlshift,none /* A8-AB br br unlshift br */ + .long none,none,none,none /* AC-AF br br br br */ + .long none,none,none,none /* B0-B3 br br br br */ + .long none,none,unrshift,none /* B4-B7 br br unrshift br */ + .long unalt,none,uncaps,none /* B8-BB unalt br uncaps br */ + .long none,none,none,none /* BC-BF br br br br */ + .long none,none,none,none /* C0-C3 br br br br */ + .long none,none,none,none /* C4-C7 br br br br */ + .long none,none,none,none /* C8-CB br br br br */ + .long none,none,none,none /* CC-CF br br br br */ + .long none,none,none,none /* D0-D3 br br br br */ + .long none,none,none,none /* D4-D7 br br br br */ + .long none,none,none,none /* D8-DB br ? ? ? */ + .long none,none,none,none /* DC-DF ? ? ? ? */ + .long none,none,none,none /* E0-E3 e0 e1 ? ? */ + .long none,none,none,none /* E4-E7 ? ? ? ? */ + .long none,none,none,none /* E8-EB ? ? ? ? */ + .long none,none,none,none /* EC-EF ? ? ? ? */ + .long none,none,none,none /* F0-F3 ? ? ? ? */ + .long none,none,none,none /* F4-F7 ? ? ? ? */ + .long none,none,none,none /* F8-FB ? ? ? ? */ + .long none,none,none,none /* FC-FF ? ? ? ? */ + +/* + * kb_wait waits for the keyboard controller buffer to empty. + * there is no timeout - if the buffer doesn't empty, we hang. + */ +kb_wait: + pushl %eax +1: inb $0x64,%al + testb $0x02,%al + jne 1b + popl %eax + ret +/* + * This routine reboots the machine by asking the keyboard + * controller to pulse the reset-line low. + */ +reboot: + call kb_wait + movw $0x1234,0x472 /* don't do memory check */ + movb $0xfc,%al /* pulse reset and A20 low */ + outb %al,$0x64 +die: jmp die diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/rs_io.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/rs_io.s new file mode 100644 index 0000000..b300643 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/rs_io.s @@ -0,0 +1,147 @@ +/* + * linux/kernel/rs_io.s + * + * (C) 1991 Linus Torvalds + */ + +/* + * rs_io.s + * + * This module implements the rs232 io interrupts. + */ + +.text +.globl _rs1_interrupt,_rs2_interrupt + +size = 1024 /* must be power of two ! + and must match the value + in tty_io.c!!! */ + +/* these are the offsets into the read/write buffer structures */ +rs_addr = 0 +head = 4 +tail = 8 +proc_list = 12 +buf = 16 + +startup = 256 /* chars left in write queue when we restart it */ + +/* + * These are the actual interrupt routines. They look where + * the interrupt is coming from, and take appropriate action. + */ +.align 2 +_rs1_interrupt: + pushl $_table_list+8 + jmp rs_int +.align 2 +_rs2_interrupt: + pushl $_table_list+16 +rs_int: + pushl %edx + pushl %ecx + pushl %ebx + pushl %eax + push %es + push %ds /* as this is an interrupt, we cannot */ + pushl $0x10 /* know that bs is ok. Load it */ + pop %ds + pushl $0x10 + pop %es + movl 24(%esp),%edx + movl (%edx),%edx + movl rs_addr(%edx),%edx + addl $2,%edx /* interrupt ident. reg */ +rep_int: + xorl %eax,%eax + inb %dx,%al + testb $1,%al + jne end + cmpb $6,%al /* this shouldn't happen, but ... */ + ja end + movl 24(%esp),%ecx + pushl %edx + subl $2,%edx + call jmp_table(,%eax,2) /* NOTE! not *4, bit0 is 0 already */ + popl %edx + jmp rep_int +end: movb $0x20,%al + outb %al,$0x20 /* EOI */ + pop %ds + pop %es + popl %eax + popl %ebx + popl %ecx + popl %edx + addl $4,%esp # jump over _table_list entry + iret + +jmp_table: + .long modem_status,write_char,read_char,line_status + +.align 2 +modem_status: + addl $6,%edx /* clear intr by reading modem status reg */ + inb %dx,%al + ret + +.align 2 +line_status: + addl $5,%edx /* clear intr by reading line status reg. */ + inb %dx,%al + ret + +.align 2 +read_char: + inb %dx,%al + movl %ecx,%edx + subl $_table_list,%edx + shrl $3,%edx + movl (%ecx),%ecx # read-queue + movl head(%ecx),%ebx + movb %al,buf(%ecx,%ebx) + incl %ebx + andl $size-1,%ebx + cmpl tail(%ecx),%ebx + je 1f + movl %ebx,head(%ecx) +1: pushl %edx + call _do_tty_interrupt + addl $4,%esp + ret + +.align 2 +write_char: + movl 4(%ecx),%ecx # write-queue + movl head(%ecx),%ebx + subl tail(%ecx),%ebx + andl $size-1,%ebx # nr chars in queue + je write_buffer_empty + cmpl $startup,%ebx + ja 1f + movl proc_list(%ecx),%ebx # wake up sleeping process + testl %ebx,%ebx # is there any? + je 1f + movl $0,(%ebx) +1: movl tail(%ecx),%ebx + movb buf(%ecx,%ebx),%al + outb %al,%dx + incl %ebx + andl $size-1,%ebx + movl %ebx,tail(%ecx) + cmpl head(%ecx),%ebx + je write_buffer_empty + ret +.align 2 +write_buffer_empty: + movl proc_list(%ecx),%ebx # wake up sleeping process + testl %ebx,%ebx # is there any? + je 1f + movl $0,(%ebx) +1: incl %edx + inb %dx,%al + jmp 1f +1: jmp 1f +1: andb $0xd,%al /* disable transmit interrupt */ + outb %al,%dx + ret diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/serial.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/serial.c new file mode 100644 index 0000000..aba25df --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/serial.c @@ -0,0 +1,59 @@ +/* + * linux/kernel/serial.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * serial.c + * + * This module implements the rs232 io functions + * void rs_write(struct tty_struct * queue); + * void rs_init(void); + * and all interrupts pertaining to serial IO. + */ + +#include +#include +#include +#include + +#define WAKEUP_CHARS (TTY_BUF_SIZE/4) + +extern void rs1_interrupt(void); +extern void rs2_interrupt(void); + +static void init(int port) +{ + outb_p(0x80,port+3); /* set DLAB of line control reg */ + outb_p(0x30,port); /* LS of divisor (48 -> 2400 bps */ + outb_p(0x00,port+1); /* MS of divisor */ + outb_p(0x03,port+3); /* reset DLAB */ + outb_p(0x0b,port+4); /* set DTR,RTS, OUT_2 */ + outb_p(0x0d,port+1); /* enable all intrs but writes */ + (void)inb(port); /* read data port to reset things (?) */ +} + +void rs_init(void) +{ + set_intr_gate(0x24,rs1_interrupt); + set_intr_gate(0x23,rs2_interrupt); + init(tty_table[1].read_q.data); + init(tty_table[2].read_q.data); + outb(inb_p(0x21)&0xE7,0x21); +} + +/* + * This routine gets called when tty_write has put something into + * the write_queue. It must check wheter the queue is empty, and + * set the interrupt register accordingly + * + * void _rs_write(struct tty_struct * tty); + */ +void rs_write(struct tty_struct * tty) +{ + cli(); + if (!EMPTY(tty->write_q)) + outb(inb_p(tty->write_q.data+1)|0x02,tty->write_q.data+1); + sti(); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/tty_io.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/tty_io.c new file mode 100644 index 0000000..ed14fa8 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/tty_io.c @@ -0,0 +1,350 @@ +/* + * linux/kernel/tty_io.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 'tty_io.c' gives an orthogonal feeling to tty's, be they consoles + * or rs-channels. It also implements echoing, cooked mode etc. + * + * Kill-line thanks to John T Kohl. + */ +#include +#include +#include + +#define ALRMMASK (1<<(SIGALRM-1)) +#define KILLMASK (1<<(SIGKILL-1)) +#define INTMASK (1<<(SIGINT-1)) +#define QUITMASK (1<<(SIGQUIT-1)) +#define TSTPMASK (1<<(SIGTSTP-1)) + +#include +#include +#include +#include + +#define _L_FLAG(tty,f) ((tty)->termios.c_lflag & f) +#define _I_FLAG(tty,f) ((tty)->termios.c_iflag & f) +#define _O_FLAG(tty,f) ((tty)->termios.c_oflag & f) + +#define L_CANON(tty) _L_FLAG((tty),ICANON) +#define L_ISIG(tty) _L_FLAG((tty),ISIG) +#define L_ECHO(tty) _L_FLAG((tty),ECHO) +#define L_ECHOE(tty) _L_FLAG((tty),ECHOE) +#define L_ECHOK(tty) _L_FLAG((tty),ECHOK) +#define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL) +#define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE) + +#define I_UCLC(tty) _I_FLAG((tty),IUCLC) +#define I_NLCR(tty) _I_FLAG((tty),INLCR) +#define I_CRNL(tty) _I_FLAG((tty),ICRNL) +#define I_NOCR(tty) _I_FLAG((tty),IGNCR) + +#define O_POST(tty) _O_FLAG((tty),OPOST) +#define O_NLCR(tty) _O_FLAG((tty),ONLCR) +#define O_CRNL(tty) _O_FLAG((tty),OCRNL) +#define O_NLRET(tty) _O_FLAG((tty),ONLRET) +#define O_LCUC(tty) _O_FLAG((tty),OLCUC) + +struct tty_struct tty_table[] = { + { + {ICRNL, /* change incoming CR to NL */ + OPOST|ONLCR, /* change outgoing NL to CRNL */ + 0, + ISIG | ICANON | ECHO | ECHOCTL | ECHOKE, + 0, /* console termio */ + INIT_C_CC}, + 0, /* initial pgrp */ + 0, /* initial stopped */ + con_write, + {0,0,0,0,""}, /* console read-queue */ + {0,0,0,0,""}, /* console write-queue */ + {0,0,0,0,""} /* console secondary queue */ + },{ + {0, /* no translation */ + 0, /* no translation */ + B2400 | CS8, + 0, + 0, + INIT_C_CC}, + 0, + 0, + rs_write, + {0x3f8,0,0,0,""}, /* rs 1 */ + {0x3f8,0,0,0,""}, + {0,0,0,0,""} + },{ + {0, /* no translation */ + 0, /* no translation */ + B2400 | CS8, + 0, + 0, + INIT_C_CC}, + 0, + 0, + rs_write, + {0x2f8,0,0,0,""}, /* rs 2 */ + {0x2f8,0,0,0,""}, + {0,0,0,0,""} + } +}; + +/* + * these are the tables used by the machine code handlers. + * you can implement pseudo-tty's or something by changing + * them. Currently not done. + */ +struct tty_queue * table_list[]={ + &tty_table[0].read_q, &tty_table[0].write_q, + &tty_table[1].read_q, &tty_table[1].write_q, + &tty_table[2].read_q, &tty_table[2].write_q + }; + +void tty_init(void) +{ + rs_init(); + con_init(); +} + +void tty_intr(struct tty_struct * tty, int mask) +{ + int i; + + if (tty->pgrp <= 0) + return; + for (i=0;ipgrp==tty->pgrp) + task[i]->signal |= mask; +} + +static void sleep_if_empty(struct tty_queue * queue) +{ + cli(); + while (!current->signal && EMPTY(*queue)) + interruptible_sleep_on(&queue->proc_list); + sti(); +} + +static void sleep_if_full(struct tty_queue * queue) +{ + if (!FULL(*queue)) + return; + cli(); + while (!current->signal && LEFT(*queue)<128) + interruptible_sleep_on(&queue->proc_list); + sti(); +} + +void wait_for_keypress(void) +{ + sleep_if_empty(&tty_table[0].secondary); +} + +void copy_to_cooked(struct tty_struct * tty) +{ + signed char c; + + while (!EMPTY(tty->read_q) && !FULL(tty->secondary)) { + GETCH(tty->read_q,c); + if (c==13) + if (I_CRNL(tty)) + c=10; + else if (I_NOCR(tty)) + continue; + else ; + else if (c==10 && I_NLCR(tty)) + c=13; + if (I_UCLC(tty)) + c=tolower(c); + if (L_CANON(tty)) { + if (c==KILL_CHAR(tty)) { + /* deal with killing the input line */ + while(!(EMPTY(tty->secondary) || + (c=LAST(tty->secondary))==10 || + c==EOF_CHAR(tty))) { + if (L_ECHO(tty)) { + if (c<32) + PUTCH(127,tty->write_q); + PUTCH(127,tty->write_q); + tty->write(tty); + } + DEC(tty->secondary.head); + } + continue; + } + if (c==ERASE_CHAR(tty)) { + if (EMPTY(tty->secondary) || + (c=LAST(tty->secondary))==10 || + c==EOF_CHAR(tty)) + continue; + if (L_ECHO(tty)) { + if (c<32) + PUTCH(127,tty->write_q); + PUTCH(127,tty->write_q); + tty->write(tty); + } + DEC(tty->secondary.head); + continue; + } + if (c==STOP_CHAR(tty)) { + tty->stopped=1; + continue; + } + if (c==START_CHAR(tty)) { + tty->stopped=0; + continue; + } + } + if (L_ISIG(tty)) { + if (c==INTR_CHAR(tty)) { + tty_intr(tty,INTMASK); + continue; + } + if (c==QUIT_CHAR(tty)) { + tty_intr(tty,QUITMASK); + continue; + } + } + if (c==10 || c==EOF_CHAR(tty)) + tty->secondary.data++; + if (L_ECHO(tty)) { + if (c==10) { + PUTCH(10,tty->write_q); + PUTCH(13,tty->write_q); + } else if (c<32) { + if (L_ECHOCTL(tty)) { + PUTCH('^',tty->write_q); + PUTCH(c+64,tty->write_q); + } + } else + PUTCH(c,tty->write_q); + tty->write(tty); + } + PUTCH(c,tty->secondary); + } + wake_up(&tty->secondary.proc_list); +} + +int tty_read(unsigned channel, char * buf, int nr) +{ + struct tty_struct * tty; + char c, * b=buf; + int minimum,time,flag=0; + long oldalarm; + + if (channel>2 || nr<0) return -1; + tty = &tty_table[channel]; + oldalarm = current->alarm; + time = 10L*tty->termios.c_cc[VTIME]; + minimum = tty->termios.c_cc[VMIN]; + if (time && !minimum) { + minimum=1; + if ((flag=(!oldalarm || time+jiffiesalarm = time+jiffies; + } + if (minimum>nr) + minimum=nr; + while (nr>0) { + if (flag && (current->signal & ALRMMASK)) { + current->signal &= ~ALRMMASK; + break; + } + if (current->signal) + break; + if (EMPTY(tty->secondary) || (L_CANON(tty) && + !tty->secondary.data && LEFT(tty->secondary)>20)) { + sleep_if_empty(&tty->secondary); + continue; + } + do { + GETCH(tty->secondary,c); + if (c==EOF_CHAR(tty) || c==10) + tty->secondary.data--; + if (c==EOF_CHAR(tty) && L_CANON(tty)) + return (b-buf); + else { + put_fs_byte(c,b++); + if (!--nr) + break; + } + } while (nr>0 && !EMPTY(tty->secondary)); + if (time && !L_CANON(tty)) { + if ((flag=(!oldalarm || time+jiffiesalarm = time+jiffies; + else + current->alarm = oldalarm; + } + if (L_CANON(tty)) { + if (b-buf) + break; + } else if (b-buf >= minimum) + break; + } + current->alarm = oldalarm; + if (current->signal && !(b-buf)) + return -EINTR; + return (b-buf); +} + +int tty_write(unsigned channel, char * buf, int nr) +{ + static int cr_flag=0; + struct tty_struct * tty; + char c, *b=buf; + + if (channel>2 || nr<0) return -1; + tty = channel + tty_table; + while (nr>0) { + sleep_if_full(&tty->write_q); + if (current->signal) + break; + while (nr>0 && !FULL(tty->write_q)) { + c=get_fs_byte(b); + if (O_POST(tty)) { + if (c=='\r' && O_CRNL(tty)) + c='\n'; + else if (c=='\n' && O_NLRET(tty)) + c='\r'; + if (c=='\n' && !cr_flag && O_NLCR(tty)) { + cr_flag = 1; + PUTCH(13,tty->write_q); + continue; + } + if (O_LCUC(tty)) + c=toupper(c); + } + b++; nr--; + cr_flag = 0; + PUTCH(c,tty->write_q); + } + tty->write(tty); + if (nr>0) + schedule(); + } + return (b-buf); +} + +/* + * Jeh, sometimes I really like the 386. + * This routine is called from an interrupt, + * and there should be absolutely no problem + * with sleeping even in an interrupt (I hope). + * Of course, if somebody proves me wrong, I'll + * hate intel for all time :-). We'll have to + * be careful and see to reinstating the interrupt + * chips before calling this, though. + * + * I don't think we sleep here under normal circumstances + * anyway, which is good, as the task sleeping might be + * totally innocent. + */ +void do_tty_interrupt(int tty) +{ + copy_to_cooked(tty_table+tty); +} + +void chr_dev_init(void) +{ +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/tty_ioctl.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/tty_ioctl.c new file mode 100644 index 0000000..e4e3745 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/tty_ioctl.c @@ -0,0 +1,204 @@ +/* + * linux/kernel/chr_drv/tty_ioctl.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include + +#include +#include +#include + +#include +#include +#include + +static unsigned short quotient[] = { + 0, 2304, 1536, 1047, 857, + 768, 576, 384, 192, 96, + 64, 48, 24, 12, 6, 3 +}; + +static void change_speed(struct tty_struct * tty) +{ + unsigned short port,quot; + + if (!(port = tty->read_q.data)) + return; + quot = quotient[tty->termios.c_cflag & CBAUD]; + cli(); + outb_p(0x80,port+3); /* set DLAB */ + outb_p(quot & 0xff,port); /* LS of divisor */ + outb_p(quot >> 8,port+1); /* MS of divisor */ + outb(0x03,port+3); /* reset DLAB */ + sti(); +} + +static void flush(struct tty_queue * queue) +{ + cli(); + queue->head = queue->tail; + sti(); +} + +static void wait_until_sent(struct tty_struct * tty) +{ + /* do nothing - not implemented */ +} + +static void send_break(struct tty_struct * tty) +{ + /* do nothing - not implemented */ +} + +static int get_termios(struct tty_struct * tty, struct termios * termios) +{ + int i; + + verify_area(termios, sizeof (*termios)); + for (i=0 ; i< (sizeof (*termios)) ; i++) + put_fs_byte( ((char *)&tty->termios)[i] , i+(char *)termios ); + return 0; +} + +static int set_termios(struct tty_struct * tty, struct termios * termios) +{ + int i; + + for (i=0 ; i< (sizeof (*termios)) ; i++) + ((char *)&tty->termios)[i]=get_fs_byte(i+(char *)termios); + change_speed(tty); + return 0; +} + +static int get_termio(struct tty_struct * tty, struct termio * termio) +{ + int i; + struct termio tmp_termio; + + verify_area(termio, sizeof (*termio)); + tmp_termio.c_iflag = tty->termios.c_iflag; + tmp_termio.c_oflag = tty->termios.c_oflag; + tmp_termio.c_cflag = tty->termios.c_cflag; + tmp_termio.c_lflag = tty->termios.c_lflag; + tmp_termio.c_line = tty->termios.c_line; + for(i=0 ; i < NCC ; i++) + tmp_termio.c_cc[i] = tty->termios.c_cc[i]; + for (i=0 ; i< (sizeof (*termio)) ; i++) + put_fs_byte( ((char *)&tmp_termio)[i] , i+(char *)termio ); + return 0; +} + +/* + * This only works as the 386 is low-byt-first + */ +static int set_termio(struct tty_struct * tty, struct termio * termio) +{ + int i; + struct termio tmp_termio; + + for (i=0 ; i< (sizeof (*termio)) ; i++) + ((char *)&tmp_termio)[i]=get_fs_byte(i+(char *)termio); + *(unsigned short *)&tty->termios.c_iflag = tmp_termio.c_iflag; + *(unsigned short *)&tty->termios.c_oflag = tmp_termio.c_oflag; + *(unsigned short *)&tty->termios.c_cflag = tmp_termio.c_cflag; + *(unsigned short *)&tty->termios.c_lflag = tmp_termio.c_lflag; + tty->termios.c_line = tmp_termio.c_line; + for(i=0 ; i < NCC ; i++) + tty->termios.c_cc[i] = tmp_termio.c_cc[i]; + change_speed(tty); + return 0; +} + +int tty_ioctl(int dev, int cmd, int arg) +{ + struct tty_struct * tty; + if (MAJOR(dev) == 5) { + dev=current->tty; + if (dev<0) + panic("tty_ioctl: dev<0"); + } else + dev=MINOR(dev); + tty = dev + tty_table; + switch (cmd) { + case TCGETS: + return get_termios(tty,(struct termios *) arg); + case TCSETSF: + flush(&tty->read_q); /* fallthrough */ + case TCSETSW: + wait_until_sent(tty); /* fallthrough */ + case TCSETS: + return set_termios(tty,(struct termios *) arg); + case TCGETA: + return get_termio(tty,(struct termio *) arg); + case TCSETAF: + flush(&tty->read_q); /* fallthrough */ + case TCSETAW: + wait_until_sent(tty); /* fallthrough */ + case TCSETA: + return set_termio(tty,(struct termio *) arg); + case TCSBRK: + if (!arg) { + wait_until_sent(tty); + send_break(tty); + } + return 0; + case TCXONC: + return -EINVAL; /* not implemented */ + case TCFLSH: + if (arg==0) + flush(&tty->read_q); + else if (arg==1) + flush(&tty->write_q); + else if (arg==2) { + flush(&tty->read_q); + flush(&tty->write_q); + } else + return -EINVAL; + return 0; + case TIOCEXCL: + return -EINVAL; /* not implemented */ + case TIOCNXCL: + return -EINVAL; /* not implemented */ + case TIOCSCTTY: + return -EINVAL; /* set controlling term NI */ + case TIOCGPGRP: + verify_area((void *) arg,4); + put_fs_long(tty->pgrp,(unsigned long *) arg); + return 0; + case TIOCSPGRP: + tty->pgrp=get_fs_long((unsigned long *) arg); + return 0; + case TIOCOUTQ: + verify_area((void *) arg,4); + put_fs_long(CHARS(tty->write_q),(unsigned long *) arg); + return 0; + case TIOCINQ: + verify_area((void *) arg,4); + put_fs_long(CHARS(tty->secondary), + (unsigned long *) arg); + return 0; + case TIOCSTI: + return -EINVAL; /* not implemented */ + case TIOCGWINSZ: + return -EINVAL; /* not implemented */ + case TIOCSWINSZ: + return -EINVAL; /* not implemented */ + case TIOCMGET: + return -EINVAL; /* not implemented */ + case TIOCMBIS: + return -EINVAL; /* not implemented */ + case TIOCMBIC: + return -EINVAL; /* not implemented */ + case TIOCMSET: + return -EINVAL; /* not implemented */ + case TIOCGSOFTCAR: + return -EINVAL; /* not implemented */ + case TIOCSSOFTCAR: + return -EINVAL; /* not implemented */ + default: + return -EINVAL; + } +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/tty_ioctl.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/tty_ioctl.s new file mode 100644 index 0000000..821f31b --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/chr_drv/tty_ioctl.s @@ -0,0 +1,446 @@ + .file "tty_ioctl.c" + .data + .align 32 +_quotient: + .word 0 + .word 2304 + .word 1536 + .word 1047 + .word 857 + .word 768 + .word 576 + .word 384 + .word 192 + .word 96 + .word 64 + .word 48 + .word 24 + .word 12 + .word 6 + .word 3 + .text + .p2align 2,,3 + .def _change_speed; .scl 3; .type 32; .endef +_change_speed: + pushl %edi + pushl %esi + pushl %ebx + movl 16(%esp), %eax + movw 48(%eax), %si + testw %si, %si + je L1 + movl 8(%eax), %eax + andl $15, %eax + movw _quotient(%eax,%eax), %cx +/APP + cli +/NO_APP + movzwl %si, %edi + leal 3(%edi), %ebx + movl $128, %eax + movl %ebx, %edx +/APP + outb %al,%dx + jmp 1f +1: jmp 1f +1: +/NO_APP + movzbl %cl, %eax + movl %esi, %edx +/APP + outb %al,%dx + jmp 1f +1: jmp 1f +1: +/NO_APP + movzbl %ch, %ecx + leal 1(%edi), %edx + movl %ecx, %eax +/APP + outb %al,%dx + jmp 1f +1: jmp 1f +1: +/NO_APP + movl %ebx, %edx + movl $3, %eax +/APP + outb %al,%dx + sti +/NO_APP +L1: + popl %ebx + popl %esi + popl %edi + ret + .p2align 2,,3 + .def _flush; .scl 3; .type 32; .endef +_flush: + movl 4(%esp), %edx +/APP + cli +/NO_APP + movl 8(%edx), %eax + movl %eax, 4(%edx) +/APP + sti +/NO_APP + ret + .p2align 2,,3 + .def _wait_until_sent; .scl 3; .type 32; .endef +_wait_until_sent: + ret + .p2align 2,,3 + .def _send_break; .scl 3; .type 32; .endef +_send_break: + ret + .p2align 2,,3 + .def _get_termios; .scl 3; .type 32; .endef +_get_termios: + pushl %esi + pushl %ebx + subl $12, %esp + movl 24(%esp), %esi + movl 28(%esp), %ebx + pushl $36 + pushl %ebx + call _verify_area + xorl %edx, %edx + addl $16, %esp + .p2align 2,,3 +L12: + movb (%edx,%esi), %al +/APP + movb %al,%fs:(%edx,%ebx) +/NO_APP + incl %edx + cmpl $35, %edx + jbe L12 + popl %edx + popl %ebx + xorl %eax, %eax + popl %esi + ret + .p2align 2,,3 + .def _set_termios; .scl 3; .type 32; .endef +_set_termios: + pushl %ebx + subl $8, %esp + movl 16(%esp), %ebx + movl 20(%esp), %ecx + xorl %edx, %edx + .p2align 2,,3 +L21: +/APP + movb %fs:(%edx,%ecx),%al +/NO_APP + movb %al, (%edx,%ebx) + incl %edx + cmpl $35, %edx + jbe L21 + subl $12, %esp + pushl %ebx + call _change_speed + addl $24, %esp + xorl %eax, %eax + popl %ebx + ret + .p2align 2,,3 + .def _get_termio; .scl 3; .type 32; .endef +_get_termio: + pushl %esi + pushl %ebx + subl $44, %esp + movl 56(%esp), %esi + movl 60(%esp), %ebx + pushl $18 + pushl %ebx + call _verify_area + movw (%esi), %ax + movw %ax, 16(%esp) + movw 4(%esi), %ax + movw %ax, 18(%esp) + movw 8(%esi), %ax + movw %ax, 20(%esp) + movw 12(%esi), %ax + movw %ax, 22(%esp) + movb 16(%esi), %al + movb %al, 24(%esp) + xorl %edx, %edx + addl $16, %esp + .p2align 2,,3 +L29: + movb 17(%edx,%esi), %al + movb %al, 9(%esp,%edx) + incl %edx + cmpl $7, %edx + jle L29 + xorl %edx, %edx + .p2align 2,,3 +L35: + movb (%esp,%edx), %al +/APP + movb %al,%fs:(%edx,%ebx) +/NO_APP + incl %edx + cmpl $17, %edx + jbe L35 + addl $36, %esp + popl %ebx + xorl %eax, %eax + popl %esi + ret + .p2align 2,,3 + .def _set_termio; .scl 3; .type 32; .endef +_set_termio: + pushl %ebx + subl $40, %esp + movl 48(%esp), %ebx + movl 52(%esp), %ecx + xorl %edx, %edx + .p2align 2,,3 +L46: +/APP + movb %fs:(%edx,%ecx),%al +/NO_APP + movb %al, (%esp,%edx) + incl %edx + cmpl $17, %edx + jbe L46 + movl (%esp), %eax + movw %ax, (%ebx) + movw 2(%esp), %ax + movw %ax, 4(%ebx) + movl 4(%esp), %eax + movw %ax, 8(%ebx) + movw 6(%esp), %ax + movw %ax, 12(%ebx) + movb 8(%esp), %al + movb %al, 16(%ebx) + xorl %edx, %edx + .p2align 2,,3 +L51: + movb 9(%esp,%edx), %al + movb %al, 17(%edx,%ebx) + incl %edx + cmpl $7, %edx + jle L51 + subl $12, %esp + pushl %ebx + call _change_speed + addl $56, %esp + xorl %eax, %eax + popl %ebx + ret +LC0: + .ascii "tty_ioctl: dev<0\0" + .p2align 2,,3 +.globl _tty_ioctl + .def _tty_ioctl; .scl 2; .type 32; .endef +_tty_ioctl: + pushl %edi + pushl %esi + pushl %ebx + movl 16(%esp), %ebx + movl %ebx, %eax + shrl $8, %eax + cmpl $5, %eax + movl 20(%esp), %esi + movl 24(%esp), %edi + je L107 + andl $255, %ebx +L59: + leal (%ebx,%ebx,4), %eax + leal (%eax,%eax,4), %eax + sall $2, %eax + subl %ebx, %eax + leal -21505(%esi), %edx + sall $5, %eax + cmpl $26, %edx + leal _tty_table(%eax), %ebx + movl $-22, %eax + ja L56 + jmp *L100(,%edx,4) + .p2align 2 + .align 4 +L100: + .long L61 + .long L64 + .long L63 + .long L62 + .long L65 + .long L68 + .long L67 + .long L66 + .long L69 + .long L98 + .long L72 + .long L98 + .long L98 + .long L98 + .long L82 + .long L84 + .long L86 + .long L98 + .long L98 + .long L98 + .long L98 + .long L98 + .long L98 + .long L98 + .long L98 + .long L98 + .long L88 +L61: + movl %edi, 20(%esp) + movl %ebx, 16(%esp) + popl %ebx + popl %esi + popl %edi + jmp _get_termios +L64: + movl %edi, 20(%esp) + movl %ebx, 16(%esp) + popl %ebx + popl %esi + popl %edi + jmp _set_termios +L63: + subl $12, %esp + pushl %ebx + call _wait_until_sent + addl $16, %esp + jmp L64 +L62: + subl $12, %esp + leal 48(%ebx), %eax + pushl %eax + call _flush + addl $16, %esp + jmp L63 +L65: + movl %edi, 20(%esp) + movl %ebx, 16(%esp) + popl %ebx + popl %esi + popl %edi + jmp _get_termio +L68: + movl %edi, 20(%esp) + movl %ebx, 16(%esp) + popl %ebx + popl %esi + popl %edi + jmp _set_termio +L67: + subl $12, %esp + pushl %ebx + call _wait_until_sent + addl $16, %esp + jmp L68 +L66: + subl $12, %esp + leal 48(%ebx), %eax + pushl %eax + call _flush + addl $16, %esp + jmp L67 +L69: + testl %edi, %edi + jne L104 + subl $12, %esp + pushl %ebx + call _wait_until_sent + movl %ebx, (%esp) + call _send_break +L105: + addl $16, %esp +L104: + xorl %eax, %eax + .p2align 2,,3 +L56: + popl %ebx + popl %esi + popl %edi + ret +L72: + testl %edi, %edi + je L108 + cmpl $1, %edi + je L109 + cmpl $2, %edi + je L110 + .p2align 2,,3 +L98: + movl $-22, %eax + jmp L56 +L110: + subl $12, %esp + leal 48(%ebx), %eax + pushl %eax + call _flush + popl %ecx +L101: + leal 1088(%ebx), %eax +L102: + pushl %eax + call _flush + jmp L105 +L109: + subl $12, %esp + jmp L101 +L108: + subl $12, %esp + leal 48(%ebx), %eax + jmp L102 +L82: + subl $8, %esp + pushl $4 + pushl %edi + call _verify_area + addl $16, %esp + movl 36(%ebx), %eax +L106: +/APP + movl %eax,%fs:(%edi) +/NO_APP + jmp L104 +L84: +/APP + movl %fs:(%edi),%eax +/NO_APP + movl %eax, 36(%ebx) + jmp L104 +L86: + subl $8, %esp + pushl $4 + pushl %edi + call _verify_area + movl 1092(%ebx), %eax + addl $16, %esp + subl 1096(%ebx), %eax +L103: + andl $1023, %eax + jmp L106 +L88: + subl $8, %esp + pushl $4 + pushl %edi + call _verify_area + movl 2132(%ebx), %eax + addl $16, %esp + subl 2136(%ebx), %eax + jmp L103 + .p2align 2,,3 +L107: + movl _current, %eax + movl 616(%eax), %ebx + testl %ebx, %ebx + jns L59 + subl $12, %esp + pushl $LC0 + call _panic + addl $16, %esp + jmp L59 + .def _panic; .scl 2; .type 32; .endef + .def _verify_area; .scl 2; .type 32; .endef diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/exit.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/exit.c new file mode 100644 index 0000000..b22de34 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/exit.c @@ -0,0 +1,196 @@ +/* + * linux/kernel/exit.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include +#include + +#include +#include +#include +#include + +int sys_pause(void); +int sys_close(int fd); + +void release(struct task_struct * p) +{ + int i; + + if (!p) + return; + for (i=1 ; i32) + return -EINVAL; + if (priv || (current->euid==p->euid) || suser()) + p->signal |= (1<<(sig-1)); + else + return -EPERM; + return 0; +} + +static void kill_session(void) +{ + struct task_struct **p = NR_TASKS + task; + + while (--p > &FIRST_TASK) { + if (*p && (*p)->session == current->session) + (*p)->signal |= 1<<(SIGHUP-1); + } +} + +/* + * XXX need to check permissions needed to send signals to process + * groups, etc. etc. kill() permissions semantics are tricky! + */ +int sys_kill(int pid,int sig) +{ + struct task_struct **p = NR_TASKS + task; + int err, retval = 0; + + if (!pid) while (--p > &FIRST_TASK) { + if (*p && (*p)->pgrp == current->pid) + if ((err=send_sig(sig,*p,1))) + retval = err; + } else if (pid>0) while (--p > &FIRST_TASK) { + if (*p && (*p)->pid == pid) + if ((err=send_sig(sig,*p,0))) + retval = err; + } else if (pid == -1) while (--p > &FIRST_TASK) { + if ((err = send_sig(sig,*p,0))) + retval = err; + } else while (--p > &FIRST_TASK) + if (*p && (*p)->pgrp == -pid) + if ((err = send_sig(sig,*p,0))) + retval = err; + return retval; +} + +static void tell_father(int pid) +{ + int i; + + if (pid) + for (i=0;ipid != pid) + continue; + task[i]->signal |= (1<<(SIGCHLD-1)); + return; + } +/* if we don't find any fathers, we just release ourselves */ +/* This is not really OK. Must change it to make father 1 */ + printk("BAD BAD - no father found\n\r"); + release(current); +} + +int do_exit(long code) +{ + int i; + free_page_tables(get_base(current->ldt[1]),get_limit(0x0f)); + free_page_tables(get_base(current->ldt[2]),get_limit(0x17)); + for (i=0 ; ifather == current->pid) { + task[i]->father = 1; + if (task[i]->state == TASK_ZOMBIE) + /* assumption task[1] is always init */ + (void) send_sig(SIGCHLD, task[1], 1); + } + for (i=0 ; ifilp[i]) + sys_close(i); + iput(current->pwd); + current->pwd=NULL; + iput(current->root); + current->root=NULL; + iput(current->executable); + current->executable=NULL; + if (current->leader && current->tty >= 0) + tty_table[current->tty].pgrp = 0; + if (last_task_used_math == current) + last_task_used_math = NULL; + if (current->leader) + kill_session(); + current->state = TASK_ZOMBIE; + current->exit_code = code; + tell_father(current->father); + schedule(); + return (-1); /* just to suppress warnings */ +} + +int sys_exit(int error_code) +{ + return do_exit((error_code&0xff)<<8); +} + +int sys_waitpid(pid_t pid,unsigned long * stat_addr, int options) +{ + int flag, code; + struct task_struct ** p; + + verify_area(stat_addr,4); +repeat: + flag=0; + for(p = &LAST_TASK ; p > &FIRST_TASK ; --p) { + if (!*p || *p == current) + continue; + if ((*p)->father != current->pid) + continue; + if (pid>0) { + if ((*p)->pid != pid) + continue; + } else if (!pid) { + if ((*p)->pgrp != current->pgrp) + continue; + } else if (pid != -1) { + if ((*p)->pgrp != -pid) + continue; + } + switch ((*p)->state) { + case TASK_STOPPED: + if (!(options & WUNTRACED)) + continue; + put_fs_long(0x7f,stat_addr); + return (*p)->pid; + case TASK_ZOMBIE: + current->cutime += (*p)->utime; + current->cstime += (*p)->stime; + flag = (*p)->pid; + code = (*p)->exit_code; + release(*p); + put_fs_long(code,stat_addr); + return flag; + default: + flag=1; + continue; + } + } + if (flag) { + if (options & WNOHANG) + return 0; + current->state=TASK_INTERRUPTIBLE; + schedule(); + if (!(current->signal &= ~(1<<(SIGCHLD-1)))) + goto repeat; + else + return -EINTR; + } + return -ECHILD; +} + + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/fork.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/fork.c new file mode 100644 index 0000000..2486b13 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/fork.c @@ -0,0 +1,148 @@ +/* + * linux/kernel/fork.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 'fork.c' contains the help-routines for the 'fork' system call + * (see also system_call.s), and some misc functions ('verify_area'). + * Fork is rather simple, once you get the hang of it, but the memory + * management can be a bitch. See 'mm/mm.c': 'copy_page_tables()' + */ +#include + +#include +#include +#include +#include + +extern void write_verify(unsigned long address); + +long last_pid=0; + +void verify_area(void * addr,int size) +{ + unsigned long start; + + start = (unsigned long) addr; + size += start & 0xfff; + start &= 0xfffff000; + start += get_base(current->ldt[2]); + while (size>0) { + size -= 4096; + write_verify(start); + start += 4096; + } +} + +int copy_mem(int nr,struct task_struct * p) +{ + unsigned long old_data_base,new_data_base,data_limit; + unsigned long old_code_base,new_code_base,code_limit; + + code_limit=get_limit(0x0f); + data_limit=get_limit(0x17); + old_code_base = get_base(current->ldt[1]); + old_data_base = get_base(current->ldt[2]); + if (old_data_base != old_code_base) + panic("We don't support separate I&D"); + if (data_limit < code_limit) + panic("Bad data_limit"); + new_data_base = new_code_base = nr * 0x4000000; + p->start_code = new_code_base; + set_base(p->ldt[1],new_code_base); + set_base(p->ldt[2],new_data_base); + if (copy_page_tables(old_data_base,new_data_base,data_limit)) { + printk("free_page_tables: from copy_mem\n"); + free_page_tables(new_data_base,data_limit); + return -ENOMEM; + } + return 0; +} + +/* + * Ok, this is the main fork-routine. It copies the system process + * information (task[nr]) and sets up the necessary registers. It + * also copies the data segment in it's entirety. + */ +int copy_process(int nr,long ebp,long edi,long esi,long gs,long none, + long ebx,long ecx,long edx, + long fs,long es,long ds, + long eip,long cs,long eflags,long esp,long ss) +{ + struct task_struct *p; + int i; + struct file *f; + + p = (struct task_struct *) get_free_page(); + if (!p) + return -EAGAIN; + task[nr] = p; + *p = *current; /* NOTE! this doesn't copy the supervisor stack */ + p->state = TASK_UNINTERRUPTIBLE; + p->pid = last_pid; + p->father = current->pid; + p->counter = p->priority; + p->signal = 0; + p->alarm = 0; + p->leader = 0; /* process leadership doesn't inherit */ + p->utime = p->stime = 0; + p->cutime = p->cstime = 0; + p->start_time = jiffies; + p->tss.back_link = 0; + p->tss.esp0 = PAGE_SIZE + (long) p; + p->tss.ss0 = 0x10; + p->tss.eip = eip; + p->tss.eflags = eflags; + p->tss.eax = 0; + p->tss.ecx = ecx; + p->tss.edx = edx; + p->tss.ebx = ebx; + p->tss.esp = esp; + p->tss.ebp = ebp; + p->tss.esi = esi; + p->tss.edi = edi; + p->tss.es = es & 0xffff; + p->tss.cs = cs & 0xffff; + p->tss.ss = ss & 0xffff; + p->tss.ds = ds & 0xffff; + p->tss.fs = fs & 0xffff; + p->tss.gs = gs & 0xffff; + p->tss.ldt = _LDT(nr); + p->tss.trace_bitmap = 0x80000000; + if (last_task_used_math == current) + __asm__("clts ; fnsave %0"::"m" (p->tss.i387)); + if (copy_mem(nr,p)) { + task[nr] = NULL; + free_page((long) p); + return -EAGAIN; + } + for (i=0; ifilp[i])) + f->f_count++; + if (current->pwd) + current->pwd->i_count++; + if (current->root) + current->root->i_count++; + if (current->executable) + current->executable->i_count++; + set_tss_desc(gdt+(nr<<1)+FIRST_TSS_ENTRY,&(p->tss)); + set_ldt_desc(gdt+(nr<<1)+FIRST_LDT_ENTRY,&(p->ldt)); + p->state = TASK_RUNNING; /* do this last, just in case */ + return last_pid; +} + +int find_empty_process(void) +{ + int i; + + repeat: + if ((++last_pid)<0) last_pid=1; + for(i=0 ; ipid == last_pid) goto repeat; + for(i=1 ; i tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/math/math_emulate.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/math/math_emulate.c new file mode 100644 index 0000000..825e528 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/math/math_emulate.c @@ -0,0 +1,42 @@ +/* + * linux/kernel/math/math_emulate.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * This directory should contain the math-emulation code. + * Currently only results in a signal. + */ + +#include + +#include +#include +#include + +void math_emulate(long edi, long esi, long ebp, long sys_call_ret, + long eax,long ebx,long ecx,long edx, + unsigned short fs,unsigned short es,unsigned short ds, + unsigned long eip,unsigned short cs,unsigned long eflags, + unsigned short ss, unsigned long esp) +{ + unsigned char first, second; + +/* 0x0007 means user code space */ + if (cs != 0x000F) { + printk("math_emulate: %04x:%08x\n\r",cs,eip); + panic("Math emulation needed in kernel"); + } + first = get_fs_byte((char *)((*&eip)++)); + second = get_fs_byte((char *)((*&eip)++)); + printk("%04x:%08x %02x %02x\n\r",cs,eip-2,first,second); + current->signal |= 1<<(SIGFPE-1); +} + +void math_error(void) +{ + __asm__("fnclex"); + if (last_task_used_math) + last_task_used_math->signal |= 1<<(SIGFPE-1); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/mktime.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/mktime.c new file mode 100644 index 0000000..a67db96 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/mktime.c @@ -0,0 +1,58 @@ +/* + * linux/kernel/mktime.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +/* + * This isn't the library routine, it is only used in the kernel. + * as such, we don't care about years<1970 etc, but assume everything + * is ok. Similarly, TZ etc is happily ignored. We just do everything + * as easily as possible. Let's find something public for the library + * routines (although I think minix times is public). + */ +/* + * PS. I hate whoever though up the year 1970 - couldn't they have gotten + * a leap-year instead? I also hate Gregorius, pope or no. I'm grumpy. + */ +#define MINUTE 60 +#define HOUR (60*MINUTE) +#define DAY (24*HOUR) +#define YEAR (365*DAY) + +/* interestingly, we assume leap-years */ +static int month[12] = { + 0, + DAY*(31), + DAY*(31+29), + DAY*(31+29+31), + DAY*(31+29+31+30), + DAY*(31+29+31+30+31), + DAY*(31+29+31+30+31+30), + DAY*(31+29+31+30+31+30+31), + DAY*(31+29+31+30+31+30+31+31), + DAY*(31+29+31+30+31+30+31+31+30), + DAY*(31+29+31+30+31+30+31+31+30+31), + DAY*(31+29+31+30+31+30+31+31+30+31+30) +}; + +long kernel_mktime(struct tm * tm) +{ + long res; + int year; + + year = tm->tm_year - 70; +/* magic offsets (y+1) needed to get leapyears right.*/ + res = YEAR*year + DAY*((year+1)/4); + res += month[tm->tm_mon]; +/* and (y+2) here. If it wasn't a leap-year, we have to adjust */ + if (tm->tm_mon>1 && ((year+2)%4)) + res -= DAY; + res += DAY*(tm->tm_mday-1); + res += HOUR*tm->tm_hour; + res += MINUTE*tm->tm_min; + res += tm->tm_sec; + return res; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/panic.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/panic.c new file mode 100644 index 0000000..566467c --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/panic.c @@ -0,0 +1,26 @@ +/* + * linux/kernel/panic.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * This function is used through-out the kernel (includeinh mm and fs) + * to indicate a major problem. + */ +#define PANIC + +#include +#include + +void sys_sync(void); /* it's really int */ + +volatile void panic(const char * s) +{ + printk("Kernel panic: %s\n\r",s); + if (current == task[0]) + printk("In swapper task - not syncing\n\r"); + else + sys_sync(); + for(;;); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/printk.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/printk.c new file mode 100644 index 0000000..c464d43 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/printk.c @@ -0,0 +1,41 @@ +/* + * linux/kernel/printk.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * When in kernel-mode, we cannot use printf, as fs is liable to + * point to 'interesting' things. Make a printf with fs-saving, and + * all is well. + */ +#include +#include + +#include + +static char buf[1024]; + +extern int vsprintf(char * buf, const char * fmt, va_list args); + +int printk(const char *fmt, ...) +{ + va_list args; + int i; + + va_start(args, fmt); + i=vsprintf(buf,fmt,args); + va_end(args); + __asm__("push %%fs\n\t" + "push %%ds\n\t" + "pop %%fs\n\t" + "pushl %0\n\t" + "pushl $_buf\n\t" + "pushl $0\n\t" + "call _tty_write\n\t" + "addl $8,%%esp\n\t" + "popl %0\n\t" + "pop %%fs" + ::"r" (i):"ax","cx","dx"); + return i; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/sched.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/sched.c new file mode 100644 index 0000000..15d839b --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/sched.c @@ -0,0 +1,412 @@ +/* + * linux/kernel/sched.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 'sched.c' is the main kernel file. It contains scheduling primitives + * (sleep_on, wakeup, schedule etc) as well as a number of simple system + * call functions (type getpid(), which just extracts a field from + * current-task + */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#define _S(nr) (1<<((nr)-1)) +#define _BLOCKABLE (~(_S(SIGKILL) | _S(SIGSTOP))) + +void show_task(int nr,struct task_struct * p) +{ + int i,j = 4096-sizeof(struct task_struct); + + printk("%d: pid=%d, state=%d, ",nr,p->pid,p->state); + i=0; + while (i>2 ] ; + +struct { + long * a; + short b; + } stack_start = { & user_stack [PAGE_SIZE>>2] , 0x10 }; +/* + * 'math_state_restore()' saves the current math information in the + * old math state array, and gets the new ones from the current task + */ +void math_state_restore() +{ + if (last_task_used_math == current) + return; + __asm__("fwait"); + if (last_task_used_math) { + __asm__("fnsave %0"::"m" (last_task_used_math->tss.i387)); + } + last_task_used_math=current; + if (current->used_math) { + __asm__("frstor %0"::"m" (current->tss.i387)); + } else { + __asm__("fninit"::); + current->used_math=1; + } +} + +/* + * 'schedule()' is the scheduler function. This is GOOD CODE! There + * probably won't be any reason to change this, as it should work well + * in all circumstances (ie gives IO-bound processes good response etc). + * The one thing you might take a look at is the signal-handler code here. + * + * NOTE!! Task 0 is the 'idle' task, which gets called when no other + * tasks can run. It can not be killed, and it cannot sleep. The 'state' + * information in task[0] is never used. + */ +void schedule(void) +{ + int i,next,c; + struct task_struct ** p; + +/* check alarm, wake up any interruptible tasks that have got a signal */ + + for(p = &LAST_TASK ; p > &FIRST_TASK ; --p) + if (*p) { + if ((*p)->alarm && (*p)->alarm < jiffies) { + (*p)->signal |= (1<<(SIGALRM-1)); + (*p)->alarm = 0; + } + if (((*p)->signal & ~(_BLOCKABLE & (*p)->blocked)) && + (*p)->state==TASK_INTERRUPTIBLE) + (*p)->state=TASK_RUNNING; + } + +/* this is the scheduler proper: */ + + while (1) { + c = -1; + next = 0; + i = NR_TASKS; + p = &task[NR_TASKS]; + while (--i) { + if (!*--p) + continue; + if ((*p)->state == TASK_RUNNING && (*p)->counter > c) + c = (*p)->counter, next = i; + } + if (c) break; + for(p = &LAST_TASK ; p > &FIRST_TASK ; --p) + if (*p) + (*p)->counter = ((*p)->counter >> 1) + + (*p)->priority; + } + switch_to(next); +} + +int sys_pause(void) +{ + current->state = TASK_INTERRUPTIBLE; + schedule(); + return 0; +} + +void sleep_on(struct task_struct **p) +{ + struct task_struct *tmp; + + if (!p) + return; + if (current == &(init_task.task)) + panic("task[0] trying to sleep"); + tmp = *p; + *p = current; + current->state = TASK_UNINTERRUPTIBLE; + schedule(); + if (tmp) + tmp->state=0; +} + +void interruptible_sleep_on(struct task_struct **p) +{ + struct task_struct *tmp; + + if (!p) + return; + if (current == &(init_task.task)) + panic("task[0] trying to sleep"); + tmp=*p; + *p=current; +repeat: current->state = TASK_INTERRUPTIBLE; + schedule(); + if (*p && *p != current) { + (**p).state=0; + goto repeat; + } + *p=NULL; + if (tmp) + tmp->state=0; +} + +void wake_up(struct task_struct **p) +{ + if (p && *p) { + (**p).state=0; + *p=NULL; + } +} + +/* + * OK, here are some floppy things that shouldn't be in the kernel + * proper. They are here because the floppy needs a timer, and this + * was the easiest way of doing it. + */ +static struct task_struct * wait_motor[4] = {NULL,NULL,NULL,NULL}; +static int mon_timer[4]={0,0,0,0}; +static int moff_timer[4]={0,0,0,0}; +unsigned char current_DOR = 0x0C; + +int ticks_to_floppy_on(unsigned int nr) +{ + extern unsigned char selected; + unsigned char mask = 0x10 << nr; + + if (nr>3) + panic("floppy_on: nr>3"); + moff_timer[nr]=10000; /* 100 s = very big :-) */ + cli(); /* use floppy_off to turn it off */ + mask |= current_DOR; + if (!selected) { + mask &= 0xFC; + mask |= nr; + } + if (mask != current_DOR) { + outb(mask,FD_DOR); + if ((mask ^ current_DOR) & 0xf0) + mon_timer[nr] = HZ/2; + else if (mon_timer[nr] < 2) + mon_timer[nr] = 2; + current_DOR = mask; + } + sti(); + return mon_timer[nr]; +} + +void floppy_on(unsigned int nr) +{ + cli(); + while (ticks_to_floppy_on(nr)) + sleep_on(nr+wait_motor); + sti(); +} + +void floppy_off(unsigned int nr) +{ + moff_timer[nr]=3*HZ; +} + +void do_floppy_timer(void) +{ + int i; + unsigned char mask = 0x10; + + for (i=0 ; i<4 ; i++,mask <<= 1) { + if (!(mask & current_DOR)) + continue; + if (mon_timer[i]) { + if (!--mon_timer[i]) + wake_up(i+wait_motor); + } else if (!moff_timer[i]) { + current_DOR &= ~mask; + outb(current_DOR,FD_DOR); + } else + moff_timer[i]--; + } +} + +#define TIME_REQUESTS 64 + +static struct timer_list { + long jiffies; + void (*fn)(); + struct timer_list * next; +} timer_list[TIME_REQUESTS], * next_timer = NULL; + +void add_timer(long jiffies, void (*fn)(void)) +{ + struct timer_list * p; + + if (!fn) + return; + cli(); + if (jiffies <= 0) + (fn)(); + else { + for (p = timer_list ; p < timer_list + TIME_REQUESTS ; p++) + if (!p->fn) + break; + if (p >= timer_list + TIME_REQUESTS) + panic("No more time requests free"); + p->fn = fn; + p->jiffies = jiffies; + p->next = next_timer; + next_timer = p; + while (p->next && p->next->jiffies < p->jiffies) { + p->jiffies -= p->next->jiffies; + fn = p->fn; + p->fn = p->next->fn; + p->next->fn = fn; + jiffies = p->jiffies; + p->jiffies = p->next->jiffies; + p->next->jiffies = jiffies; + p = p->next; + } + } + sti(); +} + +void do_timer(long cpl) +{ + extern int beepcount; + extern void sysbeepstop(void); + + if (beepcount) + if (!--beepcount) + sysbeepstop(); + + if (cpl) + current->utime++; + else + current->stime++; + + if (next_timer) { + next_timer->jiffies--; + while (next_timer && next_timer->jiffies <= 0) { + void (*fn)(void); + + fn = next_timer->fn; + next_timer->fn = NULL; + next_timer = next_timer->next; + (fn)(); + } + } + if (current_DOR & 0xf0) + do_floppy_timer(); + if ((--current->counter)>0) return; + current->counter=0; + if (!cpl) return; + schedule(); +} + +int sys_alarm(long seconds) +{ + int old = current->alarm; + + if (old) + old = (old - jiffies) / HZ; + current->alarm = (seconds>0)?(jiffies+HZ*seconds):0; + return (old); +} + +int sys_getpid(void) +{ + return current->pid; +} + +int sys_getppid(void) +{ + return current->father; +} + +int sys_getuid(void) +{ + return current->uid; +} + +int sys_geteuid(void) +{ + return current->euid; +} + +int sys_getgid(void) +{ + return current->gid; +} + +int sys_getegid(void) +{ + return current->egid; +} + +int sys_nice(long increment) +{ + if (current->priority-increment>0) + current->priority -= increment; + return 0; +} + +void sched_init(void) +{ + int i; + struct desc_struct * p; + + if (sizeof(struct sigaction) != 16) + panic("Struct sigaction MUST be 16 bytes"); + set_tss_desc(gdt+FIRST_TSS_ENTRY,&(init_task.task.tss)); + set_ldt_desc(gdt+FIRST_LDT_ENTRY,&(init_task.task.ldt)); + p = gdt+2+FIRST_TSS_ENTRY; + for(i=1;ia=p->b=0; + p++; + p->a=p->b=0; + p++; + } +/* Clear NT, so that we won't have troubles with that later on */ + __asm__("pushfl ; andl $0xffffbfff,(%esp) ; popfl"); + ltr(0); + lldt(0); + outb_p(0x36,0x43); /* binary, mode 3, LSB/MSB, ch 0 */ + outb_p(LATCH & 0xff , 0x40); /* LSB */ + outb(LATCH >> 8 , 0x40); /* MSB */ + set_intr_gate(0x20,&timer_interrupt); + outb(inb_p(0x21)&~0x01,0x21); + set_system_gate(0x80,&system_call); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/signal.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/signal.c new file mode 100644 index 0000000..055fc20 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/signal.c @@ -0,0 +1,119 @@ +/* + * linux/kernel/signal.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include +#include + +#include + +volatile void do_exit(int error_code); + +int sys_sgetmask() +{ + return current->blocked; +} + +int sys_ssetmask(int newmask) +{ + int old=current->blocked; + + current->blocked = newmask & ~(1<<(SIGKILL-1)); + return old; +} + +static inline void save_old(char * from,char * to) +{ + int i; + + verify_area(to, sizeof(struct sigaction)); + for (i=0 ; i< sizeof(struct sigaction) ; i++) { + put_fs_byte(*from,to); + from++; + to++; + } +} + +static inline void get_new(char * from,char * to) +{ + int i; + + for (i=0 ; i< sizeof(struct sigaction) ; i++) + *(to++) = get_fs_byte(from++); +} + +int sys_signal(int signum, long handler, long restorer) +{ + struct sigaction tmp; + + if (signum<1 || signum>32 || signum==SIGKILL) + return -1; + tmp.sa_handler = (void (*)(int)) handler; + tmp.sa_mask = 0; + tmp.sa_flags = SA_ONESHOT | SA_NOMASK; + tmp.sa_restorer = (void (*)(void)) restorer; + handler = (long) current->sigaction[signum-1].sa_handler; + current->sigaction[signum-1] = tmp; + return handler; +} + +int sys_sigaction(int signum, const struct sigaction * action, + struct sigaction * oldaction) +{ + struct sigaction tmp; + + if (signum<1 || signum>32 || signum==SIGKILL) + return -1; + tmp = current->sigaction[signum-1]; + get_new((char *) action, + (char *) (signum-1+current->sigaction)); + if (oldaction) + save_old((char *) &tmp,(char *) oldaction); + if (current->sigaction[signum-1].sa_flags & SA_NOMASK) + current->sigaction[signum-1].sa_mask = 0; + else + current->sigaction[signum-1].sa_mask |= (1<<(signum-1)); + return 0; +} + +void do_signal(long signr,long eax, long ebx, long ecx, long edx, + long fs, long es, long ds, + long eip, long cs, long eflags, + unsigned long * esp, long ss) +{ + unsigned long sa_handler; + long old_eip=eip; + struct sigaction * sa = current->sigaction + signr - 1; + int longs; + unsigned long * tmp_esp; + + sa_handler = (unsigned long) sa->sa_handler; + if (sa_handler==1) + return; + if (!sa_handler) { + if (signr==SIGCHLD) + return; + else + do_exit(1<<(signr-1)); + } + if (sa->sa_flags & SA_ONESHOT) + sa->sa_handler = NULL; + *(&eip) = sa_handler; + longs = (sa->sa_flags & SA_NOMASK)?7:8; + *(&esp) -= longs; + verify_area(esp,longs*4); + tmp_esp=esp; + put_fs_long((long) sa->sa_restorer,tmp_esp++); + put_fs_long(signr,tmp_esp++); + if (!(sa->sa_flags & SA_NOMASK)) + put_fs_long(current->blocked,tmp_esp++); + put_fs_long(eax,tmp_esp++); + put_fs_long(ecx,tmp_esp++); + put_fs_long(edx,tmp_esp++); + put_fs_long(eflags,tmp_esp++); + put_fs_long(old_eip,tmp_esp++); + current->blocked |= sa->sa_mask; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/sys.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/sys.c new file mode 100644 index 0000000..2c01e67 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/sys.c @@ -0,0 +1,236 @@ +/* + * linux/kernel/sys.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +#include +#include +#include +#include +#include +#include + +int sys_ftime() +{ + return -ENOSYS; +} + +int sys_break() +{ + return -ENOSYS; +} + +int sys_ptrace() +{ + return -ENOSYS; +} + +int sys_stty() +{ + return -ENOSYS; +} + +int sys_gtty() +{ + return -ENOSYS; +} + +int sys_rename() +{ + return -ENOSYS; +} + +int sys_prof() +{ + return -ENOSYS; +} + +int sys_setregid(int rgid, int egid) +{ + if (rgid>0) { + if ((current->gid == rgid) || + suser()) + current->gid = rgid; + else + return(-EPERM); + } + if (egid>0) { + if ((current->gid == egid) || + (current->egid == egid) || + (current->sgid == egid) || + suser()) + current->egid = egid; + else + return(-EPERM); + } + return 0; +} + +int sys_setgid(int gid) +{ + return(sys_setregid(gid, gid)); +} + +int sys_acct() +{ + return -ENOSYS; +} + +int sys_phys() +{ + return -ENOSYS; +} + +int sys_lock() +{ + return -ENOSYS; +} + +int sys_mpx() +{ + return -ENOSYS; +} + +int sys_ulimit() +{ + return -ENOSYS; +} + +int sys_time(long * tloc) +{ + int i; + + i = CURRENT_TIME; + if (tloc) { + verify_area(tloc,4); + put_fs_long(i,(unsigned long *)tloc); + } + return i; +} + +/* + * Unprivileged users may change the real user id to the effective uid + * or vice versa. + */ +int sys_setreuid(int ruid, int euid) +{ + int old_ruid = current->uid; + + if (ruid>0) { + if ((current->euid==ruid) || + (old_ruid == ruid) || + suser()) + current->uid = ruid; + else + return(-EPERM); + } + if (euid>0) { + if ((old_ruid == euid) || + (current->euid == euid) || + suser()) + current->euid = euid; + else { + current->uid = old_ruid; + return(-EPERM); + } + } + return 0; +} + +int sys_setuid(int uid) +{ + return(sys_setreuid(uid, uid)); +} + +int sys_stime(long * tptr) +{ + if (!suser()) + return -EPERM; + startup_time = get_fs_long((unsigned long *)tptr) - jiffies/HZ; + return 0; +} + +int sys_times(struct tms * tbuf) +{ + if (tbuf) { + verify_area(tbuf,sizeof *tbuf); + put_fs_long(current->utime,(unsigned long *)&tbuf->tms_utime); + put_fs_long(current->stime,(unsigned long *)&tbuf->tms_stime); + put_fs_long(current->cutime,(unsigned long *)&tbuf->tms_cutime); + put_fs_long(current->cstime,(unsigned long *)&tbuf->tms_cstime); + } + return jiffies; +} + +int sys_brk(unsigned long end_data_seg) +{ + if (end_data_seg >= current->end_code && + end_data_seg < current->start_stack - 16384) + current->brk = end_data_seg; + return current->brk; +} + +/* + * This needs some heave checking ... + * I just haven't get the stomach for it. I also don't fully + * understand sessions/pgrp etc. Let somebody who does explain it. + */ +int sys_setpgid(int pid, int pgid) +{ + int i; + + if (!pid) + pid = current->pid; + if (!pgid) + pgid = current->pid; + for (i=0 ; ipid==pid) { + if (task[i]->leader) + return -EPERM; + if (task[i]->session != current->session) + return -EPERM; + task[i]->pgrp = pgid; + return 0; + } + return -ESRCH; +} + +int sys_getpgrp(void) +{ + return current->pgrp; +} + +int sys_setsid(void) +{ + if (current->leader && !suser()) + return -EPERM; + current->leader = 1; + current->session = current->pgrp = current->pid; + current->tty = -1; + return current->pgrp; +} + +int sys_uname(struct utsname * name) +{ + static struct utsname thisname = { + "linux .0","nodename","release ","version ","machine " + }; + int i; + + if (!name) return -ERROR; + verify_area(name,sizeof *name); + for(i=0;iumask; + + current->umask = mask & 0777; + return (old); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/system_call.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/system_call.s new file mode 100644 index 0000000..c96826c --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/system_call.s @@ -0,0 +1,285 @@ +/* + * linux/kernel/system_call.s + * + * (C) 1991 Linus Torvalds + */ + +/* + * system_call.s contains the system-call low-level handling routines. + * This also contains the timer-interrupt handler, as some of the code is + * the same. The hd- and flopppy-interrupts are also here. + * + * NOTE: This code handles signal-recognition, which happens every time + * after a timer-interrupt and after each system call. Ordinary interrupts + * don't handle signal-recognition, as that would clutter them up totally + * unnecessarily. + * + * Stack layout in 'ret_from_system_call': + * + * 0(%esp) - %eax + * 4(%esp) - %ebx + * 8(%esp) - %ecx + * C(%esp) - %edx + * 10(%esp) - %fs + * 14(%esp) - %es + * 18(%esp) - %ds + * 1C(%esp) - %eip + * 20(%esp) - %cs + * 24(%esp) - %eflags + * 28(%esp) - %oldesp + * 2C(%esp) - %oldss + */ + +SIG_CHLD = 17 + +EAX = 0x00 +EBX = 0x04 +ECX = 0x08 +EDX = 0x0C +FS = 0x10 +ES = 0x14 +DS = 0x18 +EIP = 0x1C +CS = 0x20 +EFLAGS = 0x24 +OLDESP = 0x28 +OLDSS = 0x2C + +state = 0 # these are offsets into the task-struct. +counter = 4 +priority = 8 +signal = 12 +sigaction = 16 # MUST be 16 (=len of sigaction) +blocked = (33*16) + +# offsets within sigaction +sa_handler = 0 +sa_mask = 4 +sa_flags = 8 +sa_restorer = 12 + +nr_system_calls = 72 + +/* + * Ok, I get parallel printer interrupts while using the floppy for some + * strange reason. Urgel. Now I just ignore them. + */ +.globl _system_call,_sys_fork,_timer_interrupt,_sys_execve +.globl _hd_interrupt,_floppy_interrupt,_parallel_interrupt +.globl _device_not_available, _coprocessor_error + +.align 2 +bad_sys_call: + movl $-1,%eax + iret +.align 2 +reschedule: + pushl $ret_from_sys_call + jmp _schedule +.align 2 +_system_call: + cmpl $nr_system_calls-1,%eax + ja bad_sys_call + push %ds + push %es + push %fs + pushl %edx + pushl %ecx # push %ebx,%ecx,%edx as parameters + pushl %ebx # to the system call + movl $0x10,%edx # set up ds,es to kernel space + mov %dx,%ds + mov %dx,%es + movl $0x17,%edx # fs points to local data space + mov %dx,%fs + call _sys_call_table(,%eax,4) + pushl %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 + je 3f + cmpw $0x0f,CS(%esp) # was old code segment supervisor ? + jne 3f + cmpw $0x17,OLDSS(%esp) # was stack segment = 0x17 ? + jne 3f + movl signal(%eax),%ebx + movl blocked(%eax),%ecx + notl %ecx + andl %ebx,%ecx + bsfl %ecx,%ecx + je 3f + btrl %ecx,%ebx + movl %ebx,signal(%eax) + incl %ecx + pushl %ecx + call _do_signal + popl %eax +3: popl %eax + popl %ebx + popl %ecx + popl %edx + pop %fs + pop %es + pop %ds + iret + +.align 2 +_coprocessor_error: + push %ds + push %es + push %fs + pushl %edx + pushl %ecx + pushl %ebx + pushl %eax + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + movl $0x17,%eax + mov %ax,%fs + pushl $ret_from_sys_call + jmp _math_error + +.align 2 +_device_not_available: + push %ds + push %es + push %fs + pushl %edx + pushl %ecx + pushl %ebx + pushl %eax + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + movl $0x17,%eax + mov %ax,%fs + pushl $ret_from_sys_call + clts # clear TS so that we can use math + movl %cr0,%eax + testl $0x4,%eax # EM (math emulation bit) + je _math_state_restore + pushl %ebp + pushl %esi + pushl %edi + call _math_emulate + popl %edi + popl %esi + popl %ebp + ret + +.align 2 +_timer_interrupt: + push %ds # save ds,es and put kernel data space + push %es # into them. %fs is used by _system_call + push %fs + pushl %edx # we save %eax,%ecx,%edx as gcc doesn't + pushl %ecx # save those across function calls. %ebx + pushl %ebx # is saved as we use that in ret_sys_call + pushl %eax + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + movl $0x17,%eax + mov %ax,%fs + 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 + addl $4,%esp # task switching to accounting ... + jmp ret_from_sys_call + +.align 2 +_sys_execve: + lea EIP(%esp),%eax + pushl %eax + call _do_execve + addl $4,%esp + ret + +.align 2 +_sys_fork: + call _find_empty_process + testl %eax,%eax + js 1f + push %gs + pushl %esi + pushl %edi + pushl %ebp + pushl %eax + call _copy_process + addl $20,%esp +1: ret + +_hd_interrupt: + pushl %eax + pushl %ecx + pushl %edx + push %ds + push %es + push %fs + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + movl $0x17,%eax + mov %ax,%fs + movb $0x20,%al + outb %al,$0xA0 # EOI to interrupt controller #1 + jmp 1f # give port chance to breathe +1: jmp 1f +1: xorl %edx,%edx + xchgl _do_hd,%edx + testl %edx,%edx + jne 1f + movl $_unexpected_hd_interrupt,%edx +1: outb %al,$0x20 + call *%edx # "interesting" way of handling intr. + pop %fs + pop %es + pop %ds + popl %edx + popl %ecx + popl %eax + iret + +_floppy_interrupt: + pushl %eax + pushl %ecx + pushl %edx + push %ds + push %es + push %fs + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + movl $0x17,%eax + mov %ax,%fs + movb $0x20,%al + outb %al,$0x20 # EOI to interrupt controller #1 + xorl %eax,%eax + xchgl _do_floppy,%eax + testl %eax,%eax + jne 1f + movl $_unexpected_floppy_interrupt,%eax +1: call *%eax # "interesting" way of handling intr. + pop %fs + pop %es + pop %ds + popl %edx + popl %ecx + popl %eax + iret + +_parallel_interrupt: + pushl %eax + movb $0x20,%al + outb %al,$0x20 + popl %eax + iret diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/traps.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/traps.c new file mode 100644 index 0000000..3629a13 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/traps.c @@ -0,0 +1,208 @@ +/* + * linux/kernel/traps.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 'Traps.c' handles hardware traps and faults after we have saved some + * state in 'asm.s'. Currently mostly a debugging-aid, will be extended + * to mainly kill the offending process (probably by giving it a signal, + * but possibly by killing it outright if necessary). + */ +#include + +#include +#include +#include +#include +#include +#include + +#define get_seg_byte(seg,addr) ({ \ +register char __res; \ +__asm__("push %%fs;mov %%ax,%%fs;movb %%fs:%2,%%al;pop %%fs" \ + :"=a" (__res):"0" (seg),"m" (*(addr))); \ +__res;}) + +#define get_seg_long(seg,addr) ({ \ +register unsigned long __res; \ +__asm__("push %%fs;mov %%ax,%%fs;movl %%fs:%2,%%eax;pop %%fs" \ + :"=a" (__res):"0" (seg),"m" (*(addr))); \ +__res;}) + +#define _fs() ({ \ +register unsigned short __res; \ +__asm__("mov %%fs,%%ax":"=a" (__res):); \ +__res;}) + +int do_exit(long code); + +void page_exception(void); + +void divide_error(void); +void debug(void); +void nmi(void); +void int3(void); +void overflow(void); +void bounds(void); +void invalid_op(void); +void device_not_available(void); +void double_fault(void); +void coprocessor_segment_overrun(void); +void invalid_TSS(void); +void segment_not_present(void); +void stack_segment(void); +void general_protection(void); +void page_fault(void); +void coprocessor_error(void); +void reserved(void); +void parallel_interrupt(void); +void irq13(void); + +static void die(char * str,long esp_ptr,long nr) +{ + long * esp = (long *) esp_ptr; + int i; + + printk("%s: %04x\n\r",str,nr&0xffff); + printk("EIP:\t%04x:%p\nEFLAGS:\t%p\nESP:\t%04x:%p\n", + esp[1],esp[0],esp[2],esp[4],esp[3]); + printk("fs: %04x\n",_fs()); + printk("base: %p, limit: %p\n",get_base(current->ldt[1]),get_limit(0x17)); + if (esp[4] == 0x17) { + printk("Stack: "); + for (i=0;i<4;i++) + printk("%p ",get_seg_long(0x17,i+(long *)esp[3])); + printk("\n"); + } + str(i); + printk("Pid: %d, process nr: %d\n\r",current->pid,0xffff & i); + for(i=0;i<10;i++) + printk("%02x ",0xff & get_seg_byte(esp[1],(i+(char *)esp[0]))); + printk("\n\r"); + do_exit(11); /* play segment exception */ +} + +void do_double_fault(long esp, long error_code) +{ + die("double fault",esp,error_code); +} + +void do_general_protection(long esp, long error_code) +{ + die("general protection",esp,error_code); +} + +void do_divide_error(long esp, long error_code) +{ + die("divide error",esp,error_code); +} + +void do_int3(long * esp, long error_code, + long fs,long es,long ds, + long ebp,long esi,long edi, + long edx,long ecx,long ebx,long eax) +{ + int tr; + + __asm__("str %%ax":"=a" (tr):"0" (0)); + printk("eax\t\tebx\t\tecx\t\tedx\n\r%8x\t%8x\t%8x\t%8x\n\r", + eax,ebx,ecx,edx); + printk("esi\t\tedi\t\tebp\t\tesp\n\r%8x\t%8x\t%8x\t%8x\n\r", + esi,edi,ebp,(long) esp); + printk("\n\rds\tes\tfs\ttr\n\r%4x\t%4x\t%4x\t%4x\n\r", + ds,es,fs,tr); + printk("EIP: %8x CS: %4x EFLAGS: %8x\n\r",esp[0],esp[1],esp[2]); +} + +void do_nmi(long esp, long error_code) +{ + die("nmi",esp,error_code); +} + +void do_debug(long esp, long error_code) +{ + die("debug",esp,error_code); +} + +void do_overflow(long esp, long error_code) +{ + die("overflow",esp,error_code); +} + +void do_bounds(long esp, long error_code) +{ + die("bounds",esp,error_code); +} + +void do_invalid_op(long esp, long error_code) +{ + die("invalid operand",esp,error_code); +} + +void do_device_not_available(long esp, long error_code) +{ + die("device not available",esp,error_code); +} + +void do_coprocessor_segment_overrun(long esp, long error_code) +{ + die("coprocessor segment overrun",esp,error_code); +} + +void do_invalid_TSS(long esp,long error_code) +{ + die("invalid TSS",esp,error_code); +} + +void do_segment_not_present(long esp,long error_code) +{ + die("segment not present",esp,error_code); +} + +void do_stack_segment(long esp,long error_code) +{ + die("stack segment",esp,error_code); +} + +void do_coprocessor_error(long esp, long error_code) +{ + if (last_task_used_math != current) + return; + die("coprocessor error",esp,error_code); +} + +void do_reserved(long esp, long error_code) +{ + die("reserved (15,17-47) error",esp,error_code); +} + +void trap_init(void) +{ + int i; + + set_trap_gate(0,÷_error); + set_trap_gate(1,&debug); + set_trap_gate(2,&nmi); + set_system_gate(3,&int3); /* int3-5 can be called from all */ + set_system_gate(4,&overflow); + set_system_gate(5,&bounds); + set_trap_gate(6,&invalid_op); + set_trap_gate(7,&device_not_available); + set_trap_gate(8,&double_fault); + set_trap_gate(9,&coprocessor_segment_overrun); + set_trap_gate(10,&invalid_TSS); + set_trap_gate(11,&segment_not_present); + set_trap_gate(12,&stack_segment); + set_trap_gate(13,&general_protection); + set_trap_gate(14,&page_fault); + set_trap_gate(15,&reserved); + set_trap_gate(16,&coprocessor_error); + for (i=17;i<48;i++) + set_trap_gate(i,&reserved); + set_trap_gate(45,&irq13); + outb_p(inb_p(0x21)&0xfb,0x21); + outb(inb_p(0xA1)&0xdf,0xA1); + set_trap_gate(39,¶llel_interrupt); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/traps.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/traps.s new file mode 100644 index 0000000..283c7a7 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/traps.s @@ -0,0 +1,631 @@ + .file "traps.c" + .text +LC0: + .ascii "%s: %04x\12\15\0" + .align 32 +LC1: + .ascii "EIP:\11%04x:%p\12EFLAGS:\11%p\12ESP:\11%04x:%p\12\0" +LC2: + .ascii "fs: %04x\12\0" +LC3: + .ascii "base: %p, limit: %p\12\0" +LC7: + .ascii "Pid: %d, process nr: %d\12\15\0" +LC8: + .ascii "%02x \0" +LC9: + .ascii "\12\15\0" +LC4: + .ascii "Stack: \0" +LC5: + .ascii "%p \0" +LC6: + .ascii "\12\0" + .p2align 2,,3 + .def _die; .scl 3; .type 32; .endef +_die: + pushl %edi + pushl %esi + pushl %ebx + movl 20(%esp), %esi + pushl %ebx + movzwl 28(%esp), %eax + pushl %eax + pushl 24(%esp) + pushl $LC0 + call _printk + popl %edx + popl %ecx + pushl 12(%esi) + pushl 16(%esi) + pushl 8(%esi) + pushl (%esi) + pushl 4(%esi) + pushl $LC1 + call _printk +/APP + mov %fs,%ax +/NO_APP + addl $24, %esp + movzwl %ax, %eax + pushl %eax + pushl $LC2 + call _printk + addl $12, %esp + movl $23, %edx + movl _current, %eax +/APP + lsll %edx,%ecx + incl %ecx +/NO_APP + addl $728, %eax +/APP + movb 7(%eax),%dh + movb 4(%eax),%dl + shll $16,%edx + movw 2(%eax),%dx +/NO_APP + pushl %ecx + pushl %edx + pushl $LC3 + call _printk + addl $16, %esp + cmpl $23, 16(%esi) + je L18 +L3: + xorl %edx, %edx + movl %edx, %eax +/APP + str %ax + subl $32,%eax + shrl $4,%eax +/NO_APP + movl %eax, %ebx + pushl %eax + movzwl %bx,%eax + pushl %eax + movl _current, %eax + pushl 556(%eax) + pushl $LC7 + call _printk + xorl %ebx, %ebx + addl $16, %esp + .p2align 2,,3 +L13: + movl 4(%esi), %eax + movl (%esi), %edx +/APP + push %fs;mov %ax,%fs;movb %fs:(%ebx,%edx),%al;pop %fs +/NO_APP + subl $8, %esp + movzbl %al, %eax + pushl %eax + pushl $LC8 + incl %ebx + call _printk + addl $16, %esp + cmpl $9, %ebx + jle L13 + subl $12, %esp + pushl $LC9 + call _printk + addl $16, %esp + movl $11, 16(%esp) + popl %ebx + popl %esi + popl %edi + jmp _do_exit +L18: + subl $12, %esp + pushl $LC4 + call _printk + xorl %ebx, %ebx + addl $16, %esp + movl $23, %edi +L8: + subl $8, %esp + movl 12(%esi), %edx + movl %edi, %eax +/APP + push %fs;mov %ax,%fs;movl %fs:(%edx,%ebx,4),%eax;pop %fs +/NO_APP + pushl %eax + pushl $LC5 + incl %ebx + call _printk + addl $16, %esp + cmpl $3, %ebx + jle L8 + subl $12, %esp + pushl $LC6 + call _printk + addl $16, %esp + jmp L3 +LC10: + .ascii "double fault\0" + .p2align 2,,3 +.globl _do_double_fault + .def _do_double_fault; .scl 2; .type 32; .endef +_do_double_fault: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC10 + call _die + addl $28, %esp + ret +LC11: + .ascii "general protection\0" + .p2align 2,,3 +.globl _do_general_protection + .def _do_general_protection; .scl 2; .type 32; .endef +_do_general_protection: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC11 + call _die + addl $28, %esp + ret +LC12: + .ascii "divide error\0" + .p2align 2,,3 +.globl _do_divide_error + .def _do_divide_error; .scl 2; .type 32; .endef +_do_divide_error: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC12 + call _die + addl $28, %esp + ret + .align 32 +LC13: + .ascii "eax\11\11ebx\11\11ecx\11\11edx\12\15%8x\11%8x\11%8x\11%8x\12\15\0" + .align 32 +LC14: + .ascii "esi\11\11edi\11\11ebp\11\11esp\12\15%8x\11%8x\11%8x\11%8x\12\15\0" + .align 32 +LC15: + .ascii "\12\15ds\11es\11fs\11tr\12\15%4x\11%4x\11%4x\11%4x\12\15\0" + .align 32 +LC16: + .ascii "EIP: %8x CS: %4x EFLAGS: %8x\12\15\0" + .p2align 2,,3 +.globl _do_int3 + .def _do_int3; .scl 2; .type 32; .endef +_do_int3: + pushl %ebp + pushl %edi + pushl %esi + pushl %ebx + subl $40, %esp + movl 68(%esp), %eax + movl %eax, 36(%esp) + movl 72(%esp), %eax + movl %eax, 32(%esp) + movl 76(%esp), %eax + movl %eax, 28(%esp) + movl 84(%esp), %eax + movl 60(%esp), %esi + movl 80(%esp), %ebp + movl 88(%esp), %edi + movl %eax, 24(%esp) + pushl 92(%esp) + pushl 100(%esp) + pushl 108(%esp) + pushl 116(%esp) + xorl %ebx, %ebx + movl %ebx, %eax + pushl $LC13 +/APP + str %ax +/NO_APP + movl %eax, %ebx + call _printk + addl $20, %esp + pushl %esi + pushl %ebp + pushl %edi + pushl 36(%esp) + pushl $LC14 + call _printk + addl $20, %esp + pushl %ebx + pushl 40(%esp) + pushl 40(%esp) + pushl 40(%esp) + pushl $LC15 + call _printk + movl 8(%esi), %eax + movl %eax, 92(%esp) + movl 4(%esi), %eax + movl %eax, 88(%esp) + movl (%esi), %eax + movl %eax, 84(%esp) + movl $LC16, 80(%esp) + addl $60, %esp + popl %ebx + popl %esi + popl %edi + popl %ebp + jmp _printk +LC17: + .ascii "nmi\0" + .p2align 2,,3 +.globl _do_nmi + .def _do_nmi; .scl 2; .type 32; .endef +_do_nmi: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC17 + call _die + addl $28, %esp + ret +LC18: + .ascii "debug\0" + .p2align 2,,3 +.globl _do_debug + .def _do_debug; .scl 2; .type 32; .endef +_do_debug: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC18 + call _die + addl $28, %esp + ret +LC19: + .ascii "overflow\0" + .p2align 2,,3 +.globl _do_overflow + .def _do_overflow; .scl 2; .type 32; .endef +_do_overflow: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC19 + call _die + addl $28, %esp + ret +LC20: + .ascii "bounds\0" + .p2align 2,,3 +.globl _do_bounds + .def _do_bounds; .scl 2; .type 32; .endef +_do_bounds: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC20 + call _die + addl $28, %esp + ret +LC21: + .ascii "invalid operand\0" + .p2align 2,,3 +.globl _do_invalid_op + .def _do_invalid_op; .scl 2; .type 32; .endef +_do_invalid_op: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC21 + call _die + addl $28, %esp + ret +LC22: + .ascii "device not available\0" + .p2align 2,,3 +.globl _do_device_not_available + .def _do_device_not_available; .scl 2; .type 32; .endef +_do_device_not_available: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC22 + call _die + addl $28, %esp + ret +LC23: + .ascii "coprocessor segment overrun\0" + .p2align 2,,3 +.globl _do_coprocessor_segment_overrun + .def _do_coprocessor_segment_overrun; .scl 2; .type 32; .endef +_do_coprocessor_segment_overrun: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC23 + call _die + addl $28, %esp + ret +LC24: + .ascii "invalid TSS\0" + .p2align 2,,3 +.globl _do_invalid_TSS + .def _do_invalid_TSS; .scl 2; .type 32; .endef +_do_invalid_TSS: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC24 + call _die + addl $28, %esp + ret +LC25: + .ascii "segment not present\0" + .p2align 2,,3 +.globl _do_segment_not_present + .def _do_segment_not_present; .scl 2; .type 32; .endef +_do_segment_not_present: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC25 + call _die + addl $28, %esp + ret +LC26: + .ascii "stack segment\0" + .p2align 2,,3 +.globl _do_stack_segment + .def _do_stack_segment; .scl 2; .type 32; .endef +_do_stack_segment: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC26 + call _die + addl $28, %esp + ret +LC27: + .ascii "coprocessor error\0" + .p2align 2,,3 +.globl _do_coprocessor_error + .def _do_coprocessor_error; .scl 2; .type 32; .endef +_do_coprocessor_error: + subl $12, %esp + movl _current, %eax + cmpl %eax, _last_task_used_math + je L35 +L33: + addl $12, %esp + ret + .p2align 2,,3 +L35: + pushl %eax + pushl 24(%esp) + pushl 24(%esp) + pushl $LC27 + call _die + addl $16, %esp + jmp L33 +LC28: + .ascii "reserved (15,17-47) error\0" + .p2align 2,,3 +.globl _do_reserved + .def _do_reserved; .scl 2; .type 32; .endef +_do_reserved: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC28 + call _die + addl $28, %esp + ret + .p2align 2,,3 +.globl _trap_init + .def _trap_init; .scl 2; .type 32; .endef +_trap_init: + pushl %ebp + pushl %edi + pushl %esi + pushl %ebx + movl $_divide_error, %edx + movl $524288, %eax +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt + movl %edx,_idt+4 +/NO_APP + movl $_debug, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+8 + movl %edx,_idt+12 +/NO_APP + movl $_nmi, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+16 + movl %edx,_idt+20 +/NO_APP + movl $_int3, %edx +/APP + movw %dx,%ax + movw $-4352,%dx + movl %eax,_idt+24 + movl %edx,_idt+28 +/NO_APP + movl $_overflow, %edx +/APP + movw %dx,%ax + movw $-4352,%dx + movl %eax,_idt+32 + movl %edx,_idt+36 +/NO_APP + movl $_bounds, %edx +/APP + movw %dx,%ax + movw $-4352,%dx + movl %eax,_idt+40 + movl %edx,_idt+44 +/NO_APP + movl $_invalid_op, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+48 + movl %edx,_idt+52 +/NO_APP + movl $_device_not_available, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+56 + movl %edx,_idt+60 +/NO_APP + movl $_double_fault, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+64 + movl %edx,_idt+68 +/NO_APP + movl $_coprocessor_segment_overrun, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+72 + movl %edx,_idt+76 +/NO_APP + movl $_invalid_TSS, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+80 + movl %edx,_idt+84 +/NO_APP + movl $_segment_not_present, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+88 + movl %edx,_idt+92 +/NO_APP + movl $_stack_segment, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+96 + movl %edx,_idt+100 +/NO_APP + movl $_general_protection, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+104 + movl %edx,_idt+108 +/NO_APP + movl $_page_fault, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+112 + movl %edx,_idt+116 +/NO_APP + movl $_reserved, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+120 + movl %edx,_idt+124 +/NO_APP + movl $_coprocessor_error, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+128 + movl %edx,_idt+132 +/NO_APP + movl $17, %edi + movl $_idt, %esi + movl $_idt+4, %ebx + movl $_reserved, %ecx + movl $524288, %ebp + .p2align 2,,3 +L42: + movl %ecx, %edx + movl %ebp, %eax +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,(%esi,%edi,8) + movl %edx,(%ebx,%edi,8) +/NO_APP + incl %edi + cmpl $47, %edi + jle L42 + movl $_irq13, %edx + movl $524288, %eax +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+360 + movl %edx,_idt+364 +/NO_APP + movl $33, %edx +/APP + inb %dx,%al + jmp 1f +1: jmp 1f +1: +/NO_APP + andl $251, %eax +/APP + outb %al,%dx + jmp 1f +1: jmp 1f +1: +/NO_APP + movl $161, %edx +/APP + inb %dx,%al + jmp 1f +1: jmp 1f +1: +/NO_APP + andl $223, %eax +/APP + outb %al,%dx +/NO_APP + movl $_parallel_interrupt, %edx + movl $524288, %eax +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+312 + movl %edx,_idt+316 +/NO_APP + popl %ebx + popl %esi + popl %edi + popl %ebp + ret + .def _parallel_interrupt; .scl 2; .type 32; .endef + .def _irq13; .scl 2; .type 32; .endef + .def _coprocessor_error; .scl 2; .type 32; .endef + .def _reserved; .scl 2; .type 32; .endef + .def _page_fault; .scl 2; .type 32; .endef + .def _general_protection; .scl 2; .type 32; .endef + .def _stack_segment; .scl 2; .type 32; .endef + .def _segment_not_present; .scl 2; .type 32; .endef + .def _invalid_TSS; .scl 2; .type 32; .endef + .def _coprocessor_segment_overrun; .scl 2; .type 32; .endef + .def _double_fault; .scl 2; .type 32; .endef + .def _device_not_available; .scl 2; .type 32; .endef + .def _invalid_op; .scl 2; .type 32; .endef + .def _bounds; .scl 2; .type 32; .endef + .def _overflow; .scl 2; .type 32; .endef + .def _int3; .scl 2; .type 32; .endef + .def _nmi; .scl 2; .type 32; .endef + .def _debug; .scl 2; .type 32; .endef + .def _divide_error; .scl 2; .type 32; .endef + .def _do_exit; .scl 2; .type 32; .endef + .def _printk; .scl 2; .type 32; .endef diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/vsprintf.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/vsprintf.c new file mode 100644 index 0000000..ab70f23 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/kernel/vsprintf.c @@ -0,0 +1,235 @@ +/* + * linux/kernel/vsprintf.c + * + * (C) 1991 Linus Torvalds + */ + +/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ +/* + * Wirzenius wrote this portably, Torvalds fucked it up :-) + */ + +#include +#include + +/* we use this so that we can do without the ctype library */ +#define is_digit(c) ((c) >= '0' && (c) <= '9') + +static int skip_atoi(const char **s) +{ + int i=0; + + while (is_digit(**s)) + i = i*10 + *((*s)++) - '0'; + return i; +} + +#define ZEROPAD 1 /* pad with zero */ +#define SIGN 2 /* unsigned/signed long */ +#define PLUS 4 /* show plus */ +#define SPACE 8 /* space if plus */ +#define LEFT 16 /* left justified */ +#define SPECIAL 32 /* 0x */ +#define SMALL 64 /* use 'abcdef' instead of 'ABCDEF' */ + +#define do_div(n,base) ({ \ +int __res; \ +__asm__("divl %4":"=a" (n),"=d" (__res):"0" (n),"1" (0),"r" (base)); \ +__res; }) + +static char * number(char * str, int num, int base, int size, int precision + ,int type) +{ + char c,sign,tmp[36]; + const char *digits="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + int i; + + if (type&SMALL) digits="0123456789abcdefghijklmnopqrstuvwxyz"; + if (type&LEFT) type &= ~ZEROPAD; + if (base<2 || base>36) + return 0; + c = (type & ZEROPAD) ? '0' : ' ' ; + if (type&SIGN && num<0) { + sign='-'; + num = -num; + } else + sign=(type&PLUS) ? '+' : ((type&SPACE) ? ' ' : 0); + if (sign) size--; + if (type&SPECIAL) { + if (base==16) size -= 2; + else if (base==8) size--; + } + i=0; + if (num==0) + tmp[i++]='0'; + else while (num!=0) + tmp[i++]=digits[do_div(num,base)]; + if (i>precision) precision=i; + size -= precision; + if (!(type&(ZEROPAD+LEFT))) + while(size-->0) + *str++ = ' '; + if (sign) + *str++ = sign; + if (type&SPECIAL) { + if (base==8) + *str++ = '0'; + else if (base==16) { + *str++ = '0'; + *str++ = digits[33]; + } + } + if (!(type&LEFT)) + while(size-->0) + *str++ = c; + while(i0) + *str++ = tmp[i]; + while(size-->0) + *str++ = ' '; + return str; +} + +int vsprintf(char *buf, const char *fmt, va_list args) +{ + int len; + int i; + char * str; + char *s; + int *ip; + + int flags; /* flags to number() */ + + int field_width; /* width of output field */ + int precision; /* min. # of digits for integers; max + number of chars for from string */ + int qualifier; /* 'h', 'l', or 'L' for integer fields */ + + for (str=buf ; *fmt ; ++fmt) { + if (*fmt != '%') { + *str++ = *fmt; + continue; + } + + /* process flags */ + flags = 0; + repeat: + ++fmt; /* this also skips first '%' */ + switch (*fmt) { + case '-': flags |= LEFT; goto repeat; + case '+': flags |= PLUS; goto repeat; + case ' ': flags |= SPACE; goto repeat; + case '#': flags |= SPECIAL; goto repeat; + case '0': flags |= ZEROPAD; goto repeat; + } + + /* get field width */ + field_width = -1; + if (is_digit(*fmt)) + field_width = skip_atoi(&fmt); + else if (*fmt == '*') { + /* it's the next argument */ + field_width = va_arg(args, int); + if (field_width < 0) { + field_width = -field_width; + flags |= LEFT; + } + } + + /* get the precision */ + precision = -1; + if (*fmt == '.') { + ++fmt; + if (is_digit(*fmt)) + precision = skip_atoi(&fmt); + else if (*fmt == '*') { + /* it's the next argument */ + precision = va_arg(args, int); + } + if (precision < 0) + precision = 0; + } + + /* get the conversion qualifier */ + qualifier = -1; + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { + qualifier = *fmt; + ++fmt; + } + + switch (*fmt) { + case 'c': + if (!(flags & LEFT)) + while (--field_width > 0) + *str++ = ' '; + *str++ = (unsigned char) va_arg(args, int); + while (--field_width > 0) + *str++ = ' '; + break; + + case 's': + s = va_arg(args, char *); + len = strlen(s); + if (precision < 0) + precision = len; + else if (len > precision) + len = precision; + + if (!(flags & LEFT)) + while (len < field_width--) + *str++ = ' '; + for (i = 0; i < len; ++i) + *str++ = *s++; + while (len < field_width--) + *str++ = ' '; + break; + + case 'o': + str = number(str, va_arg(args, unsigned long), 8, + field_width, precision, flags); + break; + + case 'p': + if (field_width == -1) { + field_width = 8; + flags |= ZEROPAD; + } + str = number(str, + (unsigned long) va_arg(args, void *), 16, + field_width, precision, flags); + break; + + case 'x': + flags |= SMALL; + case 'X': + str = number(str, va_arg(args, unsigned long), 16, + field_width, precision, flags); + break; + + case 'd': + case 'i': + flags |= SIGN; + case 'u': + str = number(str, va_arg(args, unsigned long), 10, + field_width, precision, flags); + break; + + case 'n': + ip = va_arg(args, int *); + *ip = (str - buf); + break; + + default: + if (*fmt != '%') + *str++ = '%'; + if (*fmt) + *str++ = *fmt; + else + --fmt; + break; + } + } + *str = '\0'; + return str-buf; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/Makefile new file mode 100644 index 0000000..8916215 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/Makefile @@ -0,0 +1,73 @@ +# +# Makefile for some libs needed in the kernel. +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (ie not a .c file). +# + +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =gcc -mcpu=i386 +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions -nostdinc -I../include +CPP =gcc -E -nostdinc -I../include + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(AS) -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = ctype.o _exit.o open.o close.o errno.o write.o dup.o setsid.o \ + execve.o wait.o string.o malloc.o + +lib.a: $(OBJS) + $(AR) rcs lib.a $(OBJS) + sync + +clean: + rm -f core *.o *.a tmp_make + for i in *.c;do rm -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: +_exit.s _exit.o : _exit.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h +close.s close.o : close.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h +ctype.s ctype.o : ctype.c ../include/ctype.h +dup.s dup.o : dup.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h +errno.s errno.o : errno.c +execve.s execve.o : execve.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h +malloc.s malloc.o : malloc.c ../include/linux/kernel.h ../include/linux/mm.h \ + ../include/asm/system.h +open.s open.o : open.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h ../include/stdarg.h +setsid.s setsid.o : setsid.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h +string.s string.o : string.c ../include/string.h +wait.s wait.o : wait.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h ../include/sys/wait.h +write.s write.o : write.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/_exit.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/_exit.c new file mode 100644 index 0000000..c0c9d69 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/_exit.c @@ -0,0 +1,13 @@ +/* + * linux/lib/_exit.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +volatile void _exit(int exit_code) +{ + __asm__("int $0x80"::"a" (__NR_exit),"b" (exit_code)); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/close.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/close.c new file mode 100644 index 0000000..afd8364 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/close.c @@ -0,0 +1,10 @@ +/* + * linux/lib/close.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +_syscall1(int,close,int,fd) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/ctype.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/ctype.c new file mode 100644 index 0000000..877e629 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/ctype.c @@ -0,0 +1,35 @@ +/* + * linux/lib/ctype.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +char _ctmp; +unsigned char _ctype[] = {0x00, /* EOF */ +_C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ +_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ +_C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ +_C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ +_S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ +_P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ +_D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ +_D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ +_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ +_U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ +_U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ +_U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ +_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ +_L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ +_L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ +_L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 160-175 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 176-191 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 192-207 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 208-223 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 224-239 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* 240-255 */ + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/dup.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/dup.c new file mode 100644 index 0000000..dd13414 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/dup.c @@ -0,0 +1,10 @@ +/* + * linux/lib/dup.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +_syscall1(int,dup,int,fd) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/errno.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/errno.c new file mode 100644 index 0000000..50aca2e --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/errno.c @@ -0,0 +1,7 @@ +/* + * linux/lib/errno.c + * + * (C) 1991 Linus Torvalds + */ + +int errno; diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/execve.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/execve.c new file mode 100644 index 0000000..a89726d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/execve.c @@ -0,0 +1,10 @@ +/* + * linux/lib/execve.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +_syscall3(int,execve,const char *,file,char **,argv,char **,envp) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/malloc.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/malloc.c new file mode 100644 index 0000000..d48ae06 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/malloc.c @@ -0,0 +1,232 @@ +/* + * malloc.c --- a general purpose kernel memory allocator for Linux. + * + * Written by Theodore Ts'o (tytso@mit.edu), 11/29/91 + * + * This routine is written to be as fast as possible, so that it + * can be called from the interrupt level. + * + * Limitations: maximum size of memory we can allocate using this routine + * is 4k, the size of a page in Linux. + * + * The general game plan is that each page (called a bucket) will only hold + * objects of a given size. When all of the object on a page are released, + * the page can be returned to the general free pool. When malloc() is + * called, it looks for the smallest bucket size which will fulfill its + * request, and allocate a piece of memory from that bucket pool. + * + * Each bucket has as its control block a bucket descriptor which keeps + * track of how many objects are in use on that page, and the free list + * for that page. Like the buckets themselves, bucket descriptors are + * stored on pages requested from get_free_page(). However, unlike buckets, + * pages devoted to bucket descriptor pages are never released back to the + * system. Fortunately, a system should probably only need 1 or 2 bucket + * descriptor pages, since a page can hold 256 bucket descriptors (which + * corresponds to 1 megabyte worth of bucket pages.) If the kernel is using + * that much allocated memory, it's probably doing something wrong. :-) + * + * Note: malloc() and free() both call get_free_page() and free_page() + * in sections of code where interrupts are turned off, to allow + * malloc() and free() to be safely called from an interrupt routine. + * (We will probably need this functionality when networking code, + * particularily things like NFS, is added to Linux.) However, this + * presumes that get_free_page() and free_page() are interrupt-level + * safe, which they may not be once paging is added. If this is the + * case, we will need to modify malloc() to keep a few unused pages + * "pre-allocated" so that it can safely draw upon those pages if + * it is called from an interrupt routine. + * + * Another concern is that get_free_page() should not sleep; if it + * does, the code is carefully ordered so as to avoid any race + * conditions. The catch is that if malloc() is called re-entrantly, + * there is a chance that unecessary pages will be grabbed from the + * system. Except for the pages for the bucket descriptor page, the + * extra pages will eventually get released back to the system, though, + * so it isn't all that bad. + */ + +#include +#include +#include + +struct bucket_desc { /* 16 bytes */ + void *page; + struct bucket_desc *next; + void *freeptr; + unsigned short refcnt; + unsigned short bucket_size; +}; + +struct _bucket_dir { /* 8 bytes */ + int size; + struct bucket_desc *chain; +}; + +/* + * The following is the where we store a pointer to the first bucket + * descriptor for a given size. + * + * If it turns out that the Linux kernel allocates a lot of objects of a + * specific size, then we may want to add that specific size to this list, + * since that will allow the memory to be allocated more efficiently. + * However, since an entire page must be dedicated to each specific size + * on this list, some amount of temperance must be exercised here. + * + * Note that this list *must* be kept in order. + */ +struct _bucket_dir bucket_dir[] = { + { 16, (struct bucket_desc *) 0}, + { 32, (struct bucket_desc *) 0}, + { 64, (struct bucket_desc *) 0}, + { 128, (struct bucket_desc *) 0}, + { 256, (struct bucket_desc *) 0}, + { 512, (struct bucket_desc *) 0}, + { 1024, (struct bucket_desc *) 0}, + { 2048, (struct bucket_desc *) 0}, + { 4096, (struct bucket_desc *) 0}, + { 0, (struct bucket_desc *) 0}}; /* End of list marker */ + +/* + * This contains a linked list of free bucket descriptor blocks + */ +struct bucket_desc *free_bucket_desc = (struct bucket_desc *) 0; + +/* + * This routine initializes a bucket description page. + */ +static inline void init_bucket_desc() +{ + struct bucket_desc *bdesc, *first; + int i; + + first = bdesc = (struct bucket_desc *) get_free_page(); + if (!bdesc) + panic("Out of memory in init_bucket_desc()"); + for (i = PAGE_SIZE/sizeof(struct bucket_desc); i > 1; i--) { + bdesc->next = bdesc+1; + bdesc++; + } + /* + * This is done last, to avoid race conditions in case + * get_free_page() sleeps and this routine gets called again.... + */ + bdesc->next = free_bucket_desc; + free_bucket_desc = first; +} + +void *malloc(unsigned int len) +{ + struct _bucket_dir *bdir; + struct bucket_desc *bdesc; + void *retval; + + /* + * First we search the bucket_dir to find the right bucket change + * for this request. + */ + for (bdir = bucket_dir; bdir->size; bdir++) + if (bdir->size >= len) + break; + if (!bdir->size) { + printk("malloc called with impossibly large argument (%d)\n", + len); + panic("malloc: bad arg"); + } + /* + * Now we search for a bucket descriptor which has free space + */ + cli(); /* Avoid race conditions */ + for (bdesc = bdir->chain; bdesc; bdesc = bdesc->next) + if (bdesc->freeptr) + break; + /* + * If we didn't find a bucket with free space, then we'll + * allocate a new one. + */ + if (!bdesc) { + char *cp; + int i; + + if (!free_bucket_desc) + init_bucket_desc(); + bdesc = free_bucket_desc; + free_bucket_desc = bdesc->next; + bdesc->refcnt = 0; + bdesc->bucket_size = bdir->size; + bdesc->page = bdesc->freeptr = (void *) cp = get_free_page(); + if (!cp) + panic("Out of memory in kernel malloc()"); + /* Set up the chain of free objects */ + for (i=PAGE_SIZE/bdir->size; i > 1; i--) { + *((char **) cp) = cp + bdir->size; + cp += bdir->size; + } + *((char **) cp) = 0; + bdesc->next = bdir->chain; /* OK, link it in! */ + bdir->chain = bdesc; + } + retval = (void *) bdesc->freeptr; + bdesc->freeptr = *((void **) retval); + bdesc->refcnt++; + sti(); /* OK, we're safe again */ + return(retval); +} + +/* + * Here is the free routine. If you know the size of the object that you + * are freeing, then free_s() will use that information to speed up the + * search for the bucket descriptor. + * + * We will #define a macro so that "free(x)" is becomes "free_s(x, 0)" + */ +void free_s(void *obj, int size) +{ + void *page; + struct _bucket_dir *bdir; + struct bucket_desc *bdesc, *prev; + bdesc = prev = 0; + /* Calculate what page this object lives in */ + page = (void *) ((unsigned long) obj & 0xfffff000); + /* Now search the buckets looking for that page */ + for (bdir = bucket_dir; bdir->size; bdir++) { + prev = 0; + /* If size is zero then this conditional is always false */ + if (bdir->size < size) + continue; + for (bdesc = bdir->chain; bdesc; bdesc = bdesc->next) { + if (bdesc->page == page) + goto found; + prev = bdesc; + } + } + panic("Bad address passed to kernel free_s()"); +found: + cli(); /* To avoid race conditions */ + *((void **)obj) = bdesc->freeptr; + bdesc->freeptr = obj; + bdesc->refcnt--; + if (bdesc->refcnt == 0) { + /* + * We need to make sure that prev is still accurate. It + * may not be, if someone rudely interrupted us.... + */ + if ((prev && (prev->next != bdesc)) || + (!prev && (bdir->chain != bdesc))) + for (prev = bdir->chain; prev; prev = prev->next) + if (prev->next == bdesc) + break; + if (prev) + prev->next = bdesc->next; + else { + if (bdir->chain != bdesc) + panic("malloc bucket chains corrupted"); + bdir->chain = bdesc->next; + } + free_page((unsigned long) bdesc->page); + bdesc->next = free_bucket_desc; + free_bucket_desc = bdesc; + } + sti(); + return; +} + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/open.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/open.c new file mode 100644 index 0000000..8c3fc58 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/open.c @@ -0,0 +1,25 @@ +/* + * linux/lib/open.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include +#include + +int open(const char * filename, int flag, ...) +{ + register int res; + va_list arg; + + va_start(arg,flag); + __asm__("int $0x80" + :"=a" (res) + :"0" (__NR_open),"b" (filename),"c" (flag), + "d" (va_arg(arg,int))); + if (res>=0) + return res; + errno = -res; + return -1; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/setsid.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/setsid.c new file mode 100644 index 0000000..68516c7 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/setsid.c @@ -0,0 +1,10 @@ +/* + * linux/lib/setsid.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +_syscall0(pid_t,setsid) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/string.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/string.c new file mode 100644 index 0000000..1182e63 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/string.c @@ -0,0 +1,14 @@ +/* + * linux/lib/string.c + * + * (C) 1991 Linus Torvalds + */ + +#ifndef __GNUC__ +#error I want gcc! +#endif + +#define extern +#define inline +#define __LIBRARY__ +#include diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/wait.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/wait.c new file mode 100644 index 0000000..2815c16 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/wait.c @@ -0,0 +1,16 @@ +/* + * linux/lib/wait.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include +#include + +_syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options) + +pid_t wait(int * wait_stat) +{ + return waitpid(-1,wait_stat,0); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/write.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/write.c new file mode 100644 index 0000000..df52e74 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/lib/write.c @@ -0,0 +1,10 @@ +/* + * linux/lib/write.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +_syscall3(int,write,int,fd,const char *,buf,off_t,count) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/mm/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/mm/Makefile new file mode 100644 index 0000000..d53d91d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/mm/Makefile @@ -0,0 +1,38 @@ +CC =gcc -mcpu=i386 +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions -nostdinc -I../include +AS =as +AR =ar +LD =ld +CPP =gcc -E -nostdinc -I../include + +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< +.s.o: + $(AS) -o $*.o $< +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< + +OBJS = memory.o page.o + +all: mm.o + +mm.o: $(OBJS) + $(LD) -r -o mm.o $(OBJS) + +clean: + rm -f core *.o *.a tmp_make + for i in *.c;do rm -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: +memory.o: memory.c ../include/signal.h ../include/sys/types.h \ + ../include/asm/system.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \ + ../include/linux/kernel.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/mm/memory.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/mm/memory.c new file mode 100644 index 0000000..43f601b --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/mm/memory.c @@ -0,0 +1,431 @@ +/* + * linux/mm/memory.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * demand-loading started 01.12.91 - seems it is high on the list of + * things wanted, and it should be easy to implement. - Linus + */ + +/* + * Ok, demand-loading was easy, shared pages a little bit tricker. Shared + * pages started 02.12.91, seems to work. - Linus. + * + * Tested sharing by executing about 30 /bin/sh: under the old kernel it + * would have taken more than the 6M I have free, but it worked well as + * far as I could see. + * + * Also corrected some "invalidate()"s - I wasn't doing enough of them. + */ + +#include + +#include + +#include +#include +#include + +volatile void do_exit(long code); + +static inline volatile void oom(void) +{ + printk("out of memory\n\r"); + do_exit(SIGSEGV); +} + +#define invalidate() \ +__asm__("movl %%eax,%%cr3"::"a" (0)) + +/* these are not to be changed without changing head.s etc */ +#define LOW_MEM 0x100000 +#define PAGING_MEMORY (15*1024*1024) +#define PAGING_PAGES (PAGING_MEMORY>>12) +#define MAP_NR(addr) (((addr)-LOW_MEM)>>12) +#define USED 100 + +#define CODE_SPACE(addr) ((((addr)+4095)&~4095) < \ +current->start_code + current->end_code) + +static long HIGH_MEMORY = 0; + +#define copy_page(from,to) \ +__asm__("cld ; rep ; movsl"::"S" (from),"D" (to),"c" (1024)) + +static unsigned char mem_map [ PAGING_PAGES ] = {0,}; + +/* + * Get physical address of first (actually last :-) free page, and mark it + * used. If no free pages left, return 0. + */ +unsigned long get_free_page(void) +{ +register unsigned long __res asm("ax"); + +__asm__("std ; repne ; scasb\n\t" + "jne 1f\n\t" + "movb $1,1(%%edi)\n\t" + "sall $12,%%ecx\n\t" + "addl %2,%%ecx\n\t" + "movl %%ecx,%%edx\n\t" + "movl $1024,%%ecx\n\t" + "leal 4092(%%edx),%%edi\n\t" + "rep ; stosl\n\t" + "movl %%edx,%%eax\n" + "1:" + :"=a" (__res) + :"0" (0),"i" (LOW_MEM),"c" (PAGING_PAGES), + "D" (mem_map+PAGING_PAGES-1) + ); +return __res; +} + +/* + * Free a page of memory at physical address 'addr'. Used by + * 'free_page_tables()' + */ +void free_page(unsigned long addr) +{ + if (addr < LOW_MEM) return; + if (addr >= HIGH_MEMORY) + panic("trying to free nonexistent page"); + addr -= LOW_MEM; + addr >>= 12; + if (mem_map[addr]--) return; + mem_map[addr]=0; + panic("trying to free free page"); +} + +/* + * This function frees a continuos block of page tables, as needed + * by 'exit()'. As does copy_page_tables(), this handles only 4Mb blocks. + */ +int free_page_tables(unsigned long from,unsigned long size) +{ + unsigned long *pg_table; + unsigned long * dir, nr; + + if (from & 0x3fffff) + panic("free_page_tables called with wrong alignment"); + if (!from) + panic("Trying to free up swapper memory space"); + size = (size + 0x3fffff) >> 22; + dir = (unsigned long *) ((from>>20) & 0xffc); /* _pg_dir = 0 */ + for ( ; size-->0 ; dir++) { + if (!(1 & *dir)) + continue; + pg_table = (unsigned long *) (0xfffff000 & *dir); + for (nr=0 ; nr<1024 ; nr++) { + if (1 & *pg_table) + free_page(0xfffff000 & *pg_table); + *pg_table = 0; + pg_table++; + } + free_page(0xfffff000 & *dir); + *dir = 0; + } + invalidate(); + return 0; +} + +/* + * Well, here is one of the most complicated functions in mm. It + * copies a range of linerar addresses by copying only the pages. + * Let's hope this is bug-free, 'cause this one I don't want to debug :-) + * + * Note! We don't copy just any chunks of memory - addresses have to + * be divisible by 4Mb (one page-directory entry), as this makes the + * function easier. It's used only by fork anyway. + * + * NOTE 2!! When from==0 we are copying kernel space for the first + * fork(). Then we DONT want to copy a full page-directory entry, as + * that would lead to some serious memory waste - we just copy the + * first 160 pages - 640kB. Even that is more than we need, but it + * doesn't take any more memory - we don't copy-on-write in the low + * 1 Mb-range, so the pages can be shared with the kernel. Thus the + * special case for nr=xxxx. + */ +int copy_page_tables(unsigned long from,unsigned long to,long size) +{ + unsigned long * from_page_table; + unsigned long * to_page_table; + unsigned long this_page; + unsigned long * from_dir, * to_dir; + unsigned long nr; + + if ((from&0x3fffff) || (to&0x3fffff)) + panic("copy_page_tables called with wrong alignment"); + from_dir = (unsigned long *) ((from>>20) & 0xffc); /* _pg_dir = 0 */ + to_dir = (unsigned long *) ((to>>20) & 0xffc); + size = ((unsigned) (size+0x3fffff)) >> 22; + for( ; size-->0 ; from_dir++,to_dir++) { + if (1 & *to_dir) + panic("copy_page_tables: already exist"); + if (!(1 & *from_dir)) + continue; + from_page_table = (unsigned long *) (0xfffff000 & *from_dir); + if (!(to_page_table = (unsigned long *) get_free_page())) + return -1; /* Out of memory, see freeing */ + *to_dir = ((unsigned long) to_page_table) | 7; + nr = (from==0)?0xA0:1024; + for ( ; nr-- > 0 ; from_page_table++,to_page_table++) { + this_page = *from_page_table; + if (!(1 & this_page)) + continue; + this_page &= ~2; + *to_page_table = this_page; + if (this_page > LOW_MEM) { + *from_page_table = this_page; + this_page -= LOW_MEM; + this_page >>= 12; + mem_map[this_page]++; + } + } + } + invalidate(); + return 0; +} + +/* + * This function puts a page in memory at the wanted address. + * It returns the physical address of the page gotten, 0 if + * out of memory (either when trying to access page-table or + * page.) + */ +unsigned long put_page(unsigned long page,unsigned long address) +{ + unsigned long tmp, *page_table; + +/* NOTE !!! This uses the fact that _pg_dir=0 */ + + if (page < LOW_MEM || page >= HIGH_MEMORY) + printk("Trying to put page %p at %p\n",page,address); + if (mem_map[(page-LOW_MEM)>>12] != 1) + printk("mem_map disagrees with %p at %p\n",page,address); + page_table = (unsigned long *) ((address>>20) & 0xffc); + if ((*page_table)&1) + page_table = (unsigned long *) (0xfffff000 & *page_table); + else { + if (!(tmp=get_free_page())) + return 0; + *page_table = tmp|7; + page_table = (unsigned long *) tmp; + } + page_table[(address>>12) & 0x3ff] = page | 7; +/* no need for invalidate */ + return page; +} + +void un_wp_page(unsigned long * table_entry) +{ + unsigned long old_page,new_page; + + old_page = 0xfffff000 & *table_entry; + if (old_page >= LOW_MEM && mem_map[MAP_NR(old_page)]==1) { + *table_entry |= 2; + invalidate(); + return; + } + if (!(new_page=get_free_page())) + oom(); + if (old_page >= LOW_MEM) + mem_map[MAP_NR(old_page)]--; + *table_entry = new_page | 7; + invalidate(); + copy_page(old_page,new_page); +} + +/* + * This routine handles present pages, when users try to write + * to a shared page. It is done by copying the page to a new address + * and decrementing the shared-page counter for the old page. + * + * If it's in code space we exit with a segment error. + */ +void do_wp_page(unsigned long error_code,unsigned long address) +{ +#if 0 +/* we cannot do this yet: the estdio library writes to code space */ +/* stupid, stupid. I really want the libc.a from GNU */ + if (CODE_SPACE(address)) + do_exit(SIGSEGV); +#endif + un_wp_page((unsigned long *) + (((address>>10) & 0xffc) + (0xfffff000 & + *((unsigned long *) ((address>>20) &0xffc))))); + +} + +void write_verify(unsigned long address) +{ + unsigned long page; + + if (!( (page = *((unsigned long *) ((address>>20) & 0xffc)) )&1)) + return; + page &= 0xfffff000; + page += ((address>>10) & 0xffc); + if ((3 & *(unsigned long *) page) == 1) /* non-writeable, present */ + un_wp_page((unsigned long *) page); + return; +} + +void get_empty_page(unsigned long address) +{ + unsigned long tmp; + + if (!(tmp=get_free_page()) || !put_page(tmp,address)) { + free_page(tmp); /* 0 is ok - ignored */ + oom(); + } +} + +/* + * try_to_share() checks the page at address "address" in the task "p", + * to see if it exists, and if it is clean. If so, share it with the current + * task. + * + * NOTE! This assumes we have checked that p != current, and that they + * share the same executable. + */ +static int try_to_share(unsigned long address, struct task_struct * p) +{ + unsigned long from; + unsigned long to; + unsigned long from_page; + unsigned long to_page; + unsigned long phys_addr; + + from_page = to_page = ((address>>20) & 0xffc); + from_page += ((p->start_code>>20) & 0xffc); + to_page += ((current->start_code>>20) & 0xffc); +/* is there a page-directory at from? */ + from = *(unsigned long *) from_page; + if (!(from & 1)) + return 0; + from &= 0xfffff000; + from_page = from + ((address>>10) & 0xffc); + phys_addr = *(unsigned long *) from_page; +/* is the page clean and present? */ + if ((phys_addr & 0x41) != 0x01) + return 0; + phys_addr &= 0xfffff000; + if (phys_addr >= HIGH_MEMORY || phys_addr < LOW_MEM) + return 0; + to = *(unsigned long *) to_page; + if (!(to & 1)) { + if ((to = get_free_page())) + *(unsigned long *) to_page = to | 7; + else + oom(); + } + to &= 0xfffff000; + to_page = to + ((address>>10) & 0xffc); + if (1 & *(unsigned long *) to_page) + panic("try_to_share: to_page already exists"); +/* share them: write-protect */ + *(unsigned long *) from_page &= ~2; + *(unsigned long *) to_page = *(unsigned long *) from_page; + invalidate(); + phys_addr -= LOW_MEM; + phys_addr >>= 12; + mem_map[phys_addr]++; + return 1; +} + +/* + * share_page() tries to find a process that could share a page with + * the current one. Address is the address of the wanted page relative + * to the current data space. + * + * We first check if it is at all feasible by checking executable->i_count. + * It should be >1 if there are other tasks sharing this inode. + */ +static int share_page(unsigned long address) +{ + struct task_struct ** p; + + if (!current->executable) + return 0; + if (current->executable->i_count < 2) + return 0; + for (p = &LAST_TASK ; p > &FIRST_TASK ; --p) { + if (!*p) + continue; + if (current == *p) + continue; + if ((*p)->executable != current->executable) + continue; + if (try_to_share(address,*p)) + return 1; + } + return 0; +} + +void do_no_page(unsigned long error_code,unsigned long address) +{ + int nr[4]; + unsigned long tmp; + unsigned long page; + int block,i; + + address &= 0xfffff000; + tmp = address - current->start_code; + if (!current->executable || tmp >= current->end_data) { + get_empty_page(address); + return; + } + if (share_page(tmp)) + return; + if (!(page = get_free_page())) + oom(); +/* remember that 1 block is used for header */ + block = 1 + tmp/BLOCK_SIZE; + for (i=0 ; i<4 ; block++,i++) + nr[i] = bmap(current->executable,block); + bread_page(page,current->executable->i_dev,nr); + i = tmp + 4096 - current->end_data; + tmp = page + 4096; + while (i-- > 0) { + tmp--; + *(char *)tmp = 0; + } + if (put_page(page,address)) + return; + free_page(page); + oom(); +} + +void mem_init(long start_mem, long end_mem) +{ + int i; + + HIGH_MEMORY = end_mem; + for (i=0 ; i>= 12; + while (end_mem-->0) + mem_map[i++]=0; +} + +void calc_mem(void) +{ + int i,j,k,free=0; + long * pg_tbl; + + for(i=0 ; i /* fprintf */ +#include +#include /* contains exit */ +#include /* unistd.h needs this */ +#include +//#include +#include /* contains read/write */ +#include + +#define MINIX_HEADER 32 +#define GCC_HEADER 1024 + +#define SYS_SIZE 0x3000 + +#define DEFAULT_MAJOR_ROOT 2 +#define DEFAULT_MINOR_ROOT 0x1d + +/* max nr of sectors of setup: don't change unless you also change + * bootsect etc */ +#define SETUP_SECTS 4 + +#define STRINGIFY(x) #x + +#define MAJOR(a) (((unsigned)(a))>>8) +#define MINOR(a) ((a)&0xff) + +void die(char * str) +{ + fprintf(stderr,"%s\n",str); + exit(1); +} + +void usage(void) +{ + die("Usage: build bootsect setup system [rootdev] [> image]"); +} + +int main(int argc, char ** argv) +{ + int i,c,id; + char buf[1024]; + char major_root, minor_root; + struct stat sb; + int size=512+4*512; + FILE* imageFile = fopen("Boot.img","wb"); + + if ((argc != 4) && (argc != 5)) + usage(); + if (argc == 5) { + if (strcmp(argv[4], "FLOPPY")) { + if (stat(argv[4], &sb)) { + perror(argv[4]); + die("Couldn't stat root device."); + } + major_root = MAJOR(sb.st_rdev); + minor_root = MINOR(sb.st_rdev); + } else { + major_root = 0; + minor_root = 0; + } + } else { + major_root = DEFAULT_MAJOR_ROOT; + minor_root = DEFAULT_MINOR_ROOT; + } + fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root); + if ((major_root != 2) && (major_root != 3) && + (major_root != 0)) { + fprintf(stderr, "Illegal root device (major = %d)\n", + major_root); + die("Bad root device --- major #"); + } + + + for (i=0;i0 ; i+=c ) + if (write(1,buf,c)!=c) + die("Write call failed"); + close (id); + */ + for (i=0 ; (c=read(id,buf,sizeof buf))>0 ; i+=c ) + { + if (fwrite(buf,1,c,imageFile)!=c) + { + die("Write call failed"); + } + } + close (id); + + if (i > SETUP_SECTS*512) + { + die("Setup exceeds " STRINGIFY(SETUP_SECTS)" sectors - rewrite build/boot/setup"); + } + fprintf(stderr,"Setup is %d bytes.\n",i); + for (c=0 ; c sizeof(buf)) + { + c = sizeof(buf); + } +// if (write(1,buf,c) != c) + if( c != fwrite(buf,1,c,imageFile) ) + { + die("Write call failed"); + } + i += c; + } + + if ( (id=open(argv[3],O_RDONLY|O_BINARY,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'"); + for (i=0 ; (c=read(id,buf,sizeof buf))>0 ; i+=c ) + { + if (fwrite(buf,1,c,imageFile)!= c) + die("Write call failed"); + } + close(id); + size+=i; + fprintf(stderr,"System is %d bytes.\n",i); + if (i > SYS_SIZE*16) + die("System is too big"); + memset(buf,0,sizeof(buf)); + + fprintf(stderr,"total size is %d bytes.\n",1440*1024); + + //1475084 + //1474560 + while(size<1440*1024) + { + c = 1440*1024 - size; + if( c > sizeof(buf) ) + { + c = sizeof(buf); + } + c = fwrite(buf,1,c,imageFile); + size+=c; + } + + fclose(imageFile); + return(0); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/tools/build.exe b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/tools/build.exe new file mode 100644 index 0000000..d6dacf2 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/tools/build.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/tools/trans.exe b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/tools/trans.exe new file mode 100644 index 0000000..bfecea1 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11-With-PE-Loader/tools/trans.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/Boot.img b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/Boot.img new file mode 100644 index 0000000..d44fff0 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/Boot.img differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/Makefile new file mode 100644 index 0000000..6d7c177 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/Makefile @@ -0,0 +1,184 @@ +# +# if you want the ram-disk device, define this to be the +# size in blocks. +# +RAMDISK = #-DRAMDISK=512 + +#AS86 =as86 -0 -a +#LD86 =ld86 -0 + +INC=boot +AS86 = nasm +DASM = ndisasm + +AS =as +LD =ld +#LDFLAGS = -m elf_i386 -Ttext 0 -e startup_32 +LDFLAGS = -m i386pe -Ttext 0 -e startup_32 -s -M --image-base 0x0000 +CC =gcc -march=i386 $(RAMDISK) +CFLAGS =-Wall -O2 -fomit-frame-pointer -fno-builtin + + + +CPP =cpp -nostdinc -Iinclude + +# +# ROOT_DEV specifies the default root-device when making the image. +# This can be either FLOPPY, /dev/xxxx or empty, in which case the +# default of /dev/hd6 is used by 'build'. +# +ROOT_DEV= #FLOPPY + +BLK_DRV_SRC = kernel/blk_drv/ll_rw_blk.c kernel/blk_drv/floppy.c \ + kernel/blk_drv/hd.c kernel/blk_drv/ramdisk.c + +CHR_DRV_SRC = kernel/chr_drv/tty_io.c kernel/chr_drv/console.c kernel/chr_drv/keyboard.s \ + kernel/chr_drv/serial.c kernel/chr_drv/rs_io.s \ + kernel/chr_drv/tty_ioctl.s + +KERNEL_SRC = kernel/sched.c kernel/system_call.s kernel/traps.s kernel/asm.s kernel/fork.c \ + kernel/panic.c kernel/printk.c kernel/vsprintf.c kernel/sys.c kernel/exit.c \ + kernel/signal.c kernel/mktime.c + +MM_SRC = mm/memory.c mm/page.s + +FS_SRC= fs/open.c fs/read_write.c fs/inode.c fs/file_table.c fs/buffer.c fs/super.c \ + fs/block_dev.c fs/char_dev.c fs/file_dev.c fs/stat.c fs/exec.c fs/pipe.c fs/namei.c \ + fs/bitmap.c fs/fcntl.c fs/ioctl.c fs/truncate.c + +LIB_SRC = lib/ctype.c lib/_exit.c lib/open.c lib/close.c lib/errno.c lib/write.c lib/dup.c lib/setsid.c \ + lib/execve.c lib/wait.c lib/string.c lib/malloc.c + +ARCHIVES=kernel/kernel.o mm/mm.o fs/fs.o +#ARCHIVES=$(KERNEL_OBJS) mm/mm.o fs/fs.o + +DRIVERS =kernel/blk_drv/blk_drv.a kernel/chr_drv/chr_drv.a + +MATH =kernel/math/math.a +LIBS =lib/lib.a + +.c.s: + $(CC) $(CFLAGS) \ + -nostdinc -Iinclude -S -o $*.s $< +.s.o: + $(AS) -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -nostdinc -Iinclude -c -o $*.o $< + +all: Boot.img + +KERNEL_FILE = tools/system.bin + +tools/system.bin : tools/system.exe + tools/Trans.exe tools/System.exe tools/system.bin + +Boot.img: boot/bootsect.bin boot/setup.bin $(KERNEL_FILE) tools/build.exe Makefile +# objcopy -O binary -R .note -R .comment tools/system tools/kernel + tools\build.exe boot/bootsect.bin boot/setup.bin $(KERNEL_FILE) $(ROOT_DEV) +# rm tools/kernel -f +# sync +# del tools\kernel + +disk: Image + dd bs=8192 if=Image of=/dev/fd0 + +tools/build.exe: tools/build.c + $(CC) $(CFLAGS) -o tools/build tools/build.c + +boot/head.o: boot/head.s + gcc -I./include -traditional -c boot/head.s -o boot/head.o +# move head.o boot/ + +tools/system.exe: boot/head.o init/main.o \ + $(ARCHIVES) $(DRIVERS) $(MATH) $(LIBS) + $(LD) $(LDFLAGS) boot/head.o init/main.o \ + $(ARCHIVES) \ + $(DRIVERS) \ + $(MATH) \ + $(LIBS) \ + -o tools/system.exe >system.map +# nm tools/system | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aU] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)'| sort > System.map + +kernel/math/math.a:kernel/math/math_emulate.o +# (cd kernel/math ; make) + (cd kernel/math & make) + +kernel/blk_drv/blk_drv.a:$(BLK_DRV_SRC) +# (cd kernel/blk_drv ; make) + (cd kernel/blk_drv & make) + +kernel/chr_drv/chr_drv.a:$(CHR_DRV_SRC) +# (cd kernel/chr_drv ; make) + (cd kernel/chr_drv & make) + +kernel/kernel.o:$(KERNEL_SRC) +# (cd kernel; make) + (cd kernel & make) + +mm/mm.o:$(MM_SRC) +# (cd mm; make) + (cd mm & make) + +fs/fs.o:$(FS_SRC) +# (cd fs; make) + (cd fs & make) + +lib/lib.a:$(LIB_SRC) + (cd lib & make) + +boot/setup.bin: boot/setup.asm + $(AS86) -I"$(INC)"\ -o boot/setup.bin boot/setup.asm + $(DASM) -b 16 boot/setup.bin >boot/setup.disasm +# $(LD86) -s -o boot/setup boot/setup.o + +boot/bootsect.bin: boot/bootsect.asm + $(AS86) -I"$(INC)"\ -o boot/bootsect.bin boot/bootsect.asm + $(DASM) -b 16 boot/bootsect.bin >boot/bootsect.disasm +# $(LD86) -s -o boot/bootsect boot/bootsect.o + +tmp.s: boot/bootsect.s tools/system +# (echo -n "SYSSIZE = (";ls -l tools/system | grep system \ +# | cut -c25-31 | tr '\012' ' '; echo "+ 15 ) / 16") > tmp.s + cat boot/bootsect.s >> tmp.s + +clean: +# rm -f Image System.map tmp_make core boot/bootsect boot/setup +# rm -f init/*.o tools/system tools/build boot/*.o +# (cd mm;make clean) +# (cd fs;make clean) +# (cd kernel;make clean) +# (cd lib;make clean) + @del /S /Q *.a *.o system.map tools\system.exe +# del Image System.map tmp_make core boot\bootsect boot\setup +# del init\*.o tools\system tools\build boot\*.o +# (cd mm & make clean) +# (cd fs & make clean) +# (cd kernel & make clean) +# (cd lib &make clean) + + +backup: clean + (cd .. ; tar cf - linux | compress16 - > backup.Z) + sync + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done) >> tmp_make +# cp tmp_make Makefile +# (cd fs; make dep) +# (cd kernel; make dep) +# (cd mm; make dep) + + copy tmp_make Makefile + (cd fs & make dep) + (cd kernel & make dep) + (cd mm & make dep) + +### Dependencies: +init/main.o: init/main.c include/unistd.h include/sys/stat.h \ + include/sys/types.h include/sys/times.h include/sys/utsname.h \ + include/utime.h include/time.h include/linux/tty.h include/termios.h \ + include/linux/sched.h include/linux/head.h include/linux/fs.h \ + include/linux/mm.h include/signal.h include/asm/system.h \ + include/asm/io.h include/stddef.h include/stdarg.h include/fcntl.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/MinGW32.bat.lnk b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/MinGW32.bat.lnk new file mode 100644 index 0000000..e16f2bc Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/MinGW32.bat.lnk differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/bochsout.txt b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/bochsout.txt new file mode 100644 index 0000000..2bf77ce --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/bochsout.txt @@ -0,0 +1,146 @@ +00000000000i[ ] Bochs x86 Emulator 2.3.6 +00000000000i[ ] Build from CVS snapshot, on December 24, 2007 +00000000000i[ ] System configuration +00000000000i[ ] processors: 1 (cores=1, HT threads=1) +00000000000i[ ] A20 line support: yes +00000000000i[ ] APIC support: yes +00000000000i[ ] CPU configuration +00000000000i[ ] level: 6 +00000000000i[ ] TLB enabled: yes +00000000000i[ ] SMP support: no +00000000000i[ ] FPU support: yes +00000000000i[ ] MMX support: yes +00000000000i[ ] SSE support: 2 +00000000000i[ ] CLFLUSH support: yes +00000000000i[ ] VME support: yes +00000000000i[ ] 3dnow! support: no +00000000000i[ ] PAE support: yes +00000000000i[ ] PGE support: yes +00000000000i[ ] PSE support: yes +00000000000i[ ] x86-64 support: yes +00000000000i[ ] SEP support: yes +00000000000i[ ] MWAIT support: no +00000000000i[ ] Optimization configuration +00000000000i[ ] Guest2HostTLB support: yes +00000000000i[ ] RepeatSpeedups support: yes +00000000000i[ ] Icache support: yes +00000000000i[ ] Trace cache support: yes +00000000000i[ ] Fast function calls: yes +00000000000i[ ] Devices configuration +00000000000i[ ] ACPI support: yes +00000000000i[ ] NE2000 support: yes +00000000000i[ ] PCI support: yes +00000000000i[ ] SB16 support: yes +00000000000i[ ] USB support: yes +00000000000i[ ] VGA extension support: vbe cirrus +00000000000i[MEM0 ] allocated memory at 03A73020. after alignment, vector=03A74000 +00000000000i[MEM0 ] 32.00MB +00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('C:\software\Bochs-2.3.6/BIOS-bochs-latest') +00000000000i[MEM0 ] rom at 0xc0000/32768 ('C:\software\Bochs-2.3.6/VGABIOS-elpin-2.40') +00000000000i[APIC?] set APIC ID to 0 +00000000000i[APIC0] 80686 +00000000000i[APIC0] local apic in CPU apicid=00 initializing +00000000000i[IOAP ] initializing I/O APIC +00000000000i[IOAP ] set APIC ID to 1 +00000000000i[MEM0 ] Register memory access handlers: fec00000-fec00fff +00000000000i[CMOS ] Using local time for initial clock +00000000000i[CMOS ] Setting initial clock to: Fri Nov 12 23:17:12 2021 (time0=1636730232) +00000000000i[DMA ] channel 4 used by cascade +00000000000i[DMA ] channel 2 used by Floppy Drive +00000000000i[FDD ] fd0: 'boot.img' ro=0, h=2,t=80,spt=18 +00000000000i[FDD ] fd1: 'rootimage-0.11.img' ro=0, h=2,t=80,spt=18 +00000000000i[PCI ] 440FX Host bridge present at device 0, function 0 +00000000000i[PCI ] PIIX3 PCI-to-ISA bridge present at device 1, function 0 +00000000000i[MEM0 ] Register memory access handlers: 000a0000-000bffff +00000000000i[WGUI ] Desktop Window dimensions: 1920 x 1080 +00000000000i[WGUI ] Number of Mouse Buttons = 16 +00000000000i[WGUI ] IME disabled +00000000000i[KMAP ] Loading keymap from 'C:\software\Bochs-2.3.6/keymaps/x11-pc-us.map' +00000000000i[KMAP ] Loaded 168 symbols +00000000000i[MEM0 ] Register memory access handlers: e0000000-e07fffff +00000000000i[CLVGA] VBE Bochs Display Extension Enabled +00000000000i[CLVGA] interval=40000 +00000000000i[ ] init_mem of 'harddrv' plugin device by virtual method +00000000000i[ ] init_mem of 'keyboard' plugin device by virtual method +00000000000i[ ] init_mem of 'serial' plugin device by virtual method +00000000000i[ ] init_mem of 'parallel' plugin device by virtual method +00000000000i[ ] init_mem of 'extfpuirq' plugin device by virtual method +00000000000i[ ] init_mem of 'gameport' plugin device by virtual method +00000000000i[ ] init_mem of 'speaker' plugin device by virtual method +00000000000i[ ] init_mem of 'pci_ide' plugin device by virtual method +00000000000i[ ] init_mem of 'acpi' plugin device by virtual method +00000000000i[ ] init_dev of 'harddrv' plugin device by virtual method +00000000000i[HD ] HD on ata0-0: 'hdc-0.11.img' 'flat' mode +00000000000i[HD ] translation on ata0-0 set to 'none' +00000000000i[HD ] Using boot sequence floppy, none, none +00000000000i[HD ] Floppy boot signature check is enabled +00000000000i[ ] init_dev of 'keyboard' plugin device by virtual method +00000000000i[KBD ] will paste characters every 1000 keyboard ticks +00000000000i[ ] init_dev of 'serial' plugin device by virtual method +00000000000i[SER ] com1 at 0x03f8 irq 4 +00000000000i[ ] init_dev of 'parallel' plugin device by virtual method +00000000000i[PAR ] parallel port 1 at 0x0378 irq 7 +00000000000i[ ] init_dev of 'extfpuirq' plugin device by virtual method +00000000000i[ ] init_dev of 'gameport' plugin device by virtual method +00000000000i[ ] init_dev of 'speaker' plugin device by virtual method +00000000000i[ ] init_dev of 'pci_ide' plugin device by virtual method +00000000000i[PCI ] PIIX3 PCI IDE controller present at device 1, function 1 +00000000000i[ ] init_dev of 'acpi' plugin device by virtual method +00000000000i[PCI ] ACPI Controller present at device 1, function 3 +00000000000i[ ] register state of 'harddrv' plugin device by virtual method +00000000000i[ ] register state of 'keyboard' plugin device by virtual method +00000000000i[ ] register state of 'serial' plugin device by virtual method +00000000000i[ ] register state of 'parallel' plugin device by virtual method +00000000000i[ ] register state of 'extfpuirq' plugin device by virtual method +00000000000i[ ] register state of 'gameport' plugin device by virtual method +00000000000i[ ] register state of 'speaker' plugin device by virtual method +00000000000i[ ] register state of 'pci_ide' plugin device by virtual method +00000000000i[ ] register state of 'acpi' plugin device by virtual method +00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called +00000000000i[CPU0 ] cpu hardware reset +00000000000i[APIC0] local apic in CPU 0 initializing +00000000000i[ ] reset of 'harddrv' plugin device by virtual method +00000000000i[ ] reset of 'keyboard' plugin device by virtual method +00000000000i[ ] reset of 'serial' plugin device by virtual method +00000000000i[ ] reset of 'parallel' plugin device by virtual method +00000000000i[ ] reset of 'extfpuirq' plugin device by virtual method +00000000000i[ ] reset of 'gameport' plugin device by virtual method +00000000000i[ ] reset of 'speaker' plugin device by virtual method +00000000000i[ ] reset of 'pci_ide' plugin device by virtual method +00000000000i[ ] reset of 'acpi' plugin device by virtual method +00000003445i[BIOS ] $Revision: 1.193 $ $Date: 2007/12/20 18:12:11 $ +00000317060i[KBD ] reset-disable command received +00000335566i[BIOS ] Starting rombios32 +00000336278i[BIOS ] ram_size=0x02000000 +00000356699i[BIOS ] Found 1 cpu(s) +00000372171i[BIOS ] bios_table_addr: 0x000faff8 end=0x000fe05b +00000372245i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush) +00000699980i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush) +00001028427i[P2I ] PCI IRQ routing: PIRQA# set to 0x0b +00001028476i[P2I ] PCI IRQ routing: PIRQB# set to 0x09 +00001028525i[P2I ] PCI IRQ routing: PIRQC# set to 0x0b +00001028574i[P2I ] PCI IRQ routing: PIRQD# set to 0x09 +00001028589i[P2I ] write: ELCR2 = 0x0a +00001029390i[BIOS ] PIIX3 init: elcr=00 0a +00001050303i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237 +00001053276i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000 +00001055717i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010 +00001056199i[PIDE ] new BM-DMA address: 0xc000 +00001056953i[BIOS ] region 4: 0x0000c000 +00001059228i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113 +00001059759i[ACPI ] new irq line = 11 +00001059795i[ACPI ] new PM base address: 0xb000 +00001059862i[ACPI ] new SM base address: 0xb100 +00001060247i[CPU0 ] Enter to System Management Mode +00001060257i[CPU0 ] RSM: Resuming from System Management Mode +00001060291i[PCI ] setting SMRAM control register to 0x4a +00001060509i[PCI ] setting SMRAM control register to 0x0a +00001084184i[BIOS ] MP table addr=0x000fb0d0 MPC table addr=0x000fb000 size=0xd0 +00001086117i[BIOS ] ACPI tables: RSDP addr=0x000fb0e0 ACPI DATA addr=0x01ff0000 size=0x978 +00001098987i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush) +00001360000i[WGUI ] dimension update x=720 y=400 fontheight=16 fontwidth=9 bpp=8 +00009174963i[BIOS ] ata0-0: PCHS=121/16/63 translation=none LCHS=121/16/63 +00013022905i[BIOS ] IDE time out +00013120815i[BIOS ] Booting from 0000:7c00 +00021974806e[DEV ] write to port 0x03f2 with len 2 ignored +00021979699i[BIOS ] int13_harddisk: function 15, unmapped device for ELDL=81 diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/bochsrc.bxrc b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/bochsrc.bxrc new file mode 100644 index 0000000..96e70a5 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/bochsrc.bxrc @@ -0,0 +1,27 @@ +############################################################### +# bochsrc.bxrc file for Tinix. +############################################################### + +# how much memory the emulated machine will have +megs: 32 + +# filename of ROM images +romimage: file=$BXSHARE/BIOS-bochs-latest +vgaromimage: file=$BXSHARE/VGABIOS-elpin-2.40 + +# what disk images will be used +floppya: 1_44=boot.img, status=inserted +floppyb: 1_44=rootimage-0.11.img, status=inserted +ata0-master: type=disk, path="hdc-0.11.img", mode=flat, cylinders=121, heads=16, spt=63 + +# choose the boot disk. +boot: a + +# where do we send log messages? +log: bochsout.txt + +# disable the mouse, since Tinix is text only +mouse: enabled=0 + +# enable key mapping, using US layout as default. +keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-us.map diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/bootsect.asm b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/bootsect.asm new file mode 100644 index 0000000..eb6a526 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/bootsect.asm @@ -0,0 +1,246 @@ +; +; SYS_SIZE is the number of clicks (16 bytes) to be loaded. +; 0x3000 is 0x30000 bytes = 196kB, more than enough for current +; versions of linux +; +SYSSIZE equ 0x3000 +; +; bootsect.s (C) 1991 Linus Torvalds +; +; bootsect.s is loaded at 0x7c00 by the bios-startup routines, and moves +; iself out of the way to address 0x90000, and jumps there. +; +; It then loads 'setup' directly after itself (0x90200), and the system +; at 0x10000, using BIOS interrupts. +; +; NOTE! currently system is at most 8*65536 bytes long. This should be no +; problem, even in the future. I want to keep it simple. This 512 kB +; kernel size should be enough, especially as this doesn't contain the +; buffer cache as in minix +; +; The loader has been made as simple as possible, and continuos +; read errors will result in a unbreakable loop. Reboot by hand. It +; loads pretty fast by getting whole sectors at a time whenever possible. + + +SETUPLEN equ 4 ; nr of setup-sectors +BOOTSEG equ 0x07c0 ; original address of boot-sector +INITSEG equ 0x9000 ; we move boot here - out of the way +SETUPSEG equ 0x9020 ; setup starts here +SYSSEG equ 0x1000 ; system loaded at 0x10000 (65536). +ENDSEG equ SYSSEG + SYSSIZE ; where to stop loading + +; ROOT_DEV: 0x000 - same type of floppy as boot. +; 0x301 - first partition on first drive etc +ROOT_DEV equ 0x306 +[section .s16] +[BITS 16] +_start: + mov ax,BOOTSEG + mov ds,ax + mov ax,INITSEG + mov es,ax + mov cx,256 + sub si,si + sub di,di + rep + movsw + jmp INITSEG:go +go: mov ax,cs + mov ds,ax + mov es,ax +; put stack at 0x9ff00. + mov ss,ax + mov sp,0xFF00 ; arbitrary value >>512 + +; load the setup-sectors directly after the bootblock. +; Note that 'es' is already set up. + +load_setup: + mov dx,0x0000 ; drive 0, head 0 + mov cx,0x0002 ; sector 2, track 0 + mov bx,0x0200 ; address = 512, in INITSEG + mov ax,0x0200+SETUPLEN ; service 2, nr of sectors + int 0x13 ; read it + jnc ok_load_setup ; ok - continue + mov dx,0x0000 + mov ax,0x0000 ; reset the diskette + int 0x13 + jmp load_setup + +ok_load_setup: + +; Get disk drive parameters, specifically nr of sectors/track + + mov dl,0x00 + mov ax,0x0800 ; AH=8 is get drive parameters + int 0x13 + mov ch,0x00 +; seg cs + mov [sectors],cx + mov ax,INITSEG + mov es,ax + +; Print some inane message + + mov ah,0x03 ; read cursor pos + xor bh,bh + int 0x10 + + mov cx,24 + mov bx,0x0007 ; page 0, attribute 7 (normal) + mov bp,msg1 + mov ax,0x1301 ; write string, move cursor + int 0x10 + +; ok, we've written the message, now +; we want to load the system (at 0x10000) + + mov ax,SYSSEG + mov es,ax ; segment of 0x010000 + call read_it + call kill_motor + +; After that we check which root-device to use. If the device is +; defined (;= 0), nothing is done and the given device is used. +; Otherwise, either /dev/PS0 (2,28) or /dev/at0 (2,8), depending +; on the number of sectors that the BIOS reports currently. + +; seg cs + mov ax,[root_dev] + cmp ax,0 + jne root_defined +; seg cs + mov bx,[sectors] + mov ax,0x0208 ; /dev/ps0 - 1.2Mb + cmp bx,15 + je root_defined + mov ax,0x021c ; /dev/PS0 - 1.44Mb + cmp bx,18 + je root_defined +undef_root: + jmp undef_root +root_defined: +; seg cs + mov [root_dev],ax + +; after that (everyting loaded), we jump to +; the setup-routine loaded directly after +; the bootblock: + + jmp SETUPSEG:0 + +; This routine loads the system at address 0x10000, making sure +; no 64kB boundaries are crossed. We try to load it as fast as +; possible, loading whole tracks whenever we can. +; +; in: es - starting address segment (normally 0x1000) +; +sread: dw 1+SETUPLEN ; sectors read of current track +head: dw 0 ; current head +track: dw 0 ; current track + +read_it: + mov ax,es + test ax,0x0fff +die: jne die ; es must be at 64kB boundary + xor bx,bx ; bx is starting address within segment +rp_read: + mov ax,es + cmp ax,ENDSEG ; have we loaded all yet? + jb ok1_read + ret +ok1_read: +; seg cs + mov ax,[sectors] + sub ax,[sread] + mov cx,ax + shl cx,9 + add cx,bx + jnc ok2_read + je ok2_read + xor ax,ax + sub ax,bx + shr ax,9 +ok2_read: + call read_track + mov cx,ax + add ax,[sread] +; seg cs + cmp ax,[sectors] + jne ok3_read + mov ax,1 + sub ax,[head] + jne ok4_read + inc word [track] +ok4_read: + mov [head],ax + xor ax,ax +ok3_read: + mov [sread],ax + shl cx,9 + add bx,cx + jnc rp_read + mov ax,es + add ax,0x1000 + mov es,ax + xor bx,bx + jmp rp_read + +read_track: + push ax + push bx + push cx + push dx + mov dx,[track] + mov cx,[sread] + inc cx + mov ch,dl + mov dx,[head] + mov dh,dl + mov dl,0 + and dx,0x0100 + mov ah,2 + int 0x13 + jc bad_rt + pop dx + pop cx + pop bx + pop ax + ret +bad_rt: mov ax,0 + mov dx,0 + int 0x13 + pop dx + pop cx + pop bx + pop ax + jmp read_track + +;/* +; * This procedure turns off the floppy drive motor, so +; * that we enter the kernel in a known state, and +; * don't have to worry about it later. +; */ +kill_motor: + push dx + mov dx,0x3f2 + mov al,0 + out dx,ax + pop dx + ret + +sectors: + dw 0 + +msg1: + db 13,10 + db "dibingfa quick run" + db 13,10,13,10 + +times 508-($-$$) db 0 +root_dev: + dw ROOT_DEV +boot_flag: + dw 0xAA55 + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/bootsect.bin b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/bootsect.bin new file mode 100644 index 0000000..e2262a1 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/bootsect.bin differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/bootsect.disasm b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/bootsect.disasm new file mode 100644 index 0000000..e7d1304 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/bootsect.disasm @@ -0,0 +1,225 @@ +00000000 B8C007 mov ax,0x7c0 +00000003 8ED8 mov ds,ax +00000005 B80090 mov ax,0x9000 +00000008 8EC0 mov es,ax +0000000A B90001 mov cx,0x100 +0000000D 29F6 sub si,si +0000000F 29FF sub di,di +00000011 F3A5 rep movsw +00000013 EA18000090 jmp word 0x9000:0x18 +00000018 8CC8 mov ax,cs +0000001A 8ED8 mov ds,ax +0000001C 8EC0 mov es,ax +0000001E 8ED0 mov ss,ax +00000020 BC00FF mov sp,0xff00 +00000023 BA0000 mov dx,0x0 +00000026 B90200 mov cx,0x2 +00000029 BB0002 mov bx,0x200 +0000002C B80402 mov ax,0x204 +0000002F CD13 int 0x13 +00000031 730A jnc 0x3d +00000033 BA0000 mov dx,0x0 +00000036 B80000 mov ax,0x0 +00000039 CD13 int 0x13 +0000003B EBE6 jmp short 0x23 +0000003D B200 mov dl,0x0 +0000003F B80008 mov ax,0x800 +00000042 CD13 int 0x13 +00000044 B500 mov ch,0x0 +00000046 890E3901 mov [0x139],cx +0000004A B80090 mov ax,0x9000 +0000004D 8EC0 mov es,ax +0000004F B403 mov ah,0x3 +00000051 30FF xor bh,bh +00000053 CD10 int 0x10 +00000055 B91800 mov cx,0x18 +00000058 BB0700 mov bx,0x7 +0000005B BD3B01 mov bp,0x13b +0000005E B80113 mov ax,0x1301 +00000061 CD10 int 0x10 +00000063 B80010 mov ax,0x1000 +00000066 8EC0 mov es,ax +00000068 E83100 call word 0x9c +0000006B E8C200 call word 0x130 +0000006E A1FC01 mov ax,[0x1fc] +00000071 3D0000 cmp ax,0x0 +00000074 7518 jnz 0x8e +00000076 8B1E3901 mov bx,[0x139] +0000007A B80802 mov ax,0x208 +0000007D 81FB0F00 cmp bx,0xf +00000081 740B jz 0x8e +00000083 B81C02 mov ax,0x21c +00000086 81FB1200 cmp bx,0x12 +0000008A 7402 jz 0x8e +0000008C EBFE jmp short 0x8c +0000008E A3FC01 mov [0x1fc],ax +00000091 EA00002090 jmp word 0x9020:0x0 +00000096 050000 add ax,0x0 +00000099 0000 add [bx+si],al +0000009B 008CC0A9 add [si-0x5640],cl +0000009F FF0F dec word [bx] +000000A1 75FE jnz 0xa1 +000000A3 31DB xor bx,bx +000000A5 8CC0 mov ax,es +000000A7 3D0040 cmp ax,0x4000 +000000AA 7201 jc 0xad +000000AC C3 ret +000000AD A13901 mov ax,[0x139] +000000B0 2B069600 sub ax,[0x96] +000000B4 89C1 mov cx,ax +000000B6 C1E109 shl cx,0x9 +000000B9 01D9 add cx,bx +000000BB 7309 jnc 0xc6 +000000BD 7407 jz 0xc6 +000000BF 31C0 xor ax,ax +000000C1 29D8 sub ax,bx +000000C3 C1E809 shr ax,0x9 +000000C6 E83300 call word 0xfc +000000C9 89C1 mov cx,ax +000000CB 03069600 add ax,[0x96] +000000CF 3B063901 cmp ax,[0x139] +000000D3 7512 jnz 0xe7 +000000D5 B80100 mov ax,0x1 +000000D8 2B069800 sub ax,[0x98] +000000DC 7504 jnz 0xe2 +000000DE FF069A00 inc word [0x9a] +000000E2 A39800 mov [0x98],ax +000000E5 31C0 xor ax,ax +000000E7 A39600 mov [0x96],ax +000000EA C1E109 shl cx,0x9 +000000ED 01CB add bx,cx +000000EF 73B4 jnc 0xa5 +000000F1 8CC0 mov ax,es +000000F3 050010 add ax,0x1000 +000000F6 8EC0 mov es,ax +000000F8 31DB xor bx,bx +000000FA EBA9 jmp short 0xa5 +000000FC 50 push ax +000000FD 53 push bx +000000FE 51 push cx +000000FF 52 push dx +00000100 8B169A00 mov dx,[0x9a] +00000104 8B0E9600 mov cx,[0x96] +00000108 41 inc cx +00000109 88D5 mov ch,dl +0000010B 8B169800 mov dx,[0x98] +0000010F 88D6 mov dh,dl +00000111 B200 mov dl,0x0 +00000113 81E20001 and dx,0x100 +00000117 B402 mov ah,0x2 +00000119 CD13 int 0x13 +0000011B 7205 jc 0x122 +0000011D 5A pop dx +0000011E 59 pop cx +0000011F 5B pop bx +00000120 58 pop ax +00000121 C3 ret +00000122 B80000 mov ax,0x0 +00000125 BA0000 mov dx,0x0 +00000128 CD13 int 0x13 +0000012A 5A pop dx +0000012B 59 pop cx +0000012C 5B pop bx +0000012D 58 pop ax +0000012E EBCC jmp short 0xfc +00000130 52 push dx +00000131 BAF203 mov dx,0x3f2 +00000134 B000 mov al,0x0 +00000136 EF out dx,ax +00000137 5A pop dx +00000138 C3 ret +00000139 0000 add [bx+si],al +0000013B 0D0A64 or ax,0x640a +0000013E 6962696E67 imul sp,[bp+si+0x69],word 0x676e +00000143 6661 popad +00000145 207175 and [bx+di+0x75],dh +00000148 69636B2072 imul sp,[bp+di+0x6b],word 0x7220 +0000014D 756E jnz 0x1bd +0000014F 0D0A0D or ax,0xd0a +00000152 0A00 or al,[bx+si] +00000154 0000 add [bx+si],al +00000156 0000 add [bx+si],al +00000158 0000 add [bx+si],al +0000015A 0000 add [bx+si],al +0000015C 0000 add [bx+si],al +0000015E 0000 add [bx+si],al +00000160 0000 add [bx+si],al +00000162 0000 add [bx+si],al +00000164 0000 add [bx+si],al +00000166 0000 add [bx+si],al +00000168 0000 add [bx+si],al +0000016A 0000 add [bx+si],al +0000016C 0000 add [bx+si],al +0000016E 0000 add [bx+si],al +00000170 0000 add [bx+si],al +00000172 0000 add [bx+si],al +00000174 0000 add [bx+si],al +00000176 0000 add [bx+si],al +00000178 0000 add [bx+si],al +0000017A 0000 add [bx+si],al +0000017C 0000 add [bx+si],al +0000017E 0000 add [bx+si],al +00000180 0000 add [bx+si],al +00000182 0000 add [bx+si],al +00000184 0000 add [bx+si],al +00000186 0000 add [bx+si],al +00000188 0000 add [bx+si],al +0000018A 0000 add [bx+si],al +0000018C 0000 add [bx+si],al +0000018E 0000 add [bx+si],al +00000190 0000 add [bx+si],al +00000192 0000 add [bx+si],al +00000194 0000 add [bx+si],al +00000196 0000 add [bx+si],al +00000198 0000 add [bx+si],al +0000019A 0000 add [bx+si],al +0000019C 0000 add [bx+si],al +0000019E 0000 add [bx+si],al +000001A0 0000 add [bx+si],al +000001A2 0000 add [bx+si],al +000001A4 0000 add [bx+si],al +000001A6 0000 add [bx+si],al +000001A8 0000 add [bx+si],al +000001AA 0000 add [bx+si],al +000001AC 0000 add [bx+si],al +000001AE 0000 add [bx+si],al +000001B0 0000 add [bx+si],al +000001B2 0000 add [bx+si],al +000001B4 0000 add [bx+si],al +000001B6 0000 add [bx+si],al +000001B8 0000 add [bx+si],al +000001BA 0000 add [bx+si],al +000001BC 0000 add [bx+si],al +000001BE 0000 add [bx+si],al +000001C0 0000 add [bx+si],al +000001C2 0000 add [bx+si],al +000001C4 0000 add [bx+si],al +000001C6 0000 add [bx+si],al +000001C8 0000 add [bx+si],al +000001CA 0000 add [bx+si],al +000001CC 0000 add [bx+si],al +000001CE 0000 add [bx+si],al +000001D0 0000 add [bx+si],al +000001D2 0000 add [bx+si],al +000001D4 0000 add [bx+si],al +000001D6 0000 add [bx+si],al +000001D8 0000 add [bx+si],al +000001DA 0000 add [bx+si],al +000001DC 0000 add [bx+si],al +000001DE 0000 add [bx+si],al +000001E0 0000 add [bx+si],al +000001E2 0000 add [bx+si],al +000001E4 0000 add [bx+si],al +000001E6 0000 add [bx+si],al +000001E8 0000 add [bx+si],al +000001EA 0000 add [bx+si],al +000001EC 0000 add [bx+si],al +000001EE 0000 add [bx+si],al +000001F0 0000 add [bx+si],al +000001F2 0000 add [bx+si],al +000001F4 0000 add [bx+si],al +000001F6 0000 add [bx+si],al +000001F8 0000 add [bx+si],al +000001FA 0000 add [bx+si],al +000001FC 06 push es +000001FD 0355AA add dx,[di-0x56] diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/head.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/head.o new file mode 100644 index 0000000..7af05ef Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/head.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/head.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/head.s new file mode 100644 index 0000000..7c534d8 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/head.s @@ -0,0 +1,240 @@ +/* + * linux/boot/head.s + * + * (C) 1991 Linus Torvalds + */ + +/* + * head.s contains the 32-bit startup code. + * + * NOTE!!! Startup happens at absolute address 0x00000000, which is also where + * the page directory will exist. The startup code will be overwritten by + * the page directory. + */ +.text +.globl _idt,_gdt,_pg_dir,_tmp_floppy_area +_pg_dir: +.globl startup_32 +startup_32: + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + mov %ax,%fs + mov %ax,%gs + lss _stack_start,%esp + call _setup_idt + call _setup_gdt + movl $0x10,%eax # reload all the segment registers + mov %ax,%ds # after changing gdt. CS was already + mov %ax,%es # reloaded in 'setup_gdt' + mov %ax,%fs + mov %ax,%gs + lss _stack_start,%esp + xorl %eax,%eax +1: incl %eax # check that A20 really IS enabled + movl %eax,0x000000 # loop forever if it isn't + cmpl %eax,0x100000 + je 1b + +/* + * NOTE! 486 should set bit 16, to check for write-protect in supervisor + * mode. Then it would be unnecessary with the "verify_area()"-calls. + * 486 users probably want to set the NE (#5) bit also, so as to use + * int 16 for math errors. + */ + movl %cr0,%eax # check math chip + andl $0x80000011,%eax # Save PG,PE,ET +/* "orl $0x10020,%eax" here for 486 might be good */ + orl $2,%eax # set MP + movl %eax,%cr0 + call check_x87 + jmp after_page_tables + +/* + * We depend on ET to be correct. This checks for 287/387. + */ +check_x87: + fninit + fstsw %ax + cmpb $0,%al + je 1f /* no coprocessor: have to set bits */ + movl %cr0,%eax + xorl $6,%eax /* reset MP, set EM */ + movl %eax,%cr0 + ret +.align 2 +1: .byte 0xDB,0xE4 /* fsetpm for 287, ignored by 387 */ + ret + +/* + * setup_idt + * + * sets up a idt with 256 entries pointing to + * ignore_int, interrupt gates. It then loads + * idt. Everything that wants to install itself + * in the idt-table may do so themselves. Interrupts + * are enabled elsewhere, when we can be relatively + * sure everything is ok. This routine will be over- + * written by the page tables. + */ +_setup_idt: + lea ignore_int,%edx + movl $0x00080000,%eax + movw %dx,%ax /* selector = 0x0008 = cs */ + movw $0x8E00,%dx /* interrupt gate - dpl=0, present */ + + lea _idt,%edi + mov $256,%ecx +rp_sidt: + movl %eax,(%edi) + movl %edx,4(%edi) + addl $8,%edi + dec %ecx + jne rp_sidt + lidt idt_descr + ret + +/* + * setup_gdt + * + * This routines sets up a new gdt and loads it. + * Only two entries are currently built, the same + * ones that were built in init.s. The routine + * is VERY complicated at two whole lines, so this + * rather long comment is certainly needed :-). + * This routine will beoverwritten by the page tables. + */ +_setup_gdt: + lgdt gdt_descr + ret + +/* + * I put the kernel page tables right after the page directory, + * using 4 of them to span 16 Mb of physical memory. People with + * more than 16MB will have to expand this. + */ +.org 0x1000 +pg0: + +.org 0x2000 +pg1: + +.org 0x3000 +pg2: + +.org 0x4000 +pg3: + +.org 0x5000 +/* + * tmp_floppy_area is used by the floppy-driver when DMA cannot + * reach to a buffer-block. It needs to be aligned, so that it isn't + * on a 64kB border. + */ +_tmp_floppy_area: + .fill 1024,1,0 + +after_page_tables: + pushl $0 # These are the parameters to main :-) + pushl $0 + pushl $0 + pushl $L6 # return address for main, if it decides to. + pushl $_start + jmp setup_paging +L6: + jmp L6 # main should never return here, but + # just in case, we know what happens. + +/* This is the default interrupt "handler" :-) */ +int_msg: + .asciz "Unknown interrupt\n\r" +.align 2 +ignore_int: + pushl %eax + pushl %ecx + pushl %edx + push %ds + push %es + push %fs + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + mov %ax,%fs + pushl $int_msg + call _printk + popl %eax + pop %fs + pop %es + pop %ds + popl %edx + popl %ecx + popl %eax + iret + + +/* + * Setup_paging + * + * This routine sets up paging by setting the page bit + * in cr0. The page tables are set up, identity-mapping + * the first 16MB. The pager assumes that no illegal + * addresses are produced (ie >4Mb on a 4Mb machine). + * + * NOTE! Although all physical memory should be identity + * mapped by this routine, only the kernel page functions + * use the >1Mb addresses directly. All "normal" functions + * use just the lower 1Mb, or the local data space, which + * will be mapped to some other place - mm keeps track of + * that. + * + * For those with more memory than 16 Mb - tough luck. I've + * not got it, why should you :-) The source is here. Change + * it. (Seriously - it shouldn't be too difficult. Mostly + * change some constants etc. I left it at 16Mb, as my machine + * even cannot be extended past that (ok, but it was cheap :-) + * I've tried to show which constants to change by having + * some kind of marker at them (search for "16Mb"), but I + * won't guarantee that's all :-( ) + */ +.align 2 +setup_paging: + movl $1024*5,%ecx /* 5 pages - pg_dir+4 page tables */ + 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 $pg2+7,_pg_dir+8 /* --------- " " --------- */ + movl $pg3+7,_pg_dir+12 /* --------- " " --------- */ + movl $pg3+4092,%edi + movl $0xfff007,%eax /* 16Mb - 4096 + 7 (r/w user,p) */ + std +1: stosl /* fill pages backwards - more efficient :-) */ + subl $0x1000,%eax + jge 1b + xorl %eax,%eax /* pg_dir is at 0x0000 */ + movl %eax,%cr3 /* cr3 - page directory start */ + movl %cr0,%eax + orl $0x80000000,%eax + movl %eax,%cr0 /* set paging (PG) bit */ + ret /* this also flushes prefetch-queue */ + +.align 2 +.word 0 +idt_descr: + .word 256*8-1 # idt contains 256 entries + .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 :^) + + .align 8 +_idt: .fill 256,8,0 # idt is uninitialized + +_gdt: .quad 0x0000000000000000 /* NULL descriptor */ + .quad 0x00c09a0000000fff /* 16Mb */ + .quad 0x00c0920000000fff /* 16Mb */ + .quad 0x0000000000000000 /* TEMPORARY - don't use */ + .fill 252,8,0 /* space for LDT's and TSS's etc */ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/setup.asm b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/setup.asm new file mode 100644 index 0000000..e802ae8 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/setup.asm @@ -0,0 +1,214 @@ +; +; setup.s (C) 1991 Linus Torvalds +; +; setup.s is responsible for getting the system data from the BIOS, +; and putting them into the appropriate places in system memory. +; both setup.s and system has been loaded by the bootblock. +; +; This code asks the bios for memory/disk/other parameters, and +; puts them in a "safe" place: 0x90000-0x901FF, ie where the +; boot-block used to be. It is then up to the protected mode +; system to read them from there before the area is overwritten +; for buffer-blocks. +; + +; NOTE; These had better be the same as in bootsect.s; + +INITSEG equ 0x9000 ; we move boot here - out of the way +SYSSEG equ 0x1000 ; system loaded at 0x10000 (65536). +SETUPSEG equ 0x9020 ; this is the current segment + +start: + +; ok, the read went well so we get current cursor position and save it for +; posterity. + + mov ax,INITSEG ; this is done in bootsect already, but... + mov ds,ax + mov ah,0x03 ; read cursor pos + xor bh,bh + int 0x10 ; save it in known place, con_init fetches + mov [0],dx ; it from 0x90000. +; Get memory size (extended mem, kB) + + mov ah,0x88 + int 0x15 + mov [2],ax + +; Get video-card data: + + mov ah,0x0f + int 0x10 + mov [4],bx ; bh = display page + mov [6],ax ; al = video mode, ah = window width + +; check for EGA/VGA and some config parameters + + mov ah,0x12 + mov bl,0x10 + int 0x10 + mov [8],ax + mov [10],bx + mov [12],cx + +; Get hd0 data + + mov ax,0x0000 + mov ds,ax + lds si,[4*0x41] + mov ax,INITSEG + mov es,ax + mov di,0x0080 + mov cx,0x10 + rep + movsb + +; Get hd1 data + + mov ax,0x0000 + mov ds,ax + lds si,[4*0x46] + mov ax,INITSEG + mov es,ax + mov di,0x0090 + mov cx,0x10 + rep + movsb + +; Check that there IS a hd1 :-) + + mov ax,0x01500 + mov dl,0x81 + int 0x13 + jc no_disk1 + cmp ah,3 + je is_disk1 +no_disk1: + mov ax,INITSEG + mov es,ax + mov di,0x0090 + mov cx,0x10 + mov ax,0x00 + rep + stosb +is_disk1: + +; now we want to move to protected mode ... + + cli ; no interrupts allowed ; + +; first we move the system to it's rightful place + + mov ax,0x0000 + cld ; 'direction'=0, movs moves forward +do_move: + mov es,ax ; destination segment + add ax,0x1000 + cmp ax,0x9000 + jz end_move + mov ds,ax ; source segment + sub di,di + sub si,si + mov cx,0x8000 + rep + movsw + jmp do_move + +; then we load the segment descriptors + +end_move: + mov ax,SETUPSEG ; right, forgot this at first. didn't work :-) + mov ds,ax + lidt [idt_48] ; load idt with 0,0 + lgdt [gdt_48] ; load gdt with whatever appropriate + +; that was painless, now we enable A20 + + call empty_8042 + mov al,0xD1 ; command write + out 0x64,al + call empty_8042 + mov al,0xDF ; A20 on + out 0x60,al + call empty_8042 + +; well, that went ok, I hope. Now we have to reprogram the interrupts :-( +; we put them right after the intel-reserved hardware interrupts, at +; int 0x20-0x2F. There they won't mess up anything. Sadly IBM really +; messed this up with the original PC, and they haven't been able to +; rectify it afterwards. Thus the bios puts interrupts at 0x08-0x0f, +; which is used for the internal hardware interrupts as well. We just +; have to reprogram the 8259's, and it isn't fun. + + mov al,0x11 ; initialization sequence + out 0x20,al ; send it to 8259A-1 + dw 0x00eb,0x00eb ; jmp $+2, jmp $+2 + out 0xA0,al ; and to 8259A-2 + dw 0x00eb,0x00eb + mov al,0x20 ; start of hardware int's (0x20) + out 0x21,al + dw 0x00eb,0x00eb + mov al,0x28 ; start of hardware int's 2 (0x28) + out 0xA1,al + dw 0x00eb,0x00eb + mov al,0x04 ; 8259-1 is master + out 0x21,al + dw 0x00eb,0x00eb + mov al,0x02 ; 8259-2 is slave + out 0xA1,al + dw 0x00eb,0x00eb + mov al,0x01 ; 8086 mode for both + out 0x21,al + dw 0x00eb,0x00eb + out 0xA1,al + dw 0x00eb,0x00eb + mov al,0xFF ; mask off all interrupts for now + out 0x21,al + dw 0x00eb,0x00eb + out 0xA1,al + +; well, that certainly wasn't fun :-(. Hopefully it works, and we don't +; need no steenking BIOS anyway (except for the initial loading :-). +; The BIOS-routine wants lots of unnecessary data, and it's less +; "interesting" anyway. This is how REAL programmers do it. +; +; Well, now's the time to actually move into protected mode. To make +; things as simple as possible, we do no register set-up or anything, +; we let the gnu-compiled 32-bit programs do that. We just jump to +; absolute address 0x00000, in 32-bit protected mode. + mov ax,0x0001 ; protected mode (PE) bit + lmsw ax ; This is it; + jmp 8:0 ; jmp offset 0 of segment 8 (cs) + +; This routine checks that the keyboard command queue is empty +; No timeout is used - if this hangs there is something wrong with +; the machine, and we probably couldn't proceed anyway. +empty_8042: + dw 0x00eb,0x00eb + in al,0x64 ; 8042 status port + test al,2 ; is input buffer full? + jnz empty_8042 ; yes - loop + ret + + +gdt: + dw 0,0,0,0 ; dummy + + dw 0x07FF ; 8Mb - limit=2047 (2048*4096=8Mb) + dw 0x0000 ; base address=0 + dw 0x9A00 ; code read/exec + dw 0x00C0 ; granularity=4096, 386 + +DATA_DESCRIPTOR: + dw 0x07FF ; 8Mb - limit=2047 (2048*4096=8Mb) + dw 0x0000 ; base address=0 + dw 0x9200 ; data read/write + dw 0x00C0 ; granularity=4096, 386 + +idt_48: + dw 0 ; idt limit=0 + dw 0,0 ; idt base=0L + +gdt_48: + dw 0x800 ; gdt limit=2048, 256 GDT entries + dw 512+gdt,0x9 ; gdt base = 0X9xxxx diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/setup.bin b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/setup.bin new file mode 100644 index 0000000..41e8704 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/setup.bin differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/setup.disasm b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/setup.disasm new file mode 100644 index 0000000..a2fd826 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/boot/setup.disasm @@ -0,0 +1,131 @@ +00000000 B80090 mov ax,0x9000 +00000003 8ED8 mov ds,ax +00000005 B403 mov ah,0x3 +00000007 30FF xor bh,bh +00000009 CD10 int 0x10 +0000000B 89160000 mov [0x0],dx +0000000F B488 mov ah,0x88 +00000011 CD15 int 0x15 +00000013 A30200 mov [0x2],ax +00000016 B40F mov ah,0xf +00000018 CD10 int 0x10 +0000001A 891E0400 mov [0x4],bx +0000001E A30600 mov [0x6],ax +00000021 B412 mov ah,0x12 +00000023 B310 mov bl,0x10 +00000025 CD10 int 0x10 +00000027 A30800 mov [0x8],ax +0000002A 891E0A00 mov [0xa],bx +0000002E 890E0C00 mov [0xc],cx +00000032 B80000 mov ax,0x0 +00000035 8ED8 mov ds,ax +00000037 C5360401 lds si,[0x104] +0000003B B80090 mov ax,0x9000 +0000003E 8EC0 mov es,ax +00000040 BF8000 mov di,0x80 +00000043 B91000 mov cx,0x10 +00000046 F3A4 rep movsb +00000048 B80000 mov ax,0x0 +0000004B 8ED8 mov ds,ax +0000004D C5361801 lds si,[0x118] +00000051 B80090 mov ax,0x9000 +00000054 8EC0 mov es,ax +00000056 BF9000 mov di,0x90 +00000059 B91000 mov cx,0x10 +0000005C F3A4 rep movsb +0000005E B80015 mov ax,0x1500 +00000061 B281 mov dl,0x81 +00000063 CD13 int 0x13 +00000065 7205 jc 0x6c +00000067 80FC03 cmp ah,0x3 +0000006A 7410 jz 0x7c +0000006C B80090 mov ax,0x9000 +0000006F 8EC0 mov es,ax +00000071 BF9000 mov di,0x90 +00000074 B91000 mov cx,0x10 +00000077 B80000 mov ax,0x0 +0000007A F3AA rep stosb +0000007C FA cli +0000007D B80000 mov ax,0x0 +00000080 FC cld +00000081 8EC0 mov es,ax +00000083 050010 add ax,0x1000 +00000086 3D0090 cmp ax,0x9000 +00000089 740D jz 0x98 +0000008B 8ED8 mov ds,ax +0000008D 29FF sub di,di +0000008F 29F6 sub si,si +00000091 B90080 mov cx,0x8000 +00000094 F3A5 rep movsw +00000096 EBE9 jmp short 0x81 +00000098 B82090 mov ax,0x9020 +0000009B 8ED8 mov ds,ax +0000009D 0F011E2C01 lidt [0x12c] +000000A2 0F01163201 lgdt [0x132] +000000A7 E85F00 call word 0x109 +000000AA B0D1 mov al,0xd1 +000000AC E664 out 0x64,al +000000AE E85800 call word 0x109 +000000B1 B0DF mov al,0xdf +000000B3 E660 out 0x60,al +000000B5 E85100 call word 0x109 +000000B8 B011 mov al,0x11 +000000BA E620 out 0x20,al +000000BC EB00 jmp short 0xbe +000000BE EB00 jmp short 0xc0 +000000C0 E6A0 out 0xa0,al +000000C2 EB00 jmp short 0xc4 +000000C4 EB00 jmp short 0xc6 +000000C6 B020 mov al,0x20 +000000C8 E621 out 0x21,al +000000CA EB00 jmp short 0xcc +000000CC EB00 jmp short 0xce +000000CE B028 mov al,0x28 +000000D0 E6A1 out 0xa1,al +000000D2 EB00 jmp short 0xd4 +000000D4 EB00 jmp short 0xd6 +000000D6 B004 mov al,0x4 +000000D8 E621 out 0x21,al +000000DA EB00 jmp short 0xdc +000000DC EB00 jmp short 0xde +000000DE B002 mov al,0x2 +000000E0 E6A1 out 0xa1,al +000000E2 EB00 jmp short 0xe4 +000000E4 EB00 jmp short 0xe6 +000000E6 B001 mov al,0x1 +000000E8 E621 out 0x21,al +000000EA EB00 jmp short 0xec +000000EC EB00 jmp short 0xee +000000EE E6A1 out 0xa1,al +000000F0 EB00 jmp short 0xf2 +000000F2 EB00 jmp short 0xf4 +000000F4 B0FF mov al,0xff +000000F6 E621 out 0x21,al +000000F8 EB00 jmp short 0xfa +000000FA EB00 jmp short 0xfc +000000FC E6A1 out 0xa1,al +000000FE B80100 mov ax,0x1 +00000101 0F01F0 lmsw ax +00000104 EA00000800 jmp word 0x8:0x0 +00000109 EB00 jmp short 0x10b +0000010B EB00 jmp short 0x10d +0000010D E464 in al,0x64 +0000010F A802 test al,0x2 +00000111 75F6 jnz 0x109 +00000113 C3 ret +00000114 0000 add [bx+si],al +00000116 0000 add [bx+si],al +00000118 0000 add [bx+si],al +0000011A 0000 add [bx+si],al +0000011C FF07 inc word [bx] +0000011E 0000 add [bx+si],al +00000120 009AC000 add [bp+si+0xc0],bl +00000124 FF07 inc word [bx] +00000126 0000 add [bx+si],al +00000128 0092C000 add [bp+si+0xc0],dl +0000012C 0000 add [bx+si],al +0000012E 0000 add [bx+si],al +00000130 0000 add [bx+si],al +00000132 0008 add [bx+si],cl +00000134 1403 adc al,0x3 +00000136 0900 or [bx+si],ax diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/clean.bat b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/clean.bat new file mode 100644 index 0000000..e991b97 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/clean.bat @@ -0,0 +1,3 @@ +@SET PATH=..\MinGW32\bin;..\..\MinGW32\bin;..\..\..\MinGW32\bin;%PATH% + +make clean \ No newline at end of file diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/Makefile new file mode 100644 index 0000000..593a922 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/Makefile @@ -0,0 +1,100 @@ +AR =ar +AS =as +CC =gcc -mcpu=i386 +LD =ld +CFLAGS =-Wall -fstrength-reduce -fomit-frame-pointer \ + -nostdinc -I../include +CPP =gcc -E -nostdinc -I../include + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< +.s.o: + $(AS) -o $*.o $< + +OBJS= open.o read_write.o inode.o file_table.o buffer.o super.o \ + block_dev.o char_dev.o file_dev.o stat.o exec.o pipe.o namei.o \ + bitmap.o fcntl.o ioctl.o truncate.o + +fs.o: $(OBJS) + $(LD) -r -o fs.o $(OBJS) + +clean: + rm -f core *.o *.a tmp_make + for i in *.c;do rm -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: +bitmap.o: bitmap.c ../include/string.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h +block_dev.o: block_dev.c ../include/errno.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ + ../include/asm/segment.h ../include/asm/system.h +buffer.o: buffer.c ../include/stdarg.h ../include/linux/config.h \ + ../include/linux/sched.h ../include/linux/head.h ../include/linux/fs.h \ + ../include/sys/types.h ../include/linux/mm.h ../include/signal.h \ + ../include/linux/kernel.h ../include/asm/system.h ../include/asm/io.h +char_dev.o: char_dev.c ../include/errno.h ../include/sys/types.h \ + ../include/linux/sched.h ../include/linux/head.h ../include/linux/fs.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ + ../include/asm/segment.h ../include/asm/io.h +exec.o: exec.c ../include/errno.h ../include/string.h \ + ../include/sys/stat.h ../include/sys/types.h ../include/a.out.h \ + ../include/linux/fs.h ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ + ../include/asm/segment.h +fcntl.o: fcntl.c ../include/string.h ../include/errno.h \ + ../include/linux/sched.h ../include/linux/head.h ../include/linux/fs.h \ + ../include/sys/types.h ../include/linux/mm.h ../include/signal.h \ + ../include/linux/kernel.h ../include/asm/segment.h ../include/fcntl.h \ + ../include/sys/stat.h +file_dev.o: file_dev.c ../include/errno.h ../include/fcntl.h \ + ../include/sys/types.h ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/linux/mm.h ../include/signal.h \ + ../include/linux/kernel.h ../include/asm/segment.h +file_table.o: file_table.c ../include/linux/fs.h ../include/sys/types.h +inode.o: inode.c ../include/string.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/linux/mm.h ../include/signal.h \ + ../include/linux/kernel.h ../include/asm/system.h +ioctl.o: ioctl.c ../include/string.h ../include/errno.h \ + ../include/sys/stat.h ../include/sys/types.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \ + ../include/signal.h +namei.o: namei.c ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \ + ../include/signal.h ../include/linux/kernel.h ../include/asm/segment.h \ + ../include/string.h ../include/fcntl.h ../include/errno.h \ + ../include/const.h ../include/sys/stat.h +open.o: open.c ../include/string.h ../include/errno.h ../include/fcntl.h \ + ../include/sys/types.h ../include/utime.h ../include/sys/stat.h \ + ../include/linux/sched.h ../include/linux/head.h ../include/linux/fs.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/tty.h \ + ../include/termios.h ../include/linux/kernel.h ../include/asm/segment.h +pipe.o: pipe.c ../include/signal.h ../include/sys/types.h \ + ../include/linux/sched.h ../include/linux/head.h ../include/linux/fs.h \ + ../include/linux/mm.h ../include/asm/segment.h +read_write.o: read_write.c ../include/sys/stat.h ../include/sys/types.h \ + ../include/errno.h ../include/linux/kernel.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \ + ../include/signal.h ../include/asm/segment.h +stat.o: stat.c ../include/errno.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/linux/fs.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/mm.h ../include/signal.h \ + ../include/linux/kernel.h ../include/asm/segment.h +super.o: super.c ../include/linux/config.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ + ../include/asm/system.h ../include/errno.h ../include/sys/stat.h +truncate.o: truncate.c ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \ + ../include/signal.h ../include/sys/stat.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/bitmap.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/bitmap.c new file mode 100644 index 0000000..fb0741d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/bitmap.c @@ -0,0 +1,168 @@ +/* + * linux/fs/bitmap.c + * + * (C) 1991 Linus Torvalds + */ + +/* bitmap.c contains the code that handles the inode and block bitmaps */ +#include + +#include +#include + +#define clear_block(addr) \ +__asm__ __volatile__ ("cld\n\t" \ + "rep\n\t" \ + "stosl" \ + ::"a" (0),"c" (BLOCK_SIZE/4),"D" ((long) (addr))) + +#define set_bit(nr,addr) ({\ +register int res ; \ +__asm__ __volatile__("btsl %2,%3\n\tsetb %%al": \ +"=a" (res):"0" (0),"r" (nr),"m" (*(addr))); \ +res;}) + +#define clear_bit(nr,addr) ({\ +register int res ; \ +__asm__ __volatile__("btrl %2,%3\n\tsetnb %%al": \ +"=a" (res):"0" (0),"r" (nr),"m" (*(addr))); \ +res;}) + +#define find_first_zero(addr) ({ \ +int __res; \ +__asm__ __volatile__ ("cld\n" \ + "1:\tlodsl\n\t" \ + "notl %%eax\n\t" \ + "bsfl %%eax,%%edx\n\t" \ + "je 2f\n\t" \ + "addl %%edx,%%ecx\n\t" \ + "jmp 3f\n" \ + "2:\taddl $32,%%ecx\n\t" \ + "cmpl $8192,%%ecx\n\t" \ + "jl 1b\n" \ + "3:" \ + :"=c" (__res):"c" (0),"S" (addr)); \ +__res;}) + +void free_block(int dev, int block) +{ + struct super_block * sb; + struct buffer_head * bh; + + if (!(sb = get_super(dev))) + panic("trying to free block on nonexistent device"); + if (block < sb->s_firstdatazone || block >= sb->s_nzones) + panic("trying to free block not in datazone"); + bh = get_hash_table(dev,block); + if (bh) { + if (bh->b_count != 1) { + printk("trying to free block (%04x:%d), count=%d\n", + dev,block,bh->b_count); + return; + } + bh->b_dirt=0; + bh->b_uptodate=0; + brelse(bh); + } + block -= sb->s_firstdatazone - 1 ; + if (clear_bit(block&8191,sb->s_zmap[block/8192]->b_data)) { + printk("block (%04x:%d) ",dev,block+sb->s_firstdatazone-1); + panic("free_block: bit already cleared"); + } + sb->s_zmap[block/8192]->b_dirt = 1; +} + +int new_block(int dev) +{ + struct buffer_head * bh; + struct super_block * sb; + int i,j; + + if (!(sb = get_super(dev))) + panic("trying to get new block from nonexistant device"); + j = 8192; + for (i=0 ; i<8 ; i++) + if ((bh=sb->s_zmap[i])) + if ((j=find_first_zero(bh->b_data))<8192) + break; + if (i>=8 || !bh || j>=8192) + return 0; + if (set_bit(j,bh->b_data)) + panic("new_block: bit already set"); + bh->b_dirt = 1; + j += i*8192 + sb->s_firstdatazone-1; + if (j >= sb->s_nzones) + return 0; + if (!(bh=getblk(dev,j))) + panic("new_block: cannot get block"); + if (bh->b_count != 1) + panic("new block: count is != 1"); + clear_block(bh->b_data); + bh->b_uptodate = 1; + bh->b_dirt = 1; + brelse(bh); + return j; +} + +void free_inode(struct m_inode * inode) +{ + struct super_block * sb; + struct buffer_head * bh; + + if (!inode) + return; + if (!inode->i_dev) { + memset(inode,0,sizeof(*inode)); + return; + } + if (inode->i_count>1) { + printk("trying to free inode with count=%d\n",inode->i_count); + panic("free_inode"); + } + if (inode->i_nlinks) + panic("trying to free inode with links"); + if (!(sb = get_super(inode->i_dev))) + panic("trying to free inode on nonexistent device"); + if (inode->i_num < 1 || inode->i_num > sb->s_ninodes) + panic("trying to free inode 0 or nonexistant inode"); + if (!(bh=sb->s_imap[inode->i_num>>13])) + panic("nonexistent imap in superblock"); + if (clear_bit(inode->i_num&8191,bh->b_data)) + printk("free_inode: bit already cleared.\n\r"); + bh->b_dirt = 1; + memset(inode,0,sizeof(*inode)); +} + +struct m_inode * new_inode(int dev) +{ + struct m_inode * inode; + struct super_block * sb; + struct buffer_head * bh; + int i,j; + + if (!(inode=get_empty_inode())) + return NULL; + if (!(sb = get_super(dev))) + panic("new_inode with unknown device"); + j = 8192; + for (i=0 ; i<8 ; i++) + if ((bh=sb->s_imap[i])) + if ((j=find_first_zero(bh->b_data))<8192) + break; + if (!bh || j >= 8192 || j+i*8192 > sb->s_ninodes) { + iput(inode); + return NULL; + } + if (set_bit(j,bh->b_data)) + panic("new_inode: bit already set"); + bh->b_dirt = 1; + inode->i_count=1; + inode->i_nlinks=1; + inode->i_dev=dev; + inode->i_uid=current->euid; + inode->i_gid=current->egid; + inode->i_dirt=1; + inode->i_num = j + i*8192; + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; + return inode; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/bitmap.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/bitmap.o new file mode 100644 index 0000000..d534c3d Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/bitmap.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/block_dev.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/block_dev.c new file mode 100644 index 0000000..a50ae3f --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/block_dev.c @@ -0,0 +1,73 @@ +/* + * linux/fs/block_dev.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +#include +#include +#include +#include + +int block_write(int dev, long * pos, char * buf, int count) +{ + int block = *pos >> BLOCK_SIZE_BITS; + int offset = *pos & (BLOCK_SIZE-1); + int chars; + int written = 0; + struct buffer_head * bh; + register char * p; + + while (count>0) { + chars = BLOCK_SIZE - offset; + if (chars > count) + chars=count; + if (chars == BLOCK_SIZE) + bh = getblk(dev,block); + else + bh = breada(dev,block,block+1,block+2,-1); + block++; + if (!bh) + return written?written:-EIO; + p = offset + bh->b_data; + offset = 0; + *pos += chars; + written += chars; + count -= chars; + while (chars-->0) + *(p++) = get_fs_byte(buf++); + bh->b_dirt = 1; + brelse(bh); + } + return written; +} + +int block_read(int dev, unsigned long * pos, char * buf, int count) +{ + int block = *pos >> BLOCK_SIZE_BITS; + int offset = *pos & (BLOCK_SIZE-1); + int chars; + int read = 0; + struct buffer_head * bh; + register char * p; + + while (count>0) { + chars = BLOCK_SIZE-offset; + if (chars > count) + chars = count; + if (!(bh = breada(dev,block,block+1,block+2,-1))) + return read?read:-EIO; + block++; + p = offset + bh->b_data; + offset = 0; + *pos += chars; + read += chars; + count -= chars; + while (chars-->0) + put_fs_byte(*(p++),buf++); + brelse(bh); + } + return read; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/block_dev.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/block_dev.o new file mode 100644 index 0000000..f5e4420 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/block_dev.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/buffer.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/buffer.c new file mode 100644 index 0000000..47c5a4d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/buffer.c @@ -0,0 +1,384 @@ +/* + * linux/fs/buffer.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 'buffer.c' implements the buffer-cache functions. Race-conditions have + * been avoided by NEVER letting a interrupt change a buffer (except for the + * data, of course), but instead letting the caller do it. NOTE! As interrupts + * can wake up a caller, some cli-sti sequences are needed to check for + * sleep-on-calls. These should be extremely quick, though (I hope). + */ + +/* + * NOTE! There is one discordant note here: checking floppies for + * disk change. This is where it fits best, I think, as it should + * invalidate changed floppy-disk-caches. + */ + +#include + +#include +#include +#include +#include +#include + +extern int end; +extern void put_super(int); +extern void invalidate_inodes(int); + +struct buffer_head * start_buffer = (struct buffer_head *) &end; +struct buffer_head * hash_table[NR_HASH]; +static struct buffer_head * free_list; +static struct task_struct * buffer_wait = NULL; +int NR_BUFFERS = 0; + +static inline void wait_on_buffer(struct buffer_head * bh) +{ + cli(); + while (bh->b_lock) + sleep_on(&bh->b_wait); + sti(); +} + +int sys_sync(void) +{ + int i; + struct buffer_head * bh; + + sync_inodes(); /* write out inodes into buffers */ + bh = start_buffer; + for (i=0 ; ib_dirt) + ll_rw_block(WRITE,bh); + } + return 0; +} + +int sync_dev(int dev) +{ + int i; + struct buffer_head * bh; + + bh = start_buffer; + for (i=0 ; ib_dev != dev) + continue; + wait_on_buffer(bh); + if (bh->b_dev == dev && bh->b_dirt) + ll_rw_block(WRITE,bh); + } + sync_inodes(); + bh = start_buffer; + for (i=0 ; ib_dev != dev) + continue; + wait_on_buffer(bh); + if (bh->b_dev == dev && bh->b_dirt) + ll_rw_block(WRITE,bh); + } + return 0; +} + +void inline invalidate_buffers(int dev) +{ + int i; + struct buffer_head * bh; + + bh = start_buffer; + for (i=0 ; ib_dev != dev) + continue; + wait_on_buffer(bh); + if (bh->b_dev == dev) + bh->b_uptodate = bh->b_dirt = 0; + } +} + +/* + * This routine checks whether a floppy has been changed, and + * invalidates all buffer-cache-entries in that case. This + * is a relatively slow routine, so we have to try to minimize using + * it. Thus it is called only upon a 'mount' or 'open'. This + * is the best way of combining speed and utility, I think. + * People changing diskettes in the middle of an operation deserve + * to loose :-) + * + * NOTE! Although currently this is only for floppies, the idea is + * that any additional removable block-device will use this routine, + * and that mount/open needn't know that floppies/whatever are + * special. + */ +void check_disk_change(int dev) +{ + int i; + + if (MAJOR(dev) != 2) + return; + if (!floppy_change(dev & 0x03)) + return; + for (i=0 ; ib_next) + bh->b_next->b_prev = bh->b_prev; + if (bh->b_prev) + bh->b_prev->b_next = bh->b_next; + if (hash(bh->b_dev,bh->b_blocknr) == bh) + hash(bh->b_dev,bh->b_blocknr) = bh->b_next; +/* remove from free list */ + if (!(bh->b_prev_free) || !(bh->b_next_free)) + panic("Free block list corrupted"); + bh->b_prev_free->b_next_free = bh->b_next_free; + bh->b_next_free->b_prev_free = bh->b_prev_free; + if (free_list == bh) + free_list = bh->b_next_free; +} + +static inline void insert_into_queues(struct buffer_head * bh) +{ +/* put at end of free list */ + bh->b_next_free = free_list; + bh->b_prev_free = free_list->b_prev_free; + free_list->b_prev_free->b_next_free = bh; + free_list->b_prev_free = bh; +/* put the buffer in new hash-queue if it has a device */ + bh->b_prev = NULL; + bh->b_next = NULL; + if (!bh->b_dev) + return; + bh->b_next = hash(bh->b_dev,bh->b_blocknr); + hash(bh->b_dev,bh->b_blocknr) = bh; + bh->b_next->b_prev = bh; +} + +static struct buffer_head * find_buffer(int dev, int block) +{ + struct buffer_head * tmp; + + for (tmp = hash(dev,block) ; tmp != NULL ; tmp = tmp->b_next) + if (tmp->b_dev==dev && tmp->b_blocknr==block) + return tmp; + return NULL; +} + +/* + * Why like this, I hear you say... The reason is race-conditions. + * As we don't lock buffers (unless we are readint them, that is), + * something might happen to it while we sleep (ie a read-error + * will force it bad). This shouldn't really happen currently, but + * the code is ready. + */ +struct buffer_head * get_hash_table(int dev, int block) +{ + struct buffer_head * bh; + + for (;;) { + if (!(bh=find_buffer(dev,block))) + return NULL; + bh->b_count++; + wait_on_buffer(bh); + if (bh->b_dev == dev && bh->b_blocknr == block) + return bh; + bh->b_count--; + } +} + +/* + * Ok, this is getblk, and it isn't very clear, again to hinder + * race-conditions. Most of the code is seldom used, (ie repeating), + * so it should be much more efficient than it looks. + * + * The algoritm is changed: hopefully better, and an elusive bug removed. + */ +#define BADNESS(bh) (((bh)->b_dirt<<1)+(bh)->b_lock) +struct buffer_head * getblk(int dev,int block) +{ + struct buffer_head * tmp, * bh; + +repeat: + if ((bh = get_hash_table(dev,block))) + return bh; + tmp = free_list; + do { + if (tmp->b_count) + continue; + if (!bh || BADNESS(tmp)b_next_free) != free_list); + if (!bh) { + sleep_on(&buffer_wait); + goto repeat; + } + wait_on_buffer(bh); + if (bh->b_count) + goto repeat; + while (bh->b_dirt) { + sync_dev(bh->b_dev); + wait_on_buffer(bh); + if (bh->b_count) + goto repeat; + } +/* NOTE!! While we slept waiting for this block, somebody else might */ +/* already have added "this" block to the cache. check it */ + if (find_buffer(dev,block)) + goto repeat; +/* OK, FINALLY we know that this buffer is the only one of it's kind, */ +/* and that it's unused (b_count=0), unlocked (b_lock=0), and clean */ + bh->b_count=1; + bh->b_dirt=0; + bh->b_uptodate=0; + remove_from_queues(bh); + bh->b_dev=dev; + bh->b_blocknr=block; + insert_into_queues(bh); + return bh; +} + +void brelse(struct buffer_head * buf) +{ + if (!buf) + return; + wait_on_buffer(buf); + if (!(buf->b_count--)) + panic("Trying to free free buffer"); + wake_up(&buffer_wait); +} + +/* + * bread() reads a specified block and returns the buffer that contains + * it. It returns NULL if the block was unreadable. + */ +struct buffer_head * bread(int dev,int block) +{ + struct buffer_head * bh; + + if (!(bh=getblk(dev,block))) + panic("bread: getblk returned NULL\n"); + if (bh->b_uptodate) + return bh; + ll_rw_block(READ,bh); + wait_on_buffer(bh); + if (bh->b_uptodate) + return bh; + brelse(bh); + return NULL; +} + +#define COPYBLK(from,to) \ +__asm__("cld\n\t" \ + "rep\n\t" \ + "movsl\n\t" \ + ::"c" (BLOCK_SIZE/4),"S" (from),"D" (to) \ + ) + +/* + * bread_page reads four buffers into memory at the desired address. It's + * a function of its own, as there is some speed to be got by reading them + * all at the same time, not waiting for one to be read, and then another + * etc. + */ +void bread_page(unsigned long address,int dev,int b[4]) +{ + struct buffer_head * bh[4]; + int i; + + for (i=0 ; i<4 ; i++) + if (b[i]) { + if ((bh[i] = getblk(dev,b[i]))) + if (!bh[i]->b_uptodate) + ll_rw_block(READ,bh[i]); + } else + bh[i] = NULL; + for (i=0 ; i<4 ; i++,address += BLOCK_SIZE) + if (bh[i]) { + wait_on_buffer(bh[i]); + if (bh[i]->b_uptodate) + COPYBLK((unsigned long) bh[i]->b_data,address); + brelse(bh[i]); + } +} + +/* + * Ok, breada can be used as bread, but additionally to mark other + * blocks for reading as well. End the argument list with a negative + * number. + */ +struct buffer_head * breada(int dev,int first, ...) +{ + va_list args; + struct buffer_head * bh, *tmp; + + va_start(args,first); + if (!(bh=getblk(dev,first))) + panic("bread: getblk returned NULL\n"); + if (!bh->b_uptodate) + ll_rw_block(READ,bh); + while ((first=va_arg(args,int))>=0) { + tmp=getblk(dev,first); + if (tmp) { + if (!tmp->b_uptodate) + ll_rw_block(READA,bh); + tmp->b_count--; + } + } + va_end(args); + wait_on_buffer(bh); + if (bh->b_uptodate) + return bh; + brelse(bh); + return (NULL); +} + +void buffer_init(long buffer_end) +{ + struct buffer_head * h = start_buffer; + void * b; + int i; + + if (buffer_end == 1<<20) + b = (void *) (640*1024); + else + b = (void *) buffer_end; + while ( (b -= BLOCK_SIZE) >= ((void *) (h+1)) ) { + h->b_dev = 0; + h->b_dirt = 0; + h->b_count = 0; + h->b_lock = 0; + h->b_uptodate = 0; + h->b_wait = NULL; + h->b_next = NULL; + h->b_prev = NULL; + h->b_data = (char *) b; + h->b_prev_free = h-1; + h->b_next_free = h+1; + h++; + NR_BUFFERS++; + if (b == (void *) 0x100000) + b = (void *) 0xA0000; + } + h--; + free_list = start_buffer; + free_list->b_prev_free = h; + h->b_next_free = free_list; + for (i=0;i +#include + +#include +#include + +#include +#include + +extern int tty_read(unsigned minor,char * buf,int count); +extern int tty_write(unsigned minor,char * buf,int count); + +typedef int (*crw_ptr)(int rw,unsigned minor,char * buf,int count,off_t * pos); + +static int rw_ttyx(int rw,unsigned minor,char * buf,int count,off_t * pos) +{ + return ((rw==READ)?tty_read(minor,buf,count): + tty_write(minor,buf,count)); +} + +static int rw_tty(int rw,unsigned minor,char * buf,int count, off_t * pos) +{ + if (current->tty<0) + return -EPERM; + return rw_ttyx(rw,current->tty,buf,count,pos); +} + +static int rw_ram(int rw,char * buf, int count, off_t *pos) +{ + return -EIO; +} + +static int rw_mem(int rw,char * buf, int count, off_t * pos) +{ + return -EIO; +} + +static int rw_kmem(int rw,char * buf, int count, off_t * pos) +{ + return -EIO; +} + +static int rw_port(int rw,char * buf, int count, off_t * pos) +{ + int i=*pos; + + while (count-->0 && i<65536) { + if (rw==READ) + put_fs_byte(inb(i),buf++); + else + outb(get_fs_byte(buf++),i); + i++; + } + i -= *pos; + *pos += i; + return i; +} + +static int rw_memory(int rw, unsigned minor, char * buf, int count, off_t * pos) +{ + switch(minor) { + case 0: + return rw_ram(rw,buf,count,pos); + case 1: + return rw_mem(rw,buf,count,pos); + case 2: + return rw_kmem(rw,buf,count,pos); + case 3: + return (rw==READ)?0:count; /* rw_null */ + case 4: + return rw_port(rw,buf,count,pos); + default: + return -EIO; + } +} + +#define NRDEVS ((sizeof (crw_table))/(sizeof (crw_ptr))) + +static crw_ptr crw_table[]={ + NULL, /* nodev */ + rw_memory, /* /dev/mem etc */ + NULL, /* /dev/fd */ + NULL, /* /dev/hd */ + rw_ttyx, /* /dev/ttyx */ + rw_tty, /* /dev/tty */ + NULL, /* /dev/lp */ + NULL}; /* unnamed pipes */ + +int rw_char(int rw,int dev, char * buf, int count, off_t * pos) +{ + crw_ptr call_addr; + + if (MAJOR(dev)>=NRDEVS) + return -ENODEV; + if (!(call_addr=crw_table[MAJOR(dev)])) + return -ENODEV; + return call_addr(rw,MINOR(dev),buf,count,pos); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/char_dev.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/char_dev.o new file mode 100644 index 0000000..370e924 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/char_dev.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/exec.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/exec.c new file mode 100644 index 0000000..c1b6a29 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/exec.c @@ -0,0 +1,353 @@ +/* + * linux/fs/exec.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * #!-checking implemented by tytso. + */ + +/* + * Demand-loading implemented 01.12.91 - no need to read anything but + * the header into memory. The inode of the executable is put into + * "current->executable", and page faults do the actual loading. Clean. + * + * Once more I can proudly say that linux stood up to being changed: it + * was less than 2 hours work to get demand-loading completely implemented. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +extern int sys_exit(int exit_code); +extern int sys_close(int fd); + +/* + * MAX_ARG_PAGES defines the number of pages allocated for arguments + * and envelope for the new program. 32 should suffice, this gives + * a maximum env+arg of 128kB ! + */ +#define MAX_ARG_PAGES 32 + +/* + * create_tables() parses the env- and arg-strings in new user + * memory and creates the pointer tables from them, and puts their + * addresses on the "stack", returning the new stack pointer value. + */ +static unsigned long * create_tables(char * p,int argc,int envc) +{ + unsigned long *argv,*envp; + unsigned long * sp; + + sp = (unsigned long *) (0xfffffffc & (unsigned long) p); + sp -= envc+1; + envp = sp; + sp -= argc+1; + argv = sp; + put_fs_long((unsigned long)envp,--sp); + put_fs_long((unsigned long)argv,--sp); + put_fs_long((unsigned long)argc,--sp); + while (argc-->0) { + put_fs_long((unsigned long) p,argv++); + while (get_fs_byte(p++)) /* nothing */ ; + } + put_fs_long(0,argv); + while (envc-->0) { + put_fs_long((unsigned long) p,envp++); + while (get_fs_byte(p++)) /* nothing */ ; + } + put_fs_long(0,envp); + return sp; +} + +/* + * count() counts the number of arguments/envelopes + */ +static int count(char ** argv) +{ + int i=0; + char ** tmp; + + if ((tmp = argv)) + while (get_fs_long((unsigned long *) (tmp++))) + i++; + + return i; +} + +/* + * 'copy_string()' copies argument/envelope strings from user + * memory to free pages in kernel mem. These are in a format ready + * to be put directly into the top of new user memory. + * + * Modified by TYT, 11/24/91 to add the from_kmem argument, which specifies + * whether the string and the string array are from user or kernel segments: + * + * from_kmem argv * argv ** + * 0 user space user space + * 1 kernel space user space + * 2 kernel space kernel space + * + * We do this by playing games with the fs segment register. Since it + * it is expensive to load a segment register, we try to avoid calling + * set_fs() unless we absolutely have to. + */ +static unsigned long copy_strings(int argc,char ** argv,unsigned long *page, + unsigned long p, int from_kmem) +{ + char *tmp, *pag=NULL; + int len, offset = 0; + unsigned long old_fs, new_fs; + + if (!p) + return 0; /* bullet-proofing */ + new_fs = get_ds(); + old_fs = get_fs(); + if (from_kmem==2) + set_fs(new_fs); + while (argc-- > 0) { + if (from_kmem == 1) + set_fs(new_fs); + if (!(tmp = (char *)get_fs_long(((unsigned long *)argv)+argc))) + panic("argc is wrong"); + if (from_kmem == 1) + set_fs(old_fs); + len=0; /* remember zero-padding */ + do { + len++; + } while (get_fs_byte(tmp++)); + if (p-len < 0) { /* this shouldn't happen - 128kB */ + set_fs(old_fs); + return 0; + } + while (len) { + --p; --tmp; --len; + if (--offset < 0) { + offset = p % PAGE_SIZE; + if (from_kmem==2) + set_fs(old_fs); + if (!(pag = (char *) page[p/PAGE_SIZE]) && + !(pag = (char *) page[p/PAGE_SIZE] = + (unsigned long *) get_free_page())) + return 0; + if (from_kmem==2) + set_fs(new_fs); + + } + *(pag + offset) = get_fs_byte(tmp); + } + } + if (from_kmem==2) + set_fs(old_fs); + return p; +} + +static unsigned long change_ldt(unsigned long text_size,unsigned long * page) +{ + unsigned long code_limit,data_limit,code_base,data_base; + int i; + + code_limit = text_size+PAGE_SIZE -1; + code_limit &= 0xFFFFF000; + data_limit = 0x4000000; + code_base = get_base(current->ldt[1]); + data_base = code_base; + set_base(current->ldt[1],code_base); + set_limit(current->ldt[1],code_limit); + set_base(current->ldt[2],data_base); + set_limit(current->ldt[2],data_limit); +/* make sure fs points to the NEW data segment */ + __asm__("pushl $0x17\n\tpop %%fs"::); + data_base += data_limit; + for (i=MAX_ARG_PAGES-1 ; i>=0 ; i--) { + data_base -= PAGE_SIZE; + if (page[i]) + put_page(page[i],data_base); + } + return data_limit; +} + +/* + * 'do_execve()' executes a new program. + */ +int do_execve(unsigned long * eip,long tmp,char * filename, + char ** argv, char ** envp) +{ + struct m_inode * inode; + struct buffer_head * bh; + struct exec ex; + unsigned long page[MAX_ARG_PAGES]; + int i,argc,envc; + int e_uid, e_gid; + int retval; + int sh_bang = 0; + unsigned long p=PAGE_SIZE*MAX_ARG_PAGES-4; + + if ((0xffff & eip[1]) != 0x000f) + panic("execve called from supervisor mode"); + for (i=0 ; ii_mode)) { /* must be regular file */ + retval = -EACCES; + goto exec_error2; + } + i = inode->i_mode; + e_uid = (i & S_ISUID) ? inode->i_uid : current->euid; + e_gid = (i & S_ISGID) ? inode->i_gid : current->egid; + if (current->euid == inode->i_uid) + i >>= 6; + else if (current->egid == inode->i_gid) + i >>= 3; + if (!(i & 1) && + !((inode->i_mode & 0111) && suser())) { + retval = -ENOEXEC; + goto exec_error2; + } + if (!(bh = bread(inode->i_dev,inode->i_zone[0]))) { + retval = -EACCES; + goto exec_error2; + } + ex = *((struct exec *) bh->b_data); /* read exec-header */ + if ((bh->b_data[0] == '#') && (bh->b_data[1] == '!') && (!sh_bang)) { + /* + * This section does the #! interpretation. + * Sorta complicated, but hopefully it will work. -TYT + */ + + char buf[1023], *cp, *interp, *i_name, *i_arg; + unsigned long old_fs; + + strncpy(buf, bh->b_data+2, 1022); + brelse(bh); + iput(inode); + buf[1022] = '\0'; + if ((cp = strchr(buf, '\n'))) { + *cp = '\0'; + for (cp = buf; (*cp == ' ') || (*cp == '\t'); cp++); + } + if (!cp || *cp == '\0') { + retval = -ENOEXEC; /* No interpreter name found */ + goto exec_error1; + } + interp = i_name = cp; + i_arg = 0; + for ( ; *cp && (*cp != ' ') && (*cp != '\t'); cp++) { + if (*cp == '/') + i_name = cp+1; + } + if (*cp) { + *cp++ = '\0'; + i_arg = cp; + } + /* + * OK, we've parsed out the interpreter name and + * (optional) argument. + */ + if (sh_bang++ == 0) { + p = copy_strings(envc, envp, page, p, 0); + p = copy_strings(--argc, argv+1, page, p, 0); + } + /* + * Splice in (1) the interpreter's name for argv[0] + * (2) (optional) argument to interpreter + * (3) filename of shell script + * + * This is done in reverse order, because of how the + * user environment and arguments are stored. + */ + p = copy_strings(1, &filename, page, p, 1); + argc++; + if (i_arg) { + p = copy_strings(1, &i_arg, page, p, 2); + argc++; + } + p = copy_strings(1, &i_name, page, p, 2); + argc++; + if (!p) { + retval = -ENOMEM; + goto exec_error1; + } + /* + * OK, now restart the process with the interpreter's inode. + */ + old_fs = get_fs(); + set_fs(get_ds()); + if (!(inode=namei(interp))) { /* get executables inode */ + set_fs(old_fs); + retval = -ENOENT; + goto exec_error1; + } + set_fs(old_fs); + goto restart_interp; + } + brelse(bh); + if (N_MAGIC(ex) != ZMAGIC || ex.a_trsize || ex.a_drsize || + ex.a_text+ex.a_data+ex.a_bss>0x3000000 || + inode->i_size < ex.a_text+ex.a_data+ex.a_syms+N_TXTOFF(ex)) { + retval = -ENOEXEC; + goto exec_error2; + } + if (N_TXTOFF(ex) != BLOCK_SIZE) { + printk("%s: N_TXTOFF != BLOCK_SIZE. See a.out.h.", filename); + retval = -ENOEXEC; + goto exec_error2; + } + if (!sh_bang) { + p = copy_strings(envc,envp,page,p,0); + p = copy_strings(argc,argv,page,p,0); + if (!p) { + retval = -ENOMEM; + goto exec_error2; + } + } +/* OK, This is the point of no return */ + if (current->executable) + iput(current->executable); + current->executable = inode; + for (i=0 ; i<32 ; i++) + current->sigaction[i].sa_handler = NULL; + for (i=0 ; iclose_on_exec>>i)&1) + sys_close(i); + current->close_on_exec = 0; + free_page_tables(get_base(current->ldt[1]),get_limit(0x0f)); + free_page_tables(get_base(current->ldt[2]),get_limit(0x17)); + if (last_task_used_math == current) + last_task_used_math = NULL; + current->used_math = 0; + p += change_ldt(ex.a_text,page)-MAX_ARG_PAGES*PAGE_SIZE; + p = (unsigned long) create_tables((char *)p,argc,envc); + current->brk = ex.a_bss + + (current->end_data = ex.a_data + + (current->end_code = ex.a_text)); + current->start_stack = p & 0xfffff000; + current->euid = e_uid; + current->egid = e_gid; + i = ex.a_text+ex.a_data; + while (i&0xfff) + put_fs_byte(0,(char *) (i++)); + eip[0] = ex.a_entry; /* eip, magic happens :-) */ + eip[3] = p; /* stack pointer */ + return 0; +exec_error2: + iput(inode); +exec_error1: + for (i=0 ; i */ +#include +#include +#include +#include + +#include +#include + +extern int sys_close(int fd); + +static int dupfd(unsigned int fd, unsigned int arg) +{ + if (fd >= NR_OPEN || !current->filp[fd]) + return -EBADF; + if (arg >= NR_OPEN) + return -EINVAL; + while (arg < NR_OPEN) + if (current->filp[arg]) + arg++; + else + break; + if (arg >= NR_OPEN) + return -EMFILE; + current->close_on_exec &= ~(1<filp[arg] = current->filp[fd])->f_count++; + return arg; +} + +int sys_dup2(unsigned int oldfd, unsigned int newfd) +{ + sys_close(newfd); + return dupfd(oldfd,newfd); +} + +int sys_dup(unsigned int fildes) +{ + return dupfd(fildes,0); +} + +int sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg) +{ + struct file * filp; + + if (fd >= NR_OPEN || !(filp = current->filp[fd])) + return -EBADF; + switch (cmd) { + case F_DUPFD: + return dupfd(fd,arg); + case F_GETFD: + return (current->close_on_exec>>fd)&1; + case F_SETFD: + if (arg&1) + current->close_on_exec |= (1<close_on_exec &= ~(1<f_flags; + case F_SETFL: + filp->f_flags &= ~(O_APPEND | O_NONBLOCK); + filp->f_flags |= arg & (O_APPEND | O_NONBLOCK); + return 0; + case F_GETLK: case F_SETLK: case F_SETLKW: + return -1; + default: + return -1; + } +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/fcntl.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/fcntl.o new file mode 100644 index 0000000..aedf297 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/fcntl.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_dev.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_dev.c new file mode 100644 index 0000000..5aceb46 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_dev.c @@ -0,0 +1,90 @@ +/* + * linux/fs/file_dev.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include + +#include +#include +#include + +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + +int file_read(struct m_inode * inode, struct file * filp, char * buf, int count) +{ + int left,chars,nr; + struct buffer_head * bh; + + if ((left=count)<=0) + return 0; + while (left) { + if ((nr = bmap(inode,(filp->f_pos)/BLOCK_SIZE))) { + if (!(bh=bread(inode->i_dev,nr))) + break; + } else + bh = NULL; + nr = filp->f_pos % BLOCK_SIZE; + chars = MIN( BLOCK_SIZE-nr , left ); + filp->f_pos += chars; + left -= chars; + if (bh) { + char * p = nr + bh->b_data; + while (chars-->0) + put_fs_byte(*(p++),buf++); + brelse(bh); + } else { + while (chars-->0) + put_fs_byte(0,buf++); + } + } + inode->i_atime = CURRENT_TIME; + return (count-left)?(count-left):-ERROR; +} + +int file_write(struct m_inode * inode, struct file * filp, char * buf, int count) +{ + off_t pos; + int block,c; + struct buffer_head * bh; + char * p; + int i=0; + +/* + * ok, append may not work when many processes are writing at the same time + * but so what. That way leads to madness anyway. + */ + if (filp->f_flags & O_APPEND) + pos = inode->i_size; + else + pos = filp->f_pos; + while (ii_dev,block))) + break; + c = pos % BLOCK_SIZE; + p = c + bh->b_data; + bh->b_dirt = 1; + c = BLOCK_SIZE-c; + if (c > count-i) c = count-i; + pos += c; + if (pos > inode->i_size) { + inode->i_size = pos; + inode->i_dirt = 1; + } + i += c; + while (c-->0) + *(p++) = get_fs_byte(buf++); + brelse(bh); + } + inode->i_mtime = CURRENT_TIME; + if (!(filp->f_flags & O_APPEND)) { + filp->f_pos = pos; + inode->i_ctime = CURRENT_TIME; + } + return (i?i:-1); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_dev.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_dev.o new file mode 100644 index 0000000..fb1494c Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_dev.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_table.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_table.c new file mode 100644 index 0000000..e0589ac --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_table.c @@ -0,0 +1,9 @@ +/* + * linux/fs/file_table.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +struct file file_table[NR_FILE]; diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_table.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_table.o new file mode 100644 index 0000000..fdf43bc Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/file_table.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/fs.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/fs.o new file mode 100644 index 0000000..9ba14c7 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/fs.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/inode.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/inode.c new file mode 100644 index 0000000..d0b1c32 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/inode.c @@ -0,0 +1,338 @@ +/* + * linux/fs/inode.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include + +#include +#include +#include +#include + +struct m_inode inode_table[NR_INODE]={{0,},}; + +static void read_inode(struct m_inode * inode); +static void write_inode(struct m_inode * inode); + +static inline void wait_on_inode(struct m_inode * inode) +{ + cli(); + while (inode->i_lock) + sleep_on(&inode->i_wait); + sti(); +} + +static inline void lock_inode(struct m_inode * inode) +{ + cli(); + while (inode->i_lock) + sleep_on(&inode->i_wait); + inode->i_lock=1; + sti(); +} + +static inline void unlock_inode(struct m_inode * inode) +{ + inode->i_lock=0; + wake_up(&inode->i_wait); +} + +void invalidate_inodes(int dev) +{ + int i; + struct m_inode * inode; + + inode = 0+inode_table; + for(i=0 ; ii_dev == dev) { + if (inode->i_count) + printk("inode in use on removed disk\n\r"); + inode->i_dev = inode->i_dirt = 0; + } + } +} + +void sync_inodes(void) +{ + int i; + struct m_inode * inode; + + inode = 0+inode_table; + for(i=0 ; ii_dirt && !inode->i_pipe) + write_inode(inode); + } +} + +static int _bmap(struct m_inode * inode,int block,int create) +{ + struct buffer_head * bh; + int i; + + if (block<0) + panic("_bmap: block<0"); + if (block >= 7+512+512*512) + panic("_bmap: block>big"); + if (block<7) { + if (create && !inode->i_zone[block]) + if ((inode->i_zone[block]=new_block(inode->i_dev))) { + inode->i_ctime=CURRENT_TIME; + inode->i_dirt=1; + } + return inode->i_zone[block]; + } + block -= 7; + if (block<512) { + if (create && !inode->i_zone[7]) + if ((inode->i_zone[7]=new_block(inode->i_dev))) { + inode->i_dirt=1; + inode->i_ctime=CURRENT_TIME; + } + if (!inode->i_zone[7]) + return 0; + if (!(bh = bread(inode->i_dev,inode->i_zone[7]))) + return 0; + i = ((unsigned short *) (bh->b_data))[block]; + if (create && !i) + if ((i=new_block(inode->i_dev))) { + ((unsigned short *) (bh->b_data))[block]=i; + bh->b_dirt=1; + } + brelse(bh); + return i; + } + block -= 512; + if (create && !inode->i_zone[8]) + if ((inode->i_zone[8]=new_block(inode->i_dev))) { + inode->i_dirt=1; + inode->i_ctime=CURRENT_TIME; + } + if (!inode->i_zone[8]) + return 0; + if (!(bh=bread(inode->i_dev,inode->i_zone[8]))) + return 0; + i = ((unsigned short *)bh->b_data)[block>>9]; + if (create && !i) + if ((i=new_block(inode->i_dev))) { + ((unsigned short *) (bh->b_data))[block>>9]=i; + bh->b_dirt=1; + } + brelse(bh); + if (!i) + return 0; + if (!(bh=bread(inode->i_dev,i))) + return 0; + i = ((unsigned short *)bh->b_data)[block&511]; + if (create && !i) + if ((i=new_block(inode->i_dev))) { + ((unsigned short *) (bh->b_data))[block&511]=i; + bh->b_dirt=1; + } + brelse(bh); + return i; +} + +int bmap(struct m_inode * inode,int block) +{ + return _bmap(inode,block,0); +} + +int create_block(struct m_inode * inode, int block) +{ + return _bmap(inode,block,1); +} + +void iput(struct m_inode * inode) +{ + if (!inode) + return; + wait_on_inode(inode); + if (!inode->i_count) + panic("iput: trying to free free inode"); + if (inode->i_pipe) { + wake_up(&inode->i_wait); + if (--inode->i_count) + return; + free_page(inode->i_size); + inode->i_count=0; + inode->i_dirt=0; + inode->i_pipe=0; + return; + } + if (!inode->i_dev) { + inode->i_count--; + return; + } + if (S_ISBLK(inode->i_mode)) { + sync_dev(inode->i_zone[0]); + wait_on_inode(inode); + } +repeat: + if (inode->i_count>1) { + inode->i_count--; + return; + } + if (!inode->i_nlinks) { + truncate(inode); + free_inode(inode); + return; + } + if (inode->i_dirt) { + write_inode(inode); /* we can sleep - so do again */ + wait_on_inode(inode); + goto repeat; + } + inode->i_count--; + return; +} + +struct m_inode * get_empty_inode(void) +{ + struct m_inode * inode; + static struct m_inode * last_inode = inode_table; + int i; + + do { + inode = NULL; + for (i = NR_INODE; i ; i--) { + if (++last_inode >= inode_table + NR_INODE) + last_inode = inode_table; + if (!last_inode->i_count) { + inode = last_inode; + if (!inode->i_dirt && !inode->i_lock) + break; + } + } + if (!inode) { + for (i=0 ; ii_dirt) { + write_inode(inode); + wait_on_inode(inode); + } + } while (inode->i_count); + memset(inode,0,sizeof(*inode)); + inode->i_count = 1; + return inode; +} + +struct m_inode * get_pipe_inode(void) +{ + struct m_inode * inode; + + if (!(inode = get_empty_inode())) + return NULL; + if (!(inode->i_size=get_free_page())) { + inode->i_count = 0; + return NULL; + } + inode->i_count = 2; /* sum of readers/writers */ + PIPE_HEAD(*inode) = PIPE_TAIL(*inode) = 0; + inode->i_pipe = 1; + return inode; +} + +struct m_inode * iget(int dev,int nr) +{ + struct m_inode * inode, * empty; + + if (!dev) + panic("iget with dev==0"); + empty = get_empty_inode(); + inode = inode_table; + while (inode < NR_INODE+inode_table) { + if (inode->i_dev != dev || inode->i_num != nr) { + inode++; + continue; + } + wait_on_inode(inode); + if (inode->i_dev != dev || inode->i_num != nr) { + inode = inode_table; + continue; + } + inode->i_count++; + if (inode->i_mount) { + int i; + + for (i = 0 ; i= NR_SUPER) { + printk("Mounted inode hasn't got sb\n"); + if (empty) + iput(empty); + return inode; + } + iput(inode); + dev = super_block[i].s_dev; + nr = ROOT_INO; + inode = inode_table; + continue; + } + if (empty) + iput(empty); + return inode; + } + if (!empty) + return (NULL); + inode=empty; + inode->i_dev = dev; + inode->i_num = nr; + read_inode(inode); + return inode; +} + +static void read_inode(struct m_inode * inode) +{ + struct super_block * sb; + struct buffer_head * bh; + int block; + + lock_inode(inode); + if (!(sb=get_super(inode->i_dev))) + panic("trying to read inode without dev"); + block = 2 + sb->s_imap_blocks + sb->s_zmap_blocks + + (inode->i_num-1)/INODES_PER_BLOCK; + if (!(bh=bread(inode->i_dev,block))) + panic("unable to read i-node block"); + *(struct d_inode *)inode = + ((struct d_inode *)bh->b_data) + [(inode->i_num-1)%INODES_PER_BLOCK]; + brelse(bh); + unlock_inode(inode); +} + +static void write_inode(struct m_inode * inode) +{ + struct super_block * sb; + struct buffer_head * bh; + int block; + + lock_inode(inode); + if (!inode->i_dirt || !inode->i_dev) { + unlock_inode(inode); + return; + } + if (!(sb=get_super(inode->i_dev))) + panic("trying to write inode without device"); + block = 2 + sb->s_imap_blocks + sb->s_zmap_blocks + + (inode->i_num-1)/INODES_PER_BLOCK; + if (!(bh=bread(inode->i_dev,block))) + panic("unable to read i-node block"); + ((struct d_inode *)bh->b_data) + [(inode->i_num-1)%INODES_PER_BLOCK] = + *(struct d_inode *)inode; + bh->b_dirt=1; + inode->i_dirt=0; + brelse(bh); + unlock_inode(inode); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/inode.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/inode.o new file mode 100644 index 0000000..0a48104 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/inode.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/ioctl.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/ioctl.c new file mode 100644 index 0000000..47ce3cb --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/ioctl.c @@ -0,0 +1,46 @@ +/* + * linux/fs/ioctl.c + * + * (C) 1991 Linus Torvalds + */ + +/* #include */ +#include +#include + +#include + +extern int tty_ioctl(int dev, int cmd, int arg); + +typedef int (*ioctl_ptr)(int dev,int cmd,int arg); + +#define NRDEVS ((sizeof (ioctl_table))/(sizeof (ioctl_ptr))) + +static ioctl_ptr ioctl_table[]={ + NULL, /* nodev */ + NULL, /* /dev/mem */ + NULL, /* /dev/fd */ + NULL, /* /dev/hd */ + tty_ioctl, /* /dev/ttyx */ + tty_ioctl, /* /dev/tty */ + NULL, /* /dev/lp */ + NULL}; /* named pipes */ + + +int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) +{ + struct file * filp; + int dev,mode; + + if (fd >= NR_OPEN || !(filp = current->filp[fd])) + return -EBADF; + mode=filp->f_inode->i_mode; + if (!S_ISCHR(mode) && !S_ISBLK(mode)) + return -EINVAL; + dev = filp->f_inode->i_zone[0]; + if (MAJOR(dev) >= NRDEVS) + return -ENODEV; + if (!ioctl_table[MAJOR(dev)]) + return -ENOTTY; + return ioctl_table[MAJOR(dev)](dev,cmd,arg); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/ioctl.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/ioctl.o new file mode 100644 index 0000000..ded205c Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/ioctl.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/namei.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/namei.c new file mode 100644 index 0000000..97d0de4 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/namei.c @@ -0,0 +1,778 @@ +/* + * linux/fs/namei.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * Some corrections by tytso. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#define ACC_MODE(x) ("\004\002\006\377"[(x)&O_ACCMODE]) + +/* + * comment out this line if you want names > NAME_LEN chars to be + * truncated. Else they will be disallowed. + */ +/* #define NO_TRUNCATE */ + +#define MAY_EXEC 1 +#define MAY_WRITE 2 +#define MAY_READ 4 + +/* + * permission() + * + * is used to check for read/write/execute permissions on a file. + * I don't know if we should look at just the euid or both euid and + * uid, but that should be easily changed. + */ +static int permission(struct m_inode * inode,int mask) +{ + int mode = inode->i_mode; + +/* special case: not even root can read/write a deleted file */ + if (inode->i_dev && !inode->i_nlinks) + return 0; + else if (current->euid==inode->i_uid) + mode >>= 6; + else if (current->egid==inode->i_gid) + mode >>= 3; + if (((mode & mask & 0007) == mask) || suser()) + return 1; + return 0; +} + +/* + * ok, we cannot use strncmp, as the name is not in our data space. + * Thus we'll have to use match. No big problem. Match also makes + * some sanity tests. + * + * NOTE! unlike strncmp, match returns 1 for success, 0 for failure. + */ +static int match(int len,const char * name,struct dir_entry * de) +{ + register int same ; + + if (!de || !de->inode || len > NAME_LEN) + return 0; + if (len < NAME_LEN && de->name[len]) + return 0; + __asm__("cld\n\t" + "fs ; repe ; cmpsb\n\t" + "setz %%al" + :"=a" (same) + :"0" (0),"S" ((long) name),"D" ((long) de->name),"c" (len) + ); + return same; +} + +/* + * find_entry() + * + * finds an entry in the specified directory with the wanted name. It + * returns the cache buffer in which the entry was found, and the entry + * itself (as a parameter - res_dir). It does NOT read the inode of the + * entry - you'll have to do that yourself if you want to. + * + * This also takes care of the few special cases due to '..'-traversal + * over a pseudo-root and a mount point. + */ +static struct buffer_head * find_entry(struct m_inode ** dir, + const char * name, int namelen, struct dir_entry ** res_dir) +{ + int entries; + int block,i; + struct buffer_head * bh; + struct dir_entry * de; + struct super_block * sb; + +#ifdef NO_TRUNCATE + if (namelen > NAME_LEN) + return NULL; +#else + if (namelen > NAME_LEN) + namelen = NAME_LEN; +#endif + entries = (*dir)->i_size / (sizeof (struct dir_entry)); + *res_dir = NULL; + if (!namelen) + return NULL; +/* check for '..', as we might have to do some "magic" for it */ + if (namelen==2 && get_fs_byte(name)=='.' && get_fs_byte(name+1)=='.') { +/* '..' in a pseudo-root results in a faked '.' (just change namelen) */ + if ((*dir) == current->root) + namelen=1; + else if ((*dir)->i_num == ROOT_INO) { +/* '..' over a mount-point results in 'dir' being exchanged for the mounted + directory-inode. NOTE! We set mounted, so that we can iput the new dir */ + sb=get_super((*dir)->i_dev); + if (sb->s_imount) { + iput(*dir); + (*dir)=sb->s_imount; + (*dir)->i_count++; + } + } + } + if (!(block = (*dir)->i_zone[0])) + return NULL; + if (!(bh = bread((*dir)->i_dev,block))) + return NULL; + i = 0; + de = (struct dir_entry *) bh->b_data; + while (i < entries) { + if ((char *)de >= BLOCK_SIZE+bh->b_data) { + brelse(bh); + bh = NULL; + if (!(block = bmap(*dir,i/DIR_ENTRIES_PER_BLOCK)) || + !(bh = bread((*dir)->i_dev,block))) { + i += DIR_ENTRIES_PER_BLOCK; + continue; + } + de = (struct dir_entry *) bh->b_data; + } + if (match(namelen,name,de)) { + *res_dir = de; + return bh; + } + de++; + i++; + } + brelse(bh); + return NULL; +} + +/* + * add_entry() + * + * adds a file entry to the specified directory, using the same + * semantics as find_entry(). It returns NULL if it failed. + * + * NOTE!! The inode part of 'de' is left at 0 - which means you + * may not sleep between calling this and putting something into + * the entry, as someone else might have used it while you slept. + */ +static struct buffer_head * add_entry(struct m_inode * dir, + const char * name, int namelen, struct dir_entry ** res_dir) +{ + int block,i; + struct buffer_head * bh; + struct dir_entry * de; + + *res_dir = NULL; +#ifdef NO_TRUNCATE + if (namelen > NAME_LEN) + return NULL; +#else + if (namelen > NAME_LEN) + namelen = NAME_LEN; +#endif + if (!namelen) + return NULL; + if (!(block = dir->i_zone[0])) + return NULL; + if (!(bh = bread(dir->i_dev,block))) + return NULL; + i = 0; + de = (struct dir_entry *) bh->b_data; + while (1) { + if ((char *)de >= BLOCK_SIZE+bh->b_data) { + brelse(bh); + bh = NULL; + block = create_block(dir,i/DIR_ENTRIES_PER_BLOCK); + if (!block) + return NULL; + if (!(bh = bread(dir->i_dev,block))) { + i += DIR_ENTRIES_PER_BLOCK; + continue; + } + de = (struct dir_entry *) bh->b_data; + } + if (i*sizeof(struct dir_entry) >= dir->i_size) { + de->inode=0; + dir->i_size = (i+1)*sizeof(struct dir_entry); + dir->i_dirt = 1; + dir->i_ctime = CURRENT_TIME; + } + if (!de->inode) { + dir->i_mtime = CURRENT_TIME; + for (i=0; i < NAME_LEN ; i++) + de->name[i]=(ib_dirt = 1; + *res_dir = de; + return bh; + } + de++; + i++; + } + brelse(bh); + return NULL; +} + +/* + * get_dir() + * + * Getdir traverses the pathname until it hits the topmost directory. + * It returns NULL on failure. + */ +static struct m_inode * get_dir(const char * pathname) +{ + char c; + const char * thisname; + struct m_inode * inode; + struct buffer_head * bh; + int namelen,inr,idev; + struct dir_entry * de; + + if (!current->root || !current->root->i_count) + panic("No root inode"); + if (!current->pwd || !current->pwd->i_count) + panic("No cwd inode"); + if ((c=get_fs_byte(pathname))=='/') { + inode = current->root; + pathname++; + } else if (c) + inode = current->pwd; + else + return NULL; /* empty name is bad */ + inode->i_count++; + while (1) { + thisname = pathname; + if (!S_ISDIR(inode->i_mode) || !permission(inode,MAY_EXEC)) { + iput(inode); + return NULL; + } + for(namelen=0;(c=get_fs_byte(pathname++))&&(c!='/');namelen++) + /* nothing */ ; + if (!c) + return inode; + if (!(bh = find_entry(&inode,thisname,namelen,&de))) { + iput(inode); + return NULL; + } + inr = de->inode; + idev = inode->i_dev; + brelse(bh); + iput(inode); + if (!(inode = iget(idev,inr))) + return NULL; + } +} + +/* + * dir_namei() + * + * dir_namei() returns the inode of the directory of the + * specified name, and the name within that directory. + */ +static struct m_inode * dir_namei(const char * pathname, + int * namelen, const char ** name) +{ + char c; + const char * basename; + struct m_inode * dir; + + if (!(dir = get_dir(pathname))) + return NULL; + basename = pathname; + while ((c=get_fs_byte(pathname++))) + if (c=='/') + basename=pathname; + *namelen = pathname-basename-1; + *name = basename; + return dir; +} + +/* + * namei() + * + * is used by most simple commands to get the inode of a specified name. + * Open, link etc use their own routines, but this is enough for things + * like 'chmod' etc. + */ +struct m_inode * namei(const char * pathname) +{ + const char * basename; + int inr,dev,namelen; + struct m_inode * dir; + struct buffer_head * bh; + struct dir_entry * de; + + if (!(dir = dir_namei(pathname,&namelen,&basename))) + return NULL; + if (!namelen) /* special case: '/usr/' etc */ + return dir; + bh = find_entry(&dir,basename,namelen,&de); + if (!bh) { + iput(dir); + return NULL; + } + inr = de->inode; + dev = dir->i_dev; + brelse(bh); + iput(dir); + dir=iget(dev,inr); + if (dir) { + dir->i_atime=CURRENT_TIME; + dir->i_dirt=1; + } + return dir; +} + +/* + * open_namei() + * + * namei for open - this is in fact almost the whole open-routine. + */ +int open_namei(const char * pathname, int flag, int mode, + struct m_inode ** res_inode) +{ + const char * basename; + int inr,dev,namelen; + struct m_inode * dir, *inode; + struct buffer_head * bh; + struct dir_entry * de; + + if ((flag & O_TRUNC) && !(flag & O_ACCMODE)) + flag |= O_WRONLY; + mode &= 0777 & ~current->umask; + mode |= I_REGULAR; + if (!(dir = dir_namei(pathname,&namelen,&basename))) + return -ENOENT; + if (!namelen) { /* special case: '/usr/' etc */ + if (!(flag & (O_ACCMODE|O_CREAT|O_TRUNC))) { + *res_inode=dir; + return 0; + } + iput(dir); + return -EISDIR; + } + bh = find_entry(&dir,basename,namelen,&de); + if (!bh) { + if (!(flag & O_CREAT)) { + iput(dir); + return -ENOENT; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + return -EACCES; + } + inode = new_inode(dir->i_dev); + if (!inode) { + iput(dir); + return -ENOSPC; + } + inode->i_uid = current->euid; + inode->i_mode = mode; + inode->i_dirt = 1; + bh = add_entry(dir,basename,namelen,&de); + if (!bh) { + inode->i_nlinks--; + iput(inode); + iput(dir); + return -ENOSPC; + } + de->inode = inode->i_num; + bh->b_dirt = 1; + brelse(bh); + iput(dir); + *res_inode = inode; + return 0; + } + inr = de->inode; + dev = dir->i_dev; + brelse(bh); + iput(dir); + if (flag & O_EXCL) + return -EEXIST; + if (!(inode=iget(dev,inr))) + return -EACCES; + if ((S_ISDIR(inode->i_mode) && (flag & O_ACCMODE)) || + !permission(inode,ACC_MODE(flag))) { + iput(inode); + return -EPERM; + } + inode->i_atime = CURRENT_TIME; + if (flag & O_TRUNC) + truncate(inode); + *res_inode = inode; + return 0; +} + +int sys_mknod(const char * filename, int mode, int dev) +{ + const char * basename; + int namelen; + struct m_inode * dir, * inode; + struct buffer_head * bh; + struct dir_entry * de; + + if (!suser()) + return -EPERM; + if (!(dir = dir_namei(filename,&namelen,&basename))) + return -ENOENT; + if (!namelen) { + iput(dir); + return -ENOENT; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + return -EPERM; + } + bh = find_entry(&dir,basename,namelen,&de); + if (bh) { + brelse(bh); + iput(dir); + return -EEXIST; + } + inode = new_inode(dir->i_dev); + if (!inode) { + iput(dir); + return -ENOSPC; + } + inode->i_mode = mode; + if (S_ISBLK(mode) || S_ISCHR(mode)) + inode->i_zone[0] = dev; + inode->i_mtime = inode->i_atime = CURRENT_TIME; + inode->i_dirt = 1; + bh = add_entry(dir,basename,namelen,&de); + if (!bh) { + iput(dir); + inode->i_nlinks=0; + iput(inode); + return -ENOSPC; + } + de->inode = inode->i_num; + bh->b_dirt = 1; + iput(dir); + iput(inode); + brelse(bh); + return 0; +} + +int sys_mkdir(const char * pathname, int mode) +{ + const char * basename; + int namelen; + struct m_inode * dir, * inode; + struct buffer_head * bh, *dir_block; + struct dir_entry * de; + + if (!suser()) + return -EPERM; + if (!(dir = dir_namei(pathname,&namelen,&basename))) + return -ENOENT; + if (!namelen) { + iput(dir); + return -ENOENT; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + return -EPERM; + } + bh = find_entry(&dir,basename,namelen,&de); + if (bh) { + brelse(bh); + iput(dir); + return -EEXIST; + } + inode = new_inode(dir->i_dev); + if (!inode) { + iput(dir); + return -ENOSPC; + } + inode->i_size = 32; + inode->i_dirt = 1; + inode->i_mtime = inode->i_atime = CURRENT_TIME; + if (!(inode->i_zone[0]=new_block(inode->i_dev))) { + iput(dir); + inode->i_nlinks--; + iput(inode); + return -ENOSPC; + } + inode->i_dirt = 1; + if (!(dir_block=bread(inode->i_dev,inode->i_zone[0]))) { + iput(dir); + free_block(inode->i_dev,inode->i_zone[0]); + inode->i_nlinks--; + iput(inode); + return -ERROR; + } + de = (struct dir_entry *) dir_block->b_data; + de->inode=inode->i_num; + strcpy(de->name,"."); + de++; + de->inode = dir->i_num; + strcpy(de->name,".."); + inode->i_nlinks = 2; + dir_block->b_dirt = 1; + brelse(dir_block); + inode->i_mode = I_DIRECTORY | (mode & 0777 & ~current->umask); + inode->i_dirt = 1; + bh = add_entry(dir,basename,namelen,&de); + if (!bh) { + iput(dir); + free_block(inode->i_dev,inode->i_zone[0]); + inode->i_nlinks=0; + iput(inode); + return -ENOSPC; + } + de->inode = inode->i_num; + bh->b_dirt = 1; + dir->i_nlinks++; + dir->i_dirt = 1; + iput(dir); + iput(inode); + brelse(bh); + return 0; +} + +/* + * routine to check that the specified directory is empty (for rmdir) + */ +static int empty_dir(struct m_inode * inode) +{ + int nr,block; + int len; + struct buffer_head * bh; + struct dir_entry * de; + + len = inode->i_size / sizeof (struct dir_entry); + if (len<2 || !inode->i_zone[0] || + !(bh=bread(inode->i_dev,inode->i_zone[0]))) { + printk("warning - bad directory on dev %04x\n",inode->i_dev); + return 0; + } + de = (struct dir_entry *) bh->b_data; + if (de[0].inode != inode->i_num || !de[1].inode || + strcmp(".",de[0].name) || strcmp("..",de[1].name)) { + printk("warning - bad directory on dev %04x\n",inode->i_dev); + return 0; + } + nr = 2; + de += 2; + while (nr= (void *) (bh->b_data+BLOCK_SIZE)) { + brelse(bh); + block=bmap(inode,nr/DIR_ENTRIES_PER_BLOCK); + if (!block) { + nr += DIR_ENTRIES_PER_BLOCK; + continue; + } + if (!(bh=bread(inode->i_dev,block))) + return 0; + de = (struct dir_entry *) bh->b_data; + } + if (de->inode) { + brelse(bh); + return 0; + } + de++; + nr++; + } + brelse(bh); + return 1; +} + +int sys_rmdir(const char * name) +{ + const char * basename; + int namelen; + struct m_inode * dir, * inode; + struct buffer_head * bh; + struct dir_entry * de; + + if (!suser()) + return -EPERM; + if (!(dir = dir_namei(name,&namelen,&basename))) + return -ENOENT; + if (!namelen) { + iput(dir); + return -ENOENT; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + return -EPERM; + } + bh = find_entry(&dir,basename,namelen,&de); + if (!bh) { + iput(dir); + return -ENOENT; + } + if (!(inode = iget(dir->i_dev, de->inode))) { + iput(dir); + brelse(bh); + return -EPERM; + } + if ((dir->i_mode & S_ISVTX) && current->euid && + inode->i_uid != current->euid) { + iput(dir); + iput(inode); + brelse(bh); + return -EPERM; + } + if (inode->i_dev != dir->i_dev || inode->i_count>1) { + iput(dir); + iput(inode); + brelse(bh); + return -EPERM; + } + if (inode == dir) { /* we may not delete ".", but "../dir" is ok */ + iput(inode); + iput(dir); + brelse(bh); + return -EPERM; + } + if (!S_ISDIR(inode->i_mode)) { + iput(inode); + iput(dir); + brelse(bh); + return -ENOTDIR; + } + if (!empty_dir(inode)) { + iput(inode); + iput(dir); + brelse(bh); + return -ENOTEMPTY; + } + if (inode->i_nlinks != 2) + printk("empty directory has nlink!=2 (%d)",inode->i_nlinks); + de->inode = 0; + bh->b_dirt = 1; + brelse(bh); + inode->i_nlinks=0; + inode->i_dirt=1; + dir->i_nlinks--; + dir->i_ctime = dir->i_mtime = CURRENT_TIME; + dir->i_dirt=1; + iput(dir); + iput(inode); + return 0; +} + +int sys_unlink(const char * name) +{ + const char * basename; + int namelen; + struct m_inode * dir, * inode; + struct buffer_head * bh; + struct dir_entry * de; + + if (!(dir = dir_namei(name,&namelen,&basename))) + return -ENOENT; + if (!namelen) { + iput(dir); + return -ENOENT; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + return -EPERM; + } + bh = find_entry(&dir,basename,namelen,&de); + if (!bh) { + iput(dir); + return -ENOENT; + } + if (!(inode = iget(dir->i_dev, de->inode))) { + iput(dir); + brelse(bh); + return -ENOENT; + } + if ((dir->i_mode & S_ISVTX) && !suser() && + current->euid != inode->i_uid && + current->euid != dir->i_uid) { + iput(dir); + iput(inode); + brelse(bh); + return -EPERM; + } + if (S_ISDIR(inode->i_mode)) { + iput(inode); + iput(dir); + brelse(bh); + return -EPERM; + } + if (!inode->i_nlinks) { + printk("Deleting nonexistent file (%04x:%d), %d\n", + inode->i_dev,inode->i_num,inode->i_nlinks); + inode->i_nlinks=1; + } + de->inode = 0; + bh->b_dirt = 1; + brelse(bh); + inode->i_nlinks--; + inode->i_dirt = 1; + inode->i_ctime = CURRENT_TIME; + iput(inode); + iput(dir); + return 0; +} + +int sys_link(const char * oldname, const char * newname) +{ + struct dir_entry * de; + struct m_inode * oldinode, * dir; + struct buffer_head * bh; + const char * basename; + int namelen; + + oldinode=namei(oldname); + if (!oldinode) + return -ENOENT; + if (S_ISDIR(oldinode->i_mode)) { + iput(oldinode); + return -EPERM; + } + dir = dir_namei(newname,&namelen,&basename); + if (!dir) { + iput(oldinode); + return -EACCES; + } + if (!namelen) { + iput(oldinode); + iput(dir); + return -EPERM; + } + if (dir->i_dev != oldinode->i_dev) { + iput(dir); + iput(oldinode); + return -EXDEV; + } + if (!permission(dir,MAY_WRITE)) { + iput(dir); + iput(oldinode); + return -EACCES; + } + bh = find_entry(&dir,basename,namelen,&de); + if (bh) { + brelse(bh); + iput(dir); + iput(oldinode); + return -EEXIST; + } + bh = add_entry(dir,basename,namelen,&de); + if (!bh) { + iput(dir); + iput(oldinode); + return -ENOSPC; + } + de->inode = oldinode->i_num; + bh->b_dirt = 1; + brelse(bh); + iput(dir); + oldinode->i_nlinks++; + oldinode->i_ctime = CURRENT_TIME; + oldinode->i_dirt = 1; + iput(oldinode); + return 0; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/namei.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/namei.o new file mode 100644 index 0000000..472cd48 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/namei.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/open.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/open.c new file mode 100644 index 0000000..cac0082 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/open.c @@ -0,0 +1,209 @@ +/* + * linux/fs/open.c + * + * (C) 1991 Linus Torvalds + */ + +/* #include */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +int sys_ustat(int dev, struct ustat * ubuf) +{ + return -ENOSYS; +} + +int sys_utime(char * filename, struct utimbuf * times) +{ + struct m_inode * inode; + long actime,modtime; + + if (!(inode=namei(filename))) + return -ENOENT; + if (times) { + actime = get_fs_long((unsigned long *) ×->actime); + modtime = get_fs_long((unsigned long *) ×->modtime); + } else + actime = modtime = CURRENT_TIME; + inode->i_atime = actime; + inode->i_mtime = modtime; + inode->i_dirt = 1; + iput(inode); + return 0; +} + +/* + * XXX should we use the real or effective uid? BSD uses the real uid, + * so as to make this call useful to setuid programs. + */ +int sys_access(const char * filename,int mode) +{ + struct m_inode * inode; + int res, i_mode; + + mode &= 0007; + if (!(inode=namei(filename))) + return -EACCES; + i_mode = res = inode->i_mode & 0777; + iput(inode); + if (current->uid == inode->i_uid) + res >>= 6; + else if (current->gid == inode->i_gid) + res >>= 6; + if ((res & 0007 & mode) == mode) + return 0; + /* + * XXX we are doing this test last because we really should be + * swapping the effective with the real user id (temporarily), + * and then calling suser() routine. If we do call the + * suser() routine, it needs to be called last. + */ + if ((!current->uid) && + (!(mode & 1) || (i_mode & 0111))) + return 0; + return -EACCES; +} + +int sys_chdir(const char * filename) +{ + struct m_inode * inode; + + if (!(inode = namei(filename))) + return -ENOENT; + if (!S_ISDIR(inode->i_mode)) { + iput(inode); + return -ENOTDIR; + } + iput(current->pwd); + current->pwd = inode; + return (0); +} + +int sys_chroot(const char * filename) +{ + struct m_inode * inode; + + if (!(inode=namei(filename))) + return -ENOENT; + if (!S_ISDIR(inode->i_mode)) { + iput(inode); + return -ENOTDIR; + } + iput(current->root); + current->root = inode; + return (0); +} + +int sys_chmod(const char * filename,int mode) +{ + struct m_inode * inode; + + if (!(inode=namei(filename))) + return -ENOENT; + if ((current->euid != inode->i_uid) && !suser()) { + iput(inode); + return -EACCES; + } + inode->i_mode = (mode & 07777) | (inode->i_mode & ~07777); + inode->i_dirt = 1; + iput(inode); + return 0; +} + +int sys_chown(const char * filename,int uid,int gid) +{ + struct m_inode * inode; + + if (!(inode=namei(filename))) + return -ENOENT; + if (!suser()) { + iput(inode); + return -EACCES; + } + inode->i_uid=uid; + inode->i_gid=gid; + inode->i_dirt=1; + iput(inode); + return 0; +} + +int sys_open(const char * filename,int flag,int mode) +{ + struct m_inode * inode; + struct file * f; + int i,fd; + + mode &= 0777 & ~current->umask; + for(fd=0 ; fdfilp[fd]) + break; + if (fd>=NR_OPEN) + return -EINVAL; + current->close_on_exec &= ~(1<f_count) break; + if (i>=NR_FILE) + return -EINVAL; + (current->filp[fd]=f)->f_count++; + if ((i=open_namei(filename,flag,mode,&inode))<0) { + current->filp[fd]=NULL; + f->f_count=0; + return i; + } +/* ttys are somewhat special (ttyxx major==4, tty major==5) */ + if (S_ISCHR(inode->i_mode)) { + if (MAJOR(inode->i_zone[0])==4) { + if (current->leader && current->tty<0) { + current->tty = MINOR(inode->i_zone[0]); + tty_table[current->tty].pgrp = current->pgrp; + } + } else if (MAJOR(inode->i_zone[0])==5) + if (current->tty<0) { + iput(inode); + current->filp[fd]=NULL; + f->f_count=0; + return -EPERM; + } + } +/* Likewise with block-devices: check for floppy_change */ + if (S_ISBLK(inode->i_mode)) + check_disk_change(inode->i_zone[0]); + f->f_mode = inode->i_mode; + f->f_flags = flag; + f->f_count = 1; + f->f_inode = inode; + f->f_pos = 0; + return (fd); +} + +int sys_creat(const char * pathname, int mode) +{ + return sys_open(pathname, O_CREAT | O_TRUNC, mode); +} + +int sys_close(unsigned int fd) +{ + struct file * filp; + + if (fd >= NR_OPEN) + return -EINVAL; + current->close_on_exec &= ~(1<filp[fd])) + return -EINVAL; + current->filp[fd] = NULL; + if (filp->f_count == 0) + panic("Close: file count is 0"); + if (--filp->f_count) + return (0); + iput(filp->f_inode); + return (0); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/open.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/open.o new file mode 100644 index 0000000..5ba8129 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/open.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/pipe.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/pipe.c new file mode 100644 index 0000000..dfc4480 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/pipe.c @@ -0,0 +1,111 @@ +/* + * linux/fs/pipe.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +#include +#include /* for get_free_page */ +#include + +int read_pipe(struct m_inode * inode, char * buf, int count) +{ + int chars, size, read = 0; + + while (count>0) { + while (!(size=PIPE_SIZE(*inode))) { + wake_up(&inode->i_wait); + if (inode->i_count != 2) /* are there any writers? */ + return read; + sleep_on(&inode->i_wait); + } + chars = PAGE_SIZE-PIPE_TAIL(*inode); + if (chars > count) + chars = count; + if (chars > size) + chars = size; + count -= chars; + read += chars; + size = PIPE_TAIL(*inode); + PIPE_TAIL(*inode) += chars; + PIPE_TAIL(*inode) &= (PAGE_SIZE-1); + while (chars-->0) + put_fs_byte(((char *)inode->i_size)[size++],buf++); + } + wake_up(&inode->i_wait); + return read; +} + +int write_pipe(struct m_inode * inode, char * buf, int count) +{ + int chars, size, written = 0; + + while (count>0) { + while (!(size=(PAGE_SIZE-1)-PIPE_SIZE(*inode))) { + wake_up(&inode->i_wait); + if (inode->i_count != 2) { /* no readers */ + current->signal |= (1<<(SIGPIPE-1)); + return written?written:-1; + } + sleep_on(&inode->i_wait); + } + chars = PAGE_SIZE-PIPE_HEAD(*inode); + if (chars > count) + chars = count; + if (chars > size) + chars = size; + count -= chars; + written += chars; + size = PIPE_HEAD(*inode); + PIPE_HEAD(*inode) += chars; + PIPE_HEAD(*inode) &= (PAGE_SIZE-1); + while (chars-->0) + ((char *)inode->i_size)[size++]=get_fs_byte(buf++); + } + wake_up(&inode->i_wait); + return written; +} + +int sys_pipe(unsigned long * fildes) +{ + struct m_inode * inode; + struct file * f[2]; + int fd[2]; + int i,j; + + j=0; + for(i=0;j<2 && if_count++; + if (j==1) + f[0]->f_count=0; + if (j<2) + return -1; + j=0; + for(i=0;j<2 && ifilp[i]) { + current->filp[ fd[j]=i ] = f[j]; + j++; + } + if (j==1) + current->filp[fd[0]]=NULL; + if (j<2) { + f[0]->f_count=f[1]->f_count=0; + return -1; + } + if (!(inode=get_pipe_inode())) { + current->filp[fd[0]] = + current->filp[fd[1]] = NULL; + f[0]->f_count = f[1]->f_count = 0; + return -1; + } + f[0]->f_inode = f[1]->f_inode = inode; + f[0]->f_pos = f[1]->f_pos = 0; + f[0]->f_mode = 1; /* read */ + f[1]->f_mode = 2; /* write */ + put_fs_long(fd[0],0+fildes); + put_fs_long(fd[1],1+fildes); + return 0; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/pipe.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/pipe.o new file mode 100644 index 0000000..a70b1b4 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/pipe.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/read_write.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/read_write.c new file mode 100644 index 0000000..341274a --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/read_write.c @@ -0,0 +1,103 @@ +/* + * linux/fs/read_write.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include +#include + +#include +#include +#include + +extern int rw_char(int rw,int dev, char * buf, int count, off_t * pos); +extern int read_pipe(struct m_inode * inode, char * buf, int count); +extern int write_pipe(struct m_inode * inode, char * buf, int count); +extern int block_read(int dev, off_t * pos, char * buf, int count); +extern int block_write(int dev, off_t * pos, char * buf, int count); +extern int file_read(struct m_inode * inode, struct file * filp, + char * buf, int count); +extern int file_write(struct m_inode * inode, struct file * filp, + char * buf, int count); + +int sys_lseek(unsigned int fd,off_t offset, int origin) +{ + struct file * file; + int tmp; + + if (fd >= NR_OPEN || !(file=current->filp[fd]) || !(file->f_inode) + || !IS_SEEKABLE(MAJOR(file->f_inode->i_dev))) + return -EBADF; + if (file->f_inode->i_pipe) + return -ESPIPE; + switch (origin) { + case 0: + if (offset<0) return -EINVAL; + file->f_pos=offset; + break; + case 1: + if (file->f_pos+offset<0) return -EINVAL; + file->f_pos += offset; + break; + case 2: + if ((tmp=file->f_inode->i_size+offset) < 0) + return -EINVAL; + file->f_pos = tmp; + break; + default: + return -EINVAL; + } + return file->f_pos; +} + +int sys_read(unsigned int fd,char * buf,int count) +{ + struct file * file; + struct m_inode * inode; + + if (fd>=NR_OPEN || count<0 || !(file=current->filp[fd])) + return -EINVAL; + if (!count) + return 0; + verify_area(buf,count); + inode = file->f_inode; + if (inode->i_pipe) + return (file->f_mode&1)?read_pipe(inode,buf,count):-EIO; + if (S_ISCHR(inode->i_mode)) + return rw_char(READ,inode->i_zone[0],buf,count,&file->f_pos); + if (S_ISBLK(inode->i_mode)) + return block_read(inode->i_zone[0],&file->f_pos,buf,count); + if (S_ISDIR(inode->i_mode) || S_ISREG(inode->i_mode)) { + if (count+file->f_pos > inode->i_size) + count = inode->i_size - file->f_pos; + if (count<=0) + return 0; + return file_read(inode,file,buf,count); + } + printk("(Read)inode->i_mode=%06o\n\r",inode->i_mode); + return -EINVAL; +} + +int sys_write(unsigned int fd,char * buf,int count) +{ + struct file * file; + struct m_inode * inode; + + if (fd>=NR_OPEN || count <0 || !(file=current->filp[fd])) + return -EINVAL; + if (!count) + return 0; + inode=file->f_inode; + if (inode->i_pipe) + return (file->f_mode&2)?write_pipe(inode,buf,count):-EIO; + if (S_ISCHR(inode->i_mode)) + return rw_char(WRITE,inode->i_zone[0],buf,count,&file->f_pos); + if (S_ISBLK(inode->i_mode)) + return block_write(inode->i_zone[0],&file->f_pos,buf,count); + if (S_ISREG(inode->i_mode)) + return file_write(inode,file,buf,count); + printk("(Write)inode->i_mode=%06o\n\r",inode->i_mode); + return -EINVAL; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/read_write.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/read_write.o new file mode 100644 index 0000000..b7696ea Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/read_write.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/stat.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/stat.c new file mode 100644 index 0000000..61a4ceb --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/stat.c @@ -0,0 +1,56 @@ +/* + * linux/fs/stat.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include + +#include +#include +#include +#include + +static void cp_stat(struct m_inode * inode, struct stat * statbuf) +{ + struct stat tmp; + int i; + + verify_area(statbuf,sizeof (* statbuf)); + tmp.st_dev = inode->i_dev; + tmp.st_ino = inode->i_num; + tmp.st_mode = inode->i_mode; + tmp.st_nlink = inode->i_nlinks; + tmp.st_uid = inode->i_uid; + tmp.st_gid = inode->i_gid; + tmp.st_rdev = inode->i_zone[0]; + tmp.st_size = inode->i_size; + tmp.st_atime = inode->i_atime; + tmp.st_mtime = inode->i_mtime; + tmp.st_ctime = inode->i_ctime; + for (i=0 ; i= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode)) + return -EBADF; + cp_stat(inode,statbuf); + return 0; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/stat.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/stat.o new file mode 100644 index 0000000..851907d Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/stat.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/super.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/super.c new file mode 100644 index 0000000..39c4089 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/super.c @@ -0,0 +1,281 @@ +/* + * linux/fs/super.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * super.c contains code to handle the super-block tables. + */ +#include +#include +#include +#include + +#include +#include + +int sync_dev(int dev); +void wait_for_keypress(void); + +/* set_bit uses setb, as gas doesn't recognize setc */ +#define set_bit(bitnr,addr) ({ \ +register int __res ; \ +__asm__("bt %2,%3;setb %%al":"=a" (__res):"a" (0),"r" (bitnr),"m" (*(addr))); \ +__res; }) + +struct super_block super_block[NR_SUPER]; +/* this is initialized in init/main.c */ +int ROOT_DEV = 0; + +static void lock_super(struct super_block * sb) +{ + cli(); + while (sb->s_lock) + sleep_on(&(sb->s_wait)); + sb->s_lock = 1; + sti(); +} + +static void free_super(struct super_block * sb) +{ + cli(); + sb->s_lock = 0; + wake_up(&(sb->s_wait)); + sti(); +} + +static void wait_on_super(struct super_block * sb) +{ + cli(); + while (sb->s_lock) + sleep_on(&(sb->s_wait)); + sti(); +} + +struct super_block * get_super(int dev) +{ + struct super_block * s; + + if (!dev) + return NULL; + s = 0+super_block; + while (s < NR_SUPER+super_block) + if (s->s_dev == dev) { + wait_on_super(s); + if (s->s_dev == dev) + return s; + s = 0+super_block; + } else + s++; + return NULL; +} + +void put_super(int dev) +{ + struct super_block * sb; + /* struct m_inode * inode;*/ + int i; + + if (dev == ROOT_DEV) { + printk("root diskette changed: prepare for armageddon\n\r"); + return; + } + if (!(sb = get_super(dev))) + return; + if (sb->s_imount) { + printk("Mounted disk changed - tssk, tssk\n\r"); + return; + } + lock_super(sb); + sb->s_dev = 0; + for(i=0;is_imap[i]); + for(i=0;is_zmap[i]); + free_super(sb); + return; +} + +static struct super_block * read_super(int dev) +{ + struct super_block * s; + struct buffer_head * bh; + int i,block; + + if (!dev) + return NULL; + check_disk_change(dev); + if ((s = get_super(dev))) + return s; + for (s = 0+super_block ;; s++) { + if (s >= NR_SUPER+super_block) + return NULL; + if (!s->s_dev) + break; + } + s->s_dev = dev; + s->s_isup = NULL; + s->s_imount = NULL; + s->s_time = 0; + s->s_rd_only = 0; + s->s_dirt = 0; + lock_super(s); + if (!(bh = bread(dev,1))) { + s->s_dev=0; + free_super(s); + return NULL; + } + *((struct d_super_block *) s) = + *((struct d_super_block *) bh->b_data); + brelse(bh); + if (s->s_magic != SUPER_MAGIC) { + s->s_dev = 0; + free_super(s); + return NULL; + } + for (i=0;is_imap[i] = NULL; + for (i=0;is_zmap[i] = NULL; + block=2; + for (i=0 ; i < s->s_imap_blocks ; i++) + if ((s->s_imap[i]=bread(dev,block))) + block++; + else + break; + for (i=0 ; i < s->s_zmap_blocks ; i++) + if ((s->s_zmap[i]=bread(dev,block))) + block++; + else + break; + if (block != 2+s->s_imap_blocks+s->s_zmap_blocks) { + for(i=0;is_imap[i]); + for(i=0;is_zmap[i]); + s->s_dev=0; + free_super(s); + return NULL; + } + s->s_imap[0]->b_data[0] |= 1; + s->s_zmap[0]->b_data[0] |= 1; + free_super(s); + return s; +} + +int sys_umount(char * dev_name) +{ + struct m_inode * inode; + struct super_block * sb; + int dev; + + if (!(inode=namei(dev_name))) + return -ENOENT; + dev = inode->i_zone[0]; + if (!S_ISBLK(inode->i_mode)) { + iput(inode); + return -ENOTBLK; + } + iput(inode); + if (dev==ROOT_DEV) + return -EBUSY; + if (!(sb=get_super(dev)) || !(sb->s_imount)) + return -ENOENT; + if (!sb->s_imount->i_mount) + printk("Mounted inode has i_mount=0\n"); + for (inode=inode_table+0 ; inodei_dev==dev && inode->i_count) + return -EBUSY; + sb->s_imount->i_mount=0; + iput(sb->s_imount); + sb->s_imount = NULL; + iput(sb->s_isup); + sb->s_isup = NULL; + put_super(dev); + sync_dev(dev); + return 0; +} + +int sys_mount(char * dev_name, char * dir_name, int rw_flag) +{ + struct m_inode * dev_i, * dir_i; + struct super_block * sb; + int dev; + + if (!(dev_i=namei(dev_name))) + return -ENOENT; + dev = dev_i->i_zone[0]; + if (!S_ISBLK(dev_i->i_mode)) { + iput(dev_i); + return -EPERM; + } + iput(dev_i); + if (!(dir_i=namei(dir_name))) + return -ENOENT; + if (dir_i->i_count != 1 || dir_i->i_num == ROOT_INO) { + iput(dir_i); + return -EBUSY; + } + if (!S_ISDIR(dir_i->i_mode)) { + iput(dir_i); + return -EPERM; + } + if (!(sb=read_super(dev))) { + iput(dir_i); + return -EBUSY; + } + if (sb->s_imount) { + iput(dir_i); + return -EBUSY; + } + if (dir_i->i_mount) { + iput(dir_i); + return -EPERM; + } + sb->s_imount=dir_i; + dir_i->i_mount=1; + dir_i->i_dirt=1; /* NOTE! we don't iput(dir_i) */ + return 0; /* we do that in umount */ +} + +void mount_root(void) +{ + int i,free; + struct super_block * p; + struct m_inode * mi; + + if (32 != sizeof (struct d_inode)) + panic("bad i-node size"); + for(i=0;is_dev = 0; + p->s_lock = 0; + p->s_wait = NULL; + } + if (!(p=read_super(ROOT_DEV))) + panic("Unable to mount root"); + if (!(mi=iget(ROOT_DEV,ROOT_INO))) + panic("Unable to read root i-node"); + mi->i_count += 3 ; /* NOTE! it is logically used 4 times, not 1 */ + p->s_isup = p->s_imount = mi; + current->pwd = mi; + current->root = mi; + free=0; + i=p->s_nzones; + while (-- i >= 0) + if (!set_bit(i&8191,p->s_zmap[i>>13]->b_data)) + free++; + printk("%d/%d free blocks\n\r",free,p->s_nzones); + free=0; + i=p->s_ninodes+1; + while (-- i >= 0) + if (!set_bit(i&8191,p->s_imap[i>>13]->b_data)) + free++; + printk("%d/%d free inodes\n\r",free,p->s_ninodes); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/super.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/super.o new file mode 100644 index 0000000..a2c39f5 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/super.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/truncate.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/truncate.c new file mode 100644 index 0000000..cb22d5f --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/truncate.c @@ -0,0 +1,65 @@ +/* + * linux/fs/truncate.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +#include + +static void free_ind(int dev,int block) +{ + struct buffer_head * bh; + unsigned short * p; + int i; + + if (!block) + return; + if ((bh=bread(dev,block))) { + p = (unsigned short *) bh->b_data; + for (i=0;i<512;i++,p++) + if (*p) + free_block(dev,*p); + brelse(bh); + } + free_block(dev,block); +} + +static void free_dind(int dev,int block) +{ + struct buffer_head * bh; + unsigned short * p; + int i; + + if (!block) + return; + if ((bh=bread(dev,block))) { + p = (unsigned short *) bh->b_data; + for (i=0;i<512;i++,p++) + if (*p) + free_ind(dev,*p); + brelse(bh); + } + free_block(dev,block); +} + +void truncate(struct m_inode * inode) +{ + int i; + + if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) + return; + for (i=0;i<7;i++) + if (inode->i_zone[i]) { + free_block(inode->i_dev,inode->i_zone[i]); + inode->i_zone[i]=0; + } + free_ind(inode->i_dev,inode->i_zone[7]); + free_dind(inode->i_dev,inode->i_zone[8]); + inode->i_zone[7] = inode->i_zone[8] = 0; + inode->i_size = 0; + inode->i_dirt = 1; + inode->i_mtime = inode->i_ctime = CURRENT_TIME; +} + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/truncate.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/truncate.o new file mode 100644 index 0000000..2ebc9c8 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/fs/truncate.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/hdc-0.11.img b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/hdc-0.11.img new file mode 100644 index 0000000..084f9c9 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/hdc-0.11.img differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/a.out.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/a.out.h new file mode 100644 index 0000000..3e67974 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/a.out.h @@ -0,0 +1,220 @@ +#ifndef _A_OUT_H +#define _A_OUT_H + +#define __GNU_EXEC_MACROS__ + +struct exec { + unsigned long a_magic; /* Use macros N_MAGIC, etc for access */ + unsigned a_text; /* length of text, in bytes */ + unsigned a_data; /* length of data, in bytes */ + unsigned a_bss; /* length of uninitialized data area for file, in bytes */ + unsigned a_syms; /* length of symbol table data in file, in bytes */ + unsigned a_entry; /* start address */ + unsigned a_trsize; /* length of relocation info for text, in bytes */ + unsigned a_drsize; /* length of relocation info for data, in bytes */ +}; + +#ifndef N_MAGIC +#define N_MAGIC(exec) ((exec).a_magic) +#endif + +#ifndef OMAGIC +/* Code indicating object file or impure executable. */ +#define OMAGIC 0407 +/* Code indicating pure executable. */ +#define NMAGIC 0410 +/* Code indicating demand-paged executable. */ +#define ZMAGIC 0413 +#endif /* not OMAGIC */ + +#ifndef N_BADMAG +#define N_BADMAG(x) \ + (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC) +#endif + +#define _N_BADMAG(x) \ + (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC) + +#define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec)) + +#ifndef N_TXTOFF +#define N_TXTOFF(x) \ + (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec)) +#endif + +#ifndef N_DATOFF +#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text) +#endif + +#ifndef N_TRELOFF +#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data) +#endif + +#ifndef N_DRELOFF +#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize) +#endif + +#ifndef N_SYMOFF +#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize) +#endif + +#ifndef N_STROFF +#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms) +#endif + +/* Address of text segment in memory after it is loaded. */ +#ifndef N_TXTADDR +#define N_TXTADDR(x) 0 +#endif + +/* Address of data segment in memory after it is loaded. + Note that it is up to you to define SEGMENT_SIZE + on machines not listed here. */ +#if defined(vax) || defined(hp300) || defined(pyr) +#define SEGMENT_SIZE PAGE_SIZE +#endif +#ifdef hp300 +#define PAGE_SIZE 4096 +#endif +#ifdef sony +#define SEGMENT_SIZE 0x2000 +#endif /* Sony. */ +#ifdef is68k +#define SEGMENT_SIZE 0x20000 +#endif +#if defined(m68k) && defined(PORTAR) +#define PAGE_SIZE 0x400 +#define SEGMENT_SIZE PAGE_SIZE +#endif + +#define PAGE_SIZE 4096 +#define SEGMENT_SIZE 1024 + +#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1)) + +#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text) + +#ifndef N_DATADDR +#define N_DATADDR(x) \ + (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \ + : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x)))) +#endif + +/* Address of bss segment in memory after it is loaded. */ +#ifndef N_BSSADDR +#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) +#endif + +#ifndef N_NLIST_DECLARED +struct nlist { + union { + char *n_name; + struct nlist *n_next; + long n_strx; + } n_un; + unsigned char n_type; + char n_other; + short n_desc; + unsigned long n_value; +}; +#endif + +#ifndef N_UNDF +#define N_UNDF 0 +#endif +#ifndef N_ABS +#define N_ABS 2 +#endif +#ifndef N_TEXT +#define N_TEXT 4 +#endif +#ifndef N_DATA +#define N_DATA 6 +#endif +#ifndef N_BSS +#define N_BSS 8 +#endif +#ifndef N_COMM +#define N_COMM 18 +#endif +#ifndef N_FN +#define N_FN 15 +#endif + +#ifndef N_EXT +#define N_EXT 1 +#endif +#ifndef N_TYPE +#define N_TYPE 036 +#endif +#ifndef N_STAB +#define N_STAB 0340 +#endif + +/* The following type indicates the definition of a symbol as being + an indirect reference to another symbol. The other symbol + appears as an undefined reference, immediately following this symbol. + + Indirection is asymmetrical. The other symbol's value will be used + to satisfy requests for the indirect symbol, but not vice versa. + If the other symbol does not have a definition, libraries will + be searched to find a definition. */ +#define N_INDR 0xa + +/* The following symbols refer to set elements. + All the N_SET[ATDB] symbols with the same name form one set. + Space is allocated for the set in the text section, and each set + element's value is stored into one word of the space. + The first word of the space is the length of the set (number of elements). + + The address of the set is made into an N_SETV symbol + whose name is the same as the name of the set. + This symbol acts like a N_DATA global symbol + in that it can satisfy undefined external references. */ + +/* These appear as input to LD, in a .o file. */ +#define N_SETA 0x14 /* Absolute set element symbol */ +#define N_SETT 0x16 /* Text set element symbol */ +#define N_SETD 0x18 /* Data set element symbol */ +#define N_SETB 0x1A /* Bss set element symbol */ + +/* This is output from LD. */ +#define N_SETV 0x1C /* Pointer to set vector in data area. */ + +#ifndef N_RELOCATION_INFO_DECLARED + +/* This structure describes a single relocation to be performed. + The text-relocation section of the file is a vector of these structures, + all of which apply to the text section. + Likewise, the data-relocation section applies to the data section. */ + +struct relocation_info +{ + /* Address (within segment) to be relocated. */ + int r_address; + /* The meaning of r_symbolnum depends on r_extern. */ + unsigned int r_symbolnum:24; + /* Nonzero means value is a pc-relative offset + and it should be relocated for changes in its own address + as well as for changes in the symbol or section specified. */ + unsigned int r_pcrel:1; + /* Length (as exponent of 2) of the field to be relocated. + Thus, a value of 2 indicates 1<<2 bytes. */ + unsigned int r_length:2; + /* 1 => relocate with value of symbol. + r_symbolnum is the index of the symbol + in file's the symbol table. + 0 => relocate with the address of a segment. + r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS + (the N_EXT bit may be set also, but signifies nothing). */ + unsigned int r_extern:1; + /* Four bits that aren't used, but when writing an object file + it is desirable to clear them. */ + unsigned int r_pad:4; +}; +#endif /* no N_RELOCATION_INFO_DECLARED. */ + + +#endif /* __A_OUT_GNU_H__ */ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/io.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/io.h new file mode 100644 index 0000000..d5cc42a --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/io.h @@ -0,0 +1,24 @@ +#define outb(value,port) \ +__asm__ ("outb %%al,%%dx"::"a" (value),"d" (port)) + + +#define inb(port) ({ \ +unsigned char _v; \ +__asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \ +_v; \ +}) + +#define outb_p(value,port) \ +__asm__ ("outb %%al,%%dx\n" \ + "\tjmp 1f\n" \ + "1:\tjmp 1f\n" \ + "1:"::"a" (value),"d" (port)) + +#define inb_p(port) ({ \ +unsigned char _v; \ +__asm__ volatile ("inb %%dx,%%al\n" \ + "\tjmp 1f\n" \ + "1:\tjmp 1f\n" \ + "1:":"=a" (_v):"d" (port)); \ +_v; \ +}) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/memory.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/memory.h new file mode 100644 index 0000000..4457420 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/memory.h @@ -0,0 +1,14 @@ +/* + * NOTE!!! memcpy(dest,src,n) assumes ds=es=normal data segment. This + * goes for all kernel functions (ds=es=kernel space, fs=local data, + * gs=null), as well as for all well-behaving user programs (ds=es= + * user data space). This is NOT a bug, as any user program that changes + * es deserves to die if it isn't careful. + */ +#define memcpy(dest,src,n) ({ \ +void * _res = dest; \ +__asm__ ("cld;rep;movsb" \ + ::"D" ((long)(_res)),"S" ((long)(src)),"c" ((long) (n)) \ + ); \ +_res; \ +}) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/segment.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/segment.h new file mode 100644 index 0000000..94dd102 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/segment.h @@ -0,0 +1,65 @@ +static inline unsigned char get_fs_byte(const char * addr) +{ + unsigned register char _v; + + __asm__ ("movb %%fs:%1,%0":"=r" (_v):"m" (*addr)); + return _v; +} + +static inline unsigned short get_fs_word(const unsigned short *addr) +{ + unsigned short _v; + + __asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr)); + return _v; +} + +static inline unsigned long get_fs_long(const unsigned long *addr) +{ + unsigned long _v; + + __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \ + return _v; +} + +static inline void put_fs_byte(char val,char *addr) +{ +__asm__ ("movb %0,%%fs:%1"::"r" (val),"m" (*addr)); +} + +static inline void put_fs_word(short val,short * addr) +{ +__asm__ ("movw %0,%%fs:%1"::"r" (val),"m" (*addr)); +} + +static inline void put_fs_long(unsigned long val,unsigned long * addr) +{ +__asm__ ("movl %0,%%fs:%1"::"r" (val),"m" (*addr)); +} + +/* + * Someone who knows GNU asm better than I should double check the followig. + * It seems to work, but I don't know if I'm doing something subtly wrong. + * --- TYT, 11/24/91 + * [ nothing wrong here, Linus ] + */ + +static inline unsigned long get_fs() +{ + unsigned short _v; + __asm__("mov %%fs,%%ax":"=a" (_v):); + return _v; +} + +static inline unsigned long get_ds() +{ + unsigned short _v; + __asm__("mov %%ds,%%ax":"=a" (_v):); + return _v; +} + +static inline void set_fs(unsigned long val) +{ + __asm__("mov %0,%%fs"::"a" ((unsigned short) val)); +} + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/system.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/system.h new file mode 100644 index 0000000..9bc027a --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/asm/system.h @@ -0,0 +1,67 @@ +#define move_to_user_mode() \ +__asm__ ("movl %%esp,%%eax\n\t" \ + "pushl $0x17\n\t" \ + "pushl %%eax\n\t" \ + "pushfl\n\t" \ + "pushl $0x0f\n\t" \ + "pushl $1f\n\t" \ + "iret\n" \ + "1:\tmovl $0x17,%%eax\n\t" \ + "movw %%ax,%%ds\n\t" \ + "movw %%ax,%%es\n\t" \ + "movw %%ax,%%fs\n\t" \ + "movw %%ax,%%gs" \ + :::"ax") + +#define sti() __asm__ ("sti"::) +#define cli() __asm__ ("cli"::) +#define nop() __asm__ ("nop"::) + +#define iret() __asm__ ("iret"::) + +#define _set_gate(gate_addr,type,dpl,addr) \ +__asm__ ("movw %%dx,%%ax\n\t" \ + "movw %0,%%dx\n\t" \ + "movl %%eax,%1\n\t" \ + "movl %%edx,%2" \ + : \ + : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), \ + "o" (*((char *) (gate_addr))), \ + "o" (*(4+(char *) (gate_addr))), \ + "d" ((char *) (addr)),"a" (0x00080000)) + +#define set_intr_gate(n,addr) \ + _set_gate(&idt[n],14,0,addr) + +#define set_trap_gate(n,addr) \ + _set_gate(&idt[n],15,0,addr) + +#define set_system_gate(n,addr) \ + _set_gate(&idt[n],15,3,addr) + +#define _set_seg_desc(gate_addr,type,dpl,base,limit) {\ + *(gate_addr) = ((base) & 0xff000000) | \ + (((base) & 0x00ff0000)>>16) | \ + ((limit) & 0xf0000) | \ + ((dpl)<<13) | \ + (0x00408000) | \ + ((type)<<8); \ + *((gate_addr)+1) = (((base) & 0x0000ffff)<<16) | \ + ((limit) & 0x0ffff); } + +#define _set_tssldt_desc(n,addr,type) \ +__asm__ ("movw $104,%1\n\t" \ + "movw %%ax,%2\n\t" \ + "rorl $16,%%eax\n\t" \ + "movb %%al,%3\n\t" \ + "movb $" type ",%4\n\t" \ + "movb $0x00,%5\n\t" \ + "movb %%ah,%6\n\t" \ + "rorl $16,%%eax" \ + ::"a" (addr), "m" (*(n)), "m" (*(n+2)), "m" (*(n+4)), \ + "m" (*(n+5)), "m" (*(n+6)), "m" (*(n+7)) \ + ) + +#define set_tss_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),"0x89") +#define set_ldt_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),"0x82") + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/const.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/const.h new file mode 100644 index 0000000..7828e61 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/const.h @@ -0,0 +1,15 @@ +#ifndef _CONST_H +#define _CONST_H + +#define BUFFER_END 0x200000 + +#define I_TYPE 0170000 +#define I_DIRECTORY 0040000 +#define I_REGULAR 0100000 +#define I_BLOCK_SPECIAL 0060000 +#define I_CHAR_SPECIAL 0020000 +#define I_NAMED_PIPE 0010000 +#define I_SET_UID_BIT 0004000 +#define I_SET_GID_BIT 0002000 + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/ctype.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/ctype.h new file mode 100644 index 0000000..7acf55d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/ctype.h @@ -0,0 +1,34 @@ +#ifndef _CTYPE_H +#define _CTYPE_H + +#define _U 0x01 /* upper */ +#define _L 0x02 /* lower */ +#define _D 0x04 /* digit */ +#define _C 0x08 /* cntrl */ +#define _P 0x10 /* punct */ +#define _S 0x20 /* white space (space/lf/tab) */ +#define _X 0x40 /* hex digit */ +#define _SP 0x80 /* hard space (0x20) */ + +extern unsigned char _ctype[]; +extern char _ctmp; + +#define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D)) +#define isalpha(c) ((_ctype+1)[c]&(_U|_L)) +#define iscntrl(c) ((_ctype+1)[c]&(_C)) +#define isdigit(c) ((_ctype+1)[c]&(_D)) +#define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D)) +#define islower(c) ((_ctype+1)[c]&(_L)) +#define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP)) +#define ispunct(c) ((_ctype+1)[c]&(_P)) +#define isspace(c) ((_ctype+1)[c]&(_S)) +#define isupper(c) ((_ctype+1)[c]&(_U)) +#define isxdigit(c) ((_ctype+1)[c]&(_D|_X)) + +#define isascii(c) (((unsigned) c)<=0x7f) +#define toascii(c) (((unsigned) c)&0x7f) + +#define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp) +#define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp) + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/errno.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/errno.h new file mode 100644 index 0000000..c282f69 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/errno.h @@ -0,0 +1,60 @@ +#ifndef _ERRNO_H +#define _ERRNO_H + +/* + * ok, as I hadn't got any other source of information about + * possible error numbers, I was forced to use the same numbers + * as minix. + * Hopefully these are posix or something. I wouldn't know (and posix + * isn't telling me - they want $$$ for their f***ing standard). + * + * We don't use the _SIGN cludge of minix, so kernel returns must + * see to the sign by themselves. + * + * NOTE! Remember to change strerror() if you change this file! + */ + +extern int errno; + +#define ERROR 99 +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define ENOTBLK 15 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define ETXTBSY 26 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define EDOM 33 +#define ERANGE 34 +#define EDEADLK 35 +#define ENAMETOOLONG 36 +#define ENOLCK 37 +#define ENOSYS 38 +#define ENOTEMPTY 39 + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/fcntl.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/fcntl.h new file mode 100644 index 0000000..a5bf9af --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/fcntl.h @@ -0,0 +1,55 @@ +#ifndef _FCNTL_H +#define _FCNTL_H + +#include + +/* open/fcntl - NOCTTY, NDELAY isn't implemented yet */ +#define O_ACCMODE 00003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 00100 /* not fcntl */ +#define O_EXCL 00200 /* not fcntl */ +#define O_NOCTTY 00400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 /* not fcntl */ +#define O_NDELAY O_NONBLOCK + +/* Defines for fcntl-commands. Note that currently + * locking isn't supported, and other things aren't really + * tested. + */ +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 /* not implemented */ +#define F_SETLK 6 +#define F_SETLKW 7 + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* Ok, these are locking features, and aren't implemented at any + * level. POSIX wants them. + */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* Once again - not implemented, but ... */ +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +extern int creat(const char * filename,mode_t mode); +extern int fcntl(int fildes,int cmd, ...); +extern int open(const char * filename, int flags, ...); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/config.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/config.h new file mode 100644 index 0000000..819b525 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/config.h @@ -0,0 +1,48 @@ +#ifndef _CONFIG_H +#define _CONFIG_H + +/* + * The root-device is no longer hard-coded. You can change the default + * root-device by changing the line ROOT_DEV = XXX in boot/bootsect.s + */ + +/* + * define your keyboard here - + * KBD_FINNISH for Finnish keyboards + * KBD_US for US-type + * KBD_GR for German keyboards + * KBD_FR for Frech keyboard + */ +#define KBD_US +/*#define KBD_GR */ +/*#define KBD_FR */ +/*#define KBD_FINNISH */ + +/* + * Normally, Linux can get the drive parameters from the BIOS at + * startup, but if this for some unfathomable reason fails, you'd + * be left stranded. For this case, you can define HD_TYPE, which + * contains all necessary info on your harddisk. + * + * The HD_TYPE macro should look like this: + * + * #define HD_TYPE { head, sect, cyl, wpcom, lzone, ctl} + * + * In case of two harddisks, the info should be sepatated by + * commas: + * + * #define HD_TYPE { h,s,c,wpcom,lz,ctl },{ h,s,c,wpcom,lz,ctl } + */ +/* + This is an example, two drives, first is type 2, second is type 3: + +#define HD_TYPE { 4,17,615,300,615,8 }, { 6,17,615,300,615,0 } + + NOTE: ctl is 0 for all drives with heads<=8, and ctl=8 for drives + with more than 8 heads. + + If you want the BIOS to tell what kind of drive you have, just + leave HD_TYPE undefined. This is the normal thing to do. +*/ + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/fdreg.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/fdreg.h new file mode 100644 index 0000000..01355af --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/fdreg.h @@ -0,0 +1,71 @@ +/* + * This file contains some defines for the floppy disk controller. + * Various sources. Mostly "IBM Microcomputers: A Programmers + * Handbook", Sanches and Canton. + */ +#ifndef _FDREG_H +#define _FDREG_H + +extern int ticks_to_floppy_on(unsigned int nr); +extern void floppy_on(unsigned int nr); +extern void floppy_off(unsigned int nr); +extern void floppy_select(unsigned int nr); +extern void floppy_deselect(unsigned int nr); + +/* Fd controller regs. S&C, about page 340 */ +#define FD_STATUS 0x3f4 +#define FD_DATA 0x3f5 +#define FD_DOR 0x3f2 /* Digital Output Register */ +#define FD_DIR 0x3f7 /* Digital Input Register (read) */ +#define FD_DCR 0x3f7 /* Diskette Control Register (write)*/ + +/* Bits of main status register */ +#define STATUS_BUSYMASK 0x0F /* drive busy mask */ +#define STATUS_BUSY 0x10 /* FDC busy */ +#define STATUS_DMA 0x20 /* 0- DMA mode */ +#define STATUS_DIR 0x40 /* 0- cpu->fdc */ +#define STATUS_READY 0x80 /* Data reg ready */ + +/* Bits of FD_ST0 */ +#define ST0_DS 0x03 /* drive select mask */ +#define ST0_HA 0x04 /* Head (Address) */ +#define ST0_NR 0x08 /* Not Ready */ +#define ST0_ECE 0x10 /* Equipment chech error */ +#define ST0_SE 0x20 /* Seek end */ +#define ST0_INTR 0xC0 /* Interrupt code mask */ + +/* Bits of FD_ST1 */ +#define ST1_MAM 0x01 /* Missing Address Mark */ +#define ST1_WP 0x02 /* Write Protect */ +#define ST1_ND 0x04 /* No Data - unreadable */ +#define ST1_OR 0x10 /* OverRun */ +#define ST1_CRC 0x20 /* CRC error in data or addr */ +#define ST1_EOC 0x80 /* End Of Cylinder */ + +/* Bits of FD_ST2 */ +#define ST2_MAM 0x01 /* Missing Addess Mark (again) */ +#define ST2_BC 0x02 /* Bad Cylinder */ +#define ST2_SNS 0x04 /* Scan Not Satisfied */ +#define ST2_SEH 0x08 /* Scan Equal Hit */ +#define ST2_WC 0x10 /* Wrong Cylinder */ +#define ST2_CRC 0x20 /* CRC error in data field */ +#define ST2_CM 0x40 /* Control Mark = deleted */ + +/* Bits of FD_ST3 */ +#define ST3_HA 0x04 /* Head (Address) */ +#define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */ +#define ST3_WP 0x40 /* Write Protect */ + +/* Values for FD_COMMAND */ +#define FD_RECALIBRATE 0x07 /* move to track 0 */ +#define FD_SEEK 0x0F /* seek track */ +#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */ +#define FD_WRITE 0xC5 /* write with MT, MFM */ +#define FD_SENSEI 0x08 /* Sense Interrupt Status */ +#define FD_SPECIFY 0x03 /* specify HUT etc */ + +/* DMA commands */ +#define DMA_READ 0x46 +#define DMA_WRITE 0x4A + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/fs.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/fs.h new file mode 100644 index 0000000..7a90b10 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/fs.h @@ -0,0 +1,202 @@ +/* + * This file has definitions for some important file table + * structures etc. + */ + +#ifndef _FS_H +#define _FS_H + +#include + +/* devices are as follows: (same as minix, so we can use the minix + * file system. These are major numbers.) + * + * 0 - unused (nodev) + * 1 - /dev/mem + * 2 - /dev/fd + * 3 - /dev/hd + * 4 - /dev/ttyx + * 5 - /dev/tty + * 6 - /dev/lp + * 7 - unnamed pipes + */ + +#define IS_SEEKABLE(x) ((x)>=1 && (x)<=3) + +#define READ 0 +#define WRITE 1 +#define READA 2 /* read-ahead - don't pause */ +#define WRITEA 3 /* "write-ahead" - silly, but somewhat useful */ + +void buffer_init(long buffer_end); + +#define MAJOR(a) (((unsigned)(a))>>8) +#define MINOR(a) ((a)&0xff) + +#define NAME_LEN 14 +#define ROOT_INO 1 + +#define I_MAP_SLOTS 8 +#define Z_MAP_SLOTS 8 +#define SUPER_MAGIC 0x137F + +#define NR_OPEN 20 +#define NR_INODE 32 +#define NR_FILE 64 +#define NR_SUPER 8 +#define NR_HASH 307 +#define NR_BUFFERS nr_buffers +#define BLOCK_SIZE 1024 +#define BLOCK_SIZE_BITS 10 +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#define INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct d_inode))) +#define DIR_ENTRIES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct dir_entry))) + +#define PIPE_HEAD(inode) ((inode).i_zone[0]) +#define PIPE_TAIL(inode) ((inode).i_zone[1]) +#define PIPE_SIZE(inode) ((PIPE_HEAD(inode)-PIPE_TAIL(inode))&(PAGE_SIZE-1)) +#define PIPE_EMPTY(inode) (PIPE_HEAD(inode)==PIPE_TAIL(inode)) +#define PIPE_FULL(inode) (PIPE_SIZE(inode)==(PAGE_SIZE-1)) +#define INC_PIPE(head) \ +__asm__("incl %0\n\tandl $4095,%0"::"m" (head)) + +typedef char buffer_block[BLOCK_SIZE]; + +struct buffer_head { + char * b_data; /* pointer to data block (1024 bytes) */ + unsigned long b_blocknr; /* block number */ + unsigned short b_dev; /* device (0 = free) */ + unsigned char b_uptodate; + unsigned char b_dirt; /* 0-clean,1-dirty */ + unsigned char b_count; /* users using this block */ + unsigned char b_lock; /* 0 - ok, 1 -locked */ + struct task_struct * b_wait; + struct buffer_head * b_prev; + struct buffer_head * b_next; + struct buffer_head * b_prev_free; + struct buffer_head * b_next_free; +}; + +struct d_inode { + unsigned short i_mode; + unsigned short i_uid; + unsigned long i_size; + unsigned long i_time; + unsigned char i_gid; + unsigned char i_nlinks; + unsigned short i_zone[9]; +}; + +struct m_inode { + unsigned short i_mode; + unsigned short i_uid; + unsigned long i_size; + unsigned long i_mtime; + unsigned char i_gid; + unsigned char i_nlinks; + unsigned short i_zone[9]; +/* these are in memory also */ + struct task_struct * i_wait; + unsigned long i_atime; + unsigned long i_ctime; + unsigned short i_dev; + unsigned short i_num; + unsigned short i_count; + unsigned char i_lock; + unsigned char i_dirt; + unsigned char i_pipe; + unsigned char i_mount; + unsigned char i_seek; + unsigned char i_update; +}; + +struct file { + unsigned short f_mode; + unsigned short f_flags; + unsigned short f_count; + struct m_inode * f_inode; + off_t f_pos; +}; + +struct super_block { + unsigned short s_ninodes; + unsigned short s_nzones; + unsigned short s_imap_blocks; + unsigned short s_zmap_blocks; + unsigned short s_firstdatazone; + unsigned short s_log_zone_size; + unsigned long s_max_size; + unsigned short s_magic; +/* These are only in memory */ + struct buffer_head * s_imap[8]; + struct buffer_head * s_zmap[8]; + unsigned short s_dev; + struct m_inode * s_isup; + struct m_inode * s_imount; + unsigned long s_time; + struct task_struct * s_wait; + unsigned char s_lock; + unsigned char s_rd_only; + unsigned char s_dirt; +}; + +struct d_super_block { + unsigned short s_ninodes; + unsigned short s_nzones; + unsigned short s_imap_blocks; + unsigned short s_zmap_blocks; + unsigned short s_firstdatazone; + unsigned short s_log_zone_size; + unsigned long s_max_size; + unsigned short s_magic; +}; + +struct dir_entry { + unsigned short inode; + char name[NAME_LEN]; +}; + +extern struct m_inode inode_table[NR_INODE]; +extern struct file file_table[NR_FILE]; +extern struct super_block super_block[NR_SUPER]; +extern struct buffer_head * start_buffer; +extern int nr_buffers; + +extern void check_disk_change(int dev); +extern int floppy_change(unsigned int nr); +extern int ticks_to_floppy_on(unsigned int dev); +extern void floppy_on(unsigned int dev); +extern void floppy_off(unsigned int dev); +extern void truncate(struct m_inode * inode); +extern void sync_inodes(void); +extern void wait_on(struct m_inode * inode); +extern int bmap(struct m_inode * inode,int block); +extern int create_block(struct m_inode * inode,int block); +extern struct m_inode * namei(const char * pathname); +extern int open_namei(const char * pathname, int flag, int mode, + struct m_inode ** res_inode); +extern void iput(struct m_inode * inode); +extern struct m_inode * iget(int dev,int nr); +extern struct m_inode * get_empty_inode(void); +extern struct m_inode * get_pipe_inode(void); +extern struct buffer_head * get_hash_table(int dev, int block); +extern struct buffer_head * getblk(int dev, int block); +extern void ll_rw_block(int rw, struct buffer_head * bh); +extern void brelse(struct buffer_head * buf); +extern struct buffer_head * bread(int dev,int block); +extern void bread_page(unsigned long addr,int dev,int b[4]); +extern struct buffer_head * breada(int dev,int block,...); +extern int new_block(int dev); +extern void free_block(int dev, int block); +extern struct m_inode * new_inode(int dev); +extern void free_inode(struct m_inode * inode); +extern int sync_dev(int dev); +extern struct super_block * get_super(int dev); +extern int ROOT_DEV; + +extern void mount_root(void); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/hdreg.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/hdreg.h new file mode 100644 index 0000000..e6c593f --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/hdreg.h @@ -0,0 +1,65 @@ +/* + * This file contains some defines for the AT-hd-controller. + * Various sources. Check out some definitions (see comments with + * a ques). + */ +#ifndef _HDREG_H +#define _HDREG_H + +/* Hd controller regs. Ref: IBM AT Bios-listing */ +#define HD_DATA 0x1f0 /* _CTL when writing */ +#define HD_ERROR 0x1f1 /* see err-bits */ +#define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */ +#define HD_SECTOR 0x1f3 /* starting sector */ +#define HD_LCYL 0x1f4 /* starting cylinder */ +#define HD_HCYL 0x1f5 /* high byte of starting cyl */ +#define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */ +#define HD_STATUS 0x1f7 /* see status-bits */ +#define HD_PRECOMP HD_ERROR /* same io address, read=error, write=precomp */ +#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */ + +#define HD_CMD 0x3f6 + +/* Bits of HD_STATUS */ +#define ERR_STAT 0x01 +#define INDEX_STAT 0x02 +#define ECC_STAT 0x04 /* Corrected error */ +#define DRQ_STAT 0x08 +#define SEEK_STAT 0x10 +#define WRERR_STAT 0x20 +#define READY_STAT 0x40 +#define BUSY_STAT 0x80 + +/* Values for HD_COMMAND */ +#define WIN_RESTORE 0x10 +#define WIN_READ 0x20 +#define WIN_WRITE 0x30 +#define WIN_VERIFY 0x40 +#define WIN_FORMAT 0x50 +#define WIN_INIT 0x60 +#define WIN_SEEK 0x70 +#define WIN_DIAGNOSE 0x90 +#define WIN_SPECIFY 0x91 + +/* Bits for HD_ERROR */ +#define MARK_ERR 0x01 /* Bad address mark ? */ +#define TRK0_ERR 0x02 /* couldn't find track 0 */ +#define ABRT_ERR 0x04 /* ? */ +#define ID_ERR 0x10 /* ? */ +#define ECC_ERR 0x40 /* ? */ +#define BBD_ERR 0x80 /* ? */ + +struct partition { + unsigned char boot_ind; /* 0x80 - active (unused) */ + unsigned char head; /* ? */ + unsigned char sector; /* ? */ + unsigned char cyl; /* ? */ + unsigned char sys_ind; /* ? */ + unsigned char end_head; /* ? */ + unsigned char end_sector; /* ? */ + unsigned char end_cyl; /* ? */ + unsigned int start_sect; /* starting sector counting from 0 */ + unsigned int nr_sects; /* nr of sectors in partition */ +}; + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/head.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/head.h new file mode 100644 index 0000000..db3dda2 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/head.h @@ -0,0 +1,20 @@ +#ifndef _HEAD_H +#define _HEAD_H + +typedef struct desc_struct { + unsigned long a,b; +} desc_table[256]; + +extern unsigned long pg_dir[1024]; +extern desc_table idt,gdt; + +#define GDT_NUL 0 +#define GDT_CODE 1 +#define GDT_DATA 2 +#define GDT_TMP 3 + +#define LDT_NUL 0 +#define LDT_CODE 1 +#define LDT_DATA 2 + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/kernel.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/kernel.h new file mode 100644 index 0000000..cb40dd5 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/kernel.h @@ -0,0 +1,22 @@ +/* + * 'kernel.h' contains some often-used function prototypes etc + */ +void verify_area(void * addr,int count); +volatile void panic(const char * str); +int printf(const char * fmt, ...); +int printk(const char * fmt, ...); +int tty_write(unsigned ch,char * buf,int count); +void * malloc(unsigned int size); +void free_s(void * obj, int size); + +#define free(x) free_s((x), 0) + +/* + * This is defined as a macro, but at some point this might become a + * real subroutine that sets a flag if it returns true (to do + * BSD-style accounting where the process is flagged if it uses root + * privs). The implication of this is that you should do normal + * permissions checks first, and check suser() last. + */ +#define suser() (current->euid == 0) + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/mm.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/mm.h new file mode 100644 index 0000000..5a160f3 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/mm.h @@ -0,0 +1,10 @@ +#ifndef _MM_H +#define _MM_H + +#define PAGE_SIZE 4096 + +extern unsigned long get_free_page(void); +extern unsigned long put_page(unsigned long page,unsigned long address); +extern void free_page(unsigned long addr); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sched.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sched.h new file mode 100644 index 0000000..53ffbe8 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sched.h @@ -0,0 +1,256 @@ +#ifndef _SCHED_H +#define _SCHED_H + +#define NR_TASKS 64 +#define HZ 100 + +#define FIRST_TASK task[0] +#define LAST_TASK task[NR_TASKS-1] + +#include +#include +#include +#include + +#if (NR_OPEN > 32) +#error "Currently the close-on-exec-flags are in one word, max 32 files/proc" +#endif + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_ZOMBIE 3 +#define TASK_STOPPED 4 + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +extern int copy_page_tables(unsigned long from, unsigned long to, long size); +extern int free_page_tables(unsigned long from, unsigned long size); + +extern void sched_init(void); +extern void schedule(void); +extern void trap_init(void); +#ifndef PANIC +volatile void panic(const char * str); +#endif +extern int tty_write(unsigned minor,char * buf,int count); + +typedef int (*fn_ptr)(); + +struct i387_struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ +}; + +struct tss_struct { + long back_link; /* 16 high bits zero */ + long esp0; + long ss0; /* 16 high bits zero */ + long esp1; + long ss1; /* 16 high bits zero */ + long esp2; + long ss2; /* 16 high bits zero */ + long cr3; + long eip; + long eflags; + long eax,ecx,edx,ebx; + long esp; + long ebp; + long esi; + long edi; + long es; /* 16 high bits zero */ + long cs; /* 16 high bits zero */ + long ss; /* 16 high bits zero */ + long ds; /* 16 high bits zero */ + long fs; /* 16 high bits zero */ + long gs; /* 16 high bits zero */ + long ldt; /* 16 high bits zero */ + long trace_bitmap; /* bits: trace 0, bitmap 16-31 */ + struct i387_struct i387; +}; + +struct task_struct { +/* these are hardcoded - don't touch */ + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + long counter; + long priority; + long signal; + struct sigaction sigaction[32]; + long blocked; /* bitmap of masked signals */ +/* various fields */ + int exit_code; + unsigned long start_code,end_code,end_data,brk,start_stack; + long pid,father,pgrp,session,leader; + unsigned short uid,euid,suid; + unsigned short gid,egid,sgid; + long alarm; + long utime,stime,cutime,cstime,start_time; + unsigned short used_math; +/* file system info */ + int tty; /* -1 if no tty, so it must be signed */ + unsigned short umask; + struct m_inode * pwd; + struct m_inode * root; + struct m_inode * executable; + unsigned long close_on_exec; + struct file * filp[NR_OPEN]; +/* ldt for this task 0 - zero 1 - cs 2 - ds&ss */ + struct desc_struct ldt[3]; +/* tss for this task */ + struct tss_struct tss; +}; + +/* + * INIT_TASK is used to set up the first task table, touch at + * your own risk!. Base=0, limit=0x9ffff (=640kB) + */ +#define INIT_TASK \ +/* state etc */ { 0,15,15, \ +/* signals */ 0,{{},},0, \ +/* ec,brk... */ 0,0,0,0,0,0, \ +/* pid etc.. */ 0,-1,0,0,0, \ +/* uid etc */ 0,0,0,0,0,0, \ +/* alarm */ 0,0,0,0,0,0, \ +/* math */ 0, \ +/* fs info */ -1,0022,NULL,NULL,NULL,0, \ +/* filp */ {NULL,}, \ + { \ + {0,0}, \ +/* ldt */ {0x9f,0xc0fa00}, \ + {0x9f,0xc0f200}, \ + }, \ +/*tss*/ {0,PAGE_SIZE+(long)&init_task,0x10,0,0,0,0,(long)&pg_dir,\ + 0,0,0,0,0,0,0,0, \ + 0,0,0x17,0x17,0x17,0x17,0x17,0x17, \ + _LDT(0),0x80000000, \ + {} \ + }, \ +} + +extern struct task_struct *task[NR_TASKS]; +extern struct task_struct *last_task_used_math; +extern struct task_struct *current; +extern long volatile jiffies; +extern long startup_time; + +#define CURRENT_TIME (startup_time+jiffies/HZ) + +extern void add_timer(long jiffies, void (*fn)(void)); +extern void sleep_on(struct task_struct ** p); +extern void interruptible_sleep_on(struct task_struct ** p); +extern void wake_up(struct task_struct ** p); + +/* + * Entry into gdt where to find first TSS. 0-nul, 1-cs, 2-ds, 3-syscall + * 4-TSS0, 5-LDT0, 6-TSS1 etc ... + */ +#define FIRST_TSS_ENTRY 4 +#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1) +#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3)) +#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3)) +#define ltr(n) __asm__("ltr %%ax"::"a" (_TSS(n))) +#define lldt(n) __asm__("lldt %%ax"::"a" (_LDT(n))) +#define str(n) \ +__asm__("str %%ax\n\t" \ + "subl %2,%%eax\n\t" \ + "shrl $4,%%eax" \ + :"=a" (n) \ + :"a" (0),"i" (FIRST_TSS_ENTRY<<3)) +/* + * switch_to(n) should switch tasks to task nr n, first + * checking that n isn't the current task, in which case it does nothing. + * This also clears the TS-flag if the task we switched to has used + * tha math co-processor latest. + */ +#define switch_to(n) {\ +struct {long a,b;} __tmp; \ +__asm__("cmpl %%ecx,_current\n\t" \ + "je 1f\n\t" \ + "movw %%dx,%1\n\t" \ + "xchgl %%ecx,_current\n\t" \ + "ljmp *%0\n\t" \ + "cmpl %%ecx,_last_task_used_math\n\t" \ + "jne 1f\n\t" \ + "clts\n" \ + "1:" \ + ::"m" (*&__tmp.a),"m" (*&__tmp.b), \ + "d" (_TSS(n)),"c" ((long) task[n])); \ +} + +#define PAGE_ALIGN(n) (((n)+0xfff)&0xfffff000) + +#define _set_base(addr,base) \ +__asm__ ("push %%edx\n\t" \ + "movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %%dl,%1\n\t" \ + "movb %%dh,%2\n\t" \ + "pop %%edx" \ + ::"m" (*((addr)+2)), \ + "m" (*((addr)+4)), \ + "m" (*((addr)+7)), \ + "d" (base) \ + ) + +#define _set_limit(addr,limit) \ +__asm__ ("push %%edx\n\t" \ + "movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %1,%%dh\n\t" \ + "andb $0xf0,%%dh\n\t" \ + "orb %%dh,%%dl\n\t" \ + "movb %%dl,%1\n\t" \ + "pop %%edx" \ + ::"m" (*(addr)), \ + "m" (*((addr)+6)), \ + "d" (limit) \ + ) + +#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)) \ + :"memory"); \ +__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)); \ +__limit;}) + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sched.h.cur1 b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sched.h.cur1 new file mode 100644 index 0000000..20b05ce --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sched.h.cur1 @@ -0,0 +1,235 @@ +#ifndef _SCHED_H +#define _SCHED_H + +#define NR_TASKS 64 +#define HZ 100 + +#define FIRST_TASK task[0] +#define LAST_TASK task[NR_TASKS-1] + +#include +#include +#include +#include + +#if (NR_OPEN > 32) +#error "Currently the close-on-exec-flags are in one word, max 32 files/proc" +#endif + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_ZOMBIE 3 +#define TASK_STOPPED 4 + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +extern int copy_page_tables(unsigned long from, unsigned long to, long size); +extern int free_page_tables(unsigned long from, unsigned long size); + +extern void sched_init(void); +extern void schedule(void); +extern void trap_init(void); +#ifndef PANIC +volatile void panic(const char * str); +#endif +extern int tty_write(unsigned minor,char * buf,int count); + +typedef int (*fn_ptr)(); + +struct i387_struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ +}; + +struct tss_struct { + long back_link; /* 16 high bits zero */ + long esp0; + long ss0; /* 16 high bits zero */ + long esp1; + long ss1; /* 16 high bits zero */ + long esp2; + long ss2; /* 16 high bits zero */ + long cr3; + long eip; + long eflags; + long eax,ecx,edx,ebx; + long esp; + long ebp; + long esi; + long edi; + long es; /* 16 high bits zero */ + long cs; /* 16 high bits zero */ + long ss; /* 16 high bits zero */ + long ds; /* 16 high bits zero */ + long fs; /* 16 high bits zero */ + long gs; /* 16 high bits zero */ + long ldt; /* 16 high bits zero */ + long trace_bitmap; /* bits: trace 0, bitmap 16-31 */ + struct i387_struct i387; +}; + +struct task_struct { +/* these are hardcoded - don't touch */ + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + long counter; + long priority; + long signal; + struct sigaction sigaction[32]; + long blocked; /* bitmap of masked signals */ +/* various fields */ + int exit_code; + unsigned long start_code,end_code,end_data,brk,start_stack; + long pid,father,pgrp,session,leader; + unsigned short uid,euid,suid; + unsigned short gid,egid,sgid; + long alarm; + long utime,stime,cutime,cstime,start_time; + unsigned short used_math; +/* file system info */ + int tty; /* -1 if no tty, so it must be signed */ + unsigned short umask; + struct m_inode * pwd; + struct m_inode * root; + struct m_inode * executable; + unsigned long close_on_exec; + struct file * filp[NR_OPEN]; +/* ldt for this task 0 - zero 1 - cs 2 - ds&ss */ + struct desc_struct ldt[3]; +/* tss for this task */ + struct tss_struct tss; +}; + +/* + * INIT_TASK is used to set up the first task table, touch at + * your own risk!. Base=0, limit=0x9ffff (=640kB) + */ +#define INIT_TASK \ +/* state etc */ { 0,15,15, \ +/* signals */ 0,{{},},0, \ +/* ec,brk... */ 0,0,0,0,0,0, \ +/* pid etc.. */ 0,-1,0,0,0, \ +/* uid etc */ 0,0,0,0,0,0, \ +/* alarm */ 0,0,0,0,0,0, \ +/* math */ 0, \ +/* fs info */ -1,0022,NULL,NULL,NULL,0, \ +/* filp */ {NULL,}, \ + { \ + {0,0}, \ +/* ldt */ {0x9f,0xc0fa00}, \ + {0x9f,0xc0f200}, \ + }, \ +/*tss*/ {0,PAGE_SIZE+(long)&init_task,0x10,0,0,0,0,(long)&pg_dir,\ + 0,0,0,0,0,0,0,0, \ + 0,0,0x17,0x17,0x17,0x17,0x17,0x17, \ + _LDT(0),0x80000000, \ + {} \ + }, \ +} + +extern struct task_struct *task[NR_TASKS]; +extern struct task_struct *last_task_used_math; +extern struct task_struct *current; +extern long volatile jiffies; +extern long startup_time; + +#define CURRENT_TIME (startup_time+jiffies/HZ) + +extern void add_timer(long jiffies, void (*fn)(void)); +extern void sleep_on(struct task_struct ** p); +extern void interruptible_sleep_on(struct task_struct ** p); +extern void wake_up(struct task_struct ** p); + +/* + * Entry into gdt where to find first TSS. 0-nul, 1-cs, 2-ds, 3-syscall + * 4-TSS0, 5-LDT0, 6-TSS1 etc ... + */ +#define FIRST_TSS_ENTRY 4 +#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1) +#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3)) +#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3)) +#define ltr(n) __asm__("ltr %%ax"::"a" (_TSS(n))) +#define lldt(n) __asm__("lldt %%ax"::"a" (_LDT(n))) +#define str(n) \ +__asm__("str %%ax\n\t" \ + "subl %2,%%eax\n\t" \ + "shrl $4,%%eax" \ + :"=a" (n) \ + :"a" (0),"i" (FIRST_TSS_ENTRY<<3)) +/* + * switch_to(n) should switch tasks to task nr n, first + * checking that n isn't the current task, in which case it does nothing. + * This also clears the TS-flag if the task we switched to has used + * tha math co-processor latest. + */ +#define switch_to(n) {\ +struct {long a,b;} __tmp; \ +__asm__("cmpl %%ecx,current\n\t" \ + "je 1f\n\t" \ + "movw %%dx,%1\n\t" \ + "xchgl %%ecx,current\n\t" \ + "ljmp *%0\n\t" \ + "cmpl %%ecx,last_task_used_math\n\t" \ + "jne 1f\n\t" \ + "clts\n" \ + "1:" \ + ::"m" (*&__tmp.a),"m" (*&__tmp.b), \ + "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" \ + "rorl $16,%%edx\n\t" \ + "movb %%dl,%1\n\t" \ + "movb %%dh,%2\n\t" \ + ::"m" (*((addr)+2)), \ + "m" (*((addr)+4)), \ + "m" (*((addr)+7)), \ + "d" (base) \ + ) + +#define _set_limit(addr,limit) \ +__asm__ ("movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %1,%%dh\n\t" \ + "andb $0xf0,%%dh\n\t" \ + "orb %%dh,%%dl\n\t" \ + "movb %%dl,%1\n\t" \ + ::"m" (*(addr)), \ + "m" (*((addr)+6)), \ + "d" (limit) \ + ) + +#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;}) + +#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)); \ +__limit;}) + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sched.h.old b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sched.h.old new file mode 100644 index 0000000..c6e4deb --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sched.h.old @@ -0,0 +1,239 @@ +#ifndef _SCHED_H +#define _SCHED_H + +#define NR_TASKS 64 +#define HZ 100 + +#define FIRST_TASK task[0] +#define LAST_TASK task[NR_TASKS-1] + +#include +#include +#include +#include + +#if (NR_OPEN > 32) +#error "Currently the close-on-exec-flags are in one word, max 32 files/proc" +#endif + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_ZOMBIE 3 +#define TASK_STOPPED 4 + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +extern int copy_page_tables(unsigned long from, unsigned long to, long size); +extern int free_page_tables(unsigned long from, unsigned long size); + +extern void sched_init(void); +extern void schedule(void); +extern void trap_init(void); +#ifndef PANIC +extern void panic(const char * str); +#endif +extern int tty_write(unsigned minor,char * buf,int count); + +typedef int (*fn_ptr)(); + +struct i387_struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ +}; + +struct tss_struct { + long back_link; /* 16 high bits zero */ + long esp0; + long ss0; /* 16 high bits zero */ + long esp1; + long ss1; /* 16 high bits zero */ + long esp2; + long ss2; /* 16 high bits zero */ + long cr3; + long eip; + long eflags; + long eax,ecx,edx,ebx; + long esp; + long ebp; + long esi; + long edi; + long es; /* 16 high bits zero */ + long cs; /* 16 high bits zero */ + long ss; /* 16 high bits zero */ + long ds; /* 16 high bits zero */ + long fs; /* 16 high bits zero */ + long gs; /* 16 high bits zero */ + long ldt; /* 16 high bits zero */ + long trace_bitmap; /* bits: trace 0, bitmap 16-31 */ + struct i387_struct i387; +}; + +struct task_struct { +/* these are hardcoded - don't touch */ + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + long counter; + long priority; + long signal; + struct sigaction sigaction[32]; + long blocked; /* bitmap of masked signals */ +/* various fields */ + int exit_code; + unsigned long start_code,end_code,end_data,brk,start_stack; + long pid,father,pgrp,session,leader; + unsigned short uid,euid,suid; + unsigned short gid,egid,sgid; + long alarm; + long utime,stime,cutime,cstime,start_time; + unsigned short used_math; +/* file system info */ + int tty; /* -1 if no tty, so it must be signed */ + unsigned short umask; + struct m_inode * pwd; + struct m_inode * root; + struct m_inode * executable; + unsigned long close_on_exec; + struct file * filp[NR_OPEN]; +/* ldt for this task 0 - zero 1 - cs 2 - ds&ss */ + struct desc_struct ldt[3]; +/* tss for this task */ + struct tss_struct tss; +}; + +/* + * INIT_TASK is used to set up the first task table, touch at + * your own risk!. Base=0, limit=0x9ffff (=640kB) + */ +#define INIT_TASK \ +/* state etc */ { 0,15,15, \ +/* signals */ 0,{{},},0, \ +/* ec,brk... */ 0,0,0,0,0,0, \ +/* pid etc.. */ 0,-1,0,0,0, \ +/* uid etc */ 0,0,0,0,0,0, \ +/* alarm */ 0,0,0,0,0,0, \ +/* math */ 0, \ +/* fs info */ -1,0022,NULL,NULL,NULL,0, \ +/* filp */ {NULL,}, \ + { \ + {0,0}, \ +/* ldt */ {0x9f,0xc0fa00}, \ + {0x9f,0xc0f200}, \ + }, \ +/*tss*/ {0,PAGE_SIZE+(long)&init_task,0x10,0,0,0,0,(long)&pg_dir,\ + 0,0,0,0,0,0,0,0, \ + 0,0,0x17,0x17,0x17,0x17,0x17,0x17, \ + _LDT(0),0x80000000, \ + {} \ + }, \ +} + +extern struct task_struct *task[NR_TASKS]; +extern struct task_struct *last_task_used_math; +extern struct task_struct *current; +extern long volatile jiffies; +extern long startup_time; + +#define CURRENT_TIME (startup_time+jiffies/HZ) + +extern void add_timer(long jiffies, void (*fn)(void)); +extern void sleep_on(struct task_struct ** p); +extern void interruptible_sleep_on(struct task_struct ** p); +extern void wake_up(struct task_struct ** p); + +/* + * Entry into gdt where to find first TSS. 0-nul, 1-cs, 2-ds, 3-syscall + * 4-TSS0, 5-LDT0, 6-TSS1 etc ... + */ +#define FIRST_TSS_ENTRY 4 +#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1) +#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3)) +#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3)) +#define ltr(n) __asm__("ltr %%ax"::"a" (_TSS(n))) +#define lldt(n) __asm__("lldt %%ax"::"a" (_LDT(n))) +#define str(n) \ +__asm__("str %%ax\n\t" \ + "subl %2,%%eax\n\t" \ + "shrl $4,%%eax" \ + :"=a" (n) \ + :"a" (0),"i" (FIRST_TSS_ENTRY<<3)) +/* + * switch_to(n) should switch tasks to task nr n, first + * checking that n isn't the current task, in which case it does nothing. + * This also clears the TS-flag if the task we switched to has used + * tha math co-processor latest. + */ +#define switch_to(n) {\ +struct {long a,b;} __tmp; \ +__asm__("cmpl %%ecx,current\n\t" \ + "je 1f\n\t" \ + "movw %%dx,%1\n\t" \ + "xchgl %%ecx,current\n\t" \ + "ljmp *%0\n\t" \ + "cmpl %%ecx,last_task_used_math\n\t" \ + "jne 1f\n\t" \ + "clts\n" \ + "1:" \ + ::"m" (*&__tmp.a),"m" (*&__tmp.b), \ + "d" (_TSS(n)),"c" ((long) task[n])); \ +} + +#define PAGE_ALIGN(n) (((n)+0xfff)&0xfffff000) + +#define _set_base(addr,base) \ +__asm__ ("push %%edx\n\t" \ + "movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %%dl,%1\n\t" \ + "movb %%dh,%2\n\t" \ + "pop %%edx" \ + ::"m" (*((addr)+2)), \ + "m" (*((addr)+4)), \ + "m" (*((addr)+7)), \ + "d" (base) \ + ) + +#define _set_limit(addr,limit) \ +__asm__ ("push %%edx\n\t" \ + "movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %1,%%dh\n\t" \ + "andb $0xf0,%%dh\n\t" \ + "orb %%dh,%%dl\n\t" \ + "movb %%dl,%1\n\t" \ + "pop %%edx" \ + ::"m" (*(addr)), \ + "m" (*((addr)+6)), \ + "d" (limit) \ + ) + +#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;}) + +#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)); \ +__limit;}) + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sys.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sys.h new file mode 100644 index 0000000..c538fc1 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/sys.h @@ -0,0 +1,86 @@ +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(); + +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 }; diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/tty.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/tty.h new file mode 100644 index 0000000..ad846b3 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/linux/tty.h @@ -0,0 +1,77 @@ +/* + * '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 + +#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[]; + +/* 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 diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/signal.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/signal.h new file mode 100644 index 0000000..0eea9a3 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/signal.h @@ -0,0 +1,68 @@ +#ifndef _SIGNAL_H +#define _SIGNAL_H + +#include + +typedef int sig_atomic_t; +typedef unsigned int sigset_t; /* 32 bits */ + +#define _NSIG 32 +#define NSIG _NSIG + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGUNUSED 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 + +/* Ok, I haven't implemented sigactions, but trying to keep headers POSIX */ +#define SA_NOCLDSTOP 1 +#define SA_NOMASK 0x40000000 +#define SA_ONESHOT 0x80000000 + +#define SIG_BLOCK 0 /* for blocking signals */ +#define SIG_UNBLOCK 1 /* for unblocking signals */ +#define SIG_SETMASK 2 /* for setting the signal mask */ + +#define SIG_DFL ((void (*)(int))0) /* default signal handling */ +#define SIG_IGN ((void (*)(int))1) /* ignore signal */ + +struct sigaction { + void (*sa_handler)(int); + sigset_t sa_mask; + int sa_flags; + void (*sa_restorer)(void); +}; + +void (*signal(int _sig, void (*_func)(int)))(int); +int raise(int sig); +int kill(pid_t pid, int sig); +int sigaddset(sigset_t *mask, int signo); +int sigdelset(sigset_t *mask, int signo); +int sigemptyset(sigset_t *mask); +int sigfillset(sigset_t *mask); +int sigismember(sigset_t *mask, int signo); /* 1 - is, 0 - not, -1 error */ +int sigpending(sigset_t *set); +int sigprocmask(int how, sigset_t *set, sigset_t *oldset); +int sigsuspend(sigset_t *sigmask); +int sigaction(int sig, struct sigaction *act, struct sigaction *oldact); + +#endif /* _SIGNAL_H */ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/stdarg.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/stdarg.h new file mode 100644 index 0000000..fd79ec0 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/stdarg.h @@ -0,0 +1,28 @@ +#ifndef _STDARG_H +#define _STDARG_H + +typedef char *va_list; + +/* Amount of space required in an argument list for an arg of type TYPE. + TYPE may alternatively be an expression whose type is used. */ + +#define __va_rounded_size(TYPE) \ + (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) + +#ifndef __sparc__ +#define va_start(AP, LASTARG) \ + (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) +#else +#define va_start(AP, LASTARG) \ + (__builtin_saveregs (), \ + AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) +#endif + +void va_end (va_list); /* Defined in gnulib */ +#define va_end(AP) + +#define va_arg(AP, TYPE) \ + (AP += __va_rounded_size (TYPE), \ + *((TYPE *) (AP - __va_rounded_size (TYPE)))) + +#endif /* _STDARG_H */ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/stddef.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/stddef.h new file mode 100644 index 0000000..97f72ff --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/stddef.h @@ -0,0 +1,19 @@ +#ifndef _STDDEF_H +#define _STDDEF_H + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef long ptrdiff_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned long size_t; +#endif + +#undef NULL +#define NULL ((void *)0) + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/string.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/string.h new file mode 100644 index 0000000..608e86f --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/string.h @@ -0,0 +1,405 @@ +#ifndef _STRING_H_ +#define _STRING_H_ + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +extern char * strerror(int errno); + +/* + * This string-include defines all string functions as inline + * functions. Use gcc. It also assumes ds=es=data space, this should be + * normal. Most of the string-functions are rather heavily hand-optimized, + * see especially strtok,strstr,str[c]spn. They should work, but are not + * very easy to understand. Everything is done entirely within the register + * set, making the functions fast and clean. String instructions have been + * used through-out, making for "slightly" unclear code :-) + * + * (C) 1991 Linus Torvalds + */ + +extern inline char * strcpy(char * dest,const char *src) +{ +__asm__("cld\n" + "1:\tlodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + ::"S" (src),"D" (dest)); +return dest; +} + +static inline char * strncpy(char * dest,const char *src,int count) +{ +__asm__("cld\n" + "1:\tdecl %2\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "rep\n\t" + "stosb\n" + "2:" + ::"S" (src),"D" (dest),"c" (count)); +return dest; +} + +extern inline char * strcat(char * dest,const char * src) +{ +__asm__("cld\n\t" + "repne\n\t" + "scasb\n\t" + "decl %1\n" + "1:\tlodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + ::"S" (src),"D" (dest),"a" (0),"c" (0xffffffff)); +return dest; +} + +static inline char * strncat(char * dest,const char * src,int count) +{ +__asm__("cld\n\t" + "repne\n\t" + "scasb\n\t" + "decl %1\n\t" + "movl %4,%3\n" + "1:\tdecl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n" + "2:\txorl %2,%2\n\t" + "stosb" + ::"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count) + ); +return dest; +} + +extern inline int strcmp(const char * cs,const char * ct) +{ +register int __res ; +__asm__("cld\n" + "1:\tlodsb\n\t" + "scasb\n\t" + "jne 2f\n\t" + "testb %%al,%%al\n\t" + "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" + "3:" + :"=a" (__res):"D" (cs),"S" (ct)); +return __res; +} + +static inline int strncmp(const char * cs,const char * ct,int count) +{ +register int __res ; +__asm__("cld\n" + "1:\tdecl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "scasb\n\t" + "jne 3f\n\t" + "testb %%al,%%al\n\t" + "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" + "4:" + :"=a" (__res):"D" (cs),"S" (ct),"c" (count)); +return __res; +} + +static inline char * strchr(const char * s,char c) +{ +register char * __res ; +__asm__("cld\n\t" + "movb %%al,%%ah\n" + "1:\tlodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "movl $1,%1\n" + "2:\tmovl %1,%0\n\t" + "decl %0" + :"=a" (__res):"S" (s),"0" (c)); +return __res; +} + +static inline char * strrchr(const char * s,char c) +{ +register char * __res; +__asm__("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" + "2:\ttestb %%al,%%al\n\t" + "jne 1b" + :"=d" (__res):"0" (0),"S" (s),"a" (c)); +return __res; +} + +extern inline int strspn(const char * cs, const char * ct) +{ +register char * __res; +__asm__("cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "je 1b\n" + "2:\tdecl %0" + :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) + ); +return __res-cs; +} + +extern inline int strcspn(const char * cs, const char * ct) +{ +register char * __res; +__asm__("cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "jne 1b\n" + "2:\tdecl %0" + :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) + ); +return __res-cs; +} + +extern inline char * strpbrk(const char * cs,const char * ct) +{ +register char * __res ; +__asm__("cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "jne 1b\n\t" + "decl %0\n\t" + "jmp 3f\n" + "2:\txorl %0,%0\n" + "3:" + :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) + ); +return __res; +} + +extern inline char * strstr(const char * cs,const char * ct) +{ +register char * __res ; +__asm__("cld\n\t" \ + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ + "movl %%ecx,%%edx\n" + "1:\tmovl %4,%%edi\n\t" + "movl %%esi,%%eax\n\t" + "movl %%edx,%%ecx\n\t" + "repe\n\t" + "cmpsb\n\t" + "je 2f\n\t" /* also works for empty string, see above */ + "xchgl %%eax,%%esi\n\t" + "incl %%esi\n\t" + "cmpb $0,-1(%%eax)\n\t" + "jne 1b\n\t" + "xorl %%eax,%%eax\n\t" + "2:" + :"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct) + ); +return __res; +} + +extern inline int strlen(const char * s) +{ +register int __res ; +__asm__("cld\n\t" + "repne\n\t" + "scasb\n\t" + "notl %0\n\t" + "decl %0" + :"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff)); +return __res; +} + +extern char * ___strtok; + +extern inline char * strtok(char * s,const char * ct) +{ +register char * __res ; +__asm__("testl %1,%1\n\t" + "jne 1f\n\t" + "testl %0,%0\n\t" + "je 8f\n\t" + "movl %0,%1\n" + "1:\txorl %0,%0\n\t" + "movl $-1,%%ecx\n\t" + "xorl %%eax,%%eax\n\t" + "cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "je 7f\n\t" /* empty delimeter-string */ + "movl %%ecx,%%edx\n" + "2:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 7f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "je 2b\n\t" + "decl %1\n\t" + "cmpb $0,(%1)\n\t" + "je 7f\n\t" + "movl %1,%0\n" + "3:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 5f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "jne 3b\n\t" + "decl %1\n\t" + "cmpb $0,(%1)\n\t" + "je 5f\n\t" + "movb $0,(%1)\n\t" + "incl %1\n\t" + "jmp 6f\n" + "5:\txorl %1,%1\n" + "6:\tcmpb $0,(%0)\n\t" + "jne 7f\n\t" + "xorl %0,%0\n" + "7:\ttestl %0,%0\n\t" + "jne 8f\n\t" + "movl %0,%1\n" + "8:" + :"=b" (__res),"=S" (___strtok) + :"0" (___strtok),"1" (s),"g" (ct) + ); +return __res; +} + +static inline void * memcpy(void * dest,const void * src, int n) +{ +__asm__("cld\n\t" + "rep\n\t" + "movsb" + ::"c" (n),"S" (src),"D" (dest) + ); +return dest; +} + +extern inline void * memmove(void * dest,const void * src, int n) +{ +if (dest + +struct stat { + dev_t st_dev; + ino_t st_ino; + umode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + time_t st_atime; + time_t st_mtime; + time_t st_ctime; +}; + +#define S_IFMT 00170000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +extern int chmod(const char *_path, mode_t mode); +extern int fstat(int fildes, struct stat *stat_buf); +extern int mkdir(const char *_path, mode_t mode); +extern int mkfifo(const char *_path, mode_t mode); +extern int stat(const char *filename, struct stat *stat_buf); +extern mode_t umask(mode_t mask); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/times.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/times.h new file mode 100644 index 0000000..68d5bfb --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/times.h @@ -0,0 +1,15 @@ +#ifndef _TIMES_H +#define _TIMES_H + +#include + +struct tms { + time_t tms_utime; + time_t tms_stime; + time_t tms_cutime; + time_t tms_cstime; +}; + +extern time_t times(struct tms * tp); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/types.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/types.h new file mode 100644 index 0000000..557aa31 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/types.h @@ -0,0 +1,46 @@ +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef long ptrdiff_t; +#endif + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +typedef int pid_t; +typedef unsigned short uid_t; +typedef unsigned char gid_t; +typedef unsigned short dev_t; +typedef unsigned short ino_t; +typedef unsigned short mode_t; +typedef unsigned short umode_t; +typedef unsigned char nlink_t; +typedef int daddr_t; +typedef long off_t; +typedef unsigned char u_char; +typedef unsigned short ushort; + +typedef struct { int quot,rem; } div_t; +typedef struct { long quot,rem; } ldiv_t; + +struct ustat { + daddr_t f_tfree; + ino_t f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/utsname.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/utsname.h new file mode 100644 index 0000000..0a1c5a0 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/utsname.h @@ -0,0 +1,16 @@ +#ifndef _SYS_UTSNAME_H +#define _SYS_UTSNAME_H + +#include + +struct utsname { + char sysname[9]; + char nodename[9]; + char release[9]; + char version[9]; + char machine[9]; +}; + +extern int uname(struct utsname * utsbuf); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/wait.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/wait.h new file mode 100644 index 0000000..53190c2 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/sys/wait.h @@ -0,0 +1,23 @@ +#ifndef _SYS_WAIT_H +#define _SYS_WAIT_H + +#include + +#define _LOW(v) ( (v) & 0377) +#define _HIGH(v) ( ((v) >> 8) & 0377) + +/* options for waitpid, WUNTRACED not supported */ +#define WNOHANG 1 +#define WUNTRACED 2 + +#define WIFEXITED(s) (!((s)&0xFF) +#define WIFSTOPPED(s) (((s)&0xFF)==0x7F) +#define WEXITSTATUS(s) (((s)>>8)&0xFF) +#define WTERMSIG(s) ((s)&0x7F) +#define WSTOPSIG(s) (((s)>>8)&0xFF) +#define WIFSIGNALED(s) (((unsigned int)(s)-1 & 0xFFFF) < 0xFF) + +pid_t wait(int *stat_loc); +pid_t waitpid(pid_t pid, int *stat_loc, int options); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/termios.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/termios.h new file mode 100644 index 0000000..2b7b913 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/termios.h @@ -0,0 +1,228 @@ +#ifndef _TERMIOS_H +#define _TERMIOS_H + +#define TTY_BUF_SIZE 1024 + +/* 0x54 is just a magic number to make these relatively uniqe ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define TIOCINQ 0x541B + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +#define NCCS 17 +struct termios { + unsigned long c_iflag; /* input mode flags */ + unsigned long c_oflag; /* output mode flags */ + unsigned long c_cflag; /* control mode flags */ + unsigned long c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCCS]; /* control characters */ +}; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define XTABS 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 +#define FFDLY 0040000 +#define FF0 0000000 +#define FF1 0040000 + +/* c_cflag bit meaning */ +#define CBAUD 0000017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define EXTA B19200 +#define EXTB B38400 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define CPARENB 0000400 +#define CPARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#define CIBAUD 03600000 /* input baud rate (not used) */ +#define CRTSCTS 020000000000 /* flow control */ + +#define PARENB CPARENB +#define PARODD CPARODD + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#define XCASE 0000004 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define IEXTEN 0100000 + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG + +/* tcflow() and TCXONC use these */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +typedef int speed_t; + +extern speed_t cfgetispeed(struct termios *termios_p); +extern speed_t cfgetospeed(struct termios *termios_p); +extern int cfsetispeed(struct termios *termios_p, speed_t speed); +extern int cfsetospeed(struct termios *termios_p, speed_t speed); +extern int tcdrain(int fildes); +extern int tcflow(int fildes, int action); +extern int tcflush(int fildes, int queue_selector); +extern int tcgetattr(int fildes, struct termios *termios_p); +extern int tcsendbreak(int fildes, int duration); +extern int tcsetattr(int fildes, int optional_actions, + struct termios *termios_p); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/time.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/time.h new file mode 100644 index 0000000..d0a765d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/time.h @@ -0,0 +1,42 @@ +#ifndef _TIME_H +#define _TIME_H + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#define CLOCKS_PER_SEC 100 + +typedef long clock_t; + +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + +clock_t clock(void); +time_t time(time_t * tp); +double difftime(time_t time2, time_t time1); +time_t mktime(struct tm * tp); + +char * asctime(const struct tm * tp); +char * ctime(const time_t * tp); +struct tm * gmtime(const time_t *tp); +struct tm *localtime(const time_t * tp); +size_t strftime(char * s, size_t smax, const char * fmt, const struct tm * tp); +void tzset(void); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/unistd.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/unistd.h new file mode 100644 index 0000000..bf71dcb --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/unistd.h @@ -0,0 +1,253 @@ +#ifndef _UNISTD_H +#define _UNISTD_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 +#include +#include +#include + +#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 _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); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/utime.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/utime.h new file mode 100644 index 0000000..83f07c7 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/include/utime.h @@ -0,0 +1,13 @@ +#ifndef _UTIME_H +#define _UTIME_H + +#include /* I know - shouldn't do this, but .. */ + +struct utimbuf { + time_t actime; + time_t modtime; +}; + +extern int utime(const char *filename, struct utimbuf *times); + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/init/main.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/init/main.c new file mode 100644 index 0000000..581485c --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/init/main.c @@ -0,0 +1,209 @@ +/* + * linux/init/main.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include +#include + +/* + * we need this inline - forking from kernel space will result + * in NO COPY ON WRITE (!!!), until an execve is executed. This + * is no problem, but for the stack. This is handled by not letting + * main() use the stack at all after fork(). Thus, no function + * calls - which means inline code for fork too, as otherwise we + * would use the stack upon exit from 'fork()'. + * + * Actually only pause and fork are needed inline, so that there + * won't be any messing with the stack from main(), but we define + * some others too. + */ +static inline _syscall0(int,fork) +static inline _syscall0(int,pause) +static inline _syscall1(int,setup,void *,BIOS) +static inline _syscall0(int,sync) + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +static char printbuf[1024]; + +extern int vsprintf(); +extern void init(void); +extern void blk_dev_init(void); +extern void chr_dev_init(void); +extern void hd_init(void); +extern void floppy_init(void); +extern void mem_init(long start, long end); +extern long rd_init(long mem_start, int length); +extern long kernel_mktime(struct tm * tm); +extern long startup_time; + +/* + * This is set up by the setup-routine at boot-time + */ +#define EXT_MEM_K (*(unsigned short *)0x90002) +#define DRIVE_INFO (*(struct drive_info *)0x90080) +#define ORIG_ROOT_DEV (*(unsigned short *)0x901FC) + +/* + * Yeah, yeah, it's ugly, but I cannot find how to do this correctly + * and this seems to work. I anybody has more info on the real-time + * clock I'd be interested. Most of this was trial and error, and some + * bios-listing reading. Urghh. + */ + +#define CMOS_READ(addr) ({ \ +outb_p(0x80|addr,0x70); \ +inb_p(0x71); \ +}) + +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) + +static void time_init(void) +{ + struct tm time; + + do { + time.tm_sec = CMOS_READ(0); + time.tm_min = CMOS_READ(2); + time.tm_hour = CMOS_READ(4); + time.tm_mday = CMOS_READ(7); + time.tm_mon = CMOS_READ(8); + time.tm_year = CMOS_READ(9); + } while (time.tm_sec != CMOS_READ(0)); + BCD_TO_BIN(time.tm_sec); + BCD_TO_BIN(time.tm_min); + BCD_TO_BIN(time.tm_hour); + BCD_TO_BIN(time.tm_mday); + BCD_TO_BIN(time.tm_mon); + BCD_TO_BIN(time.tm_year); + time.tm_mon--; + startup_time = kernel_mktime(&time); +} + +static long memory_end = 0; +static long buffer_memory_end = 0; +static long main_memory_start = 0; + +struct drive_info { char dummy[32]; } drive_info; + +void start(void) /* This really IS void, no error here. */ +{ /* The startup routine assumes (well, ...) this */ +/* + * Interrupts are still disabled. Do necessary setups, then + * enable them + */ + ROOT_DEV = 0x301; + drive_info = DRIVE_INFO; + memory_end = (1<<20) + (EXT_MEM_K<<10); + memory_end &= 0xfffff000; + if (memory_end > 16*1024*1024) + memory_end = 16*1024*1024; + if (memory_end > 12*1024*1024) + buffer_memory_end = 4*1024*1024; + else if (memory_end > 6*1024*1024) + buffer_memory_end = 2*1024*1024; + else + buffer_memory_end = 1*1024*1024; + main_memory_start = buffer_memory_end; +#ifdef RAMDISK + main_memory_start += rd_init(main_memory_start, RAMDISK*1024); +#endif + mem_init(main_memory_start,memory_end); + trap_init(); + blk_dev_init(); + chr_dev_init(); + tty_init(); + time_init(); + sched_init(); + buffer_init(buffer_memory_end); + hd_init(); + floppy_init(); + sti(); + move_to_user_mode(); + if (!fork()) { /* we count on this going ok */ + init(); + } +/* + * NOTE!! For any other task 'pause()' would mean we have to get a + * signal to awaken, but task0 is the sole exception (see 'schedule()') + * as task 0 gets activated at every idle moment (when no other tasks + * can run). For task0 'pause()' just means we go check if some other + * task can run, and if not we return here. + */ + for(;;) pause(); +} + +static int printf(const char *fmt, ...) +{ + va_list args; + int i; + + va_start(args, fmt); + write(1,printbuf,i=vsprintf(printbuf, fmt, args)); + va_end(args); + return i; +} + +static char * argv_rc[] = { "/bin/sh", NULL }; +static char * envp_rc[] = { "HOME=/", NULL }; + +static char * argv[] = { "-/bin/sh",NULL }; +static char * envp[] = { "HOME=/usr/root", NULL }; + +void init(void) +{ + int pid,i; + + setup((void *) &drive_info); + (void) open("/dev/tty0",O_RDWR,0); + (void) dup(0); + (void) dup(0); + printf("%d buffers = %d bytes buffer space\n\r",NR_BUFFERS, + NR_BUFFERS*BLOCK_SIZE); + printf("Free mem: %d bytes\n\r",memory_end-main_memory_start); + if (!(pid=fork())) { + close(0); + if (open("/etc/rc",O_RDONLY,0)) + _exit(1); + execve("/bin/sh",argv_rc,envp_rc); + _exit(2); + } + if (pid>0) + while (pid != wait(&i)) + /* nothing */; + while (1) { + if ((pid=fork())<0) { + printf("Fork failed in init\r\n"); + continue; + } + if (!pid) { + close(0);close(1);close(2); + setsid(); + (void) open("/dev/tty0",O_RDWR,0); + (void) dup(0); + (void) dup(0); + _exit(execve("/bin/sh",argv,envp)); + } + while (1) + if (pid == wait(&i)) + break; + printf("\n\rchild %d died with code %04x\n\r",pid,i); + sync(); + } + _exit(0); /* NOTE! _exit, not exit() */ +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/init/main.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/init/main.o new file mode 100644 index 0000000..9636125 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/init/main.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/Makefile new file mode 100644 index 0000000..fbd0d43 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/Makefile @@ -0,0 +1,83 @@ +# +# Makefile for the FREAX-kernel. +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (ie not a .c file). +# + +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =gcc -mcpu=i386 +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions -nostdinc -I../include +CPP =gcc -E -nostdinc -I../include + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(AS) -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = sched.o system_call.o traps.o asm.o fork.o \ + panic.o printk.o vsprintf.o sys.o exit.o \ + signal.o mktime.o + +kernel.o: $(OBJS) + $(LD) -r -o kernel.o $(OBJS) + sync + +clean: + rm -f core *.o *.a tmp_make keyboard.s + for i in *.c;do rm -f `basename $$i .c`.s;done + (cd chr_drv; make clean) + (cd blk_drv; make clean) + (cd math; make clean) + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + (cd chr_drv; make dep) + (cd blk_drv; make dep) + +### Dependencies: +exit.s exit.o: exit.c ../include/errno.h ../include/signal.h \ + ../include/sys/types.h ../include/sys/wait.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \ + ../include/linux/kernel.h ../include/linux/tty.h ../include/termios.h \ + ../include/asm/segment.h +fork.s fork.o: fork.c ../include/errno.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \ + ../include/asm/segment.h ../include/asm/system.h +mktime.s mktime.o: mktime.c ../include/time.h +panic.s panic.o: panic.c ../include/linux/kernel.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h +printk.s printk.o: printk.c ../include/stdarg.h ../include/stddef.h \ + ../include/linux/kernel.h +sched.s sched.o: sched.c ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \ + ../include/signal.h ../include/linux/kernel.h ../include/linux/sys.h \ + ../include/linux/fdreg.h ../include/asm/system.h ../include/asm/io.h \ + ../include/asm/segment.h +signal.s signal.o: signal.c ../include/linux/sched.h ../include/linux/head.h \ + ../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \ + ../include/signal.h ../include/linux/kernel.h ../include/asm/segment.h +sys.s sys.o: sys.c ../include/errno.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/tty.h \ + ../include/termios.h ../include/linux/kernel.h ../include/asm/segment.h \ + ../include/sys/times.h ../include/sys/utsname.h +traps.s traps.o: traps.c ../include/string.h ../include/linux/head.h \ + ../include/linux/sched.h ../include/linux/fs.h ../include/sys/types.h \ + ../include/linux/mm.h ../include/signal.h ../include/linux/kernel.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 diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/asm.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/asm.o new file mode 100644 index 0000000..13eb691 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/asm.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/asm.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/asm.s new file mode 100644 index 0000000..34f9b20 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/asm.s @@ -0,0 +1,146 @@ +/* + * linux/kernel/asm.s + * + * (C) 1991 Linus Torvalds + */ + +/* + * asm.s contains the low-level code for most hardware faults. + * page_exception is handled by the mm, so that isn't here. This + * file also handles (hopefully) fpu-exceptions due to TS-bit, as + * the fpu must be properly saved/resored. This hasn't been tested. + */ + +.globl _divide_error, _debug, _nmi, _int3, _overflow,_bounds,_invalid_op +.globl _double_fault, _coprocessor_segment_overrun +.globl _invalid_TSS, _segment_not_present, _stack_segment +.globl _general_protection, _coprocessor_error,_irq13, _reserved + +_divide_error: + pushl $_do_divide_error +no_error_code: + xchgl %eax,(%esp) + pushl %ebx + pushl %ecx + pushl %edx + pushl %edi + pushl %esi + pushl %ebp + push %ds + push %es + push %fs + pushl $0 # "error code" + lea 44(%esp),%edx + pushl %edx + movl $0x10,%edx + mov %dx,%ds + mov %dx,%es + mov %dx,%fs + call *%eax + addl $8,%esp + pop %fs + pop %es + pop %ds + popl %ebp + popl %esi + popl %edi + popl %edx + popl %ecx + popl %ebx + popl %eax + iret + +_debug: + pushl $_do_int3 # _do_debug + jmp no_error_code + +_nmi: + pushl $_do_nmi + jmp no_error_code + +_int3: + pushl $_do_int3 + jmp no_error_code + +_overflow: + pushl $_do_overflow + jmp no_error_code + +_bounds: + pushl $_do_bounds + jmp no_error_code + +_invalid_op: + pushl $_do_invalid_op + jmp no_error_code + +_coprocessor_segment_overrun: + pushl $_do_coprocessor_segment_overrun + jmp no_error_code + +_reserved: + pushl $_do_reserved + jmp no_error_code + +_irq13: + pushl %eax + xorb %al,%al + outb %al,$0xF0 + movb $0x20,%al + outb %al,$0x20 + jmp 1f +1: jmp 1f +1: outb %al,$0xA0 + popl %eax + jmp _coprocessor_error + +_double_fault: + pushl $_do_double_fault +error_code: + xchgl %eax,4(%esp) # error code <-> %eax + xchgl %ebx,(%esp) # &function <-> %ebx + pushl %ecx + pushl %edx + pushl %edi + pushl %esi + pushl %ebp + push %ds + push %es + push %fs + pushl %eax # error code + lea 44(%esp),%eax # offset + pushl %eax + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + mov %ax,%fs + call *%ebx + addl $8,%esp + pop %fs + pop %es + pop %ds + popl %ebp + popl %esi + popl %edi + popl %edx + popl %ecx + popl %ebx + popl %eax + iret + +_invalid_TSS: + pushl $_do_invalid_TSS + jmp error_code + +_segment_not_present: + pushl $_do_segment_not_present + jmp error_code + +_stack_segment: + pushl $_do_stack_segment + jmp error_code + +_general_protection: + pushl $_do_general_protection + jmp error_code + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/Makefile new file mode 100644 index 0000000..14074c2 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/Makefile @@ -0,0 +1,66 @@ +# +# Makefile for the FREAX-kernel block device drivers. +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (ie not a .c file). +# + +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =gcc -mcpu=i386 +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions -nostdinc -I../../include +CPP =gcc -E -nostdinc -I../../include + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(AS) -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = ll_rw_blk.o floppy.o hd.o ramdisk.o + +blk_drv.a: $(OBJS) + $(AR) rcs blk_drv.a $(OBJS) + sync + +clean: + rm -f core *.o *.a tmp_make + for i in *.c;do rm -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: +floppy.s floppy.o: floppy.c ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/sys/types.h \ + ../../include/linux/mm.h ../../include/signal.h \ + ../../include/linux/kernel.h ../../include/linux/fdreg.h \ + ../../include/asm/system.h ../../include/asm/io.h \ + ../../include/asm/segment.h blk.h +hd.s hd.o: hd.c ../../include/linux/config.h ../../include/linux/sched.h \ + ../../include/linux/head.h ../../include/linux/fs.h \ + ../../include/sys/types.h ../../include/linux/mm.h \ + ../../include/signal.h ../../include/linux/kernel.h \ + ../../include/linux/hdreg.h ../../include/asm/system.h \ + ../../include/asm/io.h ../../include/asm/segment.h blk.h +ll_rw_blk.s ll_rw_blk.o: ll_rw_blk.c ../../include/errno.h \ + ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/sys/types.h \ + ../../include/linux/mm.h ../../include/signal.h \ + ../../include/linux/kernel.h ../../include/asm/system.h blk.h +ramdisk.s ramdisk.o: ramdisk.c ../../include/string.h ../../include/linux/config.h \ + ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/sys/types.h \ + ../../include/linux/mm.h ../../include/signal.h \ + ../../include/linux/kernel.h ../../include/asm/system.h \ + ../../include/asm/segment.h ../../include/asm/memory.h blk.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/blk.h b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/blk.h new file mode 100644 index 0000000..9ee7591 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/blk.h @@ -0,0 +1,140 @@ +#ifndef _BLK_H +#define _BLK_H + +#define NR_BLK_DEV 7 +/* + * NR_REQUEST is the number of entries in the request-queue. + * NOTE that writes may use only the low 2/3 of these: reads + * take precedence. + * + * 32 seems to be a reasonable number: enough to get some benefit + * from the elevator-mechanism, but not so much as to lock a lot of + * buffers when they are in the queue. 64 seems to be too many (easily + * long pauses in reading when heavy writing/syncing is going on) + */ +#define NR_REQUEST 32 + +/* + * Ok, this is an expanded form so that we can use the same + * request for paging requests when that is implemented. In + * paging, 'bh' is NULL, and 'waiting' is used to wait for + * read/write completion. + */ +struct request { + int dev; /* -1 if no request */ + int cmd; /* READ or WRITE */ + int errors; + unsigned long sector; + unsigned long nr_sectors; + char * buffer; + struct task_struct * waiting; + struct buffer_head * bh; + struct request * next; +}; + +/* + * This is used in the elevator algorithm: Note that + * reads always go before writes. This is natural: reads + * are much more time-critical than writes. + */ +#define IN_ORDER(s1,s2) \ +((s1)->cmd<(s2)->cmd || ((s1)->cmd==(s2)->cmd && \ +((s1)->dev < (s2)->dev || ((s1)->dev == (s2)->dev && \ +(s1)->sector < (s2)->sector)))) + +struct blk_dev_struct { + void (*request_fn)(void); + struct request * current_request; +}; + +extern struct blk_dev_struct blk_dev[NR_BLK_DEV]; +extern struct request request[NR_REQUEST]; +extern struct task_struct * wait_for_request; + +#ifdef MAJOR_NR + +/* + * Add entries as needed. Currently the only block devices + * supported are hard-disks and floppies. + */ + +#if (MAJOR_NR == 1) +/* ram disk */ +#define DEVICE_NAME "ramdisk" +#define DEVICE_REQUEST do_rd_request +#define DEVICE_NR(device) ((device) & 7) +#define DEVICE_ON(device) +#define DEVICE_OFF(device) + +#elif (MAJOR_NR == 2) +/* floppy */ +#define DEVICE_NAME "floppy" +#define DEVICE_INTR do_floppy +#define DEVICE_REQUEST do_fd_request +#define DEVICE_NR(device) ((device) & 3) +#define DEVICE_ON(device) floppy_on(DEVICE_NR(device)) +#define DEVICE_OFF(device) floppy_off(DEVICE_NR(device)) + +#elif (MAJOR_NR == 3) +/* harddisk */ +#define DEVICE_NAME "harddisk" +#define DEVICE_INTR do_hd +#define DEVICE_REQUEST do_hd_request +#define DEVICE_NR(device) (MINOR(device)/5) +#define DEVICE_ON(device) +#define DEVICE_OFF(device) + +#elif +/* unknown blk device */ +#error "unknown blk device" + +#endif + +#define CURRENT (blk_dev[MAJOR_NR].current_request) +#define CURRENT_DEV DEVICE_NR(CURRENT->dev) + +#ifdef DEVICE_INTR +void (*DEVICE_INTR)(void) = NULL; +#endif +static void (DEVICE_REQUEST)(void); + +static inline void unlock_buffer(struct buffer_head * bh) +{ + if (!bh->b_lock) + printk(DEVICE_NAME ": free buffer being unlocked\n"); + bh->b_lock=0; + wake_up(&bh->b_wait); +} + +static inline void end_request(int uptodate) +{ + DEVICE_OFF(CURRENT->dev); + if (CURRENT->bh) { + CURRENT->bh->b_uptodate = uptodate; + unlock_buffer(CURRENT->bh); + } + if (!uptodate) { + printk(DEVICE_NAME " I/O error\n\r"); + printk("dev %04x, block %d\n\r",CURRENT->dev, + CURRENT->bh->b_blocknr); + } + wake_up(&CURRENT->waiting); + wake_up(&wait_for_request); + CURRENT->dev = -1; + CURRENT = CURRENT->next; +} + +#define INIT_REQUEST \ +repeat: \ + if (!CURRENT) \ + return; \ + if (MAJOR(CURRENT->dev) != MAJOR_NR) \ + panic(DEVICE_NAME ": request list destroyed"); \ + if (CURRENT->bh) { \ + if (!CURRENT->bh->b_lock) \ + panic(DEVICE_NAME ": block not locked"); \ + } + +#endif + +#endif diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/blk_drv.a b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/blk_drv.a new file mode 100644 index 0000000..7750c82 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/blk_drv.a differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/floppy.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/floppy.c new file mode 100644 index 0000000..6ca6401 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/floppy.c @@ -0,0 +1,462 @@ +/* + * linux/kernel/floppy.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 02.12.91 - Changed to static variables to indicate need for reset + * and recalibrate. This makes some things easier (output_byte reset + * checking etc), and means less interrupt jumping in case of errors, + * so the code is hopefully easier to understand. + */ + +/* + * This file is certainly a mess. I've tried my best to get it working, + * but I don't like programming floppies, and I have only one anyway. + * Urgel. I should check for more errors, and do more graceful error + * recovery. Seems there are problems with several drives. I've tried to + * correct them. No promises. + */ + +/* + * As with hd.c, all routines within this file can (and will) be called + * by interrupts, so extreme caution is needed. A hardware interrupt + * handler may not sleep, or a kernel panic will happen. Thus I cannot + * call "floppy-on" directly, but have to set a special timer interrupt + * etc. + * + * Also, I'm not certain this works on more than 1 floppy. Bugs may + * abund. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MAJOR_NR 2 +#include "blk.h" + +static int recalibrate = 0; +static int reset = 0; +static int seek = 0; + +extern unsigned char current_DOR; + +#define immoutb_p(val,port) \ +__asm__("outb %0,%1\n\tjmp 1f\n1:\tjmp 1f\n1:"::"a" ((char) (val)),"i" (port)) + +#define TYPE(x) ((x)>>2) +#define DRIVE(x) ((x)&0x03) +/* + * Note that MAX_ERRORS=8 doesn't imply that we retry every bad read + * max 8 times - some types of errors increase the errorcount by 2, + * so we might actually retry only 5-6 times before giving up. + */ +#define MAX_ERRORS 8 + +/* + * globals used by 'result()' + */ +#define MAX_REPLIES 7 +static unsigned char reply_buffer[MAX_REPLIES]; +#define ST0 (reply_buffer[0]) +#define ST1 (reply_buffer[1]) +#define ST2 (reply_buffer[2]) +#define ST3 (reply_buffer[3]) + +/* + * This struct defines the different floppy types. Unlike minix + * linux doesn't have a "search for right type"-type, as the code + * for that is convoluted and weird. I've got enough problems with + * this driver as it is. + * + * The 'stretch' tells if the tracks need to be boubled for some + * types (ie 360kB diskette in 1.2MB drive etc). Others should + * be self-explanatory. + */ +static struct floppy_struct { + unsigned int size, sect, head, track, stretch; + unsigned char gap,rate,spec1; +} floppy_type[] = { + { 0, 0,0, 0,0,0x00,0x00,0x00 }, /* no testing */ + { 720, 9,2,40,0,0x2A,0x02,0xDF }, /* 360kB PC diskettes */ + { 2400,15,2,80,0,0x1B,0x00,0xDF }, /* 1.2 MB AT-diskettes */ + { 720, 9,2,40,1,0x2A,0x02,0xDF }, /* 360kB in 720kB drive */ + { 1440, 9,2,80,0,0x2A,0x02,0xDF }, /* 3.5" 720kB diskette */ + { 720, 9,2,40,1,0x23,0x01,0xDF }, /* 360kB in 1.2MB drive */ + { 1440, 9,2,80,0,0x23,0x01,0xDF }, /* 720kB in 1.2MB drive */ + { 2880,18,2,80,0,0x1B,0x00,0xCF }, /* 1.44MB diskette */ +}; +/* + * Rate is 0 for 500kb/s, 2 for 300kbps, 1 for 250kbps + * Spec1 is 0xSH, where S is stepping rate (F=1ms, E=2ms, D=3ms etc), + * H is head unload time (1=16ms, 2=32ms, etc) + * + * Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms etc) + * and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). + */ + +extern void floppy_interrupt(void); +extern char tmp_floppy_area[1024]; + +/* + * These are global variables, as that's the easiest way to give + * information to interrupts. They are the data used for the current + * request. + */ +static int cur_spec1 = -1; +static int cur_rate = -1; +static struct floppy_struct * floppy = floppy_type; +static unsigned char current_drive = 0; +static unsigned char sector = 0; +static unsigned char head = 0; +static unsigned char track = 0; +static unsigned char seek_track = 0; +static unsigned char current_track = 255; +static unsigned char command = 0; +unsigned char selected = 0; +struct task_struct * wait_on_floppy_select = NULL; + +void floppy_deselect(unsigned int nr) +{ + if (nr != (current_DOR & 3)) + printk("floppy_deselect: drive not selected\n\r"); + selected = 0; + wake_up(&wait_on_floppy_select); +} + +/* + * floppy-change is never called from an interrupt, so we can relax a bit + * here, sleep etc. Note that floppy-on tries to set current_DOR to point + * to the desired drive, but it will probably not survive the sleep if + * several floppies are used at the same time: thus the loop. + */ +int floppy_change(unsigned int nr) +{ +repeat: + floppy_on(nr); + while ((current_DOR & 3) != nr && selected) + interruptible_sleep_on(&wait_on_floppy_select); + if ((current_DOR & 3) != nr) + goto repeat; + if (inb(FD_DIR) & 0x80) { + floppy_off(nr); + return 1; + } + floppy_off(nr); + return 0; +} + +#define copy_buffer(from,to) \ +__asm__("cld ; rep ; movsl" \ + ::"c" (BLOCK_SIZE/4),"S" ((long)(from)),"D" ((long)(to)) \ + ) + +static void setup_DMA(void) +{ + long addr = (long) CURRENT->buffer; + + cli(); + if (addr >= 0x100000) { + addr = (long) tmp_floppy_area; + if (command == FD_WRITE) + copy_buffer(CURRENT->buffer,tmp_floppy_area); + } +/* mask DMA 2 */ + immoutb_p(4|2,10); +/* output command byte. I don't know why, but everyone (minix, */ +/* sanches & canton) output this twice, first to 12 then to 11 */ + __asm__("outb %%al,$12\n\tjmp 1f\n1:\tjmp 1f\n1:\t" + "outb %%al,$11\n\tjmp 1f\n1:\tjmp 1f\n1:":: + "a" ((char) ((command == FD_READ)?DMA_READ:DMA_WRITE))); +/* 8 low bits of addr */ + immoutb_p(addr,4); + addr >>= 8; +/* bits 8-15 of addr */ + immoutb_p(addr,4); + addr >>= 8; +/* bits 16-19 of addr */ + immoutb_p(addr,0x81); +/* low 8 bits of count-1 (1024-1=0x3ff) */ + immoutb_p(0xff,5); +/* high 8 bits of count-1 */ + immoutb_p(3,5); +/* activate DMA 2 */ + immoutb_p(0|2,10); + sti(); +} + +static void output_byte(char byte) +{ + int counter; + unsigned char status; + + if (reset) + return; + for(counter = 0 ; counter < 10000 ; counter++) { + status = inb_p(FD_STATUS) & (STATUS_READY | STATUS_DIR); + if (status == STATUS_READY) { + outb(byte,FD_DATA); + return; + } + } + reset = 1; + printk("Unable to send byte to FDC\n\r"); +} + +static int result(void) +{ + int i = 0, counter, status; + + if (reset) + return -1; + for (counter = 0 ; counter < 10000 ; counter++) { + status = inb_p(FD_STATUS)&(STATUS_DIR|STATUS_READY|STATUS_BUSY); + if (status == STATUS_READY) + return i; + if (status == (STATUS_DIR|STATUS_READY|STATUS_BUSY)) { + if (i >= MAX_REPLIES) + break; + reply_buffer[i++] = inb_p(FD_DATA); + } + } + reset = 1; + printk("Getstatus times out\n\r"); + return -1; +} + +static void bad_flp_intr(void) +{ + CURRENT->errors++; + if (CURRENT->errors > MAX_ERRORS) { + floppy_deselect(current_drive); + end_request(0); + } + if (CURRENT->errors > MAX_ERRORS/2) + reset = 1; + else + recalibrate = 1; +} + +/* + * Ok, this interrupt is called after a DMA read/write has succeeded, + * so we check the results, and copy any buffers. + */ +static void rw_interrupt(void) +{ + if (result() != 7 || (ST0 & 0xf8) || (ST1 & 0xbf) || (ST2 & 0x73)) { + if (ST1 & 0x02) { + printk("Drive %d is write protected\n\r",current_drive); + floppy_deselect(current_drive); + end_request(0); + } else + bad_flp_intr(); + do_fd_request(); + return; + } + if (command == FD_READ && (unsigned long)(CURRENT->buffer) >= 0x100000) + copy_buffer(tmp_floppy_area,CURRENT->buffer); + floppy_deselect(current_drive); + end_request(1); + do_fd_request(); +} + +inline void setup_rw_floppy(void) +{ + setup_DMA(); + do_floppy = rw_interrupt; + output_byte(command); + output_byte(head<<2 | current_drive); + output_byte(track); + output_byte(head); + output_byte(sector); + output_byte(2); /* sector size = 512 */ + output_byte(floppy->sect); + output_byte(floppy->gap); + output_byte(0xFF); /* sector size (0xff when n!=0 ?) */ + if (reset) + do_fd_request(); +} + +/* + * This is the routine called after every seek (or recalibrate) interrupt + * from the floppy controller. Note that the "unexpected interrupt" routine + * also does a recalibrate, but doesn't come here. + */ +static void seek_interrupt(void) +{ +/* sense drive status */ + output_byte(FD_SENSEI); + if (result() != 2 || (ST0 & 0xF8) != 0x20 || ST1 != seek_track) { + bad_flp_intr(); + do_fd_request(); + return; + } + current_track = ST1; + setup_rw_floppy(); +} + +/* + * This routine is called when everything should be correctly set up + * for the transfer (ie floppy motor is on and the correct floppy is + * selected). + */ +static void transfer(void) +{ + if (cur_spec1 != floppy->spec1) { + cur_spec1 = floppy->spec1; + output_byte(FD_SPECIFY); + output_byte(cur_spec1); /* hut etc */ + output_byte(6); /* Head load time =6ms, DMA */ + } + if (cur_rate != floppy->rate) + outb_p(cur_rate = floppy->rate,FD_DCR); + if (reset) { + do_fd_request(); + return; + } + if (!seek) { + setup_rw_floppy(); + return; + } + do_floppy = seek_interrupt; + if (seek_track) { + output_byte(FD_SEEK); + output_byte(head<<2 | current_drive); + output_byte(seek_track); + } else { + output_byte(FD_RECALIBRATE); + output_byte(head<<2 | current_drive); + } + if (reset) + do_fd_request(); +} + +/* + * Special case - used after a unexpected interrupt (or reset) + */ +static void recal_interrupt(void) +{ + output_byte(FD_SENSEI); + if (result()!=2 || (ST0 & 0xE0) == 0x60) + reset = 1; + else + recalibrate = 0; + do_fd_request(); +} + +void unexpected_floppy_interrupt(void) +{ + output_byte(FD_SENSEI); + if (result()!=2 || (ST0 & 0xE0) == 0x60) + reset = 1; + else + recalibrate = 1; +} + +static void recalibrate_floppy(void) +{ + recalibrate = 0; + current_track = 0; + do_floppy = recal_interrupt; + output_byte(FD_RECALIBRATE); + output_byte(head<<2 | current_drive); + if (reset) + do_fd_request(); +} + +static void reset_interrupt(void) +{ + output_byte(FD_SENSEI); + (void) result(); + output_byte(FD_SPECIFY); + output_byte(cur_spec1); /* hut etc */ + output_byte(6); /* Head load time =6ms, DMA */ + do_fd_request(); +} + +/* + * reset is done by pulling bit 2 of DOR low for a while. + */ +static void reset_floppy(void) +{ + int i; + + reset = 0; + cur_spec1 = -1; + cur_rate = -1; + recalibrate = 1; + printk("Reset-floppy called\n\r"); + cli(); + do_floppy = reset_interrupt; + outb_p(current_DOR & ~0x04,FD_DOR); + for (i=0 ; i<100 ; i++) + __asm__("nop"); + outb(current_DOR,FD_DOR); + sti(); +} + +static void floppy_on_interrupt(void) +{ +/* We cannot do a floppy-select, as that might sleep. We just force it */ + selected = 1; + if (current_drive != (current_DOR & 3)) { + current_DOR &= 0xFC; + current_DOR |= current_drive; + outb(current_DOR,FD_DOR); + add_timer(2,&transfer); + } else + transfer(); +} + +void do_fd_request(void) +{ + unsigned int block; + + seek = 0; + if (reset) { + reset_floppy(); + return; + } + if (recalibrate) { + recalibrate_floppy(); + return; + } + INIT_REQUEST; + floppy = (MINOR(CURRENT->dev)>>2) + floppy_type; + if (current_drive != CURRENT_DEV) + seek = 1; + current_drive = CURRENT_DEV; + block = CURRENT->sector; + if (block+2 > floppy->size) { + end_request(0); + goto repeat; + } + sector = block % floppy->sect; + block /= floppy->sect; + head = block % floppy->head; + track = block / floppy->head; + seek_track = track << floppy->stretch; + if (seek_track != current_track) + seek = 1; + sector++; + if (CURRENT->cmd == READ) + command = FD_READ; + else if (CURRENT->cmd == WRITE) + command = FD_WRITE; + else + panic("do_fd_request: unknown command"); + add_timer(ticks_to_floppy_on(current_drive),&floppy_on_interrupt); +} + +void floppy_init(void) +{ + blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST; + set_trap_gate(0x26,&floppy_interrupt); + outb(inb_p(0x21)&~0x40,0x21); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/floppy.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/floppy.o new file mode 100644 index 0000000..be5f2ee Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/floppy.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/hd.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/hd.c new file mode 100644 index 0000000..3e176f7 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/hd.c @@ -0,0 +1,349 @@ +/* + * linux/kernel/hd.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * This is the low-level hd interrupt support. It traverses the + * request-list, using interrupts to jump between functions. As + * all the functions are called within interrupts, we may not + * sleep. Special care is recommended. + * + * modified by Drew Eckhardt to check nr of hd's from the CMOS. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAJOR_NR 3 +#include "blk.h" + +#define CMOS_READ(addr) ({ \ +outb_p(0x80|addr,0x70); \ +inb_p(0x71); \ +}) + +/* Max read/write errors/sector */ +#define MAX_ERRORS 7 +#define MAX_HD 2 + +static void recal_intr(void); + +static int recalibrate = 1; +static int reset = 1; + +/* + * This struct defines the HD's and their types. + */ +struct hd_i_struct { + int head,sect,cyl,wpcom,lzone,ctl; + }; +#ifdef HD_TYPE +struct hd_i_struct hd_info[] = { HD_TYPE }; +#define NR_HD ((sizeof (hd_info))/(sizeof (struct hd_i_struct))) +#else +struct hd_i_struct hd_info[] = { {0,0,0,0,0,0},{0,0,0,0,0,0} }; +static int NR_HD = 0; +#endif + +static struct hd_struct { + long start_sect; + long nr_sects; +} hd[5*MAX_HD]={{0,0},}; + +#define port_read(port,buf,nr) \ +__asm__("cld;rep;insw"::"d" (port),"D" (buf),"c" (nr)) + +#define port_write(port,buf,nr) \ +__asm__("cld;rep;outsw"::"d" (port),"S" (buf),"c" (nr)) + +extern void hd_interrupt(void); +extern void rd_load(void); + +/* This may be used only once, enforced by 'static int callable' */ +int sys_setup(void * BIOS) +{ + static int callable = 1; + int i,drive; + unsigned char cmos_disks; + struct partition *p; + struct buffer_head * bh; + + if (!callable) + return -1; + callable = 0; +#ifndef HD_TYPE + for (drive=0 ; drive<2 ; drive++) { + hd_info[drive].cyl = *(unsigned short *) BIOS; + hd_info[drive].head = *(unsigned char *) (2+BIOS); + hd_info[drive].wpcom = *(unsigned short *) (5+BIOS); + hd_info[drive].ctl = *(unsigned char *) (8+BIOS); + hd_info[drive].lzone = *(unsigned short *) (12+BIOS); + hd_info[drive].sect = *(unsigned char *) (14+BIOS); + BIOS += 16; + } + if (hd_info[1].cyl) + NR_HD=2; + else + NR_HD=1; +#endif + for (i=0 ; i are the primary drives in the system, and + the ones reflected as drive 1 or 2. + + The first drive is stored in the high nibble of CMOS + byte 0x12, the second in the low nibble. This will be + either a 4 bit drive type or 0xf indicating use byte 0x19 + for an 8 bit type, drive 1, 0x1a for drive 2 in CMOS. + + Needless to say, a non-zero value means we have + an AT controller hard disk for that drive. + + + */ + + if ((cmos_disks = CMOS_READ(0x12)) & 0xf0) + if (cmos_disks & 0x0f) + NR_HD = 2; + else + NR_HD = 1; + else + NR_HD = 0; + for (i = NR_HD ; i < 2 ; i++) { + hd[i*5].start_sect = 0; + hd[i*5].nr_sects = 0; + } + for (drive=0 ; driveb_data[510] != 0x55 || (unsigned char) + bh->b_data[511] != 0xAA) { + printk("Bad partition table on drive %d\n\r",drive); + panic(""); + } + p = 0x1BE + (void *)bh->b_data; + for (i=1;i<5;i++,p++) { + hd[i+5*drive].start_sect = p->start_sect; + hd[i+5*drive].nr_sects = p->nr_sects; + } + brelse(bh); + } + if (NR_HD) + printk("Partition table%s ok.\n\r",(NR_HD>1)?"s":""); + rd_load(); + mount_root(); + return (0); +} + +static int controller_ready(void) +{ + int retries=10000; + + while (--retries && (inb_p(HD_STATUS)&0xc0)!=0x40); + return (retries); +} + +static int win_result(void) +{ + int i=inb_p(HD_STATUS); + + if ((i & (BUSY_STAT | READY_STAT | WRERR_STAT | SEEK_STAT | ERR_STAT)) + == (READY_STAT | SEEK_STAT)) + return(0); /* ok */ + if (i&1) i=inb(HD_ERROR); + return (1); +} + +static void hd_out(unsigned int drive,unsigned int nsect,unsigned int sect, + unsigned int head,unsigned int cyl,unsigned int cmd, + void (*intr_addr)(void)) +{ + register int port asm("dx"); + + if (drive>1 || head>15) + panic("Trying to write bad sector"); + if (!controller_ready()) + panic("HD controller not ready"); + do_hd = intr_addr; + outb_p(hd_info[drive].ctl,HD_CMD); + port=HD_DATA; + outb_p(hd_info[drive].wpcom>>2,++port); + outb_p(nsect,++port); + outb_p(sect,++port); + outb_p(cyl,++port); + outb_p(cyl>>8,++port); + outb_p(0xA0|(drive<<4)|head,++port); + outb(cmd,++port); +} + +static int drive_busy(void) +{ + unsigned int i; + + for (i = 0; i < 10000; i++) + if (READY_STAT == (inb_p(HD_STATUS) & (BUSY_STAT|READY_STAT))) + break; + i = inb(HD_STATUS); + i &= BUSY_STAT | READY_STAT | SEEK_STAT; + if (i == (READY_STAT | SEEK_STAT)) + return(0); + printk("HD controller times out\n\r"); + return(1); +} + +static void reset_controller(void) +{ + int i; + + outb(4,HD_CMD); + for(i = 0; i < 100; i++) nop(); + outb(hd_info[0].ctl & 0x0f ,HD_CMD); + if (drive_busy()) + printk("HD-controller still busy\n\r"); + if ((i = inb(HD_ERROR)) != 1) + printk("HD-controller reset failed: %02x\n\r",i); +} + +static void reset_hd(int nr) +{ + reset_controller(); + hd_out(nr,hd_info[nr].sect,hd_info[nr].sect,hd_info[nr].head-1, + hd_info[nr].cyl,WIN_SPECIFY,&recal_intr); +} + +void unexpected_hd_interrupt(void) +{ + printk("Unexpected HD interrupt\n\r"); +} + +static void bad_rw_intr(void) +{ + if (++CURRENT->errors >= MAX_ERRORS) + end_request(0); + if (CURRENT->errors > MAX_ERRORS/2) + reset = 1; +} + +static void read_intr(void) +{ + if (win_result()) { + bad_rw_intr(); + do_hd_request(); + return; + } + port_read(HD_DATA,CURRENT->buffer,256); + CURRENT->errors = 0; + CURRENT->buffer += 512; + CURRENT->sector++; + if (--CURRENT->nr_sectors) { + do_hd = &read_intr; + return; + } + end_request(1); + do_hd_request(); +} + +static void write_intr(void) +{ + if (win_result()) { + bad_rw_intr(); + do_hd_request(); + return; + } + if (--CURRENT->nr_sectors) { + CURRENT->sector++; + CURRENT->buffer += 512; + do_hd = &write_intr; + port_write(HD_DATA,CURRENT->buffer,256); + return; + } + end_request(1); + do_hd_request(); +} + +static void recal_intr(void) +{ + if (win_result()) + bad_rw_intr(); + do_hd_request(); +} + +void do_hd_request(void) +{ + int i,r = 0; + unsigned int block,dev; + unsigned int sec,head,cyl; + unsigned int nsect; + + INIT_REQUEST; + dev = MINOR(CURRENT->dev); + block = CURRENT->sector; + if (dev >= 5*NR_HD || block+2 > hd[dev].nr_sects) { + end_request(0); + goto repeat; + } + block += hd[dev].start_sect; + dev /= 5; + __asm__("divl %4":"=a" (block),"=d" (sec):"0" (block),"1" (0), + "r" (hd_info[dev].sect)); + __asm__("divl %4":"=a" (cyl),"=d" (head):"0" (block),"1" (0), + "r" (hd_info[dev].head)); + sec++; + nsect = CURRENT->nr_sectors; + if (reset) { + reset = 0; + recalibrate = 1; + reset_hd(CURRENT_DEV); + return; + } + if (recalibrate) { + recalibrate = 0; + hd_out(dev,hd_info[CURRENT_DEV].sect,0,0,0, + WIN_RESTORE,&recal_intr); + return; + } + if (CURRENT->cmd == WRITE) { + hd_out(dev,nsect,sec,head,cyl,WIN_WRITE,&write_intr); + for(i=0 ; i<3000 && !(r=inb_p(HD_STATUS)&DRQ_STAT) ; i++) + /* nothing */ ; + if (!r) { + bad_rw_intr(); + goto repeat; + } + port_write(HD_DATA,CURRENT->buffer,256); + } else if (CURRENT->cmd == READ) { + hd_out(dev,nsect,sec,head,cyl,WIN_READ,&read_intr); + } else + panic("unknown hd-command"); +} + +void hd_init(void) +{ + blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST; + set_intr_gate(0x2E,&hd_interrupt); + outb_p(inb_p(0x21)&0xfb,0x21); + outb(inb_p(0xA1)&0xbf,0xA1); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/hd.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/hd.o new file mode 100644 index 0000000..3e6a1b0 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/hd.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/ll_rw_blk.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/ll_rw_blk.c new file mode 100644 index 0000000..8931a81 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/ll_rw_blk.c @@ -0,0 +1,165 @@ +/* + * linux/kernel/blk_dev/ll_rw.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * This handles all read/write requests to block devices + */ +#include +#include +#include +#include + +#include "blk.h" + +/* + * The request-struct contains all necessary data + * to load a nr of sectors into memory + */ +struct request request[NR_REQUEST]; + +/* + * used to wait on when there are no free requests + */ +struct task_struct * wait_for_request = NULL; + +/* blk_dev_struct is: + * do_request-address + * next-request + */ +struct blk_dev_struct blk_dev[NR_BLK_DEV] = { + { NULL, NULL }, /* no_dev */ + { NULL, NULL }, /* dev mem */ + { NULL, NULL }, /* dev fd */ + { NULL, NULL }, /* dev hd */ + { NULL, NULL }, /* dev ttyx */ + { NULL, NULL }, /* dev tty */ + { NULL, NULL } /* dev lp */ +}; + +static inline void lock_buffer(struct buffer_head * bh) +{ + cli(); + while (bh->b_lock) + sleep_on(&bh->b_wait); + bh->b_lock=1; + sti(); +} + +static inline void unlock_buffer(struct buffer_head * bh) +{ + if (!bh->b_lock) + printk("ll_rw_block.c: buffer not locked\n\r"); + bh->b_lock = 0; + wake_up(&bh->b_wait); +} + +/* + * add-request adds a request to the linked list. + * It disables interrupts so that it can muck with the + * request-lists in peace. + */ +static void add_request(struct blk_dev_struct * dev, struct request * req) +{ + struct request * tmp; + + req->next = NULL; + cli(); + if (req->bh) + req->bh->b_dirt = 0; + if (!(tmp = dev->current_request)) { + dev->current_request = req; + sti(); + (dev->request_fn)(); + return; + } + for ( ; tmp->next ; tmp=tmp->next) + if ((IN_ORDER(tmp,req) || + !IN_ORDER(tmp,tmp->next)) && + IN_ORDER(req,tmp->next)) + break; + req->next=tmp->next; + tmp->next=req; + sti(); +} + +static void make_request(int major,int rw, struct buffer_head * bh) +{ + struct request * req; + int rw_ahead; + +/* WRITEA/READA is special case - it is not really needed, so if the */ +/* buffer is locked, we just forget about it, else it's a normal read */ + if ((rw_ahead = (rw == READA || rw == WRITEA))) { + if (bh->b_lock) + return; + if (rw == READA) + rw = READ; + else + rw = WRITE; + } + if (rw!=READ && rw!=WRITE) + panic("Bad block dev command, must be R/W/RA/WA"); + lock_buffer(bh); + if ((rw == WRITE && !bh->b_dirt) || (rw == READ && bh->b_uptodate)) { + unlock_buffer(bh); + return; + } +repeat: +/* we don't allow the write-requests to fill up the queue completely: + * we want some room for reads: they take precedence. The last third + * of the requests are only for reads. + */ + if (rw == READ) + req = request+NR_REQUEST; + else + req = request+((NR_REQUEST*2)/3); +/* find an empty request */ + while (--req >= request) + if (req->dev<0) + break; +/* if none found, sleep on new requests: check for rw_ahead */ + if (req < request) { + if (rw_ahead) { + unlock_buffer(bh); + return; + } + sleep_on(&wait_for_request); + goto repeat; + } +/* fill up the request-info, and add it to the queue */ + req->dev = bh->b_dev; + req->cmd = rw; + req->errors=0; + req->sector = bh->b_blocknr<<1; + req->nr_sectors = 2; + req->buffer = bh->b_data; + req->waiting = NULL; + req->bh = bh; + req->next = NULL; + add_request(major+blk_dev,req); +} + +void ll_rw_block(int rw, struct buffer_head * bh) +{ + unsigned int major; + + if ((major=MAJOR(bh->b_dev)) >= NR_BLK_DEV || + !(blk_dev[major].request_fn)) { + printk("Trying to read nonexistent block-device\n\r"); + return; + } + make_request(major,rw,bh); +} + +void blk_dev_init(void) +{ + int i; + + for (i=0 ; i + +#include +#include +#include +#include +#include +#include +#include + +#define MAJOR_NR 1 +#include "blk.h" + +char *rd_start; +int rd_length = 0; + +void do_rd_request(void) +{ + int len; + char *addr; + + INIT_REQUEST; + addr = rd_start + (CURRENT->sector << 9); + len = CURRENT->nr_sectors << 9; + if ((MINOR(CURRENT->dev) != 1) || (addr+len > rd_start+rd_length)) { + end_request(0); + goto repeat; + } + if (CURRENT-> cmd == WRITE) { + (void ) memcpy(addr, + CURRENT->buffer, + len); + } else if (CURRENT->cmd == READ) { + (void) memcpy(CURRENT->buffer, + addr, + len); + } else + panic("unknown ramdisk-command"); + end_request(1); + goto repeat; +} + +/* + * Returns amount of memory which needs to be reserved. + */ +long rd_init(long mem_start, int length) +{ + int i; + char *cp; + + blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST; + rd_start = (char *) mem_start; + rd_length = length; + cp = rd_start; + for (i=0; i < length; i++) + *cp++ = '\0'; + return(length); +} + +/* + * If the root device is the ram disk, try to load it. + * In order to do this, the root device is originally set to the + * floppy, and we later change it to be ram disk. + */ +void rd_load(void) +{ + struct buffer_head *bh; + struct super_block s; + int block = 256; /* Start at block 256 */ + int i = 1; + int nblocks; + char *cp; /* Move pointer */ + + if (!rd_length) + return; + printk("Ram disk: %d bytes, starting at 0x%x\n", rd_length, + (int) rd_start); + if (MAJOR(ROOT_DEV) != 2) + return; + bh = breada(ROOT_DEV,block+1,block,block+2,-1); + if (!bh) { + printk("Disk error while looking for ramdisk!\n"); + return; + } + *((struct d_super_block *) &s) = *((struct d_super_block *) bh->b_data); + brelse(bh); + if (s.s_magic != SUPER_MAGIC) + /* No ram disk image present, assume normal floppy boot */ + return; + nblocks = s.s_nzones << s.s_log_zone_size; + if (nblocks > (rd_length >> BLOCK_SIZE_BITS)) { + printk("Ram disk image too big! (%d blocks, %d avail)\n", + nblocks, rd_length >> BLOCK_SIZE_BITS); + return; + } + printk("Loading %d bytes into ram disk... 0000k", + nblocks << BLOCK_SIZE_BITS); + cp = rd_start; + while (nblocks) { + if (nblocks > 2) + bh = breada(ROOT_DEV, block, block+1, block+2, -1); + else + bh = bread(ROOT_DEV, block); + if (!bh) { + printk("I/O error on block %d, aborting load\n", + block); + return; + } + (void) memcpy(cp, bh->b_data, BLOCK_SIZE); + brelse(bh); + printk("\010\010\010\010\010%4dk",i); + cp += BLOCK_SIZE; + block++; + nblocks--; + i++; + } + printk("\010\010\010\010\010done \n"); + ROOT_DEV=0x0101; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/ramdisk.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/ramdisk.o new file mode 100644 index 0000000..c52b9f6 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/blk_drv/ramdisk.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/Makefile new file mode 100644 index 0000000..76d9cdd --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/Makefile @@ -0,0 +1,71 @@ +# +# Makefile for the FREAX-kernel character device drivers. +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (ie not a .c file). +# + +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =gcc -mcpu=i386 +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions -nostdinc -I../../include +CPP =gcc -E -nostdinc -I../../include + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(AS) -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = tty_io.o console.o keyboard.o serial.o rs_io.o \ + tty_ioctl.o + +chr_drv.a: $(OBJS) + $(AR) rcs chr_drv.a $(OBJS) + sync + +keyboard.s: keyboard.S ../../include/linux/config.h + $(CPP) -traditional keyboard.S -o keyboard.s + +clean: + rm -f core *.o *.a tmp_make keyboard.s + for i in *.c;do rm -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: +console.s console.o: console.c ../../include/linux/sched.h \ + ../../include/linux/head.h ../../include/linux/fs.h \ + ../../include/sys/types.h ../../include/linux/mm.h \ + ../../include/signal.h ../../include/linux/tty.h \ + ../../include/termios.h ../../include/asm/io.h \ + ../../include/asm/system.h +serial.s serial.o: serial.c ../../include/linux/tty.h ../../include/termios.h \ + ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/sys/types.h \ + ../../include/linux/mm.h ../../include/signal.h \ + ../../include/asm/system.h ../../include/asm/io.h +tty_io.s tty_io.o: tty_io.c ../../include/ctype.h ../../include/errno.h \ + ../../include/signal.h ../../include/sys/types.h \ + ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/linux/mm.h \ + ../../include/linux/tty.h ../../include/termios.h \ + ../../include/asm/segment.h ../../include/asm/system.h +tty_ioctl.s tty_ioctl.o: tty_ioctl.c ../../include/errno.h ../../include/termios.h \ + ../../include/linux/sched.h ../../include/linux/head.h \ + ../../include/linux/fs.h ../../include/sys/types.h \ + ../../include/linux/mm.h ../../include/signal.h \ + ../../include/linux/kernel.h ../../include/linux/tty.h \ + ../../include/asm/io.h ../../include/asm/segment.h \ + ../../include/asm/system.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/chr_drv.a b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/chr_drv.a new file mode 100644 index 0000000..0b17ac2 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/chr_drv.a differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/console.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/console.c new file mode 100644 index 0000000..3f76f61 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/console.c @@ -0,0 +1,710 @@ +/* + * linux/kernel/console.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * console.c + * + * This module implements the console io functions + * 'void con_init(void)' + * 'void con_write(struct tty_queue * queue)' + * Hopefully this will be a rather complete VT102 implementation. + * + * Beeping thanks to John T Kohl. + */ + +/* + * NOTE!!! We sometimes disable and enable interrupts for a short while + * (to put a word in video IO), but this will work even for keyboard + * interrupts. We know interrupts aren't enabled when getting a keyboard + * interrupt, as we use trap-gates. Hopefully all is well. + */ + +/* + * Code to check for different video-cards mostly by Galen Hunt, + * + */ + +#include +#include +#include +#include + +/* + * These are set up by the setup-routine at boot-time: + */ + +#define ORIG_X (*(unsigned char *)0x90000) +#define ORIG_Y (*(unsigned char *)0x90001) +#define ORIG_VIDEO_PAGE (*(unsigned short *)0x90004) +#define ORIG_VIDEO_MODE ((*(unsigned short *)0x90006) & 0xff) +#define ORIG_VIDEO_COLS (((*(unsigned short *)0x90006) & 0xff00) >> 8) +#define ORIG_VIDEO_LINES (25) +#define ORIG_VIDEO_EGA_AX (*(unsigned short *)0x90008) +#define ORIG_VIDEO_EGA_BX (*(unsigned short *)0x9000a) +#define ORIG_VIDEO_EGA_CX (*(unsigned short *)0x9000c) + +#define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */ +#define VIDEO_TYPE_CGA 0x11 /* CGA Display */ +#define VIDEO_TYPE_EGAM 0x20 /* EGA/VGA in Monochrome Mode */ +#define VIDEO_TYPE_EGAC 0x21 /* EGA/VGA in Color Mode */ + +#define NPAR 16 + +extern void keyboard_interrupt(void); + +static unsigned char video_type; /* Type of display being used */ +static unsigned long video_num_columns; /* Number of text columns */ +static unsigned long video_size_row; /* Bytes per row */ +static unsigned long video_num_lines; /* Number of test lines */ +static unsigned char video_page; /* Initial video page */ +static unsigned long video_mem_start; /* Start of video RAM */ +static unsigned long video_mem_end; /* End of video RAM (sort of) */ +static unsigned short video_port_reg; /* Video register select port */ +static unsigned short video_port_val; /* Video register value port */ +static unsigned short video_erase_char; /* Char+Attrib to erase with */ + +static unsigned long origin; /* Used for EGA/VGA fast scroll */ +static unsigned long scr_end; /* Used for EGA/VGA fast scroll */ +static unsigned long pos; +static unsigned long x,y; +static unsigned long top,bottom; +static unsigned long state=0; +static unsigned long npar,par[NPAR]; +static unsigned long ques=0; +static unsigned char attr=0x07; + +static void sysbeep(void); + +/* + * this is what the terminal answers to a ESC-Z or csi0c + * query (= vt100 response). + */ +#define RESPONSE "\033[?1;2c" + +/* NOTE! gotoxy thinks x==video_num_columns is ok */ +static inline void gotoxy(unsigned int new_x,unsigned int new_y) +{ + if (new_x > video_num_columns || new_y >= video_num_lines) + return; + x=new_x; + y=new_y; + pos=origin + y*video_size_row + (x<<1); +} + +static inline void set_origin(void) +{ + cli(); + outb_p(12, video_port_reg); + outb_p(0xff&((origin-video_mem_start)>>9), video_port_val); + outb_p(13, video_port_reg); + outb_p(0xff&((origin-video_mem_start)>>1), video_port_val); + sti(); +} + +static void scrup(void) +{ + if (video_type == VIDEO_TYPE_EGAC || video_type == VIDEO_TYPE_EGAM) + { + if (!top && bottom == video_num_lines) { + origin += video_size_row; + pos += video_size_row; + scr_end += video_size_row; + if (scr_end > video_mem_end) { + __asm__("cld\n\t" + "rep\n\t" + "movsl\n\t" + "movl _video_num_columns,%1\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((video_num_lines-1)*video_num_columns>>1), + "D" (video_mem_start), + "S" (origin) + ); + scr_end -= origin-video_mem_start; + pos -= origin-video_mem_start; + origin = video_mem_start; + } else { + __asm__("cld\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" (video_num_columns), + "D" (scr_end-video_size_row) + ); + } + set_origin(); + } else { + __asm__("cld\n\t" + "rep\n\t" + "movsl\n\t" + "movl _video_num_columns,%%ecx\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((bottom-top-1)*video_num_columns>>1), + "D" (origin+video_size_row*top), + "S" (origin+video_size_row*(top+1)) + ); + } + } + else /* Not EGA/VGA */ + { + __asm__("cld\n\t" + "rep\n\t" + "movsl\n\t" + "movl _video_num_columns,%%ecx\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((bottom-top-1)*video_num_columns>>1), + "D" (origin+video_size_row*top), + "S" (origin+video_size_row*(top+1)) + ); + } +} + +static void scrdown(void) +{ + if (video_type == VIDEO_TYPE_EGAC || video_type == VIDEO_TYPE_EGAM) + { + __asm__("std\n\t" + "rep\n\t" + "movsl\n\t" + "addl $2,%%edi\n\t" /* %edi has been decremented by 4 */ + "movl _video_num_columns,%%ecx\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((bottom-top-1)*video_num_columns>>1), + "D" (origin+video_size_row*bottom-4), + "S" (origin+video_size_row*(bottom-1)-4) + ); + } + else /* Not EGA/VGA */ + { + __asm__("std\n\t" + "rep\n\t" + "movsl\n\t" + "addl $2,%%edi\n\t" /* %edi has been decremented by 4 */ + "movl _video_num_columns,%%ecx\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((bottom-top-1)*video_num_columns>>1), + "D" (origin+video_size_row*bottom-4), + "S" (origin+video_size_row*(bottom-1)-4) + ); + } +} + +static void lf(void) +{ + if (y+1top) { + y--; + pos -= video_size_row; + return; + } + scrdown(); +} + +static void cr(void) +{ + pos -= x<<1; + x=0; +} + +static void del(void) +{ + if (x) { + pos -= 2; + x--; + *(unsigned short *)pos = video_erase_char; + } +} + +static void csi_J(int par) +{ + long count; + long start; + + switch (par) { + case 0: /* erase from cursor to end of display */ + count = (scr_end-pos)>>1; + start = pos; + break; + case 1: /* erase from start to cursor */ + count = (pos-origin)>>1; + start = origin; + break; + case 2: /* erase whole display */ + count = video_num_columns * video_num_lines; + start = origin; + break; + default: + return; + } + __asm__("cld\n\t" + "rep\n\t" + "stosw\n\t" + ::"c" (count), + "D" (start),"a" (video_erase_char) + ); +} + +static void csi_K(int par) +{ + long count; + long start; + + switch (par) { + case 0: /* erase from cursor to end of line */ + if (x>=video_num_columns) + return; + count = video_num_columns-x; + start = pos; + break; + case 1: /* erase from start of line to cursor */ + start = pos - (x<<1); + count = (x>9), video_port_val); + outb_p(15, video_port_reg); + outb_p(0xff&((pos-video_mem_start)>>1), video_port_val); + sti(); +} + +static void respond(struct tty_struct * tty) +{ + char * p = RESPONSE; + + cli(); + while (*p) { + PUTCH(*p,tty->read_q); + p++; + } + sti(); + copy_to_cooked(tty); +} + +static void insert_char(void) +{ + int i=x; + unsigned short tmp, old = video_erase_char; + unsigned short * p = (unsigned short *) pos; + + while (i++=video_num_columns) + return; + i = x; + while (++i < video_num_columns) { + *p = *(p+1); + p++; + } + *p = video_erase_char; +} + +static void delete_line(void) +{ + int oldtop,oldbottom; + + oldtop=top; + oldbottom=bottom; + top=y; + bottom = video_num_lines; + scrup(); + top=oldtop; + bottom=oldbottom; +} + +static void csi_at(unsigned int nr) +{ + if (nr > video_num_columns) + nr = video_num_columns; + else if (!nr) + nr = 1; + while (nr--) + insert_char(); +} + +static void csi_L(unsigned int nr) +{ + if (nr > video_num_lines) + nr = video_num_lines; + else if (!nr) + nr = 1; + while (nr--) + insert_line(); +} + +static void csi_P(unsigned int nr) +{ + if (nr > video_num_columns) + nr = video_num_columns; + else if (!nr) + nr = 1; + while (nr--) + delete_char(); +} + +static void csi_M(unsigned int nr) +{ + if (nr > video_num_lines) + nr = video_num_lines; + else if (!nr) + nr=1; + while (nr--) + delete_line(); +} + +static int saved_x=0; +static int saved_y=0; + +static void save_cur(void) +{ + saved_x=x; + saved_y=y; +} + +static void restore_cur(void) +{ + gotoxy(saved_x, saved_y); +} + +void con_write(struct tty_struct * tty) +{ + int nr; + char c; + + nr = CHARS(tty->write_q); + while (nr--) { + GETCH(tty->write_q,c); + switch(state) { + case 0: + if (c>31 && c<127) { + if (x>=video_num_columns) { + x -= video_num_columns; + pos -= video_size_row; + lf(); + } + __asm__("movb _attr,%%ah\n\t" + "movw %%ax,%1\n\t" + ::"a" (c),"m" (*(short *)pos) + ); + pos += 2; + x++; + } else if (c==27) + state=1; + else if (c==10 || c==11 || c==12) + lf(); + else if (c==13) + cr(); + else if (c==ERASE_CHAR(tty)) + del(); + else if (c==8) { + if (x) { + x--; + pos -= 2; + } + } else if (c==9) { + c=8-(x&7); + x += c; + pos += c<<1; + if (x>video_num_columns) { + x -= video_num_columns; + pos -= video_size_row; + lf(); + } + c=9; + } else if (c==7) + sysbeep(); + break; + case 1: + state=0; + if (c=='[') + state=2; + else if (c=='E') + gotoxy(0,y+1); + else if (c=='M') + ri(); + else if (c=='D') + lf(); + else if (c=='Z') + respond(tty); + else if (x=='7') + save_cur(); + else if (x=='8') + restore_cur(); + break; + case 2: + for(npar=0;npar='0' && c<='9') { + par[npar]=10*par[npar]+c-'0'; + break; + } else state=4; + case 4: + state=0; + switch(c) { + case 'G': case '`': + if (par[0]) par[0]--; + gotoxy(par[0],y); + break; + case 'A': + if (!par[0]) par[0]++; + gotoxy(x,y-par[0]); + break; + case 'B': case 'e': + if (!par[0]) par[0]++; + gotoxy(x,y+par[0]); + break; + case 'C': case 'a': + if (!par[0]) par[0]++; + gotoxy(x+par[0],y); + break; + case 'D': + if (!par[0]) par[0]++; + gotoxy(x-par[0],y); + break; + case 'E': + if (!par[0]) par[0]++; + gotoxy(0,y+par[0]); + break; + case 'F': + if (!par[0]) par[0]++; + gotoxy(0,y-par[0]); + break; + case 'd': + if (par[0]) par[0]--; + gotoxy(x,par[0]); + break; + case 'H': case 'f': + if (par[0]) par[0]--; + if (par[1]) par[1]--; + gotoxy(par[1],par[0]); + break; + case 'J': + csi_J(par[0]); + break; + case 'K': + csi_K(par[0]); + break; + case 'L': + csi_L(par[0]); + break; + case 'M': + csi_M(par[0]); + break; + case 'P': + csi_P(par[0]); + break; + case '@': + csi_at(par[0]); + break; + case 'm': + csi_m(); + break; + case 'r': + if (par[0]) par[0]--; + if (!par[1]) par[1] = video_num_lines; + if (par[0] < par[1] && + par[1] <= video_num_lines) { + top=par[0]; + bottom=par[1]; + } + break; + case 's': + save_cur(); + break; + case 'u': + restore_cur(); + break; + } + } + } + set_cursor(); +} + +/* + * void con_init(void); + * + * This routine initalizes console interrupts, and does nothing + * else. If you want the screen to clear, call tty_write with + * the appropriate escape-sequece. + * + * Reads the information preserved by setup.s to determine the current display + * type and sets everything accordingly. + */ +void con_init(void) +{ + register unsigned char a; + char *display_desc = "????"; + char *display_ptr; + + video_num_columns = ORIG_VIDEO_COLS; + video_size_row = video_num_columns * 2; + video_num_lines = ORIG_VIDEO_LINES; + video_page = ORIG_VIDEO_PAGE; + video_erase_char = 0x0720; + + if (ORIG_VIDEO_MODE == 7) /* Is this a monochrome display? */ + { + video_mem_start = 0xb0000; + video_port_reg = 0x3b4; + video_port_val = 0x3b5; + if ((ORIG_VIDEO_EGA_BX & 0xff) != 0x10) + { + video_type = VIDEO_TYPE_EGAM; + video_mem_end = 0xb8000; + display_desc = "EGAm"; + } + else + { + video_type = VIDEO_TYPE_MDA; + video_mem_end = 0xb2000; + display_desc = "*MDA"; + } + } + else /* If not, it is color. */ + { + video_mem_start = 0xb8000; + video_port_reg = 0x3d4; + video_port_val = 0x3d5; + if ((ORIG_VIDEO_EGA_BX & 0xff) != 0x10) + { + video_type = VIDEO_TYPE_EGAC; + video_mem_end = 0xbc000; + display_desc = "EGAc"; + } + else + { + video_type = VIDEO_TYPE_CGA; + video_mem_end = 0xba000; + display_desc = "*CGA"; + } + } + + /* Let the user known what kind of display driver we are using */ + + display_ptr = ((char *)video_mem_start) + video_size_row - 8; + while (*display_desc) + { + *display_ptr++ = *display_desc++; + display_ptr++; + } + + /* Initialize the variables used for scrolling (mostly EGA/VGA) */ + + origin = video_mem_start; + scr_end = video_mem_start + video_num_lines * video_size_row; + top = 0; + bottom = video_num_lines; + + gotoxy(ORIG_X,ORIG_Y); + set_trap_gate(0x21,&keyboard_interrupt); + outb_p(inb_p(0x21)&0xfd,0x21); + a=inb_p(0x61); + outb_p(a|0x80,0x61); + outb(a,0x61); +} +/* from bsd-net-2: */ + +void sysbeepstop(void) +{ + /* disable counter 2 */ + outb(inb_p(0x61)&0xFC, 0x61); +} + +int beepcount = 0; + +static void sysbeep(void) +{ + /* enable counter 2 */ + outb_p(inb_p(0x61)|3, 0x61); + /* set command for counter 2, 2 byte write */ + outb_p(0xB6, 0x43); + /* send 0x637 for 750 HZ */ + outb_p(0x37, 0x42); + outb(0x06, 0x42); + /* 1/8 second */ + beepcount = HZ/8; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/console.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/console.o new file mode 100644 index 0000000..ac777f3 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/console.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/keyboard.S b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/keyboard.S new file mode 100644 index 0000000..91f327b --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/keyboard.S @@ -0,0 +1,433 @@ +/* + * linux/kernel/keyboard.S + * + * (C) 1991 Linus Torvalds + */ + +/* + * Thanks to Alfred Leung for US keyboard patches + * Wolfgang Thiel for German keyboard patches + * Marc Corsini for the French keyboard + */ + +#include + +.text +.globl _keyboard_interrupt + +/* + * these are for the keyboard read functions + */ +size = 1024 /* must be a power of two ! And MUST be the same + as in tty_io.c !!!! */ +head = 4 +tail = 8 +proc_list = 12 +buf = 16 + +mode: .byte 0 /* caps, alt, ctrl and shift mode */ +leds: .byte 2 /* num-lock, caps, scroll-lock mode (nom-lock on) */ +e0: .byte 0 + +/* + * con_int is the real interrupt routine that reads the + * keyboard scan-code and converts it into the appropriate + * ascii character(s). + */ +_keyboard_interrupt: + pushl %eax + pushl %ebx + pushl %ecx + pushl %edx + push %ds + push %es + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + xor %al,%al /* %eax is scan code */ + inb $0x60,%al + cmpb $0xe0,%al + je set_e0 + cmpb $0xe1,%al + je set_e1 + call key_table(,%eax,4) + movb $0,e0 +e0_e1: inb $0x61,%al + jmp 1f +1: jmp 1f +1: orb $0x80,%al + jmp 1f +1: jmp 1f +1: outb %al,$0x61 + jmp 1f +1: jmp 1f +1: andb $0x7F,%al + outb %al,$0x61 + movb $0x20,%al + outb %al,$0x20 + pushl $0 + call _do_tty_interrupt + addl $4,%esp + pop %es + pop %ds + popl %edx + popl %ecx + popl %ebx + popl %eax + iret +set_e0: movb $1,e0 + jmp e0_e1 +set_e1: movb $2,e0 + jmp e0_e1 + +/* + * This routine fills the buffer with max 8 bytes, taken from + * %ebx:%eax. (%edx is high). The bytes are written in the + * order %al,%ah,%eal,%eah,%bl,%bh ... until %eax is zero. + */ +put_queue: + pushl %ecx + pushl %edx + movl _table_list,%edx # read-queue for console + movl head(%edx),%ecx +1: movb %al,buf(%edx,%ecx) + incl %ecx + andl $size-1,%ecx + cmpl tail(%edx),%ecx # buffer full - discard everything + je 3f + shrdl $8,%ebx,%eax + je 2f + shrl $8,%ebx + jmp 1b +2: movl %ecx,head(%edx) + movl proc_list(%edx),%ecx + testl %ecx,%ecx + je 3f + movl $0,(%ecx) +3: popl %edx + popl %ecx + ret + +ctrl: movb $0x04,%al + jmp 1f +alt: movb $0x10,%al +1: cmpb $0,e0 + je 2f + addb %al,%al +2: orb %al,mode + ret +unctrl: movb $0x04,%al + jmp 1f +unalt: movb $0x10,%al +1: cmpb $0,e0 + je 2f + addb %al,%al +2: notb %al + andb %al,mode + ret + +lshift: + orb $0x01,mode + ret +unlshift: + andb $0xfe,mode + ret +rshift: + orb $0x02,mode + ret +unrshift: + andb $0xfd,mode + ret + +caps: testb $0x80,mode + jne 1f + xorb $4,leds + xorb $0x40,mode + orb $0x80,mode +set_leds: + call kb_wait + movb $0xed,%al /* set leds command */ + outb %al,$0x60 + call kb_wait + movb leds,%al + outb %al,$0x60 + ret +uncaps: andb $0x7f,mode + ret +scroll: + xorb $1,leds + jmp set_leds +num: xorb $2,leds + jmp set_leds + +/* + * curosr-key/numeric keypad cursor keys are handled here. + * checking for numeric keypad etc. + */ +cursor: + subb $0x47,%al + jb 1f + cmpb $12,%al + ja 1f + jne cur2 /* check for ctrl-alt-del */ + testb $0x0c,mode + je cur2 + testb $0x30,mode + jne reboot +cur2: cmpb $0x01,e0 /* e0 forces cursor movement */ + je cur + testb $0x02,leds /* not num-lock forces cursor */ + je cur + testb $0x03,mode /* shift forces cursor */ + jne cur + xorl %ebx,%ebx + movb num_table(%eax),%al + jmp put_queue +1: ret + +cur: movb cur_table(%eax),%al + cmpb $'9,%al + ja ok_cur + movb $'~,%ah +ok_cur: shll $16,%eax + movw $0x5b1b,%ax + xorl %ebx,%ebx + jmp put_queue + + +num_table: + .ascii "789 456 1230," +cur_table: + .ascii "HA5 DGC YB623" + +/* + * this routine handles function keys + */ +func: + pushl %eax + pushl %ecx + pushl %edx + call _show_stat + popl %edx + popl %ecx + popl %eax + subb $0x3B,%al + jb end_func + cmpb $9,%al + jbe ok_func + subb $18,%al + cmpb $10,%al + jb end_func + cmpb $11,%al + ja end_func +ok_func: + cmpl $4,%ecx /* check that there is enough room */ + jl end_func + movl func_table(,%eax,4),%eax + xorl %ebx,%ebx + jmp put_queue +end_func: + ret + +/* + * function keys send F1:'esc [ [ A' F2:'esc [ [ B' etc. + */ +func_table: + .long 0x415b5b1b,0x425b5b1b,0x435b5b1b,0x445b5b1b + .long 0x455b5b1b,0x465b5b1b,0x475b5b1b,0x485b5b1b + .long 0x495b5b1b,0x4a5b5b1b,0x4b5b5b1b,0x4c5b5b1b + + +#if defined(KBD_US) + +key_map: + .byte 0,27 + .ascii "1234567890-=" + .byte 127,9 + .ascii "qwertyuiop[]" + .byte 13,0 + .ascii "asdfghjkl;'" + .byte '`,0 + .ascii "\\zxcvbnm,./" + .byte 0,'*,0,32 /* 36-39 */ + .fill 16,1,0 /* 3A-49 */ + .byte '-,0,0,0,'+ /* 4A-4E */ + .byte 0,0,0,0,0,0,0 /* 4F-55 */ + .byte '< + .fill 10,1,0 + + +shift_map: + .byte 0,27 + .ascii "!@#$%^&*()_+" + .byte 127,9 + .ascii "QWERTYUIOP{}" + .byte 13,0 + .ascii "ASDFGHJKL:\"" + .byte '~,0 + .ascii "|ZXCVBNM<>?" + .byte 0,'*,0,32 /* 36-39 */ + .fill 16,1,0 /* 3A-49 */ + .byte '-,0,0,0,'+ /* 4A-4E */ + .byte 0,0,0,0,0,0,0 /* 4F-55 */ + .byte '> + .fill 10,1,0 + +alt_map: + .byte 0,0 + .ascii "\0@\0$\0\0{[]}\\\0" + .byte 0,0 + .byte 0,0,0,0,0,0,0,0,0,0,0 + .byte '~,13,0 + .byte 0,0,0,0,0,0,0,0,0,0,0 + .byte 0,0 + .byte 0,0,0,0,0,0,0,0,0,0,0 + .byte 0,0,0,0 /* 36-39 */ + .fill 16,1,0 /* 3A-49 */ + .byte 0,0,0,0,0 /* 4A-4E */ + .byte 0,0,0,0,0,0,0 /* 4F-55 */ + .byte '| + .fill 10,1,0 +#else +#error "KBD-type not defined" +#endif +/* + * do_self handles "normal" keys, ie keys that don't change meaning + * and which have just one character returns. + */ +do_self: + lea alt_map,%ebx + testb $0x20,mode /* alt-gr */ + jne 1f + lea shift_map,%ebx + testb $0x03,mode + jne 1f + lea key_map,%ebx +1: movb (%ebx,%eax),%al + orb %al,%al + je none + testb $0x4c,mode /* ctrl or caps */ + je 2f + cmpb $'a,%al + jb 2f + cmpb $'},%al + ja 2f + subb $32,%al +2: testb $0x0c,mode /* ctrl */ + je 3f + cmpb $64,%al + jb 3f + cmpb $64+32,%al + jae 3f + subb $64,%al +3: testb $0x10,mode /* left alt */ + je 4f + orb $0x80,%al +4: andl $0xff,%eax + xorl %ebx,%ebx + call put_queue +none: ret + +/* + * minus has a routine of it's own, as a 'E0h' before + * the scan code for minus means that the numeric keypad + * slash was pushed. + */ +minus: cmpb $1,e0 + jne do_self + movl $'/,%eax + xorl %ebx,%ebx + jmp put_queue + +/* + * This table decides which routine to call when a scan-code has been + * gotten. Most routines just call do_self, or none, depending if + * they are make or break. + */ +key_table: + .long none,do_self,do_self,do_self /* 00-03 s0 esc 1 2 */ + .long do_self,do_self,do_self,do_self /* 04-07 3 4 5 6 */ + .long do_self,do_self,do_self,do_self /* 08-0B 7 8 9 0 */ + .long do_self,do_self,do_self,do_self /* 0C-0F + ' bs tab */ + .long do_self,do_self,do_self,do_self /* 10-13 q w e r */ + .long do_self,do_self,do_self,do_self /* 14-17 t y u i */ + .long do_self,do_self,do_self,do_self /* 18-1B o p } ^ */ + .long do_self,ctrl,do_self,do_self /* 1C-1F enter ctrl a s */ + .long do_self,do_self,do_self,do_self /* 20-23 d f g h */ + .long do_self,do_self,do_self,do_self /* 24-27 j k l | */ + .long do_self,do_self,lshift,do_self /* 28-2B { para lshift , */ + .long do_self,do_self,do_self,do_self /* 2C-2F z x c v */ + .long do_self,do_self,do_self,do_self /* 30-33 b n m , */ + .long do_self,minus,rshift,do_self /* 34-37 . - rshift * */ + .long alt,do_self,caps,func /* 38-3B alt sp caps f1 */ + .long func,func,func,func /* 3C-3F f2 f3 f4 f5 */ + .long func,func,func,func /* 40-43 f6 f7 f8 f9 */ + .long func,num,scroll,cursor /* 44-47 f10 num scr home */ + .long cursor,cursor,do_self,cursor /* 48-4B up pgup - left */ + .long cursor,cursor,do_self,cursor /* 4C-4F n5 right + end */ + .long cursor,cursor,cursor,cursor /* 50-53 dn pgdn ins del */ + .long none,none,do_self,func /* 54-57 sysreq ? < f11 */ + .long func,none,none,none /* 58-5B f12 ? ? ? */ + .long none,none,none,none /* 5C-5F ? ? ? ? */ + .long none,none,none,none /* 60-63 ? ? ? ? */ + .long none,none,none,none /* 64-67 ? ? ? ? */ + .long none,none,none,none /* 68-6B ? ? ? ? */ + .long none,none,none,none /* 6C-6F ? ? ? ? */ + .long none,none,none,none /* 70-73 ? ? ? ? */ + .long none,none,none,none /* 74-77 ? ? ? ? */ + .long none,none,none,none /* 78-7B ? ? ? ? */ + .long none,none,none,none /* 7C-7F ? ? ? ? */ + .long none,none,none,none /* 80-83 ? br br br */ + .long none,none,none,none /* 84-87 br br br br */ + .long none,none,none,none /* 88-8B br br br br */ + .long none,none,none,none /* 8C-8F br br br br */ + .long none,none,none,none /* 90-93 br br br br */ + .long none,none,none,none /* 94-97 br br br br */ + .long none,none,none,none /* 98-9B br br br br */ + .long none,unctrl,none,none /* 9C-9F br unctrl br br */ + .long none,none,none,none /* A0-A3 br br br br */ + .long none,none,none,none /* A4-A7 br br br br */ + .long none,none,unlshift,none /* A8-AB br br unlshift br */ + .long none,none,none,none /* AC-AF br br br br */ + .long none,none,none,none /* B0-B3 br br br br */ + .long none,none,unrshift,none /* B4-B7 br br unrshift br */ + .long unalt,none,uncaps,none /* B8-BB unalt br uncaps br */ + .long none,none,none,none /* BC-BF br br br br */ + .long none,none,none,none /* C0-C3 br br br br */ + .long none,none,none,none /* C4-C7 br br br br */ + .long none,none,none,none /* C8-CB br br br br */ + .long none,none,none,none /* CC-CF br br br br */ + .long none,none,none,none /* D0-D3 br br br br */ + .long none,none,none,none /* D4-D7 br br br br */ + .long none,none,none,none /* D8-DB br ? ? ? */ + .long none,none,none,none /* DC-DF ? ? ? ? */ + .long none,none,none,none /* E0-E3 e0 e1 ? ? */ + .long none,none,none,none /* E4-E7 ? ? ? ? */ + .long none,none,none,none /* E8-EB ? ? ? ? */ + .long none,none,none,none /* EC-EF ? ? ? ? */ + .long none,none,none,none /* F0-F3 ? ? ? ? */ + .long none,none,none,none /* F4-F7 ? ? ? ? */ + .long none,none,none,none /* F8-FB ? ? ? ? */ + .long none,none,none,none /* FC-FF ? ? ? ? */ + +/* + * kb_wait waits for the keyboard controller buffer to empty. + * there is no timeout - if the buffer doesn't empty, we hang. + */ +kb_wait: + pushl %eax +1: inb $0x64,%al + testb $0x02,%al + jne 1b + popl %eax + ret +/* + * This routine reboots the machine by asking the keyboard + * controller to pulse the reset-line low. + */ +reboot: + call kb_wait + movw $0x1234,0x472 /* don't do memory check */ + movb $0xfc,%al /* pulse reset and A20 low */ + outb %al,$0x64 +die: jmp die diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/keyboard.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/keyboard.o new file mode 100644 index 0000000..3d026bd Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/keyboard.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/rs_io.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/rs_io.o new file mode 100644 index 0000000..0c69e52 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/rs_io.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/rs_io.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/rs_io.s new file mode 100644 index 0000000..b300643 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/rs_io.s @@ -0,0 +1,147 @@ +/* + * linux/kernel/rs_io.s + * + * (C) 1991 Linus Torvalds + */ + +/* + * rs_io.s + * + * This module implements the rs232 io interrupts. + */ + +.text +.globl _rs1_interrupt,_rs2_interrupt + +size = 1024 /* must be power of two ! + and must match the value + in tty_io.c!!! */ + +/* these are the offsets into the read/write buffer structures */ +rs_addr = 0 +head = 4 +tail = 8 +proc_list = 12 +buf = 16 + +startup = 256 /* chars left in write queue when we restart it */ + +/* + * These are the actual interrupt routines. They look where + * the interrupt is coming from, and take appropriate action. + */ +.align 2 +_rs1_interrupt: + pushl $_table_list+8 + jmp rs_int +.align 2 +_rs2_interrupt: + pushl $_table_list+16 +rs_int: + pushl %edx + pushl %ecx + pushl %ebx + pushl %eax + push %es + push %ds /* as this is an interrupt, we cannot */ + pushl $0x10 /* know that bs is ok. Load it */ + pop %ds + pushl $0x10 + pop %es + movl 24(%esp),%edx + movl (%edx),%edx + movl rs_addr(%edx),%edx + addl $2,%edx /* interrupt ident. reg */ +rep_int: + xorl %eax,%eax + inb %dx,%al + testb $1,%al + jne end + cmpb $6,%al /* this shouldn't happen, but ... */ + ja end + movl 24(%esp),%ecx + pushl %edx + subl $2,%edx + call jmp_table(,%eax,2) /* NOTE! not *4, bit0 is 0 already */ + popl %edx + jmp rep_int +end: movb $0x20,%al + outb %al,$0x20 /* EOI */ + pop %ds + pop %es + popl %eax + popl %ebx + popl %ecx + popl %edx + addl $4,%esp # jump over _table_list entry + iret + +jmp_table: + .long modem_status,write_char,read_char,line_status + +.align 2 +modem_status: + addl $6,%edx /* clear intr by reading modem status reg */ + inb %dx,%al + ret + +.align 2 +line_status: + addl $5,%edx /* clear intr by reading line status reg. */ + inb %dx,%al + ret + +.align 2 +read_char: + inb %dx,%al + movl %ecx,%edx + subl $_table_list,%edx + shrl $3,%edx + movl (%ecx),%ecx # read-queue + movl head(%ecx),%ebx + movb %al,buf(%ecx,%ebx) + incl %ebx + andl $size-1,%ebx + cmpl tail(%ecx),%ebx + je 1f + movl %ebx,head(%ecx) +1: pushl %edx + call _do_tty_interrupt + addl $4,%esp + ret + +.align 2 +write_char: + movl 4(%ecx),%ecx # write-queue + movl head(%ecx),%ebx + subl tail(%ecx),%ebx + andl $size-1,%ebx # nr chars in queue + je write_buffer_empty + cmpl $startup,%ebx + ja 1f + movl proc_list(%ecx),%ebx # wake up sleeping process + testl %ebx,%ebx # is there any? + je 1f + movl $0,(%ebx) +1: movl tail(%ecx),%ebx + movb buf(%ecx,%ebx),%al + outb %al,%dx + incl %ebx + andl $size-1,%ebx + movl %ebx,tail(%ecx) + cmpl head(%ecx),%ebx + je write_buffer_empty + ret +.align 2 +write_buffer_empty: + movl proc_list(%ecx),%ebx # wake up sleeping process + testl %ebx,%ebx # is there any? + je 1f + movl $0,(%ebx) +1: incl %edx + inb %dx,%al + jmp 1f +1: jmp 1f +1: andb $0xd,%al /* disable transmit interrupt */ + outb %al,%dx + ret diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/serial.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/serial.c new file mode 100644 index 0000000..aba25df --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/serial.c @@ -0,0 +1,59 @@ +/* + * linux/kernel/serial.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * serial.c + * + * This module implements the rs232 io functions + * void rs_write(struct tty_struct * queue); + * void rs_init(void); + * and all interrupts pertaining to serial IO. + */ + +#include +#include +#include +#include + +#define WAKEUP_CHARS (TTY_BUF_SIZE/4) + +extern void rs1_interrupt(void); +extern void rs2_interrupt(void); + +static void init(int port) +{ + outb_p(0x80,port+3); /* set DLAB of line control reg */ + outb_p(0x30,port); /* LS of divisor (48 -> 2400 bps */ + outb_p(0x00,port+1); /* MS of divisor */ + outb_p(0x03,port+3); /* reset DLAB */ + outb_p(0x0b,port+4); /* set DTR,RTS, OUT_2 */ + outb_p(0x0d,port+1); /* enable all intrs but writes */ + (void)inb(port); /* read data port to reset things (?) */ +} + +void rs_init(void) +{ + set_intr_gate(0x24,rs1_interrupt); + set_intr_gate(0x23,rs2_interrupt); + init(tty_table[1].read_q.data); + init(tty_table[2].read_q.data); + outb(inb_p(0x21)&0xE7,0x21); +} + +/* + * This routine gets called when tty_write has put something into + * the write_queue. It must check wheter the queue is empty, and + * set the interrupt register accordingly + * + * void _rs_write(struct tty_struct * tty); + */ +void rs_write(struct tty_struct * tty) +{ + cli(); + if (!EMPTY(tty->write_q)) + outb(inb_p(tty->write_q.data+1)|0x02,tty->write_q.data+1); + sti(); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/serial.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/serial.o new file mode 100644 index 0000000..1aa897e Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/serial.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_io.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_io.c new file mode 100644 index 0000000..ed14fa8 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_io.c @@ -0,0 +1,350 @@ +/* + * linux/kernel/tty_io.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 'tty_io.c' gives an orthogonal feeling to tty's, be they consoles + * or rs-channels. It also implements echoing, cooked mode etc. + * + * Kill-line thanks to John T Kohl. + */ +#include +#include +#include + +#define ALRMMASK (1<<(SIGALRM-1)) +#define KILLMASK (1<<(SIGKILL-1)) +#define INTMASK (1<<(SIGINT-1)) +#define QUITMASK (1<<(SIGQUIT-1)) +#define TSTPMASK (1<<(SIGTSTP-1)) + +#include +#include +#include +#include + +#define _L_FLAG(tty,f) ((tty)->termios.c_lflag & f) +#define _I_FLAG(tty,f) ((tty)->termios.c_iflag & f) +#define _O_FLAG(tty,f) ((tty)->termios.c_oflag & f) + +#define L_CANON(tty) _L_FLAG((tty),ICANON) +#define L_ISIG(tty) _L_FLAG((tty),ISIG) +#define L_ECHO(tty) _L_FLAG((tty),ECHO) +#define L_ECHOE(tty) _L_FLAG((tty),ECHOE) +#define L_ECHOK(tty) _L_FLAG((tty),ECHOK) +#define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL) +#define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE) + +#define I_UCLC(tty) _I_FLAG((tty),IUCLC) +#define I_NLCR(tty) _I_FLAG((tty),INLCR) +#define I_CRNL(tty) _I_FLAG((tty),ICRNL) +#define I_NOCR(tty) _I_FLAG((tty),IGNCR) + +#define O_POST(tty) _O_FLAG((tty),OPOST) +#define O_NLCR(tty) _O_FLAG((tty),ONLCR) +#define O_CRNL(tty) _O_FLAG((tty),OCRNL) +#define O_NLRET(tty) _O_FLAG((tty),ONLRET) +#define O_LCUC(tty) _O_FLAG((tty),OLCUC) + +struct tty_struct tty_table[] = { + { + {ICRNL, /* change incoming CR to NL */ + OPOST|ONLCR, /* change outgoing NL to CRNL */ + 0, + ISIG | ICANON | ECHO | ECHOCTL | ECHOKE, + 0, /* console termio */ + INIT_C_CC}, + 0, /* initial pgrp */ + 0, /* initial stopped */ + con_write, + {0,0,0,0,""}, /* console read-queue */ + {0,0,0,0,""}, /* console write-queue */ + {0,0,0,0,""} /* console secondary queue */ + },{ + {0, /* no translation */ + 0, /* no translation */ + B2400 | CS8, + 0, + 0, + INIT_C_CC}, + 0, + 0, + rs_write, + {0x3f8,0,0,0,""}, /* rs 1 */ + {0x3f8,0,0,0,""}, + {0,0,0,0,""} + },{ + {0, /* no translation */ + 0, /* no translation */ + B2400 | CS8, + 0, + 0, + INIT_C_CC}, + 0, + 0, + rs_write, + {0x2f8,0,0,0,""}, /* rs 2 */ + {0x2f8,0,0,0,""}, + {0,0,0,0,""} + } +}; + +/* + * these are the tables used by the machine code handlers. + * you can implement pseudo-tty's or something by changing + * them. Currently not done. + */ +struct tty_queue * table_list[]={ + &tty_table[0].read_q, &tty_table[0].write_q, + &tty_table[1].read_q, &tty_table[1].write_q, + &tty_table[2].read_q, &tty_table[2].write_q + }; + +void tty_init(void) +{ + rs_init(); + con_init(); +} + +void tty_intr(struct tty_struct * tty, int mask) +{ + int i; + + if (tty->pgrp <= 0) + return; + for (i=0;ipgrp==tty->pgrp) + task[i]->signal |= mask; +} + +static void sleep_if_empty(struct tty_queue * queue) +{ + cli(); + while (!current->signal && EMPTY(*queue)) + interruptible_sleep_on(&queue->proc_list); + sti(); +} + +static void sleep_if_full(struct tty_queue * queue) +{ + if (!FULL(*queue)) + return; + cli(); + while (!current->signal && LEFT(*queue)<128) + interruptible_sleep_on(&queue->proc_list); + sti(); +} + +void wait_for_keypress(void) +{ + sleep_if_empty(&tty_table[0].secondary); +} + +void copy_to_cooked(struct tty_struct * tty) +{ + signed char c; + + while (!EMPTY(tty->read_q) && !FULL(tty->secondary)) { + GETCH(tty->read_q,c); + if (c==13) + if (I_CRNL(tty)) + c=10; + else if (I_NOCR(tty)) + continue; + else ; + else if (c==10 && I_NLCR(tty)) + c=13; + if (I_UCLC(tty)) + c=tolower(c); + if (L_CANON(tty)) { + if (c==KILL_CHAR(tty)) { + /* deal with killing the input line */ + while(!(EMPTY(tty->secondary) || + (c=LAST(tty->secondary))==10 || + c==EOF_CHAR(tty))) { + if (L_ECHO(tty)) { + if (c<32) + PUTCH(127,tty->write_q); + PUTCH(127,tty->write_q); + tty->write(tty); + } + DEC(tty->secondary.head); + } + continue; + } + if (c==ERASE_CHAR(tty)) { + if (EMPTY(tty->secondary) || + (c=LAST(tty->secondary))==10 || + c==EOF_CHAR(tty)) + continue; + if (L_ECHO(tty)) { + if (c<32) + PUTCH(127,tty->write_q); + PUTCH(127,tty->write_q); + tty->write(tty); + } + DEC(tty->secondary.head); + continue; + } + if (c==STOP_CHAR(tty)) { + tty->stopped=1; + continue; + } + if (c==START_CHAR(tty)) { + tty->stopped=0; + continue; + } + } + if (L_ISIG(tty)) { + if (c==INTR_CHAR(tty)) { + tty_intr(tty,INTMASK); + continue; + } + if (c==QUIT_CHAR(tty)) { + tty_intr(tty,QUITMASK); + continue; + } + } + if (c==10 || c==EOF_CHAR(tty)) + tty->secondary.data++; + if (L_ECHO(tty)) { + if (c==10) { + PUTCH(10,tty->write_q); + PUTCH(13,tty->write_q); + } else if (c<32) { + if (L_ECHOCTL(tty)) { + PUTCH('^',tty->write_q); + PUTCH(c+64,tty->write_q); + } + } else + PUTCH(c,tty->write_q); + tty->write(tty); + } + PUTCH(c,tty->secondary); + } + wake_up(&tty->secondary.proc_list); +} + +int tty_read(unsigned channel, char * buf, int nr) +{ + struct tty_struct * tty; + char c, * b=buf; + int minimum,time,flag=0; + long oldalarm; + + if (channel>2 || nr<0) return -1; + tty = &tty_table[channel]; + oldalarm = current->alarm; + time = 10L*tty->termios.c_cc[VTIME]; + minimum = tty->termios.c_cc[VMIN]; + if (time && !minimum) { + minimum=1; + if ((flag=(!oldalarm || time+jiffiesalarm = time+jiffies; + } + if (minimum>nr) + minimum=nr; + while (nr>0) { + if (flag && (current->signal & ALRMMASK)) { + current->signal &= ~ALRMMASK; + break; + } + if (current->signal) + break; + if (EMPTY(tty->secondary) || (L_CANON(tty) && + !tty->secondary.data && LEFT(tty->secondary)>20)) { + sleep_if_empty(&tty->secondary); + continue; + } + do { + GETCH(tty->secondary,c); + if (c==EOF_CHAR(tty) || c==10) + tty->secondary.data--; + if (c==EOF_CHAR(tty) && L_CANON(tty)) + return (b-buf); + else { + put_fs_byte(c,b++); + if (!--nr) + break; + } + } while (nr>0 && !EMPTY(tty->secondary)); + if (time && !L_CANON(tty)) { + if ((flag=(!oldalarm || time+jiffiesalarm = time+jiffies; + else + current->alarm = oldalarm; + } + if (L_CANON(tty)) { + if (b-buf) + break; + } else if (b-buf >= minimum) + break; + } + current->alarm = oldalarm; + if (current->signal && !(b-buf)) + return -EINTR; + return (b-buf); +} + +int tty_write(unsigned channel, char * buf, int nr) +{ + static int cr_flag=0; + struct tty_struct * tty; + char c, *b=buf; + + if (channel>2 || nr<0) return -1; + tty = channel + tty_table; + while (nr>0) { + sleep_if_full(&tty->write_q); + if (current->signal) + break; + while (nr>0 && !FULL(tty->write_q)) { + c=get_fs_byte(b); + if (O_POST(tty)) { + if (c=='\r' && O_CRNL(tty)) + c='\n'; + else if (c=='\n' && O_NLRET(tty)) + c='\r'; + if (c=='\n' && !cr_flag && O_NLCR(tty)) { + cr_flag = 1; + PUTCH(13,tty->write_q); + continue; + } + if (O_LCUC(tty)) + c=toupper(c); + } + b++; nr--; + cr_flag = 0; + PUTCH(c,tty->write_q); + } + tty->write(tty); + if (nr>0) + schedule(); + } + return (b-buf); +} + +/* + * Jeh, sometimes I really like the 386. + * This routine is called from an interrupt, + * and there should be absolutely no problem + * with sleeping even in an interrupt (I hope). + * Of course, if somebody proves me wrong, I'll + * hate intel for all time :-). We'll have to + * be careful and see to reinstating the interrupt + * chips before calling this, though. + * + * I don't think we sleep here under normal circumstances + * anyway, which is good, as the task sleeping might be + * totally innocent. + */ +void do_tty_interrupt(int tty) +{ + copy_to_cooked(tty_table+tty); +} + +void chr_dev_init(void) +{ +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_io.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_io.o new file mode 100644 index 0000000..ad5d075 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_io.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_ioctl.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_ioctl.c new file mode 100644 index 0000000..e4e3745 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_ioctl.c @@ -0,0 +1,204 @@ +/* + * linux/kernel/chr_drv/tty_ioctl.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include + +#include +#include +#include + +#include +#include +#include + +static unsigned short quotient[] = { + 0, 2304, 1536, 1047, 857, + 768, 576, 384, 192, 96, + 64, 48, 24, 12, 6, 3 +}; + +static void change_speed(struct tty_struct * tty) +{ + unsigned short port,quot; + + if (!(port = tty->read_q.data)) + return; + quot = quotient[tty->termios.c_cflag & CBAUD]; + cli(); + outb_p(0x80,port+3); /* set DLAB */ + outb_p(quot & 0xff,port); /* LS of divisor */ + outb_p(quot >> 8,port+1); /* MS of divisor */ + outb(0x03,port+3); /* reset DLAB */ + sti(); +} + +static void flush(struct tty_queue * queue) +{ + cli(); + queue->head = queue->tail; + sti(); +} + +static void wait_until_sent(struct tty_struct * tty) +{ + /* do nothing - not implemented */ +} + +static void send_break(struct tty_struct * tty) +{ + /* do nothing - not implemented */ +} + +static int get_termios(struct tty_struct * tty, struct termios * termios) +{ + int i; + + verify_area(termios, sizeof (*termios)); + for (i=0 ; i< (sizeof (*termios)) ; i++) + put_fs_byte( ((char *)&tty->termios)[i] , i+(char *)termios ); + return 0; +} + +static int set_termios(struct tty_struct * tty, struct termios * termios) +{ + int i; + + for (i=0 ; i< (sizeof (*termios)) ; i++) + ((char *)&tty->termios)[i]=get_fs_byte(i+(char *)termios); + change_speed(tty); + return 0; +} + +static int get_termio(struct tty_struct * tty, struct termio * termio) +{ + int i; + struct termio tmp_termio; + + verify_area(termio, sizeof (*termio)); + tmp_termio.c_iflag = tty->termios.c_iflag; + tmp_termio.c_oflag = tty->termios.c_oflag; + tmp_termio.c_cflag = tty->termios.c_cflag; + tmp_termio.c_lflag = tty->termios.c_lflag; + tmp_termio.c_line = tty->termios.c_line; + for(i=0 ; i < NCC ; i++) + tmp_termio.c_cc[i] = tty->termios.c_cc[i]; + for (i=0 ; i< (sizeof (*termio)) ; i++) + put_fs_byte( ((char *)&tmp_termio)[i] , i+(char *)termio ); + return 0; +} + +/* + * This only works as the 386 is low-byt-first + */ +static int set_termio(struct tty_struct * tty, struct termio * termio) +{ + int i; + struct termio tmp_termio; + + for (i=0 ; i< (sizeof (*termio)) ; i++) + ((char *)&tmp_termio)[i]=get_fs_byte(i+(char *)termio); + *(unsigned short *)&tty->termios.c_iflag = tmp_termio.c_iflag; + *(unsigned short *)&tty->termios.c_oflag = tmp_termio.c_oflag; + *(unsigned short *)&tty->termios.c_cflag = tmp_termio.c_cflag; + *(unsigned short *)&tty->termios.c_lflag = tmp_termio.c_lflag; + tty->termios.c_line = tmp_termio.c_line; + for(i=0 ; i < NCC ; i++) + tty->termios.c_cc[i] = tmp_termio.c_cc[i]; + change_speed(tty); + return 0; +} + +int tty_ioctl(int dev, int cmd, int arg) +{ + struct tty_struct * tty; + if (MAJOR(dev) == 5) { + dev=current->tty; + if (dev<0) + panic("tty_ioctl: dev<0"); + } else + dev=MINOR(dev); + tty = dev + tty_table; + switch (cmd) { + case TCGETS: + return get_termios(tty,(struct termios *) arg); + case TCSETSF: + flush(&tty->read_q); /* fallthrough */ + case TCSETSW: + wait_until_sent(tty); /* fallthrough */ + case TCSETS: + return set_termios(tty,(struct termios *) arg); + case TCGETA: + return get_termio(tty,(struct termio *) arg); + case TCSETAF: + flush(&tty->read_q); /* fallthrough */ + case TCSETAW: + wait_until_sent(tty); /* fallthrough */ + case TCSETA: + return set_termio(tty,(struct termio *) arg); + case TCSBRK: + if (!arg) { + wait_until_sent(tty); + send_break(tty); + } + return 0; + case TCXONC: + return -EINVAL; /* not implemented */ + case TCFLSH: + if (arg==0) + flush(&tty->read_q); + else if (arg==1) + flush(&tty->write_q); + else if (arg==2) { + flush(&tty->read_q); + flush(&tty->write_q); + } else + return -EINVAL; + return 0; + case TIOCEXCL: + return -EINVAL; /* not implemented */ + case TIOCNXCL: + return -EINVAL; /* not implemented */ + case TIOCSCTTY: + return -EINVAL; /* set controlling term NI */ + case TIOCGPGRP: + verify_area((void *) arg,4); + put_fs_long(tty->pgrp,(unsigned long *) arg); + return 0; + case TIOCSPGRP: + tty->pgrp=get_fs_long((unsigned long *) arg); + return 0; + case TIOCOUTQ: + verify_area((void *) arg,4); + put_fs_long(CHARS(tty->write_q),(unsigned long *) arg); + return 0; + case TIOCINQ: + verify_area((void *) arg,4); + put_fs_long(CHARS(tty->secondary), + (unsigned long *) arg); + return 0; + case TIOCSTI: + return -EINVAL; /* not implemented */ + case TIOCGWINSZ: + return -EINVAL; /* not implemented */ + case TIOCSWINSZ: + return -EINVAL; /* not implemented */ + case TIOCMGET: + return -EINVAL; /* not implemented */ + case TIOCMBIS: + return -EINVAL; /* not implemented */ + case TIOCMBIC: + return -EINVAL; /* not implemented */ + case TIOCMSET: + return -EINVAL; /* not implemented */ + case TIOCGSOFTCAR: + return -EINVAL; /* not implemented */ + case TIOCSSOFTCAR: + return -EINVAL; /* not implemented */ + default: + return -EINVAL; + } +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_ioctl.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_ioctl.o new file mode 100644 index 0000000..95803bb Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_ioctl.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_ioctl.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_ioctl.s new file mode 100644 index 0000000..821f31b --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/chr_drv/tty_ioctl.s @@ -0,0 +1,446 @@ + .file "tty_ioctl.c" + .data + .align 32 +_quotient: + .word 0 + .word 2304 + .word 1536 + .word 1047 + .word 857 + .word 768 + .word 576 + .word 384 + .word 192 + .word 96 + .word 64 + .word 48 + .word 24 + .word 12 + .word 6 + .word 3 + .text + .p2align 2,,3 + .def _change_speed; .scl 3; .type 32; .endef +_change_speed: + pushl %edi + pushl %esi + pushl %ebx + movl 16(%esp), %eax + movw 48(%eax), %si + testw %si, %si + je L1 + movl 8(%eax), %eax + andl $15, %eax + movw _quotient(%eax,%eax), %cx +/APP + cli +/NO_APP + movzwl %si, %edi + leal 3(%edi), %ebx + movl $128, %eax + movl %ebx, %edx +/APP + outb %al,%dx + jmp 1f +1: jmp 1f +1: +/NO_APP + movzbl %cl, %eax + movl %esi, %edx +/APP + outb %al,%dx + jmp 1f +1: jmp 1f +1: +/NO_APP + movzbl %ch, %ecx + leal 1(%edi), %edx + movl %ecx, %eax +/APP + outb %al,%dx + jmp 1f +1: jmp 1f +1: +/NO_APP + movl %ebx, %edx + movl $3, %eax +/APP + outb %al,%dx + sti +/NO_APP +L1: + popl %ebx + popl %esi + popl %edi + ret + .p2align 2,,3 + .def _flush; .scl 3; .type 32; .endef +_flush: + movl 4(%esp), %edx +/APP + cli +/NO_APP + movl 8(%edx), %eax + movl %eax, 4(%edx) +/APP + sti +/NO_APP + ret + .p2align 2,,3 + .def _wait_until_sent; .scl 3; .type 32; .endef +_wait_until_sent: + ret + .p2align 2,,3 + .def _send_break; .scl 3; .type 32; .endef +_send_break: + ret + .p2align 2,,3 + .def _get_termios; .scl 3; .type 32; .endef +_get_termios: + pushl %esi + pushl %ebx + subl $12, %esp + movl 24(%esp), %esi + movl 28(%esp), %ebx + pushl $36 + pushl %ebx + call _verify_area + xorl %edx, %edx + addl $16, %esp + .p2align 2,,3 +L12: + movb (%edx,%esi), %al +/APP + movb %al,%fs:(%edx,%ebx) +/NO_APP + incl %edx + cmpl $35, %edx + jbe L12 + popl %edx + popl %ebx + xorl %eax, %eax + popl %esi + ret + .p2align 2,,3 + .def _set_termios; .scl 3; .type 32; .endef +_set_termios: + pushl %ebx + subl $8, %esp + movl 16(%esp), %ebx + movl 20(%esp), %ecx + xorl %edx, %edx + .p2align 2,,3 +L21: +/APP + movb %fs:(%edx,%ecx),%al +/NO_APP + movb %al, (%edx,%ebx) + incl %edx + cmpl $35, %edx + jbe L21 + subl $12, %esp + pushl %ebx + call _change_speed + addl $24, %esp + xorl %eax, %eax + popl %ebx + ret + .p2align 2,,3 + .def _get_termio; .scl 3; .type 32; .endef +_get_termio: + pushl %esi + pushl %ebx + subl $44, %esp + movl 56(%esp), %esi + movl 60(%esp), %ebx + pushl $18 + pushl %ebx + call _verify_area + movw (%esi), %ax + movw %ax, 16(%esp) + movw 4(%esi), %ax + movw %ax, 18(%esp) + movw 8(%esi), %ax + movw %ax, 20(%esp) + movw 12(%esi), %ax + movw %ax, 22(%esp) + movb 16(%esi), %al + movb %al, 24(%esp) + xorl %edx, %edx + addl $16, %esp + .p2align 2,,3 +L29: + movb 17(%edx,%esi), %al + movb %al, 9(%esp,%edx) + incl %edx + cmpl $7, %edx + jle L29 + xorl %edx, %edx + .p2align 2,,3 +L35: + movb (%esp,%edx), %al +/APP + movb %al,%fs:(%edx,%ebx) +/NO_APP + incl %edx + cmpl $17, %edx + jbe L35 + addl $36, %esp + popl %ebx + xorl %eax, %eax + popl %esi + ret + .p2align 2,,3 + .def _set_termio; .scl 3; .type 32; .endef +_set_termio: + pushl %ebx + subl $40, %esp + movl 48(%esp), %ebx + movl 52(%esp), %ecx + xorl %edx, %edx + .p2align 2,,3 +L46: +/APP + movb %fs:(%edx,%ecx),%al +/NO_APP + movb %al, (%esp,%edx) + incl %edx + cmpl $17, %edx + jbe L46 + movl (%esp), %eax + movw %ax, (%ebx) + movw 2(%esp), %ax + movw %ax, 4(%ebx) + movl 4(%esp), %eax + movw %ax, 8(%ebx) + movw 6(%esp), %ax + movw %ax, 12(%ebx) + movb 8(%esp), %al + movb %al, 16(%ebx) + xorl %edx, %edx + .p2align 2,,3 +L51: + movb 9(%esp,%edx), %al + movb %al, 17(%edx,%ebx) + incl %edx + cmpl $7, %edx + jle L51 + subl $12, %esp + pushl %ebx + call _change_speed + addl $56, %esp + xorl %eax, %eax + popl %ebx + ret +LC0: + .ascii "tty_ioctl: dev<0\0" + .p2align 2,,3 +.globl _tty_ioctl + .def _tty_ioctl; .scl 2; .type 32; .endef +_tty_ioctl: + pushl %edi + pushl %esi + pushl %ebx + movl 16(%esp), %ebx + movl %ebx, %eax + shrl $8, %eax + cmpl $5, %eax + movl 20(%esp), %esi + movl 24(%esp), %edi + je L107 + andl $255, %ebx +L59: + leal (%ebx,%ebx,4), %eax + leal (%eax,%eax,4), %eax + sall $2, %eax + subl %ebx, %eax + leal -21505(%esi), %edx + sall $5, %eax + cmpl $26, %edx + leal _tty_table(%eax), %ebx + movl $-22, %eax + ja L56 + jmp *L100(,%edx,4) + .p2align 2 + .align 4 +L100: + .long L61 + .long L64 + .long L63 + .long L62 + .long L65 + .long L68 + .long L67 + .long L66 + .long L69 + .long L98 + .long L72 + .long L98 + .long L98 + .long L98 + .long L82 + .long L84 + .long L86 + .long L98 + .long L98 + .long L98 + .long L98 + .long L98 + .long L98 + .long L98 + .long L98 + .long L98 + .long L88 +L61: + movl %edi, 20(%esp) + movl %ebx, 16(%esp) + popl %ebx + popl %esi + popl %edi + jmp _get_termios +L64: + movl %edi, 20(%esp) + movl %ebx, 16(%esp) + popl %ebx + popl %esi + popl %edi + jmp _set_termios +L63: + subl $12, %esp + pushl %ebx + call _wait_until_sent + addl $16, %esp + jmp L64 +L62: + subl $12, %esp + leal 48(%ebx), %eax + pushl %eax + call _flush + addl $16, %esp + jmp L63 +L65: + movl %edi, 20(%esp) + movl %ebx, 16(%esp) + popl %ebx + popl %esi + popl %edi + jmp _get_termio +L68: + movl %edi, 20(%esp) + movl %ebx, 16(%esp) + popl %ebx + popl %esi + popl %edi + jmp _set_termio +L67: + subl $12, %esp + pushl %ebx + call _wait_until_sent + addl $16, %esp + jmp L68 +L66: + subl $12, %esp + leal 48(%ebx), %eax + pushl %eax + call _flush + addl $16, %esp + jmp L67 +L69: + testl %edi, %edi + jne L104 + subl $12, %esp + pushl %ebx + call _wait_until_sent + movl %ebx, (%esp) + call _send_break +L105: + addl $16, %esp +L104: + xorl %eax, %eax + .p2align 2,,3 +L56: + popl %ebx + popl %esi + popl %edi + ret +L72: + testl %edi, %edi + je L108 + cmpl $1, %edi + je L109 + cmpl $2, %edi + je L110 + .p2align 2,,3 +L98: + movl $-22, %eax + jmp L56 +L110: + subl $12, %esp + leal 48(%ebx), %eax + pushl %eax + call _flush + popl %ecx +L101: + leal 1088(%ebx), %eax +L102: + pushl %eax + call _flush + jmp L105 +L109: + subl $12, %esp + jmp L101 +L108: + subl $12, %esp + leal 48(%ebx), %eax + jmp L102 +L82: + subl $8, %esp + pushl $4 + pushl %edi + call _verify_area + addl $16, %esp + movl 36(%ebx), %eax +L106: +/APP + movl %eax,%fs:(%edi) +/NO_APP + jmp L104 +L84: +/APP + movl %fs:(%edi),%eax +/NO_APP + movl %eax, 36(%ebx) + jmp L104 +L86: + subl $8, %esp + pushl $4 + pushl %edi + call _verify_area + movl 1092(%ebx), %eax + addl $16, %esp + subl 1096(%ebx), %eax +L103: + andl $1023, %eax + jmp L106 +L88: + subl $8, %esp + pushl $4 + pushl %edi + call _verify_area + movl 2132(%ebx), %eax + addl $16, %esp + subl 2136(%ebx), %eax + jmp L103 + .p2align 2,,3 +L107: + movl _current, %eax + movl 616(%eax), %ebx + testl %ebx, %ebx + jns L59 + subl $12, %esp + pushl $LC0 + call _panic + addl $16, %esp + jmp L59 + .def _panic; .scl 2; .type 32; .endef + .def _verify_area; .scl 2; .type 32; .endef diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/exit.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/exit.c new file mode 100644 index 0000000..b22de34 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/exit.c @@ -0,0 +1,196 @@ +/* + * linux/kernel/exit.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include +#include + +#include +#include +#include +#include + +int sys_pause(void); +int sys_close(int fd); + +void release(struct task_struct * p) +{ + int i; + + if (!p) + return; + for (i=1 ; i32) + return -EINVAL; + if (priv || (current->euid==p->euid) || suser()) + p->signal |= (1<<(sig-1)); + else + return -EPERM; + return 0; +} + +static void kill_session(void) +{ + struct task_struct **p = NR_TASKS + task; + + while (--p > &FIRST_TASK) { + if (*p && (*p)->session == current->session) + (*p)->signal |= 1<<(SIGHUP-1); + } +} + +/* + * XXX need to check permissions needed to send signals to process + * groups, etc. etc. kill() permissions semantics are tricky! + */ +int sys_kill(int pid,int sig) +{ + struct task_struct **p = NR_TASKS + task; + int err, retval = 0; + + if (!pid) while (--p > &FIRST_TASK) { + if (*p && (*p)->pgrp == current->pid) + if ((err=send_sig(sig,*p,1))) + retval = err; + } else if (pid>0) while (--p > &FIRST_TASK) { + if (*p && (*p)->pid == pid) + if ((err=send_sig(sig,*p,0))) + retval = err; + } else if (pid == -1) while (--p > &FIRST_TASK) { + if ((err = send_sig(sig,*p,0))) + retval = err; + } else while (--p > &FIRST_TASK) + if (*p && (*p)->pgrp == -pid) + if ((err = send_sig(sig,*p,0))) + retval = err; + return retval; +} + +static void tell_father(int pid) +{ + int i; + + if (pid) + for (i=0;ipid != pid) + continue; + task[i]->signal |= (1<<(SIGCHLD-1)); + return; + } +/* if we don't find any fathers, we just release ourselves */ +/* This is not really OK. Must change it to make father 1 */ + printk("BAD BAD - no father found\n\r"); + release(current); +} + +int do_exit(long code) +{ + int i; + free_page_tables(get_base(current->ldt[1]),get_limit(0x0f)); + free_page_tables(get_base(current->ldt[2]),get_limit(0x17)); + for (i=0 ; ifather == current->pid) { + task[i]->father = 1; + if (task[i]->state == TASK_ZOMBIE) + /* assumption task[1] is always init */ + (void) send_sig(SIGCHLD, task[1], 1); + } + for (i=0 ; ifilp[i]) + sys_close(i); + iput(current->pwd); + current->pwd=NULL; + iput(current->root); + current->root=NULL; + iput(current->executable); + current->executable=NULL; + if (current->leader && current->tty >= 0) + tty_table[current->tty].pgrp = 0; + if (last_task_used_math == current) + last_task_used_math = NULL; + if (current->leader) + kill_session(); + current->state = TASK_ZOMBIE; + current->exit_code = code; + tell_father(current->father); + schedule(); + return (-1); /* just to suppress warnings */ +} + +int sys_exit(int error_code) +{ + return do_exit((error_code&0xff)<<8); +} + +int sys_waitpid(pid_t pid,unsigned long * stat_addr, int options) +{ + int flag, code; + struct task_struct ** p; + + verify_area(stat_addr,4); +repeat: + flag=0; + for(p = &LAST_TASK ; p > &FIRST_TASK ; --p) { + if (!*p || *p == current) + continue; + if ((*p)->father != current->pid) + continue; + if (pid>0) { + if ((*p)->pid != pid) + continue; + } else if (!pid) { + if ((*p)->pgrp != current->pgrp) + continue; + } else if (pid != -1) { + if ((*p)->pgrp != -pid) + continue; + } + switch ((*p)->state) { + case TASK_STOPPED: + if (!(options & WUNTRACED)) + continue; + put_fs_long(0x7f,stat_addr); + return (*p)->pid; + case TASK_ZOMBIE: + current->cutime += (*p)->utime; + current->cstime += (*p)->stime; + flag = (*p)->pid; + code = (*p)->exit_code; + release(*p); + put_fs_long(code,stat_addr); + return flag; + default: + flag=1; + continue; + } + } + if (flag) { + if (options & WNOHANG) + return 0; + current->state=TASK_INTERRUPTIBLE; + schedule(); + if (!(current->signal &= ~(1<<(SIGCHLD-1)))) + goto repeat; + else + return -EINTR; + } + return -ECHILD; +} + + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/exit.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/exit.o new file mode 100644 index 0000000..dc1979c Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/exit.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/fork.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/fork.c new file mode 100644 index 0000000..2486b13 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/fork.c @@ -0,0 +1,148 @@ +/* + * linux/kernel/fork.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 'fork.c' contains the help-routines for the 'fork' system call + * (see also system_call.s), and some misc functions ('verify_area'). + * Fork is rather simple, once you get the hang of it, but the memory + * management can be a bitch. See 'mm/mm.c': 'copy_page_tables()' + */ +#include + +#include +#include +#include +#include + +extern void write_verify(unsigned long address); + +long last_pid=0; + +void verify_area(void * addr,int size) +{ + unsigned long start; + + start = (unsigned long) addr; + size += start & 0xfff; + start &= 0xfffff000; + start += get_base(current->ldt[2]); + while (size>0) { + size -= 4096; + write_verify(start); + start += 4096; + } +} + +int copy_mem(int nr,struct task_struct * p) +{ + unsigned long old_data_base,new_data_base,data_limit; + unsigned long old_code_base,new_code_base,code_limit; + + code_limit=get_limit(0x0f); + data_limit=get_limit(0x17); + old_code_base = get_base(current->ldt[1]); + old_data_base = get_base(current->ldt[2]); + if (old_data_base != old_code_base) + panic("We don't support separate I&D"); + if (data_limit < code_limit) + panic("Bad data_limit"); + new_data_base = new_code_base = nr * 0x4000000; + p->start_code = new_code_base; + set_base(p->ldt[1],new_code_base); + set_base(p->ldt[2],new_data_base); + if (copy_page_tables(old_data_base,new_data_base,data_limit)) { + printk("free_page_tables: from copy_mem\n"); + free_page_tables(new_data_base,data_limit); + return -ENOMEM; + } + return 0; +} + +/* + * Ok, this is the main fork-routine. It copies the system process + * information (task[nr]) and sets up the necessary registers. It + * also copies the data segment in it's entirety. + */ +int copy_process(int nr,long ebp,long edi,long esi,long gs,long none, + long ebx,long ecx,long edx, + long fs,long es,long ds, + long eip,long cs,long eflags,long esp,long ss) +{ + struct task_struct *p; + int i; + struct file *f; + + p = (struct task_struct *) get_free_page(); + if (!p) + return -EAGAIN; + task[nr] = p; + *p = *current; /* NOTE! this doesn't copy the supervisor stack */ + p->state = TASK_UNINTERRUPTIBLE; + p->pid = last_pid; + p->father = current->pid; + p->counter = p->priority; + p->signal = 0; + p->alarm = 0; + p->leader = 0; /* process leadership doesn't inherit */ + p->utime = p->stime = 0; + p->cutime = p->cstime = 0; + p->start_time = jiffies; + p->tss.back_link = 0; + p->tss.esp0 = PAGE_SIZE + (long) p; + p->tss.ss0 = 0x10; + p->tss.eip = eip; + p->tss.eflags = eflags; + p->tss.eax = 0; + p->tss.ecx = ecx; + p->tss.edx = edx; + p->tss.ebx = ebx; + p->tss.esp = esp; + p->tss.ebp = ebp; + p->tss.esi = esi; + p->tss.edi = edi; + p->tss.es = es & 0xffff; + p->tss.cs = cs & 0xffff; + p->tss.ss = ss & 0xffff; + p->tss.ds = ds & 0xffff; + p->tss.fs = fs & 0xffff; + p->tss.gs = gs & 0xffff; + p->tss.ldt = _LDT(nr); + p->tss.trace_bitmap = 0x80000000; + if (last_task_used_math == current) + __asm__("clts ; fnsave %0"::"m" (p->tss.i387)); + if (copy_mem(nr,p)) { + task[nr] = NULL; + free_page((long) p); + return -EAGAIN; + } + for (i=0; ifilp[i])) + f->f_count++; + if (current->pwd) + current->pwd->i_count++; + if (current->root) + current->root->i_count++; + if (current->executable) + current->executable->i_count++; + set_tss_desc(gdt+(nr<<1)+FIRST_TSS_ENTRY,&(p->tss)); + set_ldt_desc(gdt+(nr<<1)+FIRST_LDT_ENTRY,&(p->ldt)); + p->state = TASK_RUNNING; /* do this last, just in case */ + return last_pid; +} + +int find_empty_process(void) +{ + int i; + + repeat: + if ((++last_pid)<0) last_pid=1; + for(i=0 ; ipid == last_pid) goto repeat; + for(i=1 ; i tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/math/math.a b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/math/math.a new file mode 100644 index 0000000..29bb54f Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/math/math.a differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/math/math_emulate.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/math/math_emulate.c new file mode 100644 index 0000000..825e528 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/math/math_emulate.c @@ -0,0 +1,42 @@ +/* + * linux/kernel/math/math_emulate.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * This directory should contain the math-emulation code. + * Currently only results in a signal. + */ + +#include + +#include +#include +#include + +void math_emulate(long edi, long esi, long ebp, long sys_call_ret, + long eax,long ebx,long ecx,long edx, + unsigned short fs,unsigned short es,unsigned short ds, + unsigned long eip,unsigned short cs,unsigned long eflags, + unsigned short ss, unsigned long esp) +{ + unsigned char first, second; + +/* 0x0007 means user code space */ + if (cs != 0x000F) { + printk("math_emulate: %04x:%08x\n\r",cs,eip); + panic("Math emulation needed in kernel"); + } + first = get_fs_byte((char *)((*&eip)++)); + second = get_fs_byte((char *)((*&eip)++)); + printk("%04x:%08x %02x %02x\n\r",cs,eip-2,first,second); + current->signal |= 1<<(SIGFPE-1); +} + +void math_error(void) +{ + __asm__("fnclex"); + if (last_task_used_math) + last_task_used_math->signal |= 1<<(SIGFPE-1); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/math/math_emulate.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/math/math_emulate.o new file mode 100644 index 0000000..1925a47 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/math/math_emulate.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/mktime.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/mktime.c new file mode 100644 index 0000000..a67db96 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/mktime.c @@ -0,0 +1,58 @@ +/* + * linux/kernel/mktime.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +/* + * This isn't the library routine, it is only used in the kernel. + * as such, we don't care about years<1970 etc, but assume everything + * is ok. Similarly, TZ etc is happily ignored. We just do everything + * as easily as possible. Let's find something public for the library + * routines (although I think minix times is public). + */ +/* + * PS. I hate whoever though up the year 1970 - couldn't they have gotten + * a leap-year instead? I also hate Gregorius, pope or no. I'm grumpy. + */ +#define MINUTE 60 +#define HOUR (60*MINUTE) +#define DAY (24*HOUR) +#define YEAR (365*DAY) + +/* interestingly, we assume leap-years */ +static int month[12] = { + 0, + DAY*(31), + DAY*(31+29), + DAY*(31+29+31), + DAY*(31+29+31+30), + DAY*(31+29+31+30+31), + DAY*(31+29+31+30+31+30), + DAY*(31+29+31+30+31+30+31), + DAY*(31+29+31+30+31+30+31+31), + DAY*(31+29+31+30+31+30+31+31+30), + DAY*(31+29+31+30+31+30+31+31+30+31), + DAY*(31+29+31+30+31+30+31+31+30+31+30) +}; + +long kernel_mktime(struct tm * tm) +{ + long res; + int year; + + year = tm->tm_year - 70; +/* magic offsets (y+1) needed to get leapyears right.*/ + res = YEAR*year + DAY*((year+1)/4); + res += month[tm->tm_mon]; +/* and (y+2) here. If it wasn't a leap-year, we have to adjust */ + if (tm->tm_mon>1 && ((year+2)%4)) + res -= DAY; + res += DAY*(tm->tm_mday-1); + res += HOUR*tm->tm_hour; + res += MINUTE*tm->tm_min; + res += tm->tm_sec; + return res; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/mktime.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/mktime.o new file mode 100644 index 0000000..dde0086 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/mktime.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/panic.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/panic.c new file mode 100644 index 0000000..566467c --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/panic.c @@ -0,0 +1,26 @@ +/* + * linux/kernel/panic.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * This function is used through-out the kernel (includeinh mm and fs) + * to indicate a major problem. + */ +#define PANIC + +#include +#include + +void sys_sync(void); /* it's really int */ + +volatile void panic(const char * s) +{ + printk("Kernel panic: %s\n\r",s); + if (current == task[0]) + printk("In swapper task - not syncing\n\r"); + else + sys_sync(); + for(;;); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/panic.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/panic.o new file mode 100644 index 0000000..09e9368 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/panic.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/printk.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/printk.c new file mode 100644 index 0000000..c464d43 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/printk.c @@ -0,0 +1,41 @@ +/* + * linux/kernel/printk.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * When in kernel-mode, we cannot use printf, as fs is liable to + * point to 'interesting' things. Make a printf with fs-saving, and + * all is well. + */ +#include +#include + +#include + +static char buf[1024]; + +extern int vsprintf(char * buf, const char * fmt, va_list args); + +int printk(const char *fmt, ...) +{ + va_list args; + int i; + + va_start(args, fmt); + i=vsprintf(buf,fmt,args); + va_end(args); + __asm__("push %%fs\n\t" + "push %%ds\n\t" + "pop %%fs\n\t" + "pushl %0\n\t" + "pushl $_buf\n\t" + "pushl $0\n\t" + "call _tty_write\n\t" + "addl $8,%%esp\n\t" + "popl %0\n\t" + "pop %%fs" + ::"r" (i):"ax","cx","dx"); + return i; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/printk.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/printk.o new file mode 100644 index 0000000..d5022aa Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/printk.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sched.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sched.c new file mode 100644 index 0000000..15d839b --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sched.c @@ -0,0 +1,412 @@ +/* + * linux/kernel/sched.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 'sched.c' is the main kernel file. It contains scheduling primitives + * (sleep_on, wakeup, schedule etc) as well as a number of simple system + * call functions (type getpid(), which just extracts a field from + * current-task + */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#define _S(nr) (1<<((nr)-1)) +#define _BLOCKABLE (~(_S(SIGKILL) | _S(SIGSTOP))) + +void show_task(int nr,struct task_struct * p) +{ + int i,j = 4096-sizeof(struct task_struct); + + printk("%d: pid=%d, state=%d, ",nr,p->pid,p->state); + i=0; + while (i>2 ] ; + +struct { + long * a; + short b; + } stack_start = { & user_stack [PAGE_SIZE>>2] , 0x10 }; +/* + * 'math_state_restore()' saves the current math information in the + * old math state array, and gets the new ones from the current task + */ +void math_state_restore() +{ + if (last_task_used_math == current) + return; + __asm__("fwait"); + if (last_task_used_math) { + __asm__("fnsave %0"::"m" (last_task_used_math->tss.i387)); + } + last_task_used_math=current; + if (current->used_math) { + __asm__("frstor %0"::"m" (current->tss.i387)); + } else { + __asm__("fninit"::); + current->used_math=1; + } +} + +/* + * 'schedule()' is the scheduler function. This is GOOD CODE! There + * probably won't be any reason to change this, as it should work well + * in all circumstances (ie gives IO-bound processes good response etc). + * The one thing you might take a look at is the signal-handler code here. + * + * NOTE!! Task 0 is the 'idle' task, which gets called when no other + * tasks can run. It can not be killed, and it cannot sleep. The 'state' + * information in task[0] is never used. + */ +void schedule(void) +{ + int i,next,c; + struct task_struct ** p; + +/* check alarm, wake up any interruptible tasks that have got a signal */ + + for(p = &LAST_TASK ; p > &FIRST_TASK ; --p) + if (*p) { + if ((*p)->alarm && (*p)->alarm < jiffies) { + (*p)->signal |= (1<<(SIGALRM-1)); + (*p)->alarm = 0; + } + if (((*p)->signal & ~(_BLOCKABLE & (*p)->blocked)) && + (*p)->state==TASK_INTERRUPTIBLE) + (*p)->state=TASK_RUNNING; + } + +/* this is the scheduler proper: */ + + while (1) { + c = -1; + next = 0; + i = NR_TASKS; + p = &task[NR_TASKS]; + while (--i) { + if (!*--p) + continue; + if ((*p)->state == TASK_RUNNING && (*p)->counter > c) + c = (*p)->counter, next = i; + } + if (c) break; + for(p = &LAST_TASK ; p > &FIRST_TASK ; --p) + if (*p) + (*p)->counter = ((*p)->counter >> 1) + + (*p)->priority; + } + switch_to(next); +} + +int sys_pause(void) +{ + current->state = TASK_INTERRUPTIBLE; + schedule(); + return 0; +} + +void sleep_on(struct task_struct **p) +{ + struct task_struct *tmp; + + if (!p) + return; + if (current == &(init_task.task)) + panic("task[0] trying to sleep"); + tmp = *p; + *p = current; + current->state = TASK_UNINTERRUPTIBLE; + schedule(); + if (tmp) + tmp->state=0; +} + +void interruptible_sleep_on(struct task_struct **p) +{ + struct task_struct *tmp; + + if (!p) + return; + if (current == &(init_task.task)) + panic("task[0] trying to sleep"); + tmp=*p; + *p=current; +repeat: current->state = TASK_INTERRUPTIBLE; + schedule(); + if (*p && *p != current) { + (**p).state=0; + goto repeat; + } + *p=NULL; + if (tmp) + tmp->state=0; +} + +void wake_up(struct task_struct **p) +{ + if (p && *p) { + (**p).state=0; + *p=NULL; + } +} + +/* + * OK, here are some floppy things that shouldn't be in the kernel + * proper. They are here because the floppy needs a timer, and this + * was the easiest way of doing it. + */ +static struct task_struct * wait_motor[4] = {NULL,NULL,NULL,NULL}; +static int mon_timer[4]={0,0,0,0}; +static int moff_timer[4]={0,0,0,0}; +unsigned char current_DOR = 0x0C; + +int ticks_to_floppy_on(unsigned int nr) +{ + extern unsigned char selected; + unsigned char mask = 0x10 << nr; + + if (nr>3) + panic("floppy_on: nr>3"); + moff_timer[nr]=10000; /* 100 s = very big :-) */ + cli(); /* use floppy_off to turn it off */ + mask |= current_DOR; + if (!selected) { + mask &= 0xFC; + mask |= nr; + } + if (mask != current_DOR) { + outb(mask,FD_DOR); + if ((mask ^ current_DOR) & 0xf0) + mon_timer[nr] = HZ/2; + else if (mon_timer[nr] < 2) + mon_timer[nr] = 2; + current_DOR = mask; + } + sti(); + return mon_timer[nr]; +} + +void floppy_on(unsigned int nr) +{ + cli(); + while (ticks_to_floppy_on(nr)) + sleep_on(nr+wait_motor); + sti(); +} + +void floppy_off(unsigned int nr) +{ + moff_timer[nr]=3*HZ; +} + +void do_floppy_timer(void) +{ + int i; + unsigned char mask = 0x10; + + for (i=0 ; i<4 ; i++,mask <<= 1) { + if (!(mask & current_DOR)) + continue; + if (mon_timer[i]) { + if (!--mon_timer[i]) + wake_up(i+wait_motor); + } else if (!moff_timer[i]) { + current_DOR &= ~mask; + outb(current_DOR,FD_DOR); + } else + moff_timer[i]--; + } +} + +#define TIME_REQUESTS 64 + +static struct timer_list { + long jiffies; + void (*fn)(); + struct timer_list * next; +} timer_list[TIME_REQUESTS], * next_timer = NULL; + +void add_timer(long jiffies, void (*fn)(void)) +{ + struct timer_list * p; + + if (!fn) + return; + cli(); + if (jiffies <= 0) + (fn)(); + else { + for (p = timer_list ; p < timer_list + TIME_REQUESTS ; p++) + if (!p->fn) + break; + if (p >= timer_list + TIME_REQUESTS) + panic("No more time requests free"); + p->fn = fn; + p->jiffies = jiffies; + p->next = next_timer; + next_timer = p; + while (p->next && p->next->jiffies < p->jiffies) { + p->jiffies -= p->next->jiffies; + fn = p->fn; + p->fn = p->next->fn; + p->next->fn = fn; + jiffies = p->jiffies; + p->jiffies = p->next->jiffies; + p->next->jiffies = jiffies; + p = p->next; + } + } + sti(); +} + +void do_timer(long cpl) +{ + extern int beepcount; + extern void sysbeepstop(void); + + if (beepcount) + if (!--beepcount) + sysbeepstop(); + + if (cpl) + current->utime++; + else + current->stime++; + + if (next_timer) { + next_timer->jiffies--; + while (next_timer && next_timer->jiffies <= 0) { + void (*fn)(void); + + fn = next_timer->fn; + next_timer->fn = NULL; + next_timer = next_timer->next; + (fn)(); + } + } + if (current_DOR & 0xf0) + do_floppy_timer(); + if ((--current->counter)>0) return; + current->counter=0; + if (!cpl) return; + schedule(); +} + +int sys_alarm(long seconds) +{ + int old = current->alarm; + + if (old) + old = (old - jiffies) / HZ; + current->alarm = (seconds>0)?(jiffies+HZ*seconds):0; + return (old); +} + +int sys_getpid(void) +{ + return current->pid; +} + +int sys_getppid(void) +{ + return current->father; +} + +int sys_getuid(void) +{ + return current->uid; +} + +int sys_geteuid(void) +{ + return current->euid; +} + +int sys_getgid(void) +{ + return current->gid; +} + +int sys_getegid(void) +{ + return current->egid; +} + +int sys_nice(long increment) +{ + if (current->priority-increment>0) + current->priority -= increment; + return 0; +} + +void sched_init(void) +{ + int i; + struct desc_struct * p; + + if (sizeof(struct sigaction) != 16) + panic("Struct sigaction MUST be 16 bytes"); + set_tss_desc(gdt+FIRST_TSS_ENTRY,&(init_task.task.tss)); + set_ldt_desc(gdt+FIRST_LDT_ENTRY,&(init_task.task.ldt)); + p = gdt+2+FIRST_TSS_ENTRY; + for(i=1;ia=p->b=0; + p++; + p->a=p->b=0; + p++; + } +/* Clear NT, so that we won't have troubles with that later on */ + __asm__("pushfl ; andl $0xffffbfff,(%esp) ; popfl"); + ltr(0); + lldt(0); + outb_p(0x36,0x43); /* binary, mode 3, LSB/MSB, ch 0 */ + outb_p(LATCH & 0xff , 0x40); /* LSB */ + outb(LATCH >> 8 , 0x40); /* MSB */ + set_intr_gate(0x20,&timer_interrupt); + outb(inb_p(0x21)&~0x01,0x21); + set_system_gate(0x80,&system_call); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sched.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sched.o new file mode 100644 index 0000000..3b7345a Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sched.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/signal.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/signal.c new file mode 100644 index 0000000..055fc20 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/signal.c @@ -0,0 +1,119 @@ +/* + * linux/kernel/signal.c + * + * (C) 1991 Linus Torvalds + */ + +#include +#include +#include + +#include + +volatile void do_exit(int error_code); + +int sys_sgetmask() +{ + return current->blocked; +} + +int sys_ssetmask(int newmask) +{ + int old=current->blocked; + + current->blocked = newmask & ~(1<<(SIGKILL-1)); + return old; +} + +static inline void save_old(char * from,char * to) +{ + int i; + + verify_area(to, sizeof(struct sigaction)); + for (i=0 ; i< sizeof(struct sigaction) ; i++) { + put_fs_byte(*from,to); + from++; + to++; + } +} + +static inline void get_new(char * from,char * to) +{ + int i; + + for (i=0 ; i< sizeof(struct sigaction) ; i++) + *(to++) = get_fs_byte(from++); +} + +int sys_signal(int signum, long handler, long restorer) +{ + struct sigaction tmp; + + if (signum<1 || signum>32 || signum==SIGKILL) + return -1; + tmp.sa_handler = (void (*)(int)) handler; + tmp.sa_mask = 0; + tmp.sa_flags = SA_ONESHOT | SA_NOMASK; + tmp.sa_restorer = (void (*)(void)) restorer; + handler = (long) current->sigaction[signum-1].sa_handler; + current->sigaction[signum-1] = tmp; + return handler; +} + +int sys_sigaction(int signum, const struct sigaction * action, + struct sigaction * oldaction) +{ + struct sigaction tmp; + + if (signum<1 || signum>32 || signum==SIGKILL) + return -1; + tmp = current->sigaction[signum-1]; + get_new((char *) action, + (char *) (signum-1+current->sigaction)); + if (oldaction) + save_old((char *) &tmp,(char *) oldaction); + if (current->sigaction[signum-1].sa_flags & SA_NOMASK) + current->sigaction[signum-1].sa_mask = 0; + else + current->sigaction[signum-1].sa_mask |= (1<<(signum-1)); + return 0; +} + +void do_signal(long signr,long eax, long ebx, long ecx, long edx, + long fs, long es, long ds, + long eip, long cs, long eflags, + unsigned long * esp, long ss) +{ + unsigned long sa_handler; + long old_eip=eip; + struct sigaction * sa = current->sigaction + signr - 1; + int longs; + unsigned long * tmp_esp; + + sa_handler = (unsigned long) sa->sa_handler; + if (sa_handler==1) + return; + if (!sa_handler) { + if (signr==SIGCHLD) + return; + else + do_exit(1<<(signr-1)); + } + if (sa->sa_flags & SA_ONESHOT) + sa->sa_handler = NULL; + *(&eip) = sa_handler; + longs = (sa->sa_flags & SA_NOMASK)?7:8; + *(&esp) -= longs; + verify_area(esp,longs*4); + tmp_esp=esp; + put_fs_long((long) sa->sa_restorer,tmp_esp++); + put_fs_long(signr,tmp_esp++); + if (!(sa->sa_flags & SA_NOMASK)) + put_fs_long(current->blocked,tmp_esp++); + put_fs_long(eax,tmp_esp++); + put_fs_long(ecx,tmp_esp++); + put_fs_long(edx,tmp_esp++); + put_fs_long(eflags,tmp_esp++); + put_fs_long(old_eip,tmp_esp++); + current->blocked |= sa->sa_mask; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/signal.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/signal.o new file mode 100644 index 0000000..e04f8da Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/signal.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sys.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sys.c new file mode 100644 index 0000000..2c01e67 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sys.c @@ -0,0 +1,236 @@ +/* + * linux/kernel/sys.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +#include +#include +#include +#include +#include +#include + +int sys_ftime() +{ + return -ENOSYS; +} + +int sys_break() +{ + return -ENOSYS; +} + +int sys_ptrace() +{ + return -ENOSYS; +} + +int sys_stty() +{ + return -ENOSYS; +} + +int sys_gtty() +{ + return -ENOSYS; +} + +int sys_rename() +{ + return -ENOSYS; +} + +int sys_prof() +{ + return -ENOSYS; +} + +int sys_setregid(int rgid, int egid) +{ + if (rgid>0) { + if ((current->gid == rgid) || + suser()) + current->gid = rgid; + else + return(-EPERM); + } + if (egid>0) { + if ((current->gid == egid) || + (current->egid == egid) || + (current->sgid == egid) || + suser()) + current->egid = egid; + else + return(-EPERM); + } + return 0; +} + +int sys_setgid(int gid) +{ + return(sys_setregid(gid, gid)); +} + +int sys_acct() +{ + return -ENOSYS; +} + +int sys_phys() +{ + return -ENOSYS; +} + +int sys_lock() +{ + return -ENOSYS; +} + +int sys_mpx() +{ + return -ENOSYS; +} + +int sys_ulimit() +{ + return -ENOSYS; +} + +int sys_time(long * tloc) +{ + int i; + + i = CURRENT_TIME; + if (tloc) { + verify_area(tloc,4); + put_fs_long(i,(unsigned long *)tloc); + } + return i; +} + +/* + * Unprivileged users may change the real user id to the effective uid + * or vice versa. + */ +int sys_setreuid(int ruid, int euid) +{ + int old_ruid = current->uid; + + if (ruid>0) { + if ((current->euid==ruid) || + (old_ruid == ruid) || + suser()) + current->uid = ruid; + else + return(-EPERM); + } + if (euid>0) { + if ((old_ruid == euid) || + (current->euid == euid) || + suser()) + current->euid = euid; + else { + current->uid = old_ruid; + return(-EPERM); + } + } + return 0; +} + +int sys_setuid(int uid) +{ + return(sys_setreuid(uid, uid)); +} + +int sys_stime(long * tptr) +{ + if (!suser()) + return -EPERM; + startup_time = get_fs_long((unsigned long *)tptr) - jiffies/HZ; + return 0; +} + +int sys_times(struct tms * tbuf) +{ + if (tbuf) { + verify_area(tbuf,sizeof *tbuf); + put_fs_long(current->utime,(unsigned long *)&tbuf->tms_utime); + put_fs_long(current->stime,(unsigned long *)&tbuf->tms_stime); + put_fs_long(current->cutime,(unsigned long *)&tbuf->tms_cutime); + put_fs_long(current->cstime,(unsigned long *)&tbuf->tms_cstime); + } + return jiffies; +} + +int sys_brk(unsigned long end_data_seg) +{ + if (end_data_seg >= current->end_code && + end_data_seg < current->start_stack - 16384) + current->brk = end_data_seg; + return current->brk; +} + +/* + * This needs some heave checking ... + * I just haven't get the stomach for it. I also don't fully + * understand sessions/pgrp etc. Let somebody who does explain it. + */ +int sys_setpgid(int pid, int pgid) +{ + int i; + + if (!pid) + pid = current->pid; + if (!pgid) + pgid = current->pid; + for (i=0 ; ipid==pid) { + if (task[i]->leader) + return -EPERM; + if (task[i]->session != current->session) + return -EPERM; + task[i]->pgrp = pgid; + return 0; + } + return -ESRCH; +} + +int sys_getpgrp(void) +{ + return current->pgrp; +} + +int sys_setsid(void) +{ + if (current->leader && !suser()) + return -EPERM; + current->leader = 1; + current->session = current->pgrp = current->pid; + current->tty = -1; + return current->pgrp; +} + +int sys_uname(struct utsname * name) +{ + static struct utsname thisname = { + "linux .0","nodename","release ","version ","machine " + }; + int i; + + if (!name) return -ERROR; + verify_area(name,sizeof *name); + for(i=0;iumask; + + current->umask = mask & 0777; + return (old); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sys.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sys.o new file mode 100644 index 0000000..e7dc013 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/sys.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/system_call.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/system_call.o new file mode 100644 index 0000000..9886f8d Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/system_call.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/system_call.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/system_call.s new file mode 100644 index 0000000..c96826c --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/system_call.s @@ -0,0 +1,285 @@ +/* + * linux/kernel/system_call.s + * + * (C) 1991 Linus Torvalds + */ + +/* + * system_call.s contains the system-call low-level handling routines. + * This also contains the timer-interrupt handler, as some of the code is + * the same. The hd- and flopppy-interrupts are also here. + * + * NOTE: This code handles signal-recognition, which happens every time + * after a timer-interrupt and after each system call. Ordinary interrupts + * don't handle signal-recognition, as that would clutter them up totally + * unnecessarily. + * + * Stack layout in 'ret_from_system_call': + * + * 0(%esp) - %eax + * 4(%esp) - %ebx + * 8(%esp) - %ecx + * C(%esp) - %edx + * 10(%esp) - %fs + * 14(%esp) - %es + * 18(%esp) - %ds + * 1C(%esp) - %eip + * 20(%esp) - %cs + * 24(%esp) - %eflags + * 28(%esp) - %oldesp + * 2C(%esp) - %oldss + */ + +SIG_CHLD = 17 + +EAX = 0x00 +EBX = 0x04 +ECX = 0x08 +EDX = 0x0C +FS = 0x10 +ES = 0x14 +DS = 0x18 +EIP = 0x1C +CS = 0x20 +EFLAGS = 0x24 +OLDESP = 0x28 +OLDSS = 0x2C + +state = 0 # these are offsets into the task-struct. +counter = 4 +priority = 8 +signal = 12 +sigaction = 16 # MUST be 16 (=len of sigaction) +blocked = (33*16) + +# offsets within sigaction +sa_handler = 0 +sa_mask = 4 +sa_flags = 8 +sa_restorer = 12 + +nr_system_calls = 72 + +/* + * Ok, I get parallel printer interrupts while using the floppy for some + * strange reason. Urgel. Now I just ignore them. + */ +.globl _system_call,_sys_fork,_timer_interrupt,_sys_execve +.globl _hd_interrupt,_floppy_interrupt,_parallel_interrupt +.globl _device_not_available, _coprocessor_error + +.align 2 +bad_sys_call: + movl $-1,%eax + iret +.align 2 +reschedule: + pushl $ret_from_sys_call + jmp _schedule +.align 2 +_system_call: + cmpl $nr_system_calls-1,%eax + ja bad_sys_call + push %ds + push %es + push %fs + pushl %edx + pushl %ecx # push %ebx,%ecx,%edx as parameters + pushl %ebx # to the system call + movl $0x10,%edx # set up ds,es to kernel space + mov %dx,%ds + mov %dx,%es + movl $0x17,%edx # fs points to local data space + mov %dx,%fs + call _sys_call_table(,%eax,4) + pushl %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 + je 3f + cmpw $0x0f,CS(%esp) # was old code segment supervisor ? + jne 3f + cmpw $0x17,OLDSS(%esp) # was stack segment = 0x17 ? + jne 3f + movl signal(%eax),%ebx + movl blocked(%eax),%ecx + notl %ecx + andl %ebx,%ecx + bsfl %ecx,%ecx + je 3f + btrl %ecx,%ebx + movl %ebx,signal(%eax) + incl %ecx + pushl %ecx + call _do_signal + popl %eax +3: popl %eax + popl %ebx + popl %ecx + popl %edx + pop %fs + pop %es + pop %ds + iret + +.align 2 +_coprocessor_error: + push %ds + push %es + push %fs + pushl %edx + pushl %ecx + pushl %ebx + pushl %eax + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + movl $0x17,%eax + mov %ax,%fs + pushl $ret_from_sys_call + jmp _math_error + +.align 2 +_device_not_available: + push %ds + push %es + push %fs + pushl %edx + pushl %ecx + pushl %ebx + pushl %eax + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + movl $0x17,%eax + mov %ax,%fs + pushl $ret_from_sys_call + clts # clear TS so that we can use math + movl %cr0,%eax + testl $0x4,%eax # EM (math emulation bit) + je _math_state_restore + pushl %ebp + pushl %esi + pushl %edi + call _math_emulate + popl %edi + popl %esi + popl %ebp + ret + +.align 2 +_timer_interrupt: + push %ds # save ds,es and put kernel data space + push %es # into them. %fs is used by _system_call + push %fs + pushl %edx # we save %eax,%ecx,%edx as gcc doesn't + pushl %ecx # save those across function calls. %ebx + pushl %ebx # is saved as we use that in ret_sys_call + pushl %eax + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + movl $0x17,%eax + mov %ax,%fs + 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 + addl $4,%esp # task switching to accounting ... + jmp ret_from_sys_call + +.align 2 +_sys_execve: + lea EIP(%esp),%eax + pushl %eax + call _do_execve + addl $4,%esp + ret + +.align 2 +_sys_fork: + call _find_empty_process + testl %eax,%eax + js 1f + push %gs + pushl %esi + pushl %edi + pushl %ebp + pushl %eax + call _copy_process + addl $20,%esp +1: ret + +_hd_interrupt: + pushl %eax + pushl %ecx + pushl %edx + push %ds + push %es + push %fs + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + movl $0x17,%eax + mov %ax,%fs + movb $0x20,%al + outb %al,$0xA0 # EOI to interrupt controller #1 + jmp 1f # give port chance to breathe +1: jmp 1f +1: xorl %edx,%edx + xchgl _do_hd,%edx + testl %edx,%edx + jne 1f + movl $_unexpected_hd_interrupt,%edx +1: outb %al,$0x20 + call *%edx # "interesting" way of handling intr. + pop %fs + pop %es + pop %ds + popl %edx + popl %ecx + popl %eax + iret + +_floppy_interrupt: + pushl %eax + pushl %ecx + pushl %edx + push %ds + push %es + push %fs + movl $0x10,%eax + mov %ax,%ds + mov %ax,%es + movl $0x17,%eax + mov %ax,%fs + movb $0x20,%al + outb %al,$0x20 # EOI to interrupt controller #1 + xorl %eax,%eax + xchgl _do_floppy,%eax + testl %eax,%eax + jne 1f + movl $_unexpected_floppy_interrupt,%eax +1: call *%eax # "interesting" way of handling intr. + pop %fs + pop %es + pop %ds + popl %edx + popl %ecx + popl %eax + iret + +_parallel_interrupt: + pushl %eax + movb $0x20,%al + outb %al,$0x20 + popl %eax + iret diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/traps.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/traps.c new file mode 100644 index 0000000..3629a13 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/traps.c @@ -0,0 +1,208 @@ +/* + * linux/kernel/traps.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * 'Traps.c' handles hardware traps and faults after we have saved some + * state in 'asm.s'. Currently mostly a debugging-aid, will be extended + * to mainly kill the offending process (probably by giving it a signal, + * but possibly by killing it outright if necessary). + */ +#include + +#include +#include +#include +#include +#include +#include + +#define get_seg_byte(seg,addr) ({ \ +register char __res; \ +__asm__("push %%fs;mov %%ax,%%fs;movb %%fs:%2,%%al;pop %%fs" \ + :"=a" (__res):"0" (seg),"m" (*(addr))); \ +__res;}) + +#define get_seg_long(seg,addr) ({ \ +register unsigned long __res; \ +__asm__("push %%fs;mov %%ax,%%fs;movl %%fs:%2,%%eax;pop %%fs" \ + :"=a" (__res):"0" (seg),"m" (*(addr))); \ +__res;}) + +#define _fs() ({ \ +register unsigned short __res; \ +__asm__("mov %%fs,%%ax":"=a" (__res):); \ +__res;}) + +int do_exit(long code); + +void page_exception(void); + +void divide_error(void); +void debug(void); +void nmi(void); +void int3(void); +void overflow(void); +void bounds(void); +void invalid_op(void); +void device_not_available(void); +void double_fault(void); +void coprocessor_segment_overrun(void); +void invalid_TSS(void); +void segment_not_present(void); +void stack_segment(void); +void general_protection(void); +void page_fault(void); +void coprocessor_error(void); +void reserved(void); +void parallel_interrupt(void); +void irq13(void); + +static void die(char * str,long esp_ptr,long nr) +{ + long * esp = (long *) esp_ptr; + int i; + + printk("%s: %04x\n\r",str,nr&0xffff); + printk("EIP:\t%04x:%p\nEFLAGS:\t%p\nESP:\t%04x:%p\n", + esp[1],esp[0],esp[2],esp[4],esp[3]); + printk("fs: %04x\n",_fs()); + printk("base: %p, limit: %p\n",get_base(current->ldt[1]),get_limit(0x17)); + if (esp[4] == 0x17) { + printk("Stack: "); + for (i=0;i<4;i++) + printk("%p ",get_seg_long(0x17,i+(long *)esp[3])); + printk("\n"); + } + str(i); + printk("Pid: %d, process nr: %d\n\r",current->pid,0xffff & i); + for(i=0;i<10;i++) + printk("%02x ",0xff & get_seg_byte(esp[1],(i+(char *)esp[0]))); + printk("\n\r"); + do_exit(11); /* play segment exception */ +} + +void do_double_fault(long esp, long error_code) +{ + die("double fault",esp,error_code); +} + +void do_general_protection(long esp, long error_code) +{ + die("general protection",esp,error_code); +} + +void do_divide_error(long esp, long error_code) +{ + die("divide error",esp,error_code); +} + +void do_int3(long * esp, long error_code, + long fs,long es,long ds, + long ebp,long esi,long edi, + long edx,long ecx,long ebx,long eax) +{ + int tr; + + __asm__("str %%ax":"=a" (tr):"0" (0)); + printk("eax\t\tebx\t\tecx\t\tedx\n\r%8x\t%8x\t%8x\t%8x\n\r", + eax,ebx,ecx,edx); + printk("esi\t\tedi\t\tebp\t\tesp\n\r%8x\t%8x\t%8x\t%8x\n\r", + esi,edi,ebp,(long) esp); + printk("\n\rds\tes\tfs\ttr\n\r%4x\t%4x\t%4x\t%4x\n\r", + ds,es,fs,tr); + printk("EIP: %8x CS: %4x EFLAGS: %8x\n\r",esp[0],esp[1],esp[2]); +} + +void do_nmi(long esp, long error_code) +{ + die("nmi",esp,error_code); +} + +void do_debug(long esp, long error_code) +{ + die("debug",esp,error_code); +} + +void do_overflow(long esp, long error_code) +{ + die("overflow",esp,error_code); +} + +void do_bounds(long esp, long error_code) +{ + die("bounds",esp,error_code); +} + +void do_invalid_op(long esp, long error_code) +{ + die("invalid operand",esp,error_code); +} + +void do_device_not_available(long esp, long error_code) +{ + die("device not available",esp,error_code); +} + +void do_coprocessor_segment_overrun(long esp, long error_code) +{ + die("coprocessor segment overrun",esp,error_code); +} + +void do_invalid_TSS(long esp,long error_code) +{ + die("invalid TSS",esp,error_code); +} + +void do_segment_not_present(long esp,long error_code) +{ + die("segment not present",esp,error_code); +} + +void do_stack_segment(long esp,long error_code) +{ + die("stack segment",esp,error_code); +} + +void do_coprocessor_error(long esp, long error_code) +{ + if (last_task_used_math != current) + return; + die("coprocessor error",esp,error_code); +} + +void do_reserved(long esp, long error_code) +{ + die("reserved (15,17-47) error",esp,error_code); +} + +void trap_init(void) +{ + int i; + + set_trap_gate(0,÷_error); + set_trap_gate(1,&debug); + set_trap_gate(2,&nmi); + set_system_gate(3,&int3); /* int3-5 can be called from all */ + set_system_gate(4,&overflow); + set_system_gate(5,&bounds); + set_trap_gate(6,&invalid_op); + set_trap_gate(7,&device_not_available); + set_trap_gate(8,&double_fault); + set_trap_gate(9,&coprocessor_segment_overrun); + set_trap_gate(10,&invalid_TSS); + set_trap_gate(11,&segment_not_present); + set_trap_gate(12,&stack_segment); + set_trap_gate(13,&general_protection); + set_trap_gate(14,&page_fault); + set_trap_gate(15,&reserved); + set_trap_gate(16,&coprocessor_error); + for (i=17;i<48;i++) + set_trap_gate(i,&reserved); + set_trap_gate(45,&irq13); + outb_p(inb_p(0x21)&0xfb,0x21); + outb(inb_p(0xA1)&0xdf,0xA1); + set_trap_gate(39,¶llel_interrupt); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/traps.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/traps.o new file mode 100644 index 0000000..63d76a5 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/traps.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/traps.s b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/traps.s new file mode 100644 index 0000000..283c7a7 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/traps.s @@ -0,0 +1,631 @@ + .file "traps.c" + .text +LC0: + .ascii "%s: %04x\12\15\0" + .align 32 +LC1: + .ascii "EIP:\11%04x:%p\12EFLAGS:\11%p\12ESP:\11%04x:%p\12\0" +LC2: + .ascii "fs: %04x\12\0" +LC3: + .ascii "base: %p, limit: %p\12\0" +LC7: + .ascii "Pid: %d, process nr: %d\12\15\0" +LC8: + .ascii "%02x \0" +LC9: + .ascii "\12\15\0" +LC4: + .ascii "Stack: \0" +LC5: + .ascii "%p \0" +LC6: + .ascii "\12\0" + .p2align 2,,3 + .def _die; .scl 3; .type 32; .endef +_die: + pushl %edi + pushl %esi + pushl %ebx + movl 20(%esp), %esi + pushl %ebx + movzwl 28(%esp), %eax + pushl %eax + pushl 24(%esp) + pushl $LC0 + call _printk + popl %edx + popl %ecx + pushl 12(%esi) + pushl 16(%esi) + pushl 8(%esi) + pushl (%esi) + pushl 4(%esi) + pushl $LC1 + call _printk +/APP + mov %fs,%ax +/NO_APP + addl $24, %esp + movzwl %ax, %eax + pushl %eax + pushl $LC2 + call _printk + addl $12, %esp + movl $23, %edx + movl _current, %eax +/APP + lsll %edx,%ecx + incl %ecx +/NO_APP + addl $728, %eax +/APP + movb 7(%eax),%dh + movb 4(%eax),%dl + shll $16,%edx + movw 2(%eax),%dx +/NO_APP + pushl %ecx + pushl %edx + pushl $LC3 + call _printk + addl $16, %esp + cmpl $23, 16(%esi) + je L18 +L3: + xorl %edx, %edx + movl %edx, %eax +/APP + str %ax + subl $32,%eax + shrl $4,%eax +/NO_APP + movl %eax, %ebx + pushl %eax + movzwl %bx,%eax + pushl %eax + movl _current, %eax + pushl 556(%eax) + pushl $LC7 + call _printk + xorl %ebx, %ebx + addl $16, %esp + .p2align 2,,3 +L13: + movl 4(%esi), %eax + movl (%esi), %edx +/APP + push %fs;mov %ax,%fs;movb %fs:(%ebx,%edx),%al;pop %fs +/NO_APP + subl $8, %esp + movzbl %al, %eax + pushl %eax + pushl $LC8 + incl %ebx + call _printk + addl $16, %esp + cmpl $9, %ebx + jle L13 + subl $12, %esp + pushl $LC9 + call _printk + addl $16, %esp + movl $11, 16(%esp) + popl %ebx + popl %esi + popl %edi + jmp _do_exit +L18: + subl $12, %esp + pushl $LC4 + call _printk + xorl %ebx, %ebx + addl $16, %esp + movl $23, %edi +L8: + subl $8, %esp + movl 12(%esi), %edx + movl %edi, %eax +/APP + push %fs;mov %ax,%fs;movl %fs:(%edx,%ebx,4),%eax;pop %fs +/NO_APP + pushl %eax + pushl $LC5 + incl %ebx + call _printk + addl $16, %esp + cmpl $3, %ebx + jle L8 + subl $12, %esp + pushl $LC6 + call _printk + addl $16, %esp + jmp L3 +LC10: + .ascii "double fault\0" + .p2align 2,,3 +.globl _do_double_fault + .def _do_double_fault; .scl 2; .type 32; .endef +_do_double_fault: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC10 + call _die + addl $28, %esp + ret +LC11: + .ascii "general protection\0" + .p2align 2,,3 +.globl _do_general_protection + .def _do_general_protection; .scl 2; .type 32; .endef +_do_general_protection: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC11 + call _die + addl $28, %esp + ret +LC12: + .ascii "divide error\0" + .p2align 2,,3 +.globl _do_divide_error + .def _do_divide_error; .scl 2; .type 32; .endef +_do_divide_error: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC12 + call _die + addl $28, %esp + ret + .align 32 +LC13: + .ascii "eax\11\11ebx\11\11ecx\11\11edx\12\15%8x\11%8x\11%8x\11%8x\12\15\0" + .align 32 +LC14: + .ascii "esi\11\11edi\11\11ebp\11\11esp\12\15%8x\11%8x\11%8x\11%8x\12\15\0" + .align 32 +LC15: + .ascii "\12\15ds\11es\11fs\11tr\12\15%4x\11%4x\11%4x\11%4x\12\15\0" + .align 32 +LC16: + .ascii "EIP: %8x CS: %4x EFLAGS: %8x\12\15\0" + .p2align 2,,3 +.globl _do_int3 + .def _do_int3; .scl 2; .type 32; .endef +_do_int3: + pushl %ebp + pushl %edi + pushl %esi + pushl %ebx + subl $40, %esp + movl 68(%esp), %eax + movl %eax, 36(%esp) + movl 72(%esp), %eax + movl %eax, 32(%esp) + movl 76(%esp), %eax + movl %eax, 28(%esp) + movl 84(%esp), %eax + movl 60(%esp), %esi + movl 80(%esp), %ebp + movl 88(%esp), %edi + movl %eax, 24(%esp) + pushl 92(%esp) + pushl 100(%esp) + pushl 108(%esp) + pushl 116(%esp) + xorl %ebx, %ebx + movl %ebx, %eax + pushl $LC13 +/APP + str %ax +/NO_APP + movl %eax, %ebx + call _printk + addl $20, %esp + pushl %esi + pushl %ebp + pushl %edi + pushl 36(%esp) + pushl $LC14 + call _printk + addl $20, %esp + pushl %ebx + pushl 40(%esp) + pushl 40(%esp) + pushl 40(%esp) + pushl $LC15 + call _printk + movl 8(%esi), %eax + movl %eax, 92(%esp) + movl 4(%esi), %eax + movl %eax, 88(%esp) + movl (%esi), %eax + movl %eax, 84(%esp) + movl $LC16, 80(%esp) + addl $60, %esp + popl %ebx + popl %esi + popl %edi + popl %ebp + jmp _printk +LC17: + .ascii "nmi\0" + .p2align 2,,3 +.globl _do_nmi + .def _do_nmi; .scl 2; .type 32; .endef +_do_nmi: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC17 + call _die + addl $28, %esp + ret +LC18: + .ascii "debug\0" + .p2align 2,,3 +.globl _do_debug + .def _do_debug; .scl 2; .type 32; .endef +_do_debug: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC18 + call _die + addl $28, %esp + ret +LC19: + .ascii "overflow\0" + .p2align 2,,3 +.globl _do_overflow + .def _do_overflow; .scl 2; .type 32; .endef +_do_overflow: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC19 + call _die + addl $28, %esp + ret +LC20: + .ascii "bounds\0" + .p2align 2,,3 +.globl _do_bounds + .def _do_bounds; .scl 2; .type 32; .endef +_do_bounds: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC20 + call _die + addl $28, %esp + ret +LC21: + .ascii "invalid operand\0" + .p2align 2,,3 +.globl _do_invalid_op + .def _do_invalid_op; .scl 2; .type 32; .endef +_do_invalid_op: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC21 + call _die + addl $28, %esp + ret +LC22: + .ascii "device not available\0" + .p2align 2,,3 +.globl _do_device_not_available + .def _do_device_not_available; .scl 2; .type 32; .endef +_do_device_not_available: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC22 + call _die + addl $28, %esp + ret +LC23: + .ascii "coprocessor segment overrun\0" + .p2align 2,,3 +.globl _do_coprocessor_segment_overrun + .def _do_coprocessor_segment_overrun; .scl 2; .type 32; .endef +_do_coprocessor_segment_overrun: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC23 + call _die + addl $28, %esp + ret +LC24: + .ascii "invalid TSS\0" + .p2align 2,,3 +.globl _do_invalid_TSS + .def _do_invalid_TSS; .scl 2; .type 32; .endef +_do_invalid_TSS: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC24 + call _die + addl $28, %esp + ret +LC25: + .ascii "segment not present\0" + .p2align 2,,3 +.globl _do_segment_not_present + .def _do_segment_not_present; .scl 2; .type 32; .endef +_do_segment_not_present: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC25 + call _die + addl $28, %esp + ret +LC26: + .ascii "stack segment\0" + .p2align 2,,3 +.globl _do_stack_segment + .def _do_stack_segment; .scl 2; .type 32; .endef +_do_stack_segment: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC26 + call _die + addl $28, %esp + ret +LC27: + .ascii "coprocessor error\0" + .p2align 2,,3 +.globl _do_coprocessor_error + .def _do_coprocessor_error; .scl 2; .type 32; .endef +_do_coprocessor_error: + subl $12, %esp + movl _current, %eax + cmpl %eax, _last_task_used_math + je L35 +L33: + addl $12, %esp + ret + .p2align 2,,3 +L35: + pushl %eax + pushl 24(%esp) + pushl 24(%esp) + pushl $LC27 + call _die + addl $16, %esp + jmp L33 +LC28: + .ascii "reserved (15,17-47) error\0" + .p2align 2,,3 +.globl _do_reserved + .def _do_reserved; .scl 2; .type 32; .endef +_do_reserved: + subl $16, %esp + pushl 24(%esp) + pushl 24(%esp) + pushl $LC28 + call _die + addl $28, %esp + ret + .p2align 2,,3 +.globl _trap_init + .def _trap_init; .scl 2; .type 32; .endef +_trap_init: + pushl %ebp + pushl %edi + pushl %esi + pushl %ebx + movl $_divide_error, %edx + movl $524288, %eax +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt + movl %edx,_idt+4 +/NO_APP + movl $_debug, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+8 + movl %edx,_idt+12 +/NO_APP + movl $_nmi, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+16 + movl %edx,_idt+20 +/NO_APP + movl $_int3, %edx +/APP + movw %dx,%ax + movw $-4352,%dx + movl %eax,_idt+24 + movl %edx,_idt+28 +/NO_APP + movl $_overflow, %edx +/APP + movw %dx,%ax + movw $-4352,%dx + movl %eax,_idt+32 + movl %edx,_idt+36 +/NO_APP + movl $_bounds, %edx +/APP + movw %dx,%ax + movw $-4352,%dx + movl %eax,_idt+40 + movl %edx,_idt+44 +/NO_APP + movl $_invalid_op, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+48 + movl %edx,_idt+52 +/NO_APP + movl $_device_not_available, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+56 + movl %edx,_idt+60 +/NO_APP + movl $_double_fault, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+64 + movl %edx,_idt+68 +/NO_APP + movl $_coprocessor_segment_overrun, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+72 + movl %edx,_idt+76 +/NO_APP + movl $_invalid_TSS, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+80 + movl %edx,_idt+84 +/NO_APP + movl $_segment_not_present, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+88 + movl %edx,_idt+92 +/NO_APP + movl $_stack_segment, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+96 + movl %edx,_idt+100 +/NO_APP + movl $_general_protection, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+104 + movl %edx,_idt+108 +/NO_APP + movl $_page_fault, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+112 + movl %edx,_idt+116 +/NO_APP + movl $_reserved, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+120 + movl %edx,_idt+124 +/NO_APP + movl $_coprocessor_error, %edx +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+128 + movl %edx,_idt+132 +/NO_APP + movl $17, %edi + movl $_idt, %esi + movl $_idt+4, %ebx + movl $_reserved, %ecx + movl $524288, %ebp + .p2align 2,,3 +L42: + movl %ecx, %edx + movl %ebp, %eax +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,(%esi,%edi,8) + movl %edx,(%ebx,%edi,8) +/NO_APP + incl %edi + cmpl $47, %edi + jle L42 + movl $_irq13, %edx + movl $524288, %eax +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+360 + movl %edx,_idt+364 +/NO_APP + movl $33, %edx +/APP + inb %dx,%al + jmp 1f +1: jmp 1f +1: +/NO_APP + andl $251, %eax +/APP + outb %al,%dx + jmp 1f +1: jmp 1f +1: +/NO_APP + movl $161, %edx +/APP + inb %dx,%al + jmp 1f +1: jmp 1f +1: +/NO_APP + andl $223, %eax +/APP + outb %al,%dx +/NO_APP + movl $_parallel_interrupt, %edx + movl $524288, %eax +/APP + movw %dx,%ax + movw $-28928,%dx + movl %eax,_idt+312 + movl %edx,_idt+316 +/NO_APP + popl %ebx + popl %esi + popl %edi + popl %ebp + ret + .def _parallel_interrupt; .scl 2; .type 32; .endef + .def _irq13; .scl 2; .type 32; .endef + .def _coprocessor_error; .scl 2; .type 32; .endef + .def _reserved; .scl 2; .type 32; .endef + .def _page_fault; .scl 2; .type 32; .endef + .def _general_protection; .scl 2; .type 32; .endef + .def _stack_segment; .scl 2; .type 32; .endef + .def _segment_not_present; .scl 2; .type 32; .endef + .def _invalid_TSS; .scl 2; .type 32; .endef + .def _coprocessor_segment_overrun; .scl 2; .type 32; .endef + .def _double_fault; .scl 2; .type 32; .endef + .def _device_not_available; .scl 2; .type 32; .endef + .def _invalid_op; .scl 2; .type 32; .endef + .def _bounds; .scl 2; .type 32; .endef + .def _overflow; .scl 2; .type 32; .endef + .def _int3; .scl 2; .type 32; .endef + .def _nmi; .scl 2; .type 32; .endef + .def _debug; .scl 2; .type 32; .endef + .def _divide_error; .scl 2; .type 32; .endef + .def _do_exit; .scl 2; .type 32; .endef + .def _printk; .scl 2; .type 32; .endef diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/vsprintf.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/vsprintf.c new file mode 100644 index 0000000..ab70f23 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/vsprintf.c @@ -0,0 +1,235 @@ +/* + * linux/kernel/vsprintf.c + * + * (C) 1991 Linus Torvalds + */ + +/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ +/* + * Wirzenius wrote this portably, Torvalds fucked it up :-) + */ + +#include +#include + +/* we use this so that we can do without the ctype library */ +#define is_digit(c) ((c) >= '0' && (c) <= '9') + +static int skip_atoi(const char **s) +{ + int i=0; + + while (is_digit(**s)) + i = i*10 + *((*s)++) - '0'; + return i; +} + +#define ZEROPAD 1 /* pad with zero */ +#define SIGN 2 /* unsigned/signed long */ +#define PLUS 4 /* show plus */ +#define SPACE 8 /* space if plus */ +#define LEFT 16 /* left justified */ +#define SPECIAL 32 /* 0x */ +#define SMALL 64 /* use 'abcdef' instead of 'ABCDEF' */ + +#define do_div(n,base) ({ \ +int __res; \ +__asm__("divl %4":"=a" (n),"=d" (__res):"0" (n),"1" (0),"r" (base)); \ +__res; }) + +static char * number(char * str, int num, int base, int size, int precision + ,int type) +{ + char c,sign,tmp[36]; + const char *digits="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + int i; + + if (type&SMALL) digits="0123456789abcdefghijklmnopqrstuvwxyz"; + if (type&LEFT) type &= ~ZEROPAD; + if (base<2 || base>36) + return 0; + c = (type & ZEROPAD) ? '0' : ' ' ; + if (type&SIGN && num<0) { + sign='-'; + num = -num; + } else + sign=(type&PLUS) ? '+' : ((type&SPACE) ? ' ' : 0); + if (sign) size--; + if (type&SPECIAL) { + if (base==16) size -= 2; + else if (base==8) size--; + } + i=0; + if (num==0) + tmp[i++]='0'; + else while (num!=0) + tmp[i++]=digits[do_div(num,base)]; + if (i>precision) precision=i; + size -= precision; + if (!(type&(ZEROPAD+LEFT))) + while(size-->0) + *str++ = ' '; + if (sign) + *str++ = sign; + if (type&SPECIAL) { + if (base==8) + *str++ = '0'; + else if (base==16) { + *str++ = '0'; + *str++ = digits[33]; + } + } + if (!(type&LEFT)) + while(size-->0) + *str++ = c; + while(i0) + *str++ = tmp[i]; + while(size-->0) + *str++ = ' '; + return str; +} + +int vsprintf(char *buf, const char *fmt, va_list args) +{ + int len; + int i; + char * str; + char *s; + int *ip; + + int flags; /* flags to number() */ + + int field_width; /* width of output field */ + int precision; /* min. # of digits for integers; max + number of chars for from string */ + int qualifier; /* 'h', 'l', or 'L' for integer fields */ + + for (str=buf ; *fmt ; ++fmt) { + if (*fmt != '%') { + *str++ = *fmt; + continue; + } + + /* process flags */ + flags = 0; + repeat: + ++fmt; /* this also skips first '%' */ + switch (*fmt) { + case '-': flags |= LEFT; goto repeat; + case '+': flags |= PLUS; goto repeat; + case ' ': flags |= SPACE; goto repeat; + case '#': flags |= SPECIAL; goto repeat; + case '0': flags |= ZEROPAD; goto repeat; + } + + /* get field width */ + field_width = -1; + if (is_digit(*fmt)) + field_width = skip_atoi(&fmt); + else if (*fmt == '*') { + /* it's the next argument */ + field_width = va_arg(args, int); + if (field_width < 0) { + field_width = -field_width; + flags |= LEFT; + } + } + + /* get the precision */ + precision = -1; + if (*fmt == '.') { + ++fmt; + if (is_digit(*fmt)) + precision = skip_atoi(&fmt); + else if (*fmt == '*') { + /* it's the next argument */ + precision = va_arg(args, int); + } + if (precision < 0) + precision = 0; + } + + /* get the conversion qualifier */ + qualifier = -1; + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { + qualifier = *fmt; + ++fmt; + } + + switch (*fmt) { + case 'c': + if (!(flags & LEFT)) + while (--field_width > 0) + *str++ = ' '; + *str++ = (unsigned char) va_arg(args, int); + while (--field_width > 0) + *str++ = ' '; + break; + + case 's': + s = va_arg(args, char *); + len = strlen(s); + if (precision < 0) + precision = len; + else if (len > precision) + len = precision; + + if (!(flags & LEFT)) + while (len < field_width--) + *str++ = ' '; + for (i = 0; i < len; ++i) + *str++ = *s++; + while (len < field_width--) + *str++ = ' '; + break; + + case 'o': + str = number(str, va_arg(args, unsigned long), 8, + field_width, precision, flags); + break; + + case 'p': + if (field_width == -1) { + field_width = 8; + flags |= ZEROPAD; + } + str = number(str, + (unsigned long) va_arg(args, void *), 16, + field_width, precision, flags); + break; + + case 'x': + flags |= SMALL; + case 'X': + str = number(str, va_arg(args, unsigned long), 16, + field_width, precision, flags); + break; + + case 'd': + case 'i': + flags |= SIGN; + case 'u': + str = number(str, va_arg(args, unsigned long), 10, + field_width, precision, flags); + break; + + case 'n': + ip = va_arg(args, int *); + *ip = (str - buf); + break; + + default: + if (*fmt != '%') + *str++ = '%'; + if (*fmt) + *str++ = *fmt; + else + --fmt; + break; + } + } + *str = '\0'; + return str-buf; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/vsprintf.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/vsprintf.o new file mode 100644 index 0000000..c38e19a Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/kernel/vsprintf.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/Makefile new file mode 100644 index 0000000..8916215 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/Makefile @@ -0,0 +1,73 @@ +# +# Makefile for some libs needed in the kernel. +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (ie not a .c file). +# + +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =gcc -mcpu=i386 +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions -nostdinc -I../include +CPP =gcc -E -nostdinc -I../include + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(AS) -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = ctype.o _exit.o open.o close.o errno.o write.o dup.o setsid.o \ + execve.o wait.o string.o malloc.o + +lib.a: $(OBJS) + $(AR) rcs lib.a $(OBJS) + sync + +clean: + rm -f core *.o *.a tmp_make + for i in *.c;do rm -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: +_exit.s _exit.o : _exit.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h +close.s close.o : close.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h +ctype.s ctype.o : ctype.c ../include/ctype.h +dup.s dup.o : dup.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h +errno.s errno.o : errno.c +execve.s execve.o : execve.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h +malloc.s malloc.o : malloc.c ../include/linux/kernel.h ../include/linux/mm.h \ + ../include/asm/system.h +open.s open.o : open.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h ../include/stdarg.h +setsid.s setsid.o : setsid.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h +string.s string.o : string.c ../include/string.h +wait.s wait.o : wait.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h ../include/sys/wait.h +write.s write.o : write.c ../include/unistd.h ../include/sys/stat.h \ + ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \ + ../include/utime.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/_exit.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/_exit.c new file mode 100644 index 0000000..c0c9d69 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/_exit.c @@ -0,0 +1,13 @@ +/* + * linux/lib/_exit.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +volatile void _exit(int exit_code) +{ + __asm__("int $0x80"::"a" (__NR_exit),"b" (exit_code)); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/_exit.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/_exit.o new file mode 100644 index 0000000..898074f Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/_exit.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/close.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/close.c new file mode 100644 index 0000000..afd8364 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/close.c @@ -0,0 +1,10 @@ +/* + * linux/lib/close.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +_syscall1(int,close,int,fd) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/close.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/close.o new file mode 100644 index 0000000..cf11819 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/close.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/ctype.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/ctype.c new file mode 100644 index 0000000..877e629 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/ctype.c @@ -0,0 +1,35 @@ +/* + * linux/lib/ctype.c + * + * (C) 1991 Linus Torvalds + */ + +#include + +char _ctmp; +unsigned char _ctype[] = {0x00, /* EOF */ +_C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ +_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ +_C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ +_C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ +_S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ +_P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ +_D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ +_D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ +_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ +_U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ +_U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ +_U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ +_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ +_L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ +_L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ +_L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 160-175 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 176-191 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 192-207 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 208-223 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 224-239 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* 240-255 */ + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/ctype.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/ctype.o new file mode 100644 index 0000000..f27a816 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/ctype.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/dup.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/dup.c new file mode 100644 index 0000000..dd13414 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/dup.c @@ -0,0 +1,10 @@ +/* + * linux/lib/dup.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +_syscall1(int,dup,int,fd) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/dup.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/dup.o new file mode 100644 index 0000000..c0053eb Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/dup.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/errno.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/errno.c new file mode 100644 index 0000000..50aca2e --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/errno.c @@ -0,0 +1,7 @@ +/* + * linux/lib/errno.c + * + * (C) 1991 Linus Torvalds + */ + +int errno; diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/errno.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/errno.o new file mode 100644 index 0000000..be58c95 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/errno.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/execve.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/execve.c new file mode 100644 index 0000000..a89726d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/execve.c @@ -0,0 +1,10 @@ +/* + * linux/lib/execve.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +_syscall3(int,execve,const char *,file,char **,argv,char **,envp) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/execve.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/execve.o new file mode 100644 index 0000000..45e8690 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/execve.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/lib.a b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/lib.a new file mode 100644 index 0000000..e185198 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/lib.a differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/malloc.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/malloc.c new file mode 100644 index 0000000..d48ae06 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/malloc.c @@ -0,0 +1,232 @@ +/* + * malloc.c --- a general purpose kernel memory allocator for Linux. + * + * Written by Theodore Ts'o (tytso@mit.edu), 11/29/91 + * + * This routine is written to be as fast as possible, so that it + * can be called from the interrupt level. + * + * Limitations: maximum size of memory we can allocate using this routine + * is 4k, the size of a page in Linux. + * + * The general game plan is that each page (called a bucket) will only hold + * objects of a given size. When all of the object on a page are released, + * the page can be returned to the general free pool. When malloc() is + * called, it looks for the smallest bucket size which will fulfill its + * request, and allocate a piece of memory from that bucket pool. + * + * Each bucket has as its control block a bucket descriptor which keeps + * track of how many objects are in use on that page, and the free list + * for that page. Like the buckets themselves, bucket descriptors are + * stored on pages requested from get_free_page(). However, unlike buckets, + * pages devoted to bucket descriptor pages are never released back to the + * system. Fortunately, a system should probably only need 1 or 2 bucket + * descriptor pages, since a page can hold 256 bucket descriptors (which + * corresponds to 1 megabyte worth of bucket pages.) If the kernel is using + * that much allocated memory, it's probably doing something wrong. :-) + * + * Note: malloc() and free() both call get_free_page() and free_page() + * in sections of code where interrupts are turned off, to allow + * malloc() and free() to be safely called from an interrupt routine. + * (We will probably need this functionality when networking code, + * particularily things like NFS, is added to Linux.) However, this + * presumes that get_free_page() and free_page() are interrupt-level + * safe, which they may not be once paging is added. If this is the + * case, we will need to modify malloc() to keep a few unused pages + * "pre-allocated" so that it can safely draw upon those pages if + * it is called from an interrupt routine. + * + * Another concern is that get_free_page() should not sleep; if it + * does, the code is carefully ordered so as to avoid any race + * conditions. The catch is that if malloc() is called re-entrantly, + * there is a chance that unecessary pages will be grabbed from the + * system. Except for the pages for the bucket descriptor page, the + * extra pages will eventually get released back to the system, though, + * so it isn't all that bad. + */ + +#include +#include +#include + +struct bucket_desc { /* 16 bytes */ + void *page; + struct bucket_desc *next; + void *freeptr; + unsigned short refcnt; + unsigned short bucket_size; +}; + +struct _bucket_dir { /* 8 bytes */ + int size; + struct bucket_desc *chain; +}; + +/* + * The following is the where we store a pointer to the first bucket + * descriptor for a given size. + * + * If it turns out that the Linux kernel allocates a lot of objects of a + * specific size, then we may want to add that specific size to this list, + * since that will allow the memory to be allocated more efficiently. + * However, since an entire page must be dedicated to each specific size + * on this list, some amount of temperance must be exercised here. + * + * Note that this list *must* be kept in order. + */ +struct _bucket_dir bucket_dir[] = { + { 16, (struct bucket_desc *) 0}, + { 32, (struct bucket_desc *) 0}, + { 64, (struct bucket_desc *) 0}, + { 128, (struct bucket_desc *) 0}, + { 256, (struct bucket_desc *) 0}, + { 512, (struct bucket_desc *) 0}, + { 1024, (struct bucket_desc *) 0}, + { 2048, (struct bucket_desc *) 0}, + { 4096, (struct bucket_desc *) 0}, + { 0, (struct bucket_desc *) 0}}; /* End of list marker */ + +/* + * This contains a linked list of free bucket descriptor blocks + */ +struct bucket_desc *free_bucket_desc = (struct bucket_desc *) 0; + +/* + * This routine initializes a bucket description page. + */ +static inline void init_bucket_desc() +{ + struct bucket_desc *bdesc, *first; + int i; + + first = bdesc = (struct bucket_desc *) get_free_page(); + if (!bdesc) + panic("Out of memory in init_bucket_desc()"); + for (i = PAGE_SIZE/sizeof(struct bucket_desc); i > 1; i--) { + bdesc->next = bdesc+1; + bdesc++; + } + /* + * This is done last, to avoid race conditions in case + * get_free_page() sleeps and this routine gets called again.... + */ + bdesc->next = free_bucket_desc; + free_bucket_desc = first; +} + +void *malloc(unsigned int len) +{ + struct _bucket_dir *bdir; + struct bucket_desc *bdesc; + void *retval; + + /* + * First we search the bucket_dir to find the right bucket change + * for this request. + */ + for (bdir = bucket_dir; bdir->size; bdir++) + if (bdir->size >= len) + break; + if (!bdir->size) { + printk("malloc called with impossibly large argument (%d)\n", + len); + panic("malloc: bad arg"); + } + /* + * Now we search for a bucket descriptor which has free space + */ + cli(); /* Avoid race conditions */ + for (bdesc = bdir->chain; bdesc; bdesc = bdesc->next) + if (bdesc->freeptr) + break; + /* + * If we didn't find a bucket with free space, then we'll + * allocate a new one. + */ + if (!bdesc) { + char *cp; + int i; + + if (!free_bucket_desc) + init_bucket_desc(); + bdesc = free_bucket_desc; + free_bucket_desc = bdesc->next; + bdesc->refcnt = 0; + bdesc->bucket_size = bdir->size; + bdesc->page = bdesc->freeptr = (void *) cp = get_free_page(); + if (!cp) + panic("Out of memory in kernel malloc()"); + /* Set up the chain of free objects */ + for (i=PAGE_SIZE/bdir->size; i > 1; i--) { + *((char **) cp) = cp + bdir->size; + cp += bdir->size; + } + *((char **) cp) = 0; + bdesc->next = bdir->chain; /* OK, link it in! */ + bdir->chain = bdesc; + } + retval = (void *) bdesc->freeptr; + bdesc->freeptr = *((void **) retval); + bdesc->refcnt++; + sti(); /* OK, we're safe again */ + return(retval); +} + +/* + * Here is the free routine. If you know the size of the object that you + * are freeing, then free_s() will use that information to speed up the + * search for the bucket descriptor. + * + * We will #define a macro so that "free(x)" is becomes "free_s(x, 0)" + */ +void free_s(void *obj, int size) +{ + void *page; + struct _bucket_dir *bdir; + struct bucket_desc *bdesc, *prev; + bdesc = prev = 0; + /* Calculate what page this object lives in */ + page = (void *) ((unsigned long) obj & 0xfffff000); + /* Now search the buckets looking for that page */ + for (bdir = bucket_dir; bdir->size; bdir++) { + prev = 0; + /* If size is zero then this conditional is always false */ + if (bdir->size < size) + continue; + for (bdesc = bdir->chain; bdesc; bdesc = bdesc->next) { + if (bdesc->page == page) + goto found; + prev = bdesc; + } + } + panic("Bad address passed to kernel free_s()"); +found: + cli(); /* To avoid race conditions */ + *((void **)obj) = bdesc->freeptr; + bdesc->freeptr = obj; + bdesc->refcnt--; + if (bdesc->refcnt == 0) { + /* + * We need to make sure that prev is still accurate. It + * may not be, if someone rudely interrupted us.... + */ + if ((prev && (prev->next != bdesc)) || + (!prev && (bdir->chain != bdesc))) + for (prev = bdir->chain; prev; prev = prev->next) + if (prev->next == bdesc) + break; + if (prev) + prev->next = bdesc->next; + else { + if (bdir->chain != bdesc) + panic("malloc bucket chains corrupted"); + bdir->chain = bdesc->next; + } + free_page((unsigned long) bdesc->page); + bdesc->next = free_bucket_desc; + free_bucket_desc = bdesc; + } + sti(); + return; +} + diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/malloc.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/malloc.o new file mode 100644 index 0000000..9e92e7e Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/malloc.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/open.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/open.c new file mode 100644 index 0000000..8c3fc58 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/open.c @@ -0,0 +1,25 @@ +/* + * linux/lib/open.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include +#include + +int open(const char * filename, int flag, ...) +{ + register int res; + va_list arg; + + va_start(arg,flag); + __asm__("int $0x80" + :"=a" (res) + :"0" (__NR_open),"b" (filename),"c" (flag), + "d" (va_arg(arg,int))); + if (res>=0) + return res; + errno = -res; + return -1; +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/open.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/open.o new file mode 100644 index 0000000..1174a62 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/open.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/setsid.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/setsid.c new file mode 100644 index 0000000..68516c7 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/setsid.c @@ -0,0 +1,10 @@ +/* + * linux/lib/setsid.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +_syscall0(pid_t,setsid) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/setsid.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/setsid.o new file mode 100644 index 0000000..444632e Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/setsid.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/string.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/string.c new file mode 100644 index 0000000..1182e63 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/string.c @@ -0,0 +1,14 @@ +/* + * linux/lib/string.c + * + * (C) 1991 Linus Torvalds + */ + +#ifndef __GNUC__ +#error I want gcc! +#endif + +#define extern +#define inline +#define __LIBRARY__ +#include diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/string.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/string.o new file mode 100644 index 0000000..bb205d0 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/string.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/wait.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/wait.c new file mode 100644 index 0000000..2815c16 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/wait.c @@ -0,0 +1,16 @@ +/* + * linux/lib/wait.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include +#include + +_syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options) + +pid_t wait(int * wait_stat) +{ + return waitpid(-1,wait_stat,0); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/wait.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/wait.o new file mode 100644 index 0000000..488215c Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/wait.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/write.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/write.c new file mode 100644 index 0000000..df52e74 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/write.c @@ -0,0 +1,10 @@ +/* + * linux/lib/write.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include + +_syscall3(int,write,int,fd,const char *,buf,off_t,count) diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/write.o b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/write.o new file mode 100644 index 0000000..1569de1 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/lib/write.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/mm/Makefile b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/mm/Makefile new file mode 100644 index 0000000..d53d91d --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/mm/Makefile @@ -0,0 +1,38 @@ +CC =gcc -mcpu=i386 +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions -nostdinc -I../include +AS =as +AR =ar +LD =ld +CPP =gcc -E -nostdinc -I../include + +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< +.s.o: + $(AS) -o $*.o $< +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< + +OBJS = memory.o page.o + +all: mm.o + +mm.o: $(OBJS) + $(LD) -r -o mm.o $(OBJS) + +clean: + rm -f core *.o *.a tmp_make + for i in *.c;do rm -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: +memory.o: memory.c ../include/signal.h ../include/sys/types.h \ + ../include/asm/system.h ../include/linux/sched.h \ + ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \ + ../include/linux/kernel.h diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/mm/memory.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/mm/memory.c new file mode 100644 index 0000000..43f601b --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/mm/memory.c @@ -0,0 +1,431 @@ +/* + * linux/mm/memory.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * demand-loading started 01.12.91 - seems it is high on the list of + * things wanted, and it should be easy to implement. - Linus + */ + +/* + * Ok, demand-loading was easy, shared pages a little bit tricker. Shared + * pages started 02.12.91, seems to work. - Linus. + * + * Tested sharing by executing about 30 /bin/sh: under the old kernel it + * would have taken more than the 6M I have free, but it worked well as + * far as I could see. + * + * Also corrected some "invalidate()"s - I wasn't doing enough of them. + */ + +#include + +#include + +#include +#include +#include + +volatile void do_exit(long code); + +static inline volatile void oom(void) +{ + printk("out of memory\n\r"); + do_exit(SIGSEGV); +} + +#define invalidate() \ +__asm__("movl %%eax,%%cr3"::"a" (0)) + +/* these are not to be changed without changing head.s etc */ +#define LOW_MEM 0x100000 +#define PAGING_MEMORY (15*1024*1024) +#define PAGING_PAGES (PAGING_MEMORY>>12) +#define MAP_NR(addr) (((addr)-LOW_MEM)>>12) +#define USED 100 + +#define CODE_SPACE(addr) ((((addr)+4095)&~4095) < \ +current->start_code + current->end_code) + +static long HIGH_MEMORY = 0; + +#define copy_page(from,to) \ +__asm__("cld ; rep ; movsl"::"S" (from),"D" (to),"c" (1024)) + +static unsigned char mem_map [ PAGING_PAGES ] = {0,}; + +/* + * Get physical address of first (actually last :-) free page, and mark it + * used. If no free pages left, return 0. + */ +unsigned long get_free_page(void) +{ +register unsigned long __res asm("ax"); + +__asm__("std ; repne ; scasb\n\t" + "jne 1f\n\t" + "movb $1,1(%%edi)\n\t" + "sall $12,%%ecx\n\t" + "addl %2,%%ecx\n\t" + "movl %%ecx,%%edx\n\t" + "movl $1024,%%ecx\n\t" + "leal 4092(%%edx),%%edi\n\t" + "rep ; stosl\n\t" + "movl %%edx,%%eax\n" + "1:" + :"=a" (__res) + :"0" (0),"i" (LOW_MEM),"c" (PAGING_PAGES), + "D" (mem_map+PAGING_PAGES-1) + ); +return __res; +} + +/* + * Free a page of memory at physical address 'addr'. Used by + * 'free_page_tables()' + */ +void free_page(unsigned long addr) +{ + if (addr < LOW_MEM) return; + if (addr >= HIGH_MEMORY) + panic("trying to free nonexistent page"); + addr -= LOW_MEM; + addr >>= 12; + if (mem_map[addr]--) return; + mem_map[addr]=0; + panic("trying to free free page"); +} + +/* + * This function frees a continuos block of page tables, as needed + * by 'exit()'. As does copy_page_tables(), this handles only 4Mb blocks. + */ +int free_page_tables(unsigned long from,unsigned long size) +{ + unsigned long *pg_table; + unsigned long * dir, nr; + + if (from & 0x3fffff) + panic("free_page_tables called with wrong alignment"); + if (!from) + panic("Trying to free up swapper memory space"); + size = (size + 0x3fffff) >> 22; + dir = (unsigned long *) ((from>>20) & 0xffc); /* _pg_dir = 0 */ + for ( ; size-->0 ; dir++) { + if (!(1 & *dir)) + continue; + pg_table = (unsigned long *) (0xfffff000 & *dir); + for (nr=0 ; nr<1024 ; nr++) { + if (1 & *pg_table) + free_page(0xfffff000 & *pg_table); + *pg_table = 0; + pg_table++; + } + free_page(0xfffff000 & *dir); + *dir = 0; + } + invalidate(); + return 0; +} + +/* + * Well, here is one of the most complicated functions in mm. It + * copies a range of linerar addresses by copying only the pages. + * Let's hope this is bug-free, 'cause this one I don't want to debug :-) + * + * Note! We don't copy just any chunks of memory - addresses have to + * be divisible by 4Mb (one page-directory entry), as this makes the + * function easier. It's used only by fork anyway. + * + * NOTE 2!! When from==0 we are copying kernel space for the first + * fork(). Then we DONT want to copy a full page-directory entry, as + * that would lead to some serious memory waste - we just copy the + * first 160 pages - 640kB. Even that is more than we need, but it + * doesn't take any more memory - we don't copy-on-write in the low + * 1 Mb-range, so the pages can be shared with the kernel. Thus the + * special case for nr=xxxx. + */ +int copy_page_tables(unsigned long from,unsigned long to,long size) +{ + unsigned long * from_page_table; + unsigned long * to_page_table; + unsigned long this_page; + unsigned long * from_dir, * to_dir; + unsigned long nr; + + if ((from&0x3fffff) || (to&0x3fffff)) + panic("copy_page_tables called with wrong alignment"); + from_dir = (unsigned long *) ((from>>20) & 0xffc); /* _pg_dir = 0 */ + to_dir = (unsigned long *) ((to>>20) & 0xffc); + size = ((unsigned) (size+0x3fffff)) >> 22; + for( ; size-->0 ; from_dir++,to_dir++) { + if (1 & *to_dir) + panic("copy_page_tables: already exist"); + if (!(1 & *from_dir)) + continue; + from_page_table = (unsigned long *) (0xfffff000 & *from_dir); + if (!(to_page_table = (unsigned long *) get_free_page())) + return -1; /* Out of memory, see freeing */ + *to_dir = ((unsigned long) to_page_table) | 7; + nr = (from==0)?0xA0:1024; + for ( ; nr-- > 0 ; from_page_table++,to_page_table++) { + this_page = *from_page_table; + if (!(1 & this_page)) + continue; + this_page &= ~2; + *to_page_table = this_page; + if (this_page > LOW_MEM) { + *from_page_table = this_page; + this_page -= LOW_MEM; + this_page >>= 12; + mem_map[this_page]++; + } + } + } + invalidate(); + return 0; +} + +/* + * This function puts a page in memory at the wanted address. + * It returns the physical address of the page gotten, 0 if + * out of memory (either when trying to access page-table or + * page.) + */ +unsigned long put_page(unsigned long page,unsigned long address) +{ + unsigned long tmp, *page_table; + +/* NOTE !!! This uses the fact that _pg_dir=0 */ + + if (page < LOW_MEM || page >= HIGH_MEMORY) + printk("Trying to put page %p at %p\n",page,address); + if (mem_map[(page-LOW_MEM)>>12] != 1) + printk("mem_map disagrees with %p at %p\n",page,address); + page_table = (unsigned long *) ((address>>20) & 0xffc); + if ((*page_table)&1) + page_table = (unsigned long *) (0xfffff000 & *page_table); + else { + if (!(tmp=get_free_page())) + return 0; + *page_table = tmp|7; + page_table = (unsigned long *) tmp; + } + page_table[(address>>12) & 0x3ff] = page | 7; +/* no need for invalidate */ + return page; +} + +void un_wp_page(unsigned long * table_entry) +{ + unsigned long old_page,new_page; + + old_page = 0xfffff000 & *table_entry; + if (old_page >= LOW_MEM && mem_map[MAP_NR(old_page)]==1) { + *table_entry |= 2; + invalidate(); + return; + } + if (!(new_page=get_free_page())) + oom(); + if (old_page >= LOW_MEM) + mem_map[MAP_NR(old_page)]--; + *table_entry = new_page | 7; + invalidate(); + copy_page(old_page,new_page); +} + +/* + * This routine handles present pages, when users try to write + * to a shared page. It is done by copying the page to a new address + * and decrementing the shared-page counter for the old page. + * + * If it's in code space we exit with a segment error. + */ +void do_wp_page(unsigned long error_code,unsigned long address) +{ +#if 0 +/* we cannot do this yet: the estdio library writes to code space */ +/* stupid, stupid. I really want the libc.a from GNU */ + if (CODE_SPACE(address)) + do_exit(SIGSEGV); +#endif + un_wp_page((unsigned long *) + (((address>>10) & 0xffc) + (0xfffff000 & + *((unsigned long *) ((address>>20) &0xffc))))); + +} + +void write_verify(unsigned long address) +{ + unsigned long page; + + if (!( (page = *((unsigned long *) ((address>>20) & 0xffc)) )&1)) + return; + page &= 0xfffff000; + page += ((address>>10) & 0xffc); + if ((3 & *(unsigned long *) page) == 1) /* non-writeable, present */ + un_wp_page((unsigned long *) page); + return; +} + +void get_empty_page(unsigned long address) +{ + unsigned long tmp; + + if (!(tmp=get_free_page()) || !put_page(tmp,address)) { + free_page(tmp); /* 0 is ok - ignored */ + oom(); + } +} + +/* + * try_to_share() checks the page at address "address" in the task "p", + * to see if it exists, and if it is clean. If so, share it with the current + * task. + * + * NOTE! This assumes we have checked that p != current, and that they + * share the same executable. + */ +static int try_to_share(unsigned long address, struct task_struct * p) +{ + unsigned long from; + unsigned long to; + unsigned long from_page; + unsigned long to_page; + unsigned long phys_addr; + + from_page = to_page = ((address>>20) & 0xffc); + from_page += ((p->start_code>>20) & 0xffc); + to_page += ((current->start_code>>20) & 0xffc); +/* is there a page-directory at from? */ + from = *(unsigned long *) from_page; + if (!(from & 1)) + return 0; + from &= 0xfffff000; + from_page = from + ((address>>10) & 0xffc); + phys_addr = *(unsigned long *) from_page; +/* is the page clean and present? */ + if ((phys_addr & 0x41) != 0x01) + return 0; + phys_addr &= 0xfffff000; + if (phys_addr >= HIGH_MEMORY || phys_addr < LOW_MEM) + return 0; + to = *(unsigned long *) to_page; + if (!(to & 1)) { + if ((to = get_free_page())) + *(unsigned long *) to_page = to | 7; + else + oom(); + } + to &= 0xfffff000; + to_page = to + ((address>>10) & 0xffc); + if (1 & *(unsigned long *) to_page) + panic("try_to_share: to_page already exists"); +/* share them: write-protect */ + *(unsigned long *) from_page &= ~2; + *(unsigned long *) to_page = *(unsigned long *) from_page; + invalidate(); + phys_addr -= LOW_MEM; + phys_addr >>= 12; + mem_map[phys_addr]++; + return 1; +} + +/* + * share_page() tries to find a process that could share a page with + * the current one. Address is the address of the wanted page relative + * to the current data space. + * + * We first check if it is at all feasible by checking executable->i_count. + * It should be >1 if there are other tasks sharing this inode. + */ +static int share_page(unsigned long address) +{ + struct task_struct ** p; + + if (!current->executable) + return 0; + if (current->executable->i_count < 2) + return 0; + for (p = &LAST_TASK ; p > &FIRST_TASK ; --p) { + if (!*p) + continue; + if (current == *p) + continue; + if ((*p)->executable != current->executable) + continue; + if (try_to_share(address,*p)) + return 1; + } + return 0; +} + +void do_no_page(unsigned long error_code,unsigned long address) +{ + int nr[4]; + unsigned long tmp; + unsigned long page; + int block,i; + + address &= 0xfffff000; + tmp = address - current->start_code; + if (!current->executable || tmp >= current->end_data) { + get_empty_page(address); + return; + } + if (share_page(tmp)) + return; + if (!(page = get_free_page())) + oom(); +/* remember that 1 block is used for header */ + block = 1 + tmp/BLOCK_SIZE; + for (i=0 ; i<4 ; block++,i++) + nr[i] = bmap(current->executable,block); + bread_page(page,current->executable->i_dev,nr); + i = tmp + 4096 - current->end_data; + tmp = page + 4096; + while (i-- > 0) { + tmp--; + *(char *)tmp = 0; + } + if (put_page(page,address)) + return; + free_page(page); + oom(); +} + +void mem_init(long start_mem, long end_mem) +{ + int i; + + HIGH_MEMORY = end_mem; + for (i=0 ; i>= 12; + while (end_mem-->0) + mem_map[i++]=0; +} + +void calc_mem(void) +{ + int i,j,k,free=0; + long * pg_tbl; + + for(i=0 ; i +#include +#include +#include + +void ShowError(LPTSTR lpszFunction) +{ + // Retrieve the system error message for the last-error code + + LPVOID lpMsgBuf; + LPVOID lpDisplayBuf; + DWORD dw = GetLastError(); + + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + dw, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &lpMsgBuf, + 0, NULL ); + + // Display the error message and exit the process + + lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, + (lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR)); + StringCchPrintf((LPTSTR)lpDisplayBuf, + LocalSize(lpDisplayBuf) / sizeof(TCHAR), + TEXT("%s failed with error %d: %s"), + lpszFunction, dw, lpMsgBuf); + + char strAnsi[128]; + int len =WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)lpDisplayBuf, -1, strAnsi, 128,NULL,NULL); + printf("%s ",strAnsi); + + LocalFree(lpMsgBuf); + LocalFree(lpDisplayBuf); +} +void *base; +bool mapExeToMemory(LPCWSTR exeFile) +{ + HANDLE hFile, hMapping; + hFile = CreateFile(exeFile, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE, + 0, + OPEN_EXISTING, + FILE_FLAG_SEQUENTIAL_SCAN, 0); + if(INVALID_HANDLE_VALUE == hFile ) + { + ShowError(L"CreateFile!"); + return false; + } + hMapping = CreateFileMapping(hFile, 0, PAGE_READONLY | SEC_COMMIT, 0, 0, 0); + if(NULL == hMapping) + { + ShowError(L"CreateFileMapping"); + CloseHandle(hFile); + return false; + } + base = MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0); + if(NULL == base ) + { + ShowError(L"MapViewOfFile"); + CloseHandle(hMapping); + CloseHandle(hFile); + return false; + } + CloseHandle(hMapping); + CloseHandle(hFile); + return true; +} +bool TranslateFile(LPCWSTR exeFile,LPCWSTR outFile) +{ + CFile *file; + if(!mapExeToMemory(exeFile)) + { + return false; + } + + PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)base; + + PIMAGE_NT_HEADERS ntHeader = (PIMAGE_NT_HEADERS)((DWORD_PTR)base+dosHeader->e_lfanew); + + DWORD sectionNumber = ntHeader->FileHeader.NumberOfSections; + try + { + file = new CFile(outFile,CFile::typeBinary | CFile::modeWrite | CFile::modeCreate ); + } + catch(CFileException ex) + { + ex.ReportError(); + return false; + } + + try + { + int vSize = 0; + + PIMAGE_SECTION_HEADER sectionHeader=IMAGE_FIRST_SECTION(ntHeader); + + for(int i=0;iSetLength(vSize); + + file->SeekToBegin(); + + char c = 0; + + for(int i=0;iWrite(&c,1); + } + + file->SeekToBegin(); + + for(int i=0;iSeek(virtualAddress,CFile::begin); + + file->Write((char*)base+RawOffset,sizeOfRawData); + } + } + catch(CFileException ex) + { + ex.ReportError(); + file->Close(); + return false; + } + file->Close(); + return true; +} +int _tmain(int argc,LPCWSTR argv[]) +{ + if(3 != argc) + { + puts("usage: Trans exeFile binFileName"); + } + TranslateFile(argv[1],argv[2]); + UnmapViewOfFile(base); + return 0; +} \ No newline at end of file diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/build.c b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/build.c new file mode 100644 index 0000000..81461b4 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/build.c @@ -0,0 +1,244 @@ +/* + * linux/tools/build.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * This file builds a disk-image from three different files: + * + * - bootsect: max 510 bytes of 8086 machine code, loads the rest + * - setup: max 4 sectors of 8086 machine code, sets up system parm + * - system: 80386 code for actual system + * + * It does some checking that all files are of the correct type, and + * just writes the result to stdout, removing headers and padding to + * the right amount. It also writes some system data to stderr. + */ + +/* + * Changes by tytso to allow root device specification + */ + +#include /* fprintf */ +#include +#include /* contains exit */ +#include /* unistd.h needs this */ +#include +//#include +#include /* contains read/write */ +#include + +#define MINIX_HEADER 32 +#define GCC_HEADER 1024 + +#define SYS_SIZE 0x3000 + +#define DEFAULT_MAJOR_ROOT 2 +#define DEFAULT_MINOR_ROOT 0x1d + +/* max nr of sectors of setup: don't change unless you also change + * bootsect etc */ +#define SETUP_SECTS 4 + +#define STRINGIFY(x) #x + +#define MAJOR(a) (((unsigned)(a))>>8) +#define MINOR(a) ((a)&0xff) + +void die(char * str) +{ + fprintf(stderr,"%s\n",str); + exit(1); +} + +void usage(void) +{ + die("Usage: build bootsect setup system [rootdev] [> image]"); +} + +int main(int argc, char ** argv) +{ + int i,c,id; + char buf[1024]; + char major_root, minor_root; + struct stat sb; + int size=512+4*512; + FILE* imageFile = fopen("Boot.img","wb"); + + if ((argc != 4) && (argc != 5)) + usage(); + if (argc == 5) { + if (strcmp(argv[4], "FLOPPY")) { + if (stat(argv[4], &sb)) { + perror(argv[4]); + die("Couldn't stat root device."); + } + major_root = MAJOR(sb.st_rdev); + minor_root = MINOR(sb.st_rdev); + } else { + major_root = 0; + minor_root = 0; + } + } else { + major_root = DEFAULT_MAJOR_ROOT; + minor_root = DEFAULT_MINOR_ROOT; + } + fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root); + if ((major_root != 2) && (major_root != 3) && + (major_root != 0)) { + fprintf(stderr, "Illegal root device (major = %d)\n", + major_root); + die("Bad root device --- major #"); + } + + + for (i=0;i0 ; i+=c ) + if (write(1,buf,c)!=c) + die("Write call failed"); + close (id); + */ + for (i=0 ; (c=read(id,buf,sizeof buf))>0 ; i+=c ) + { + if (fwrite(buf,1,c,imageFile)!=c) + { + die("Write call failed"); + } + } + close (id); + + if (i > SETUP_SECTS*512) + { + die("Setup exceeds " STRINGIFY(SETUP_SECTS)" sectors - rewrite build/boot/setup"); + } + fprintf(stderr,"Setup is %d bytes.\n",i); + for (c=0 ; c sizeof(buf)) + { + c = sizeof(buf); + } +// if (write(1,buf,c) != c) + if( c != fwrite(buf,1,c,imageFile) ) + { + die("Write call failed"); + } + i += c; + } + + if ( (id=open(argv[3],O_RDONLY|O_BINARY,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'"); + for (i=0 ; (c=read(id,buf,sizeof buf))>0 ; i+=c ) + { + if (fwrite(buf,1,c,imageFile)!= c) + die("Write call failed"); + } + close(id); + size+=i; + fprintf(stderr,"System is %d bytes.\n",i); + if (i > SYS_SIZE*16) + die("System is too big"); + memset(buf,0,sizeof(buf)); + + fprintf(stderr,"total size is %d bytes.\n",1440*1024); + + //1475084 + //1474560 + while(size<1440*1024) + { + c = 1440*1024 - size; + if( c > sizeof(buf) ) + { + c = sizeof(buf); + } + c = fwrite(buf,1,c,imageFile); + size+=c; + } + + fclose(imageFile); + return(0); +} diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/build.exe b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/build.exe new file mode 100644 index 0000000..d6dacf2 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/build.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/data.bin b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/data.bin new file mode 100644 index 0000000..40a3ddf Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/data.bin differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/system.bin b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/system.bin new file mode 100644 index 0000000..af5a693 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/system.bin differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/system.exe b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/system.exe new file mode 100644 index 0000000..411e29c Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/system.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/trans.exe b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/trans.exe new file mode 100644 index 0000000..74daf94 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/Linux-0.11/tools/trans.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/MinGW32.bat b/一些非必要的资料/linux-0.11-quickstart/MinGW32/MinGW32.bat new file mode 100644 index 0000000..eaf07cf --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/MinGW32/MinGW32.bat @@ -0,0 +1 @@ +@SET PATH=..\MinGW32\bin;..\..\MinGW32\bin;..\..\..\MinGW32\bin;%PATH% \ No newline at end of file diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/COPYING b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/COPYING new file mode 100644 index 0000000..5ab7695 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/COPYING @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/a2dll b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/a2dll new file mode 100644 index 0000000..eb7be60 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/a2dll @@ -0,0 +1,104 @@ +#!/bin/sh + +# This is a2dll 1.0 +# (c)1999-2000 Paul Sokolovsky +# a2dll is distrubuted under GNU General Public License, see http://www.gnu.org + + +usage() { + echo 'a2dll 1.0: convert static library into win32 dll' + echo ' by ' + echo 'Usage: a2dll [-o ] [linker commands:-L,-l,-s] [--relink]' + exit 0 +} + + +cmdline=$@ + +while test $# -ge 1 +do +case "$1" in + -\? | -h* | --h*) usage;; + -o ) out="$2"; shift; shift;; + --relink) relink=1; shift;; + -* ) libs="$libs $1"; shift;; + *) in=$1; shift;; + esac +done + +if [ "$in" = "" ] +then + usage +fi + +base=`basename $in .a` + +if [ "$out" = "" ] +then + out=`awk -v n=$base 'BEGIN {print substr(n,4); exit;}'`.dll +fi + +if [ "$relink" != "1" ] +then + rm -f .dll/* + /usr/bin/mkdir -p .dll + cd .dll + ar x ../$in +else + cd .dll +fi + +echo Creating shared library \'$out\' + +dllwrap --export-all -o ../$out `ls` $libs >../ld.err 2>&1 + +cd .. +if [ `wc ld.err|awk ' {print $1}' ` -gt 2 ] +then + echo Linking error, consult file \'ld.err\', correct errors, and run + echo \'$0 $cmdline --relink\' + exit 1 +else +# cleanup + + rm -f ld.err + rm -f .dll/* + /usr/bin/rmdir .dll + +# create .def +# we use pexports on dll instead of dlltool on objects for this, +# because it's: +# 1. faster +# 2. I just saw that dlltool lies about assembly-sourced files, it +# lists their symbols as data + + pexports $out >$base.def + +# create import library + + mv $in $in.static + dlltool --dllname $out --def $base.def --output-lib $in + +# finally, we check whether dll exports data symbols +# if yes, we suggest user on steps to perform + + pexports $out | awk '/DATA/ { print $1}' >$out.data + if test -s $out.data + then + echo + echo Shared library exports data symbols, they are listed \ +in \'$out.data\'. For using them in client application, you should mark \ +them as __declspec\(dllimport\) in library headers. You can quickly \ +find places where these data symbols declared by issuing + echo + echo " grep -f $out.data *.h" + echo + echo in library header directory. Also note that this step is optional, you can postpone \ +it until you\'ll get during linking unresolved symbol _imp__\, where \ +\ is one of the symbols listed in $out.data. Read documentation \ +\(static2dll_howto.txt\) for more information. + else + rm $out.data + fi + rm $base.def +fi diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/ar.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/ar.exe new file mode 100644 index 0000000..ce93b2b Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/ar.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/as.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/as.exe new file mode 100644 index 0000000..6f093e6 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/as.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/dsw2mak b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/dsw2mak new file mode 100644 index 0000000..4ca66e3 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/dsw2mak @@ -0,0 +1,976 @@ +#!gawk -f +# dsw2mak.awk +# +# An Awk script that generates a unix Makefile from a +# Microsoft Developer Studio workspace file. +# +# Copyright (C) 2001 Jos Fonseca +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License, http://www.gnu.org/copyleft/gpl.html +# for more details. +# +# Jos Fonseca +# +# Features: +# - generation of GUI applications (including resource files), +# DLLs, console applications and static libraries +# - translations of the most common compiler and linker options +# - conversion of workspace files (.dsw) and all associated +# projects files (.dsp) generating all necessary Makefiles +# - handling of nested !IF, !ELSEIF and !ENDIF maintaining the +# same build configurations as the original project +# - automatic generation of the dependencies +# +# Example: +# gawk -f dsw2mak.awk MyApp.dsw +# +# Notes: +# - Make sure that both this script and the input files are in +# a line ending convention that gawk version in your system +# can handle. +# - If an option is not handled by this script don't edit all +# generate Makefiles by hand. Add support for the option in +# this script and submit your additions to the author. +# +# Changelog (incomplete): +# 2001-02-18: Jos Fonseca +# Improved linker libraries and options handling. +# Debug output. +# Better handling of custom builds +# +# 2001-02-15: Jos Fonseca +# Improved C compiler options handling. +# More verbose warning output. +# +# 2001-02-14: Jos Fonseca +# Added comments to the source code. +# + + +# check and remove unnecessary quotes from a string +function fixquotes(str) { + if(str ~ /^"[^[:blank:]]+"$/) { + sub(/^"/, "", str); + sub(/"$/, "", str); + } + + return str +} + +# fixes a path string +function fixpath(path) { + # remove leading and trainling whitespaces + sub(/^[[:blank:]]+/, "", path); + sub(/[[:blank:]]+$/, "", path); + + # check and remove unnecessary quotes + path = fixquotes(path) + + # change the forward slashes to backslashes + gsub(/\\/, "/", path) + + # remove reduntant ./ directories + gsub(/^(\.\/)+/, "", path) + gsub(/^\/(\.\/)+/, "", path) + + return path +} + +# get the base directory from a path +function basedir(path) { + # remove leading and trainling whitespaces + sub(/^[[:blank:]]+/, "", path); + sub(/[[:blank:]]+$/, "", path); + + # remove the quotes + if(path ~ /^".+"$/) { + sub(/^"/, "", path); + sub(/"$/, "", path); + } + + # remove the leading path + sub(/(^|[\/\\:])[^\/\\:]*$/, "", path) + + # add quotes if needed + if(path ~ /[[:blank:]]/) + path = "\"" path "\"" + + return path +} + +# get the filename from a path +function basefile(path) { + # remove leading and trainling whitespaces + sub(/^[[:blank:]]+/, "", path); + sub(/[[:blank:]]+$/, "", path); + + # remove the quotes + if(path ~ /^".+"$/) { + sub(/^"/, "", path); + sub(/"$/, "", path); + } + + # remove the trailing path + sub(/^.*[\/\\:]/, "", path) + + # add quotes if needed + if(path ~ /[[:blank:]]/) + path = "\"" path "\"" + + return path +} + +# skip lines until matching a given regular expression +# NOTE: not used but it could be eventually handy +function skip(regexp, infile, ret) { + while((ret = getline < infile) == 1 && $0 !~ regexp) {} + + return ret +} + +# parses a project file (.dsp) specified by 'infile' and generates a makefile to 'outfile' +function parse_dsp(infile, outfile, i) { + print infile + + # this specifies verbose debug output + debug = 0 + + # this specifies a prefix to the binutils and gcc binaries + #prefix = "mingw32-" + prefix = "" + + # this specifies the name of the 'rm -f' or equivalent command + rm = "rm -f" + + # check for a bad file + if((getline < infile) == -1) { + print infile ": " ERRNO + return + } + + # Strip DOS line-endings + gsub(/\r$/, "") + + # count the number of lines + inline = 1 + + # print the Makefile header + print "# Makefile - " basefile(infile) > outfile + print "" > outfile + + # this specifies the default name for the dependencies file + dependencies = ".dependencies" + + # attemp to get the project name + if(/^# Microsoft Developer Studio Project File/) { + name = gensub(/^# Microsoft Developer Studio Project File - Name="(.*)".*$/, "\\1", "1") + dependencies = name ".dep" + } + + # main loop + while((getline < infile) == 1) { + # Strip DOS line-endings + gsub(/\r$/, "") + + # increment the number of lines + inline = inline + 1 + + # catch the target type definition + if(/^# TARGTYPE/) { + if (/[[:space:]]0x0101$/) { + # Win32 (x86) Application + exeflag = 1 + dllflag = 0 + libflag = 0 + } + if (/[[:space:]]0x0102$/) { + # Win32 (x86) Dynamic-Link Library + exeflag = 0 + dllflag = 1 + libflag = 0 + } + if (/[[:space:]]0x0103$/) { + # Win32 (x86) Console Application + exeflag = 1 + dllflag = 0 + libflag = 0 + } + if (/[[:space:]]0x0104$/) { + # Win32 (x86) Static Library + exeflag = 0 + dllflag = 0 + libflag = 1 + } + continue + } + + # catch the default configuration definition + if(/^CFG=/) { + print "ifndef CFG" > outfile + print > outfile + print "endif" > outfile + } + + # deal with the preprocessor commands + if(/^!/) { + # as GNU make doesn't have the '!ELSEIF' equivalent we have to use nested 'if ... else .. endif' to obtain the same effect + # a stack is used to keep track of the current nested level + + if(/^!IF/) { + $0 = gensub(/^!IF[[:space:]]+(.+)[[:space:]]*==[[:space:]]*(.+)$/, "ifeq \\1 \\2", "1") + $0 = gensub(/^!IF[[:space:]]+(.+)[[:space:]]*!=[[:space:]]*(.+)$/, "ifneq \\1 \\2", "1") + print > outfile + stacktop += 1 + stack[stacktop] = 1 + continue + } + if(/^!ELSE$/) { + print "else" + } + if(/^!ELSEIF/) { + $0 = gensub(/^!ELSEIF[[:space:]]+(.+)[[:space:]]*==[[:space:]]*(.+)$/, "else\nifeq \\1 \\2", "1") + $0 = gensub(/^!ELSEIF[[:space:]]+(.+)[[:space:]]*!=[[:space:]]*(.+)$/, "else\nifneq \\1 \\2", "1") + print > outfile + stack[stacktop] += 1 + continue + } + if(/^!ENDIF[[:space:]]*$/) { + for (i = 0; i < stack[stacktop]; i++) + print "endif" > outfile + stacktop -= 1 + continue + } + } + + # catch the C++ compiler definition + if(/^CPP=/) { + print "CC=" prefix "gcc" > outfile + print "CFLAGS=" > outfile + print "CXX=" prefix "g++" > outfile + print "CXXFLAGS=$(CFLAGS)" > outfile + + continue + } + + # catch the C++ compiler flags + if(/^# ADD CPP /) { + if (debug) + print infile ":" inline ": " $0 + + # extract the flags from the line + cflags = $0 + sub(/^# ADD CPP /, "", cflags) + + split(" " cflags, options, /[[:space:]]+\//) + + cflags = "" + for(i in options) { + option = options[i] + + # translate the options + # some of the translations effectively remove the option (and its arguments) since there is no translation equivalent + + if (option == "") { + } else if(option ~ /^nologo$/) { + # Suppress Startup Banner and Information Messages + option = "" + } else if (option ~ /^W0$/) { + # Turns off all warning messages + option = "-w" + } else if (option ~ /^W[123]$/) { + # Warning Level + option = "-W" + } else if (option ~ /^W4$/) { + # Warning Level + option = "-Wall" + } else if (option ~ /^WX$/) { + # Warnings As Errors + option = "-Werror" + } else if (option ~ /^Gm$/) { + # Enable Minimal Rebuild + option = "" + } else if (option ~ /^GX$/) { + # Enable Exception Handling + option = "-fexceptions" + } else if (option ~ /^Z[d7iI]$/) { + # Debug Info + option = "-g" + } else if (option ~ /^Od$/) { + # Disable Optimizations + option = "-O0" + } else if (option ~ /^O1$/) { + # Minimize Size + option = "-Os" + } else if (option ~ /^O2$/) { + # Maximize Speed + option = "-O2" + } else if (option ~ /^Ob0$/) { + # Disables inline Expansion + option = "-fno-inline" + } else if (option ~ /^Ob1$/) { + # In-line Function Expansion + option = "" + } else if (option ~ /^Ob2$/) { + # auto In-line Function Expansion + option = "-finline-functions" + } else if (option ~ /^Oy$/) { + # Frame-Pointer Omission + option = "-fomit-frame-pointer" + } else if (option ~ /^GZ$/) { + # Catch Release-Build Errors in Debug Build + option = "" + } else if (option ~ /^M[DLT]d?$/) { + # Use Multithreaded Run-Time Library + option = "" + } else if (option ~ /^D/) { + # Preprocessor Definitions + gsub(/^D[[:space:]]*/, "", option) + option = "-D" fixquotes(option) + } else if (option ~ /^I/) { + # Additional Include Directories + gsub(/^I[[:space:]]*/, "", option) + option = "-I" fixpath(option) + } else if (option ~ /^U/) { + # Undefines a previously defined symbol + gsub(/^U[[:space:]]*/, "", option) + option = "-U" fixquotes(option) + } else if (option ~ /^Fp/) { + # Name .PCH File + option = "" + } else if (option ~ /^F[Rr]/) { + # Create .SBR File + option = "" + } else if (option ~ /^YX$/) { + # Automatic Use of Precompiled Headers + option = "" + } else if (option ~ /^FD$/) { + # Generate File Dependencies + option = "" + } else if (option ~ /^c$/) { + # Compile Without Linking + # this option is always present and is already specified in the suffix rules + option = "" + } else if (option ~ /^GB$/) { + # Blend Optimization + option = "-mcpu=pentiumpro -D_M_IX86=500" + } else if (option ~ /^G6$/) { + # Pentium Pro Optimization + option = "-march=pentiumpro -D_M_IX86=600" + } else if (option ~ /^G5$/) { + # Pentium Optimization + option = "-mcpu=pentium -D_M_IX86=500" + } else if (option ~ /^G3$/) { + # 80386 Optimization + option = "-mcpu=i386 -D_M_IX86=300" + } else if (option ~ /^G4$/) { + # 80486 Optimization + option = "-mcpu=i486 -D_M_IX86=400" + } else if (option ~ /^Yc/) { + # Create Precompiled Header + option = "" + } else if (option ~ /^Yu/) { + # Use Precompiled Header + option = "" + } else if (option ~ /^Za$/) { + # Disable Language Extensions + option = "-ansi" + } else if (option ~ /^Ze$/) { + # Enable Microsoft Extensions + print infile ":" inline ": /" option ": Enable Microsoft Extensions option ignored" > "/dev/stderr" + option = "" + } else if (option ~ /^Zm[[:digit:]]+$/) { + # Specify Memory Allocation Limit + option = "" + } else if (option ~ /^Zp1$/) { + # Packs structures on 1-byte boundaries + option = "-fpack-struct" + } else if (option ~ /^Zp(2|4|8|16)?$/) { + # Struct Member Alignment + option = "" + print infile ":" inline ": /" option ": Struct Member Alignment option ignored" > "/dev/stderr" + } else { + print infile ":" inline ": /" option ": C compiler option not implemented" > "/dev/stderr" + option = "" + } + + if (option != "") { + if(cflags == "") + cflags = option + else + cflags = cflags " " option + } + + } + + # change the slashes + gsub(/\\/, "/", cflags) + + print "CFLAGS+=" cflags > outfile + + if (debug) + print outfile ": " "CFLAGS+=" cflags + + continue + } + + # catch the linker definition + if(/^LINK32=/) { + if (exeflag) + print "LD=$(CXX) $(CXXFLAGS)" > outfile + if (dllflag) + print "LD=" prefix "dllwrap" > outfile + + print "LDFLAGS=" > outfile + + continue + } + + # catch the linker flags + if(/^# ADD LINK32 /) { + if (debug) + print infile ":" inline ": " $0 + + # extract the flags from the line + ldflags = $0 + sub(/^# ADD LINK32 /, "", ldflags) + + split(ldflags, options, /[[:space:]]+\//) + + # attempts to get the used libraries to a seperate variable + libs = options[1] + libs = gensub(/([[:alnum:]/\\_-]+)\.lib/, "-l\\1", "g", libs) + delete options[1] + + ldflags = "" + for(i in options) { + option = options[i] + + # translate the options + # some of the translations effectively remove the option (and its arguments) since there is no translation equivalent + if (option == "") { + } else if (option ~ /^base:/) { + # Base Address + gsub(/^base:/, "--image-base ", option) + } else if (option ~ /^debug$/) { + # Generate Debug Info + option = "" + } else if (option ~ /^dll$/) { + # Build a DLL + dllflag = 1 + + # remove this option since the DLL output option is handled by the suffix rules + option = "" + } else if (option ~ /^incremental:[[:alpha:]]+$/) { + # Link Incrmentally + option = "" + } else if (option ~ /^implib:/) { + # Name import library + gsub(/^implib:/, "", option) + option = "--implib " fixpath(gensub(/([[:alnum:]_-]+)\.lib/, "lib\\1.a", "g", option)) + } else if (option ~ /^libpath:/) { + # Additional Libpath + gsub(/^libpath:/, "", option) + option = "-L" fixpath(option) + } else if (option ~ /^machine:[[:alnum:]]+$/) { + # Specify Target Platform + option = "" + } else if (option ~ /^map/) { + # Generate Mapfile + if (option ~ /^map:/) + gsub(/^map:/, "-Map ", option) + else + option = "-Map " name ".map" + } else if(option ~ /^nologo$/) { + # Suppress Startup Banner and Information Messages + option = "" + } else if (option ~ /^out:/) { + # Output File Name + target = fixpath(gensub(/out:("[^"]+"|[^[:space:]]+).*$/, "\\1", "1", option)) + + print "TARGET=" target > outfile + + # remove this option since the output option is handled by the suffix rules + option = "" + } else if (option ~ /^pdbtype:/) { + # Program Database Storage + option = "" + } else if (option ~ /^subsystem:/) { + # Specify Subsystem + gsub(/^subsystem:/, "-Wl,--subsystem,", option) + } else if (option ~ /^version:[[:digit:].]+$/) { + # Version Information + option = "" + } else { + print infile ":" inline ": /" option ": linker option not implemented" > "/dev/stderr" + option = "" + } + + if (option != "") { + if(ldflags == "") + ldflags = option + else + ldflags = ldflags " " option + } + + } + + # attempt to get the name of the target from the '/out:' option + if (ldflags ~ /\/out:/) { # Output File Name + } + + # change the slashes + gsub(/\\/, "/", ldflags) + + print "LDFLAGS+=" ldflags > outfile + print "LIBS+=" libs > outfile + + if (debug) { + print outfile ": " "LDFLAGS+=" ldflags + print outfile ": " "LIBS+=" libs + } + + continue + } + + # catch the library archiver definition + if(/^LIB32=/) { + libflag = 1 + + print "AR=" prefix "ar" > outfile + + continue + } + + # catch the library archiver flags + if(/^# ADD LIB32 /) { + # extract the flags from the line + arflags = $0 + sub(/^# ADD LIB32 /, "", arflags) + + # translate the options + gsub(/\/nologo[[:space:]]*/, "", arflags) # Suppress Startup Banner and Information Messages + gsub(/\/machine:[[:alnum:]]+[[:space:]]*/, "", arflags) # Specify Target Platform + + # attempt to get the name of the target from the '/out:' option + if (arflags ~ /\/out:/) { + target = fixpath(gensub(/^.*\/out:(".*"|[^[:space:]]+).*$/, "\\1", "1", arflags)) + target = basedir(target) "/lib" basefile(gensub(/(\.[^.]*)?$/, ".a", 1, target)) + + print "TARGET=" target > outfile + + # remove this option since the output option is handled differentely + sub(/\/out:(".*"|[^[:space:]]+)/, "", arflags) + } + + # change the slashes + gsub(/\\/, "/", arflags) + + print "ARFLAGS=rus" > outfile + + continue + } + + # catch the resource compiler definition + if(/^RSC=/) { + print "RC=" prefix "windres -O COFF" > outfile + continue + } + + # handle the begin of the target definition + if(/^# Begin Target$/) { + print "" > outfile + + # print the default target name definition + print "ifndef TARGET" > outfile + if(exeflag) + print "TARGET=" name ".exe" > outfile + if(dllflag) + print "TARGET=" name ".dll" > outfile + if(libflag) + print "TARGET=lib" name ".a" > outfile + print "endif" > outfile + print "" > outfile + + # print the default target and the suffix rules + print ".PHONY: all" > outfile + print "all: $(TARGET)" > outfile + print "" > outfile + print "%.o: %.c" > outfile + print "\t$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<" > outfile + print "" > outfile + print "%.o: %.cc" > outfile + print "\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<" > outfile + print "" > outfile + print "%.o: %.cpp" > outfile + print "\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<" > outfile + print "" > outfile + print "%.o: %.cxx" > outfile + print "\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<" > outfile + print "" > outfile + print "%.res: %.rc" > outfile + print "\t$(RC) $(CPPFLAGS) -o $@ -i $<" > outfile + print "" > outfile + + # initialize some bookeeping variables + ngroups = 0 # number of groups in the target + nsources = 0 # number of isolated sources in the target + groupflag = 0 # state variable that indicates if we are inside or outside of a group definition + + continue + } + + # handle the end of a target definition + if(/^# End Target$/) { + # print the sources files definition that includes... + printf "SRCS=" > outfile + + # ... the sources groups variables... + for (i = 0; i < ngroups; i++) + printf "$(%s) ", groups[i] > outfile + + # ... and isolated sources not included in any group + if (nsources) { + print " \\" > outfile + for (i = 0; i < nsources - 1; i++) + print "\t" sources[i] " \\" > outfile + print "\t" sources[i] > outfile + } + else + print "" > outfile + print "" > outfile + + # define the objects automatically from the sources in the Makefile + print "OBJS=$(patsubst %.rc,%.res,$(patsubst %.cxx,%.o,$(patsubst %.cpp,%.o,$(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(filter %.c %.cc %.cpp %.cxx %.rc,$(SRCS)))))))" > outfile + print "" > outfile + + # print the target rule, according with the type of target + print "$(TARGET): $(OBJS)" > outfile + if (exeflag) + print "\t$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)" > outfile + if (dllflag) + print "\t$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)" > outfile + if (libflag) + print "\t$(AR) $(ARFLAGS) $@ $(OBJS)" > outfile + print "" > outfile + + continue + } + + # gather groups of source files to put them in diferent variables in the Makefile + if(/^# Begin Group/) { + # get the group name + groupname = gensub(/^# Begin Group "(.*)"$/, "\\1", "1") + + # take the variable name as the upper case of the group name and changing the spaces to underscores + groupvarname = toupper(groupname) + gsub(/[[:space:]]/, "_", groupvarname) + + # add this information to the groups array + groups[ngroups] = groupvarname + ngroups += 1 + + # initialize some bookeeping variables + ngsources = 0 # number of sources in this group + + # signal that we are inside a group + groupflag = 1 + + continue + } + if(/^# End Group$/) { + # print the group source variable definition + printf "%s=", groupvarname > outfile + if (ngsources) { + for (i = 0; i < ngsources; i++) + printf " \\\n\t%s", gsources[i] > outfile + } + print "" > outfile + print "" > outfile + + # signal that we are outside a group + groupflag = 0 + + continue + } + + if (/^SOURCE=/) { + # get the source file name + source = fixpath(gensub(/^SOURCE=(.*)$/, "\\1", "1")) + + # add to the group sources or isolated sources according we are in a group or not + if (groupflag) + { + gsources[ngsources] = source + ngsources += 1 + } + else + { + sources[nsources] = source + nsources += 1 + } + + continue + } + + # attempts to handle custom builds definition + if(/^# Begin Custom Build/) { + print infile ":" inline ": " source ": Custom Build" > "/dev/stderr" + + # signal we are inside a custom build definition + customflag = 1 + ncustomvars = 0 + + continue + } + if(/^# End Custom Build/) { + # signal we are leaving a custom build definition + customflag = 0 + + continue + } + if(customflag) { + if (debug) + print infile ": " $0 + + # MSDS handles customs builds defining a series of variables for the user convenience + # handle their definition ... + if($0 ~ /^IntDir=/) { + gsub(/^IntDir=/, "", $0) + Intdir = fixpath($0) + continue + } + if($0 ~ /^IntPath=/) { + gsub(/^IntPath=/, "", $0) + IntPath = fixpath($0) + continue + } + if($0 ~ /^OutDir=/) { + gsub(/^OutDir=/, "", $0) + OutDir_ = fixpath($0) + OutDir = "." + continue + } + if($0 ~ /^InputDir=/) { + gsub(/^InputDir=/, "", $0) + InputDir = fixpath($0) + continue + } + if($0 ~ /^InputName=/) { + gsub(/^InputName=/, "", $0) + InputName = fixquotes($0) + continue + } + if($0 ~ /^InputPath=/) { + gsub(/^InputPath=/, "", $0) + InputPath = fixpath($0) + continue + } + if($0 ~ /^TargetDir=/) { + gsub(/^TargetDir=/, "", $0) + TargetDir_ = fixpath($0) + TargetDir = "." + continue + } + if($0 ~ /^TargetPath=/) { + gsub(/^TargetPath=/, "", $0) + gsub(TargetDir_, ".", $0) + TargetPath = fixpath($0) + continue + } + + # ... and substitute them in the rules + gsub(/\$\(IntDir\)/, IntDir) + gsub(/\$\(IntPath\)/, IntPath) + gsub(/\$\(OutDir\)/, OutDir) + gsub(/\$\(InputDir\)/, InputDir) + gsub(/\$\(InputName\)/, InputName) + gsub(/\$\(InputPath\)/, InputPath) + gsub(/\$\(TargetDir\)/, TargetDir) + gsub(/\$\(TargetPath\)/, TargetPath) + + gsub(/\$\(SOURCE\)/, source) + gsub(/"\$\(INTDIR\)"[[:space:]]*/, "") + gsub(/"\$\(OUTDIR\)"[[:space:]]*/, "") + + # do a serie of generic actions to convert the rule + gsub(/^ /, "\t") + gsub(/\\/, "/") + gsub(/\/$/, "\\") + gsub(/\.obj/, ".o") + + print > outfile + + if (debug) + print outfile ": " $0 + } + } + + # print the 'clean' target rule + print ".PHONY: clean" > outfile + print "clean:" > outfile + print "\t-" rm " $(OBJS) $(TARGET) " dependencies > outfile + print "" > outfile + + # print the 'depends' target rule for automatic dependencies generation + print ".PHONY: depends" > outfile + print "depends:" > outfile + print "\t-$(CXX) $(CXXFLAGS) $(CPPFLAGS) -MM $(filter %.c %.cc %.cpp %.cxx,$(SRCS)) > " dependencies> outfile + print "" > outfile + print "-include " dependencies > outfile + print "" > outfile + + # close the files + close(outfile) + close(infile) +} + +# parses a workpace file (.dsw) specified by 'infile' and generates a makefile to 'outfile' +function parse_dsw(infile, outfile, i) +{ + print infile + + # print the Makefile header + print "# Makefile - " basefile(infile) > outfile + print "" > outfile + + # initialize the number of projects counter + nprojects = 0 + + # main loop + while((getline < infile) == 1) { + # catch a project definition + if(/^Project:/) { + # increment the project counter + project = nprojects + nprojects++ + + # extract the project name and filename + project_name[project] = fixpath(gensub(/^Project:[[:blank:]]+(.*)=(.*)[[:blank:]]+-[[:blank:]]+.*$/, "\\1", 1)) + project_file[project] = fixpath(gensub(/^Project:[[:blank:]]+(.*)=(.*)[[:blank:]]+-[[:blank:]]+.*$/, "\\2", 1)) + + # check for a .dsp file extension + if(project_file[project] ~ /\.[Dd][Ss][Pp]$/) { + # create the output filename by renaming the file extension from .dsp to .mak + project_makefile[project] = project_file[project] + sub(/(\.[^.]*)?$/, ".mak", project_makefile[project]) + } + else + project_makefile[project] = "" + + # initialize the project dependencies + project_dependencies[project] = "" + + continue + } + + # catch a project dependency marker + if(project && /^{{{$/) { + # read dependencies until the end marker + while((getline < infile) == 1 && !/^}}}$/) + if(/^[[:blank:]]*Project_Dep_Name[[:blank:]]+/) + project_dependencies[project] = project_dependencies[project] " " fixpath(gensub(/^[[:blank:]]*Project_Dep_Name[[:blank:]]+(.*)$/, "\\1", 1)) + + continue + } + + # catch other (perhaps important) section definitions and produce a warning + if(/^[[:alpha:]]+:/) + { + project = 0 + print infile ": " gensub(/^([[:alpha:]]+):/, "\\1", 1) ": unknown section" > "/dev/stderr" + } + } + + # print the default target rule + print ".PHONY: all" > outfile + printf "all:" > outfile + for(i = 0; i < nprojects; i++) + printf " \\\n\t%s", project_name[i] > outfile + print "" > outfile + print "" > outfile + + # print the rules for each project target + for(i = 0; i < nprojects; i++) { + print ".PHONY: " project_name[i] > outfile + print project_name[i] ":" project_dependencies[i] > outfile + if(project_makefile[i] != "") { + if(basedir(project_makefile[i]) == "") + print "\t$(MAKE) -f " project_makefile[i] > outfile + else + print "\t$(MAKE) -C " basedir(project_makefile[i]) " -f " basefile(project_makefile[i]) > outfile + } + print "" > outfile + } + + # print the 'clean' target rule + print ".PHONY: clean" > outfile + print "clean:" > outfile + for(i = 0; i < nprojects; i++) + if(project_makefile[i] != "") { + if(basedir(project_makefile[i]) == "") + print "\t$(MAKE) -f " project_makefile[i] " clean" > outfile + else + print "\t$(MAKE) -C " basedir(project_makefile[i]) " -f " basefile(project_makefile[i]) " clean" > outfile + } + print "" > outfile + + # print the 'depends' target rule for automatic dependencies generation + print ".PHONY: depends" > outfile + print "depends:" > outfile + for(i = 0; i < nprojects; i++) + if(project_makefile[i] != "") { + if(basedir(project_makefile[i]) == "") + print "\t$(MAKE) -f " project_makefile[i] " depends" > outfile + else + print "\t$(MAKE) -C " basedir(project_makefile[i]) " -f " basefile(project_makefile[i]) " depends" > outfile + } + print "" > outfile + + close(outfile) + close(infile) + + # parse every project file + for(i = 0; i < nprojects; i++) + if(project_makefile[i] != "") { + if(basedir(infile) == "") + parse_dsp(project_file[i], project_makefile[i]) + else + parse_dsp(basedir(infile) "\\" project_file[i], basedir(infile) "\\" project_makefile[i]) + } +} + +# main program +BEGIN { + print "dsw2mak.awk Generates a Makefile from a .DSW/.DSP file Jose Fonseca" + print "" + + # for each argument ... + for (i = 1; i < ARGC; i++) { + infile = ARGV[i] + + # determine whether is a workspace or a project file and parse it + if(infile ~ /\.[Dd][Ss][Ww]$/) { + # create the output filename by renaming the filename to Makefile + outfile = infile + sub(/[^\/\\:]+$/, "Makefile", outfile) + + parse_dsw(infile, outfile) + } else if(infile ~ /\.[Dd][Ss][Pp]$/) { + # create the output filename by renaming the file extension from .dsp to .mak + outfile = infile + sub(/(\.[^.]*)?$/, ".mak", outfile) + + parse_dsp(infile, outfile) + } else { + print infile ": unknown file format" > "/dev/stderr" + } + } +} diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/gcc.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/gcc.exe new file mode 100644 index 0000000..214c674 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/gcc.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/gccbug b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/gccbug new file mode 100644 index 0000000..cbc98b0 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/gccbug @@ -0,0 +1,551 @@ +#!/bin/sh +# Submit a problem report to a GNATS site. +# Copyright (C) 1993, 2000, 2001, 2002 Free Software Foundation, Inc. +# Contributed by Brendan Kehoe (brendan@cygnus.com), based on a +# version written by Heinz G. Seidl (hgs@cygnus.com). +# +# This file is part of GNU GNATS. +# +# GNU GNATS is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU GNATS is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU GNATS; see the file COPYING. If not, write to +# the Free Software Foundation, 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# The version of this send-pr. +VERSION=3.113 + +# The submitter-id for your site. +SUBMITTER=net + +# The default mail address for PR submissions. +GNATS_ADDR=gcc-gnats@gcc.gnu.org + +# The default release for this host. +DEFAULT_RELEASE="3.2.3 (mingw special 20030425-1)" + +# The default organization. +DEFAULT_ORGANIZATION= + +# What mailer to use. This must come after the config file, since it is +# host-dependent. +# Copied from cvsbug +if [ -f /usr/sbin/sendmail ]; then + MAIL_AGENT="/usr/sbin/sendmail -oi -t" +else + MAIL_AGENT="/usr/lib/sendmail -oi -t" +fi +MAILER=`echo $MAIL_AGENT | sed -e 's, .*,,'` +if [ ! -f "$MAILER" ] ; then + echo "$COMMAND: Cannot file mail program \"$MAILER\"." + echo "$COMMAND: Please fix the MAIL_AGENT entry in the $COMMAND file." + exit 1 +fi + + +# How to read the passwd database. +PASSWD="cat /etc/passwd" + +ECHON=bsd + +if [ $ECHON = bsd ] ; then + ECHON1="echo -n" + ECHON2= +elif [ $ECHON = sysv ] ; then + ECHON1=echo + ECHON2='\c' +else + ECHON1=echo + ECHON2= +fi + +# + +if [ -z "$TMPDIR" ]; then + TMPDIR=/tmp +else + if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then + TMPDIR="`echo $TMPDIR | sed -e 's,/$,,'`" + fi +fi + +if [ yes = yes ]; then + TEMP0=`mktemp $TMPDIR/poXXXXXX` || exit 1 + TEMP=`mktemp $TMPDIR/pXXXXXX` || exit 1 + BAD=`mktemp $TMPDIR/pbadXXXXXX` || exit 1 + REF=`mktemp $TMPDIR/pfXXXXXX` || exit 1 + REMOVE_TEMP="rm -f $TEMP0 $TEMP $BAD $REF" +else + TEMPD=$TMPDIR/pd$$ + TEMP0=$TEMPD/po$$ + TEMP=$TEMPD/p$$ + BAD=$TEMPD/pbad$$ + REF=$TEMPD/pf$$ + mkdir $TEMPD || exit 1 + REMOVE_TEMP="rm -rf $TEMPD" +fi + +# find a user name +if [ "$LOGNAME" = "" ]; then + if [ "$USER" != "" ]; then + LOGNAME="$USER" + else + LOGNAME="UNKNOWN" + fi +fi + +FROM="$LOGNAME" +REPLY_TO="${REPLY_TO:-${REPLYTO:-$LOGNAME}}" + +# Find out the name of the originator of this PR. +if [ -n "$NAME" ]; then + ORIGINATOR="$NAME" +elif [ -f $HOME/.fullname ]; then + ORIGINATOR="`sed -e '1q' $HOME/.fullname`" +else + # Must use temp file due to incompatibilities in quoting behavior + # and to protect shell metacharacters in the expansion of $LOGNAME + $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP0 + ORIGINATOR="`cat $TEMP0`" + rm -f $TEMP0 +fi + +if [ -n "$ORGANIZATION" ]; then + if [ -f "$ORGANIZATION" ]; then + ORGANIZATION="`cat $ORGANIZATION`" + fi +else + if [ -n "$DEFAULT_ORGANIZATION" ]; then + ORGANIZATION="$DEFAULT_ORGANIZATION" + elif [ -f $HOME/.organization ]; then + ORGANIZATION="`cat $HOME/.organization`" + fi +fi + +# If they don't have a preferred editor set, then use +if [ -z "$VISUAL" ]; then + if [ -z "$EDITOR" ]; then + EDIT=vi + else + EDIT="$EDITOR" + fi +else + EDIT="$VISUAL" +fi + +# Find out some information. +SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \ + ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""` +ARCH=`[ -f /bin/arch ] && /bin/arch` +MACHINE=`[ -f /bin/machine ] && /bin/machine` + +COMMAND=`echo $0 | sed -e 's,.*/,,'` +USAGE="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity] + [-c address] [--request-id] [--version]" +REMOVE= +BATCH= +CC= +SEVERITY_C= + +while [ $# -gt 0 ]; do + case "$1" in + -r) ;; # Ignore for backward compat. + -t | --to) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi + shift ; GNATS_ADDR="$1" + EXPLICIT_GNATS_ADDR=true + ;; + -f | --file) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi + shift ; IN_FILE="$1" + if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then + echo "$COMMAND: cannot read $IN_FILE" + $REMOVE_TEMP + exit 1 + fi + ;; + -b | --batch) BATCH=true ;; + -c | --cc) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi + shift ; CC="$1" + ;; + -s | --severity) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi + shift ; SEVERITY_C="$1" + ;; + -p | -P | --print) PRINT=true ;; + -L | --list) FORMAT=norm ;; + -l | -CL | --lisp) FORMAT=lisp ;; + --request-id) REQUEST_ID=true ;; + -h | --help) echo "$USAGE"; $REMOVE_TEMP; exit 0 ;; + -V | --version) cat < max) { max = length($0); } } + END {print max + 1;}'` + c=`expr 70 / $l` + if [ $c -eq 0 ]; then c=1; fi + echo "$CATEGORIES" | \ + awk 'BEGIN {print "Known categories:"; i = 0 } + { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } } + END { print ""; }' + $REMOVE_TEMP + exit 0 + ;; +esac + +ORIGINATOR_C='' +ORGANIZATION_C='' +SYNOPSIS_C='' +if [ -z "$SEVERITY_C" ]; then + SEVERITY_C='<[ non-critical | serious | critical ] (one line)>' +fi +PRIORITY_C='<[ low | medium ] (one line)>' +CATEGORY_C='' +RELEASE_C='' +ENVIRONMENT_C='' +DESCRIPTION_C='' +HOW_TO_REPEAT_C='' +FIX_C='' + +# Catch some signals. ($xs kludge needed by Sun /bin/sh) +xs=0 +trap '$REMOVE_TEMP; exit $xs' 0 +trap 'echo "$COMMAND: Aborting ..."; $REMOVE_TEMP; xs=1; exit' 1 3 13 15 + +# If they told us to use a specific file, then do so. +if [ -n "$IN_FILE" ]; then + if [ "$IN_FILE" = "-" ]; then + # The PR is coming from the standard input. + if [ -n "$EXPLICIT_GNATS_ADDR" ]; then + sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP + else + cat > $TEMP + fi + else + # Use the file they named. + if [ -n "$EXPLICIT_GNATS_ADDR" ]; then + sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP + else + cat $IN_FILE > $TEMP + fi + fi +else + + if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then + # If their PR_FORM points to a bogus entry, then bail. + if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then + echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM" + sleep 1 + PRINT_INTERN=bad_prform + fi + fi + + if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then + cp $PR_FORM $TEMP || + ( echo "$COMMAND: could not copy $PR_FORM" ; xs=1; exit ) + else + for file in $TEMP $REF ; do + cat > $file << '__EOF__' +SEND-PR: -*- send-pr -*- +SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as +SEND-PR: will all comments (text enclosed in `<' and `>'). +SEND-PR: +SEND-PR: Please consult the GCC manual if you are not sure how to +SEND-PR: fill out a problem report. +SEND-PR: Note that the Synopsis field is mandatory. The Subject (for +SEND-PR: the mail) will be made the same as Synopsis unless explicitly +SEND-PR: changed. +SEND-PR: +SEND-PR: Choose from the following categories: +SEND-PR: +__EOF__ + + # Format the categories so they fit onto lines. + l=`echo "$CATEGORIES" | \ + awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } } + END {print max + 1;}'` + c=`expr 61 / $l` + if [ $c -eq 0 ]; then c=1; fi + echo "$CATEGORIES" | \ + awk 'BEGIN {printf "SEND-PR: "; i = 0 } + { printf ("%-'$l'.'$l's", $0); + if ((++i % '$c') == 0) { printf "\nSEND-PR: " } } + END { printf "\nSEND-PR:\n"; }' >> $file + + cat >> $file << __EOF__ +To: $GNATS_ADDR +Subject: +From: $FROM +Reply-To: $REPLYTO +Cc: $CC +X-send-pr-version: $VERSION +X-GNATS-Notify: + + +>Submitter-Id: $SUBMITTER +>Originator: $ORIGINATOR +>Organization: ${ORGANIZATION-$ORGANIZATION_C} +>Confidential: no +SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public. +>Synopsis: $SYNOPSIS_C +>Severity: $SEVERITY_C +SEND-PR: critical GCC is completely not operational; no work-around known. +SEND-PR: serious GCC is not working properly; a work-around is possible. +SEND-PR: non-critical Report indicates minor problem. +>Priority: $PRIORITY_C +SEND-PR: medium The problem should be solved in the next release. +SEND-PR: low The problem should be solve in a future release. +>Category: $CATEGORY_C +>Class: <[ doc-bug | accepts-illegal | rejects-legal | wrong-code | ice-on-legal-code| ice-on-illegal-code | pessimizes-code | sw-bug | change-request | support ] (one line)> +SEND-PR: doc-bug The documentation is incorrect. +SEND-PR: accepts-illegal GCC fails to reject erroneous code. +SEND-PR: rejects-legal GCC gives an error message for correct code. +SEND-PR: wrong-code The machine code generated by gcc is incorrect. +SEND-PR: ice-on-legal-code GCC gives an Internal Compiler Error (ICE) +SEND-PR: for correct code +SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error +SEND-PR: pessimizes-code GCC misses an important optimization opportunity +SEND-PR: sw-bug Software bug of some other class than above +SEND-PR: change-request A feature in GCC is missing. +SEND-PR: support I need help with gcc. +>Release: ${DEFAULT_RELEASE-$RELEASE_C} +>Environment: +`[ -n "$SYSTEM" ] && echo System: $SYSTEM` +`[ -n "$ARCH" ] && echo Architecture: $ARCH` +`[ -n "$MACHINE" ] && echo Machine: $MACHINE` + $ENVIRONMENT_C +host: i386-pc-mingw32 +build: i386-pc-mingw32 +target: i386-pc-mingw32 +configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c++,f77,objc --disable-win32-registry --disable-shared --enable-sjlj-exceptions +>Description: + $DESCRIPTION_C +>How-To-Repeat: + $HOW_TO_REPEAT_C +>Fix: + $FIX_C +__EOF__ + done + fi + + if [ "$PRINT" = true -o "$PRINT_INTERN" = true ]; then + cat $TEMP + xs=0; exit + fi + + chmod u+w $TEMP + if [ -z "$REQUEST_ID" ]; then + eval $EDIT $TEMP + else + ed -s $TEMP << '__EOF__' +/^Subject/s/^Subject:.*/Subject: request for a customer id/ +/^>Category/s/^>Category:.*/>Category: send-pr/ +w +q +__EOF__ + fi + + if cmp -s $REF $TEMP ; then + echo "$COMMAND: problem report not filled out, therefore not sent" + xs=1; exit + fi +fi + +# +# Check the enumeration fields + +# This is a "sed-subroutine" with one keyword parameter +# (with workaround for Sun sed bug) +# +SED_CMD=' +/$PATTERN/{ +s||| +s|<.*>|| +s|^[ ]*|| +s|[ ]*$|| +p +q +}' + + +while [ -z "$REQUEST_ID" ]; do + CNT=0 + + # 1) Confidential + # + PATTERN=">Confidential:" + CONFIDENTIAL=`eval sed -n -e "\"$SED_CMD\"" $TEMP` + case "$CONFIDENTIAL" in + no) CNT=`expr $CNT + 1` ;; + *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;; + esac + # + # 2) Severity + # + PATTERN=">Severity:" + SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP` + case "$SEVERITY" in + ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;; + *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'." + esac + # + # 3) Priority + # + PATTERN=">Priority:" + PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP` + case "$PRIORITY" in + ""|low|medium) CNT=`expr $CNT + 1` ;; + high) echo "$COMMAND: \`Priority: high' is reserved for GCC maintainers." ;; + *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'." + esac + # + # 4) Category + # + PATTERN=">Category:" + CATEGORY=`eval sed -n -e "\"$SED_CMD\"" $TEMP` + FOUND= + for C in $CATEGORIES + do + if [ "$C" = "$CATEGORY" ]; then FOUND=true ; break ; fi + done + if [ -n "$FOUND" ]; then + CNT=`expr $CNT + 1` + else + if [ -z "$CATEGORY" ]; then + echo "$COMMAND: you must include a Category: field in your report." + else + echo "$COMMAND: \`$CATEGORY' is not a known category." + fi + fi + # + # 5) Class + # + PATTERN=">Class:" + CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP` + case "$CLASS" in + ""|doc-bug|accepts-illegal|rejects-legal|wrong-code|ice-on-legal-code|ice-on-illegal-code|pessimizes-code|sw-bug|change-request|support) CNT=`expr $CNT + 1` ;; + *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'." + esac + # + # 6) Check that synopsis is not empty + # + if grep "^>Synopsis:[ ]*${SYNOPSIS_C}\$" $TEMP > /dev/null + then + echo "$COMMAND: Synopsis must not be empty." + else + CNT=`expr $CNT + 1` + fi + + [ $CNT -lt 6 -a -z "$BATCH" ] && + echo "Errors were found with the problem report." + + while true; do + if [ -z "$BATCH" ]; then + $ECHON1 "a)bort, e)dit or s)end? $ECHON2" + read input + else + if [ $CNT -eq 6 ]; then + input=s + else + input=a + fi + fi + case "$input" in + a*) + if [ -z "$BATCH" ]; then + echo "$COMMAND: the problem report remains in $BAD and is not sent." + REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF" + mv $TEMP $BAD + else + echo "$COMMAND: the problem report is not sent." + fi + xs=1; exit + ;; + e*) + eval $EDIT $TEMP + continue 2 + ;; + s*) + break 2 + ;; + esac + done +done + +# +# Make sure the mail has got a Subject. If not, use the same as +# in Synopsis. +# + +if grep '^Subject:[ ]*$' $TEMP > /dev/null +then + SYNOPSIS=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ ]*//'` + ed -s $TEMP << __EOF__ +/^Subject:/s/:.*\$/: $SYNOPSIS/ +w +q +__EOF__ +fi + +# +# Remove comments and send the problem report +# (we have to use patterns, where the comment contains regex chars) +# +# /^>Originator:/s;$ORIGINATOR;; +sed -e " +/^SEND-PR:/d +/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;; +/^>Confidential:/s;<.*>;; +/^>Synopsis:/s;$SYNOPSIS_C;; +/^>Severity:/s;<.*>;; +/^>Priority:/s;<.*>;; +/^>Category:/s;$CATEGORY_C;; +/^>Class:/s;<.*>;; +/^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;; +/^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;; +/^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;; +/^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;; +/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;; +" $TEMP > $REF + +if $MAIL_AGENT < $REF; then + echo "$COMMAND: problem report sent" + xs=0; exit +else + echo "$COMMAND: mysterious mail failure." + if [ -z "$BATCH" ]; then + echo "$COMMAND: the problem report remains in $BAD and is not sent." + REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF" + mv $REF $BAD + else + echo "$COMMAND: the problem report is not sent." + fi + xs=1; exit +fi diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/ld.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/ld.exe new file mode 100644 index 0000000..92846b0 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/ld.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/make.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/make.exe new file mode 100644 index 0000000..429ce7c Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/make.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/mingwm10.dll b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/mingwm10.dll new file mode 100644 index 0000000..34cf146 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/mingwm10.dll differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/nasm.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/nasm.exe new file mode 100644 index 0000000..e2597b5 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/nasm.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/ndisasm.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/ndisasm.exe new file mode 100644 index 0000000..ca1cd6d Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/ndisasm.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/ldrdf.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/ldrdf.exe new file mode 100644 index 0000000..d47ae93 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/ldrdf.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdf2bin.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdf2bin.exe new file mode 100644 index 0000000..7831697 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdf2bin.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdf2com.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdf2com.exe new file mode 100644 index 0000000..7831697 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdf2com.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdf2ihx.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdf2ihx.exe new file mode 100644 index 0000000..6d2c37a Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdf2ihx.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdfdump.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdfdump.exe new file mode 100644 index 0000000..c9a796e Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdfdump.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdflib.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdflib.exe new file mode 100644 index 0000000..6d59fad Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdflib.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdx.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdx.exe new file mode 100644 index 0000000..9890f27 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/rdoff/rdx.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/sync.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/sync.exe new file mode 100644 index 0000000..e13ea7a Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/bin/sync.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/SYSCALLS.c.X b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/SYSCALLS.c.X new file mode 100644 index 0000000..1d4c9c2 --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/SYSCALLS.c.X @@ -0,0 +1,1350 @@ +/* compiled from: . */ +/* SYSCALLS.c:241:OC */ extern int TLappend (/* ??? */); +/* SYSCALLS.c:242:OC */ extern int TLassign (/* ??? */); +/* SYSCALLS.c:243:OC */ extern int TLclose (/* ??? */); +/* SYSCALLS.c:244:OC */ extern int TLdelete (/* ??? */); +/* SYSCALLS.c:245:OC */ extern int TLfreeentry (/* ??? */); +/* SYSCALLS.c:246:OC */ extern ENTRY TLgetentry (/* ??? */); +/* SYSCALLS.c:247:OC */ extern unsigned char *TLgetfield (/* ??? */); +/* SYSCALLS.c:248:OC */ extern int TLopen (/* ??? */); +/* SYSCALLS.c:249:OC */ extern int TLread (/* ??? */); +/* SYSCALLS.c:250:OC */ extern int TLsearch1 (/* ??? */); +/* SYSCALLS.c:251:OC */ extern int TLsubst (/* ??? */); +/* SYSCALLS.c:252:OC */ extern int TLsync (/* ??? */); +/* SYSCALLS.c:253:OC */ extern int TLwrite (/* ??? */); +/* SYSCALLS.c:254:NC */ extern int __acancel (int, const long int *, int); +/* SYSCALLS.c:255:NC */ extern int __aread (int, int, char *, uint, ecb_t *); +/* SYSCALLS.c:256:NC */ extern void __assert (const char *, const char *, int); +/* SYSCALLS.c:257:NC */ extern int __asyncio (int, aioop_t *, int); +/* SYSCALLS.c:258:NC */ extern int __awrite (int, int, char *, uint, ecb_t *); +/* SYSCALLS.c:259:NC */ extern int __evcntl (evver_t, evcntlcmds_t, long int, long int); +/* SYSCALLS.c:260:NC */ extern int __evexit (evver_t, idtype_t, id_t, const ecb_t *); +/* SYSCALLS.c:261:NC */ extern int __evexitset (evver_t, const procset_t *, hostid_t, const ecb_t *); +/* SYSCALLS.c:262:NC */ extern int __evpoll (evver_t, evpollcmds_t, event_t *, int, const hrtime_t *); +/* SYSCALLS.c:263:NC */ extern int __evpollmore (evver_t, event_t *, int); +/* SYSCALLS.c:264:NC */ extern int __evpost (evver_t, event_t *, int, int); +/* SYSCALLS.c:265:NC */ extern int __evqcntl (evver_t, int, evqcntlcmds_t, long int); +/* SYSCALLS.c:266:NC */ extern int __evsig (evver_t, const sigset_t *, const ecb_t *, evsiginfo_t *, int); +/* SYSCALLS.c:267:NC */ extern int __evtrap (evver_t, evpollcmds_t, event_t *, int, long int, void (*) (event_t *, int, long int, evcontext_t *), const evta_t *); +/* SYSCALLS.c:268:NC */ extern int __evtrapcancel (evver_t, long int *, int); +/* SYSCALLS.c:269:NC */ extern int __filbuf (FILE *); +/* SYSCALLS.c:270:NC */ extern int __flsbuf (int, FILE *); +/* SYSCALLS.c:271:NC */ extern major_t __major (int, dev_t); +/* SYSCALLS.c:272:NC */ extern dev_t __makedev (int, major_t, minor_t); +/* SYSCALLS.c:273:NC */ extern minor_t __minor (int, dev_t); +/* SYSCALLS.c:274:OC */ extern long int __priocntl (/* ??? */); +/* SYSCALLS.c:275:OC */ extern long int __priocntlset (/* ??? */); +/* SYSCALLS.c:276:NC */ extern void _exit (int); +/* SYSCALLS.c:277:NC */ extern int _filbuf (FILE *); +/* SYSCALLS.c:278:NC */ extern int _flsbuf (unsigned int, FILE *); +/* SYSCALLS.c:279:NC */ extern int _fxstat (int, int, struct stat *); +/* SYSCALLS.c:280:OC */ extern u_long _getlong (/* ??? */); +/* SYSCALLS.c:281:OC */ extern u_short _getshort (/* ??? */); +/* SYSCALLS.c:282:NC */ extern int _getsyx (int *, int *); +/* SYSCALLS.c:283:NC */ extern int _longjmp (jmp_buf, int); +/* SYSCALLS.c:284:NC */ extern int _lxstat (int, const char *, struct stat *); +/* SYSCALLS.c:285:NC */ extern int _meta (int); +/* SYSCALLS.c:286:NC */ extern struct nd_hostservlist _netdir_getbyaddr (struct netconfig *, struct netbuf *); +/* SYSCALLS.c:287:NC */ extern struct nd_addrlist *_netdir_getbyname (struct netconfig *, struct nd_hostserv *); +/* SYSCALLS.c:288:NC */ extern int _overlay (WINDOW *, WINDOW *, int); +/* SYSCALLS.c:289:NC */ extern int _ring (int); +/* SYSCALLS.c:290:OC */ extern int _rpc_dtbsize (/* ??? */); +/* SYSCALLS.c:291:OC */ extern int _rpc_endconf (/* ??? */); +/* SYSCALLS.c:292:OC */ extern u_int _rpc_get_a_size (/* ??? */); +/* SYSCALLS.c:293:OC */ extern u_int _rpc_get_t_size (/* ??? */); +/* SYSCALLS.c:294:OC */ extern struct netconfig *_rpc_getconf (/* ??? */); +/* SYSCALLS.c:295:OC */ extern struct netconfig *_rpc_getconfip (/* ??? */); +/* SYSCALLS.c:296:OC */ extern char *_rpc_gethostname (/* ??? */); +/* SYSCALLS.c:297:OC */ extern int _rpc_setconf (/* ??? */); +/* SYSCALLS.c:298:OC */ extern void _s_aligned_copy (/* ??? */); +/* SYSCALLS.c:299:OC */ extern struct _si_user *_s_checkfd (/* ??? */); +/* SYSCALLS.c:300:OC */ extern void _s_close (/* ??? */); +/* SYSCALLS.c:301:OC */ extern int _s_do_ioctl (/* ??? */); +/* SYSCALLS.c:302:OC */ extern int _s_getfamily (/* ??? */); +/* SYSCALLS.c:303:OC */ extern int _s_getudata (/* ??? */); +/* SYSCALLS.c:304:OC */ extern int _s_is_ok (/* ??? */); +/* SYSCALLS.c:305:OC */ extern struct netconfig *_s_match (/* ??? */); +/* SYSCALLS.c:306:OC */ extern int _s_max (/* ??? */); +/* SYSCALLS.c:307:OC */ extern int _s_min (/* ??? */); +/* SYSCALLS.c:308:OC */ extern struct _si_user *_s_open (/* ??? */); +/* SYSCALLS.c:309:OC */ extern int _s_soreceive (/* ??? */); +/* SYSCALLS.c:310:OC */ extern int _s_sosend (/* ??? */); +/* SYSCALLS.c:311:OC */ extern int _s_uxpathlen (/* ??? */); +/* SYSCALLS.c:312:NC */ extern int _setecho (int); +/* SYSCALLS.c:313:NC */ extern int _setjmp (jmp_buf); +/* SYSCALLS.c:314:NC */ extern int _setnonl (int); +/* SYSCALLS.c:315:NC */ extern void _setqiflush (int); +/* SYSCALLS.c:316:NC */ extern char *_taddr2uaddr (struct netconfig *, struct netbuf *); +/* SYSCALLS.c:317:NC */ extern int _tolower (int); +/* SYSCALLS.c:318:NC */ extern int _toupper (int); +/* SYSCALLS.c:319:NC */ extern struct netbuf *_uaddr2taddr (struct netconfig *, char *); +/* SYSCALLS.c:320:OC */ extern bool _xdr_yprequest (/* ??? */); +/* SYSCALLS.c:321:OC */ extern bool _xdr_ypresponse (/* ??? */); +/* SYSCALLS.c:322:NC */ extern int _xftw (int, const char *, int (*) (const char *, const struct stat *, int), int); +/* SYSCALLS.c:323:NC */ extern int _xmknod (int, const char *, mode_t, dev_t); +/* SYSCALLS.c:324:NC */ extern int _xstat (int, const char *, struct stat *); +/* SYSCALLS.c:325:OC */ extern int _yp_dobind (/* ??? */); +/* SYSCALLS.c:326:NC */ extern long int a64l (const char *); +/* SYSCALLS.c:327:NC */ extern char *aatos (char *, struct address *, int); +/* SYSCALLS.c:328:NC */ extern void abort (void); +/* SYSCALLS.c:329:NC */ extern int abs (int); +/* SYSCALLS.c:330:NC */ extern int access (const char *, int); +/* SYSCALLS.c:331:NC */ extern int acct (const char *); +/* SYSCALLS.c:332:NC */ extern double acos (double); +/* SYSCALLS.c:333:NC */ extern float acosf (float); +/* SYSCALLS.c:334:NC */ extern double acosh (double); +/* SYSCALLS.c:335:NC */ extern int addexportent (FILE *, char *, char *); +/* SYSCALLS.c:336:NC */ extern int addseverity (int, const char *); +/* SYSCALLS.c:337:NC */ extern int adjtime (struct timeval *, struct timeval *); +/* SYSCALLS.c:338:NC */ extern int advance (const char *, const char *); +/* SYSCALLS.c:339:NC */ extern unsigned int alarm (unsigned int); +/* SYSCALLS.c:340:NC */ extern void *alloca (size_t); +/* SYSCALLS.c:341:NC */ extern int and (void); +/* SYSCALLS.c:342:NC */ extern int ascftime (char *, const char *, const struct tm *); +/* SYSCALLS.c:343:NC */ extern char *asctime (const struct tm *); +/* SYSCALLS.c:344:NC */ extern double asin (double); +/* SYSCALLS.c:345:NC */ extern float asinf (float); +/* SYSCALLS.c:346:NC */ extern double asinh (double); +/* SYSCALLS.c:347:NC */ extern struct address *astoa (char *, struct address *); +/* SYSCALLS.c:348:NC */ extern double atan (double); +/* SYSCALLS.c:349:NC */ extern double atan2 (double, double); +/* SYSCALLS.c:350:NC */ extern float atan2f (float, float); +/* SYSCALLS.c:351:NC */ extern float atanf (float); +/* SYSCALLS.c:352:NC */ extern double atanh (double); +/* SYSCALLS.c:353:NC */ extern int atexit (void (*) (void)); +/* SYSCALLS.c:354:NC */ extern double atof (const char *); +/* SYSCALLS.c:355:NC */ extern int atoi (const char *); +/* SYSCALLS.c:356:NC */ extern long int atol (const char *); +/* SYSCALLS.c:357:NC */ extern char *atos (char *, struct netbuf *, int); +/* SYSCALLS.c:358:NC */ extern void auth_destroy (AUTH *); +/* SYSCALLS.c:359:OC */ extern AUTH *authdes_create (/* ??? */); +/* SYSCALLS.c:360:NC */ extern void authdes_getcred (struct authdes_cred *, short int *, short int *, short int *, int *); +/* SYSCALLS.c:361:OC */ extern AUTH *authdes_seccreate (/* ??? */); +/* SYSCALLS.c:362:NC */ extern AUTH *authnone_create (void); +/* SYSCALLS.c:363:NC */ extern AUTH *authsys_create (char *, int, int, int, int *); +/* SYSCALLS.c:364:NC */ extern AUTH *authsys_create_default (void); +/* SYSCALLS.c:365:NC */ extern AUTH *authunix_create (char *, int, int, int, int *); +/* SYSCALLS.c:366:NC */ extern AUTH *authunix_create_default (void); +/* SYSCALLS.c:367:NC */ extern char *basename (char *); +/* SYSCALLS.c:368:NC */ extern int baudrate (void); +/* SYSCALLS.c:369:NC */ extern int bcmp (const void *, const void *, size_t); +/* SYSCALLS.c:370:NC */ extern void bcopy (const void *, void *, size_t); +/* SYSCALLS.c:371:NC */ extern int beep (void); +/* SYSCALLS.c:372:NC */ extern void (*berk_signal (int, void (*) (int, ...))) (int, ...); +/* SYSCALLS.c:373:NC */ extern char *bgets (char *, size_t, FILE *, char *); +/* SYSCALLS.c:374:NC */ extern int bottom_panel (PANEL *); +/* SYSCALLS.c:375:NC */ extern int box32 (WINDOW *, chtype, chtype); +/* SYSCALLS.c:376:NC */ extern int brk (void *); +/* SYSCALLS.c:377:NC */ extern void *bsearch (const void *, const void *, size_t, size_t, int (*) (const void *, const void *)); +/* SYSCALLS.c:378:NC */ extern size_t bufsplit (char *, size_t, char *); +/* SYSCALLS.c:379:NC */ extern void bzero (void *, size_t); +/* SYSCALLS.c:380:OC */ extern long int calchash (/* ??? */); +/* SYSCALLS.c:381:NC */ extern void *calloc (size_t, size_t); +/* SYSCALLS.c:382:NC */ extern void callrpc (char *, long unsigned int, long unsigned int, long unsigned int, xdrproc_t, char *, xdrproc_t, char *); +/* SYSCALLS.c:383:NC */ extern bool can_change_color (void); +/* SYSCALLS.c:384:NC */ extern int catclose (nl_catd); +/* SYSCALLS.c:385:NC */ extern char *catgets (nl_catd, int, int, char *); +/* SYSCALLS.c:386:NC */ extern nl_catd catopen (const char *, int); +/* SYSCALLS.c:387:NC */ extern int cbreak (void); +/* SYSCALLS.c:388:NC */ extern double cbrt (double); +/* SYSCALLS.c:389:NC */ extern double ceil (double); +/* SYSCALLS.c:390:NC */ extern float ceilf (float); +/* SYSCALLS.c:391:NC */ extern speed_t cfgetispeed (const struct termios *); +/* SYSCALLS.c:392:NC */ extern speed_t cfgetospeed (const struct termios *); +/* SYSCALLS.c:393:NC */ extern void cfree (void *); +/* SYSCALLS.c:394:NC */ extern int cfsetispeed (struct termios *, speed_t); +/* SYSCALLS.c:395:NC */ extern int cfsetospeed (struct termios *, speed_t); +/* SYSCALLS.c:396:NC */ extern int cftime (char *, char *, const time_t *); +/* SYSCALLS.c:397:NC */ extern int chdir (const char *); +/* SYSCALLS.c:398:NC */ extern int chmod (const char *, mode_t); +/* SYSCALLS.c:399:NC */ extern int chown (const char *, uid_t, gid_t); +/* SYSCALLS.c:400:NC */ extern int chroot (const char *); +/* SYSCALLS.c:401:OC */ extern void clean_GEN_rd (/* ??? */); +/* SYSCALLS.c:402:OC */ extern void cleanup (/* ??? */); +/* SYSCALLS.c:403:NC */ extern void clearerr (FILE *); +/* SYSCALLS.c:404:NC */ extern int clearok (WINDOW *, int); +/* SYSCALLS.c:405:NC */ extern enum clnt_stat clnt_broadcast (long unsigned int, long unsigned int, long unsigned int, xdrproc_t, char *, xdrproc_t, char *, resultproc_t); +/* SYSCALLS.c:406:NC */ extern enum clnt_stat clnt_call (CLIENT *, long unsigned int, xdrproc_t, char *, xdrproc_t, char *, struct timeval); +/* SYSCALLS.c:407:NC */ extern bool_t clnt_control (CLIENT *, int, char *); +/* SYSCALLS.c:408:NC */ extern CLIENT *clnt_create (char *, long unsigned int, long unsigned int, char *); +/* SYSCALLS.c:409:NC */ extern void clnt_destroy (CLIENT *); +/* SYSCALLS.c:410:NC */ extern int clnt_freeres (CLIENT *, xdrproc_t, char *); +/* SYSCALLS.c:411:NC */ extern void clnt_geterr (CLIENT *, struct rpc_err *); +/* SYSCALLS.c:412:NC */ extern void clnt_pcreateerror (char *); +/* SYSCALLS.c:413:NC */ extern void clnt_perrno (enum clnt_stat); +/* SYSCALLS.c:414:NC */ extern void clnt_perror (CLIENT *, char *); +/* SYSCALLS.c:415:NC */ extern char *clnt_spcreateerror (char *); +/* SYSCALLS.c:416:NC */ extern char *clnt_sperrno (enum clnt_stat); +/* SYSCALLS.c:417:NC */ extern char *clnt_sperror (CLIENT *, char *); +/* SYSCALLS.c:418:OC */ extern CLIENT *clnt_tli_create (/* ??? */); +/* SYSCALLS.c:419:OC */ extern CLIENT *clnt_tp_create (/* ??? */); +/* SYSCALLS.c:420:OC */ extern CLIENT *clnt_vc_create (/* ??? */); +/* SYSCALLS.c:421:NC */ extern CLIENT *clntraw_create (long unsigned int, long unsigned int); +/* SYSCALLS.c:422:NC */ extern CLIENT *clnttcp_create (struct sockaddr_in *, long unsigned int, long unsigned int, int *, unsigned int, unsigned int *); +/* SYSCALLS.c:423:NC */ extern CLIENT *clntudp_bufcreate (struct sockaddr_in *, long unsigned int, long unsigned int, struct timeval, int *, unsigned int, unsigned int); +/* SYSCALLS.c:424:NC */ extern CLIENT *clntudp_create (struct sockaddr_in *, long unsigned int, long unsigned int, struct timeval, int *); +/* SYSCALLS.c:425:NC */ extern clock_t clock (void); +/* SYSCALLS.c:426:NC */ extern int close (int); +/* SYSCALLS.c:427:NC */ extern int closedir (DIR *); +/* SYSCALLS.c:428:NC */ extern int color_content (int, short int *, short int *, short int *); +/* SYSCALLS.c:429:NC */ extern char *compile (const char *, char *, char *); +/* SYSCALLS.c:430:NC */ extern char *copylist (const char *, off_t *); +/* SYSCALLS.c:431:NC */ extern double copysign (double, double); +/* SYSCALLS.c:432:NC */ extern int copywin (WINDOW *, WINDOW *, int, int, int, int, int, int, int); +/* SYSCALLS.c:433:NC */ extern double cos (double); +/* SYSCALLS.c:434:NC */ extern float cosf (float); +/* SYSCALLS.c:435:NC */ extern double cosh (double); +/* SYSCALLS.c:436:NC */ extern float coshf (float); +/* SYSCALLS.c:437:OC */ extern struct rd_user *cr_rduser (/* ??? */); +/* SYSCALLS.c:438:NC */ extern int creat (const char *, mode_t); +/* SYSCALLS.c:439:NC */ extern int crmode (void); +/* SYSCALLS.c:440:NC */ extern char *crypt (const char *, const char *); +/* SYSCALLS.c:441:NC */ extern int crypt_close (int *); +/* SYSCALLS.c:442:NC */ extern char *ctermid (char *); +/* SYSCALLS.c:443:NC */ extern char *ctime (const time_t *); +/* SYSCALLS.c:444:NC */ extern FIELD *current_field (FORM *); +/* SYSCALLS.c:445:NC */ extern ITEM *current_item (MENU *); +/* SYSCALLS.c:446:NC */ extern int curs_set (int); +/* SYSCALLS.c:447:NC */ extern void curserr (void); +/* SYSCALLS.c:448:NC */ extern char *cuserid (char *); +/* SYSCALLS.c:449:NC */ extern int data_ahead (FORM *); +/* SYSCALLS.c:450:NC */ extern int data_behind (FORM *); +/* SYSCALLS.c:451:NC */ extern void dbmclose (void); +/* SYSCALLS.c:452:NC */ extern void dbminit (const char *); +/* SYSCALLS.c:453:NC */ extern int def_prog_mode (void); +/* SYSCALLS.c:454:NC */ extern int def_shell_mode (void); +/* SYSCALLS.c:455:OC */ extern char *defread (/* ??? */); +/* SYSCALLS.c:456:NC */ extern int del_panel (PANEL *); +/* SYSCALLS.c:457:OC */ extern void del_rduser (/* ??? */); +/* SYSCALLS.c:458:NC */ extern void delay (long int); +/* SYSCALLS.c:459:NC */ extern int delay_output (int); +/* SYSCALLS.c:460:NC */ extern void delete (datum); +/* SYSCALLS.c:461:NC */ extern void delscreen (SCREEN *); +/* SYSCALLS.c:462:NC */ extern int delterm (TERMINAL *); +/* SYSCALLS.c:463:NC */ extern int delwin (WINDOW *); +/* SYSCALLS.c:464:NC */ extern WINDOW *derwin (WINDOW *, int, int, int, int); +/* SYSCALLS.c:465:NC */ extern char *des_crypt (const char *, const char *); +/* SYSCALLS.c:466:NC */ extern void des_encrypt (char *, int); +/* SYSCALLS.c:467:NC */ extern void des_setkey (const char *); +/* SYSCALLS.c:468:OC */ extern char *devattr (/* ??? */); +/* SYSCALLS.c:469:OC */ extern int devfree (/* ??? */); +/* SYSCALLS.c:470:OC */ extern char **devreserv (/* ??? */); +/* SYSCALLS.c:471:NC */ extern int dial (CALL); +/* SYSCALLS.c:472:NC */ extern double difftime (time_t, time_t); +/* SYSCALLS.c:473:NC */ extern char *dirname (char *); +/* SYSCALLS.c:474:NC */ extern div_t div (int, int); +/* SYSCALLS.c:475:NC */ extern int dlclose (void *); +/* SYSCALLS.c:476:NC */ extern char *dlerror (void); +/* SYSCALLS.c:477:NC */ extern void *dlopen (char *, int); +/* SYSCALLS.c:478:NC */ extern void *dlsym (void *, char *); +/* SYSCALLS.c:479:NC */ extern void dma_access (u_char, u_int, u_int, u_char, u_char); +/* SYSCALLS.c:480:NC */ extern int doupdate (void); +/* SYSCALLS.c:481:NC */ extern int drainio (int); +/* SYSCALLS.c:482:NC */ extern double drand48 (void); +/* SYSCALLS.c:483:NC */ extern double drem (double, double); +/* SYSCALLS.c:484:OC */ extern int drv_getevtoken (/* ??? */); +/* SYSCALLS.c:485:OC */ extern void drv_relevtoken (/* ??? */); +/* SYSCALLS.c:486:NC */ extern int dup (int); +/* SYSCALLS.c:487:NC */ extern int dup2 (int, int); +/* SYSCALLS.c:488:NC */ extern FIELD *dup_field (FIELD *, int, int); +/* SYSCALLS.c:489:NC */ extern WINDOW *dupwin (WINDOW *); +/* SYSCALLS.c:490:NC */ extern int dynamic_field_info (FIELD *, int *, int *, int *); +/* SYSCALLS.c:491:NC */ extern int dysize (int); +/* SYSCALLS.c:492:NC */ extern int eaccess (const char *, int); +/* SYSCALLS.c:493:NC */ extern int echo (void); +/* SYSCALLS.c:494:NC */ extern char *ecvt (double, int, int *, int *); +/* SYSCALLS.c:495:NC */ extern size_t elf32_fsize (Elf_Type, size_t, unsigned int); +/* SYSCALLS.c:496:NC */ extern Elf32_Ehdr *elf32_getehdr (Elf *); +/* SYSCALLS.c:497:NC */ extern Elf32_Phdr *elf32_getphdr (Elf *); +/* SYSCALLS.c:498:NC */ extern Elf32_Shdr *elf32_getshdr (Elf_Scn *); +/* SYSCALLS.c:499:NC */ extern Elf32_Ehdr *elf32_newehdr (Elf *); +/* SYSCALLS.c:500:NC */ extern Elf32_Phdr *elf32_newphdr (Elf *, size_t); +/* SYSCALLS.c:501:NC */ extern Elf_Data *elf32_xlatetof (Elf_Data *, const Elf_Data *, unsigned int); +/* SYSCALLS.c:502:NC */ extern Elf_Data *elf32_xlatetom (Elf_Data *, const Elf_Data *, unsigned int); +/* SYSCALLS.c:503:NC */ extern Elf *elf_begin (int, Elf_Cmd, Elf *); +/* SYSCALLS.c:504:NC */ extern int elf_cntl (Elf *, Elf_Cmd); +/* SYSCALLS.c:505:NC */ extern int elf_end (Elf *); +/* SYSCALLS.c:506:NC */ extern const char *elf_errmsg (int); +/* SYSCALLS.c:507:NC */ extern int elf_errno (void); +/* SYSCALLS.c:508:NC */ extern void elf_fill (int); +/* SYSCALLS.c:509:NC */ extern unsigned int elf_flagdata (Elf_Data *, Elf_Cmd, unsigned int); +/* SYSCALLS.c:510:NC */ extern unsigned int elf_flagehdr (Elf *, Elf_Cmd, unsigned int); +/* SYSCALLS.c:511:NC */ extern unsigned int elf_flagelf (Elf *, Elf_Cmd, unsigned int); +/* SYSCALLS.c:512:NC */ extern unsigned int elf_flagphdr (Elf *, Elf_Cmd, unsigned int); +/* SYSCALLS.c:513:NC */ extern unsigned int elf_flagscn (Elf_Scn *, Elf_Cmd, unsigned int); +/* SYSCALLS.c:514:NC */ extern unsigned int elf_flagshdr (Elf_Scn *, Elf_Cmd, unsigned int); +/* SYSCALLS.c:515:NC */ extern Elf_Arhdr *elf_getarhdr (Elf *); +/* SYSCALLS.c:516:NC */ extern Elf_Arsym *elf_getarsym (Elf *, size_t *); +/* SYSCALLS.c:517:NC */ extern off_t elf_getbase (Elf *); +/* SYSCALLS.c:518:NC */ extern Elf_Data *elf_getdata (Elf_Scn *, Elf_Data *); +/* SYSCALLS.c:519:NC */ extern char *elf_getident (Elf *, size_t *); +/* SYSCALLS.c:520:NC */ extern Elf_Scn *elf_getscn (Elf *, size_t); +/* SYSCALLS.c:521:NC */ extern long unsigned int elf_hash (const char *); +/* SYSCALLS.c:522:NC */ extern Elf_Kind elf_kind (Elf *); +/* SYSCALLS.c:523:NC */ extern size_t elf_ndxscn (Elf_Scn *); +/* SYSCALLS.c:524:NC */ extern Elf_Data *elf_newdata (Elf_Scn *); +/* SYSCALLS.c:525:NC */ extern Elf_Scn *elf_newscn (Elf *); +/* SYSCALLS.c:526:NC */ extern Elf_Cmd elf_next (Elf *); +/* SYSCALLS.c:527:NC */ extern Elf_Scn *elf_nextscn (Elf *, Elf_Scn *); +/* SYSCALLS.c:528:NC */ extern size_t elf_rand (Elf *, size_t); +/* SYSCALLS.c:529:NC */ extern Elf_Data *elf_rawdata (Elf_Scn *, Elf_Data *); +/* SYSCALLS.c:530:NC */ extern char *elf_rawfile (Elf *, size_t *); +/* SYSCALLS.c:531:NC */ extern char *elf_strptr (Elf *, size_t, size_t); +/* SYSCALLS.c:532:NC */ extern off_t elf_update (Elf *, Elf_Cmd); +/* SYSCALLS.c:533:NC */ extern unsigned int elf_version (unsigned int); +/* SYSCALLS.c:534:NC */ extern void encrypt (char *, int); +/* SYSCALLS.c:535:NC */ extern void endgrent (void); +/* SYSCALLS.c:536:NC */ extern int endnetconfig (void *); +/* SYSCALLS.c:537:NC */ extern int endnetpath (void *); +/* SYSCALLS.c:538:NC */ extern void endpwent (void); +/* SYSCALLS.c:539:NC */ extern void endrpcent (void); +/* SYSCALLS.c:540:NC */ extern void endspent (void); +/* SYSCALLS.c:541:NC */ extern void endutent (void); +/* SYSCALLS.c:542:NC */ extern void endutxent (void); +/* SYSCALLS.c:543:NC */ extern int endwin (void); +/* SYSCALLS.c:544:NC */ extern double erand (short int *); +/* SYSCALLS.c:545:NC */ extern double erand48 (short unsigned int *); +/* SYSCALLS.c:546:NC */ extern char erasechar (void); +/* SYSCALLS.c:547:NC */ extern double erf (double); +/* SYSCALLS.c:548:NC */ extern double erfc (double); +/* SYSCALLS.c:549:NC */ extern int execl (const char *, const char *, ...); +/* SYSCALLS.c:550:NC */ extern int execle (const char *, const char *, ...); +/* SYSCALLS.c:551:NC */ extern int execlp (const char *, const char *, ...); +/* SYSCALLS.c:552:NC */ extern int exect (const char *, const char **, char **); +/* SYSCALLS.c:553:NC */ extern int execv (const char *, char *const *); +/* SYSCALLS.c:554:NC */ extern int execve (const char *, char *const *, char *const *); +/* SYSCALLS.c:555:NC */ extern int execvp (const char *, char *const *); +/* SYSCALLS.c:556:NC */ extern void exit (int); +/* SYSCALLS.c:557:NC */ extern double exp (double); +/* SYSCALLS.c:558:NC */ extern float expf (float); +/* SYSCALLS.c:559:NC */ extern double fabs (double); +/* SYSCALLS.c:560:NC */ extern float fabsf (float); +/* SYSCALLS.c:561:NC */ extern int fattach (int, const char *); +/* SYSCALLS.c:562:NC */ extern int fchdir (int); +/* SYSCALLS.c:563:NC */ extern int fchmod (int, mode_t); +/* SYSCALLS.c:564:NC */ extern int fchown (int, uid_t, gid_t); +/* SYSCALLS.c:565:NC */ extern int fclose (FILE *); +/* SYSCALLS.c:566:NC */ extern int fcntl (int, int, ...); +/* SYSCALLS.c:567:NC */ extern char *fcvt (double, int, int *, int *); +/* SYSCALLS.c:568:NC */ extern int fdetach (const char *); +/* SYSCALLS.c:569:NC */ extern FILE *fdopen (int, const char *); +/* SYSCALLS.c:570:NC */ extern int feof (FILE *); +/* SYSCALLS.c:571:NC */ extern int ferror (FILE *); +/* SYSCALLS.c:572:NC */ extern datum fetch (datum); +/* SYSCALLS.c:573:NC */ extern int fflush (FILE *); +/* SYSCALLS.c:574:NC */ extern int ffs (int); +/* SYSCALLS.c:575:NC */ extern int fgetc (FILE *); +/* SYSCALLS.c:576:NC */ extern struct group *fgetgrent (FILE *); +/* SYSCALLS.c:577:NC */ extern int fgetpos (FILE *, fpos_t *); +/* SYSCALLS.c:578:NC */ extern struct passwd *fgetpwent (FILE *); +/* SYSCALLS.c:579:NC */ extern char *fgets (char *, int, FILE *); +/* SYSCALLS.c:580:NC */ extern struct spwd *fgetspent (FILE *); +/* SYSCALLS.c:581:NC */ extern char *field_arg (FIELD *); +/* SYSCALLS.c:582:NC */ extern chtype field_back (FIELD *); +/* SYSCALLS.c:583:NC */ extern char *field_buffer (FIELD *, int); +/* SYSCALLS.c:584:NC */ extern int field_count (FORM *); +/* SYSCALLS.c:585:NC */ extern chtype field_fore (FIELD *); +/* SYSCALLS.c:586:NC */ extern int field_index (FIELD *); +/* SYSCALLS.c:587:NC */ extern int field_info (FIELD *, int *, int *, int *, int *, int *, int *); +/* SYSCALLS.c:588:NC */ extern PTF_void field_init (FORM *); +/* SYSCALLS.c:589:NC */ extern int field_just (FIELD *); +/* SYSCALLS.c:590:NC */ extern OPTIONS field_opts (FIELD *); +/* SYSCALLS.c:591:NC */ extern int field_opts_off (FIELD *, OPTIONS); +/* SYSCALLS.c:592:NC */ extern int field_opts_on (FIELD *, OPTIONS); +/* SYSCALLS.c:593:NC */ extern int field_pad (FIELD *); +/* SYSCALLS.c:594:NC */ extern int field_status (FIELD *); +/* SYSCALLS.c:595:NC */ extern PTF_void field_term (FORM *); +/* SYSCALLS.c:596:NC */ extern FIELDTYPE *field_type (FIELD *); +/* SYSCALLS.c:597:NC */ extern char *field_userptr (FIELD *); +/* SYSCALLS.c:598:NC */ extern int fileno (FILE *); +/* SYSCALLS.c:599:NC */ extern int filter (void); +/* SYSCALLS.c:600:NC */ extern int finite (double); +/* SYSCALLS.c:601:OC */ extern datum firsthash (/* ??? */); +/* SYSCALLS.c:602:NC */ extern datum firstkey (void); +/* SYSCALLS.c:603:NC */ extern int flash (void); +/* SYSCALLS.c:604:NC */ extern int flock (int, int); +/* SYSCALLS.c:605:NC */ extern double floor (double); +/* SYSCALLS.c:606:NC */ extern float floorf (float); +/* SYSCALLS.c:607:NC */ extern int flushinp (void); +/* SYSCALLS.c:608:NC */ extern double fmod (double, double); +/* SYSCALLS.c:609:NC */ extern float fmodf (float, float); +/* SYSCALLS.c:610:NC */ extern int fmtmsg (long int, const char *, int, const char *, const char *, const char *); +/* SYSCALLS.c:611:NC */ extern FILE *fopen (const char *, const char *); +/* SYSCALLS.c:612:NC */ extern pid_t fork (void); +/* SYSCALLS.c:613:NC */ extern int form_driver (FORM *, int); +/* SYSCALLS.c:614:NC */ extern FIELD **form_fields (FORM *); +/* SYSCALLS.c:615:NC */ extern PTF_void form_init (FORM *); +/* SYSCALLS.c:616:NC */ extern OPTIONS form_opts (FORM *); +/* SYSCALLS.c:617:NC */ extern int form_opts_off (FORM *, OPTIONS); +/* SYSCALLS.c:618:NC */ extern int form_opts_on (FORM *, OPTIONS); +/* SYSCALLS.c:619:NC */ extern int form_page (FORM *); +/* SYSCALLS.c:620:NC */ extern WINDOW *form_sub (FORM *); +/* SYSCALLS.c:621:NC */ extern PTF_void form_term (FORM *); +/* SYSCALLS.c:622:NC */ extern char *form_userptr (FORM *); +/* SYSCALLS.c:623:NC */ extern WINDOW *form_win (FORM *); +/* SYSCALLS.c:624:NC */ extern long int fpathconf (int, int); +/* SYSCALLS.c:625:NC */ extern fpclass_t fpclass (double); +/* SYSCALLS.c:626:NC */ extern int fpgetmask (void); +/* SYSCALLS.c:627:NC */ extern fp_rnd fpgetround (void); +/* SYSCALLS.c:628:NC */ extern int fpgetsticky (void); +/* SYSCALLS.c:629:NC */ extern int fprintf (FILE *, const char *, ...); +/* SYSCALLS.c:630:NC */ extern int fpsetmask (int); +/* SYSCALLS.c:631:NC */ extern fp_rnd fpsetround (fp_rnd); +/* SYSCALLS.c:632:NC */ extern int fpsetsticky (int); +/* SYSCALLS.c:633:NC */ extern int fputc (int, FILE *); +/* SYSCALLS.c:634:NC */ extern int fputs (const char *, FILE *); +/* SYSCALLS.c:635:NC */ extern size_t fread (void *, size_t, size_t, FILE *); +/* SYSCALLS.c:636:NC */ extern void free (void *); +/* SYSCALLS.c:637:NC */ extern int free_field (FIELD *); +/* SYSCALLS.c:638:NC */ extern int free_fieldtype (FIELDTYPE *); +/* SYSCALLS.c:639:NC */ extern int free_form (FORM *); +/* SYSCALLS.c:640:NC */ extern int free_item (ITEM *); +/* SYSCALLS.c:641:NC */ extern int free_menu (MENU *); +/* SYSCALLS.c:642:NC */ extern void freenetconfigent (struct netconfig *); +/* SYSCALLS.c:643:NC */ extern FILE *freopen (const char *, const char *, FILE *); +/* SYSCALLS.c:644:NC */ extern double frexp (double, int *); +/* SYSCALLS.c:645:NC */ extern int fscanf (FILE *, const char *, ...); +/* SYSCALLS.c:646:NC */ extern int fseek (FILE *, long int, int); +/* SYSCALLS.c:647:NC */ extern int fsetpos (FILE *, const fpos_t *); +/* SYSCALLS.c:648:NC */ extern int fstat (int, struct stat *); +/* SYSCALLS.c:649:NC */ extern int fstatfs (int, struct statfs *, int, int); +/* SYSCALLS.c:650:NC */ extern int fstatvfs (int, struct statvfs *); +/* SYSCALLS.c:651:NC */ extern int fsync (int); +/* SYSCALLS.c:652:NC */ extern long int ftell (FILE *); +/* SYSCALLS.c:653:NC */ extern key_t ftok (const char *, int); +/* SYSCALLS.c:654:NC */ extern int ftruncate (int, off_t); +/* SYSCALLS.c:655:NC */ extern int ftw (const char *, int (*) (const char *, const struct stat *, int), int); +/* SYSCALLS.c:656:NC */ extern size_t fwrite (const void *, size_t, size_t, FILE *); +/* SYSCALLS.c:657:NC */ extern double gamma (double); +/* SYSCALLS.c:658:NC */ extern char *gcvt (double, int, char *); +/* SYSCALLS.c:659:OC */ extern int get_error (/* ??? */); +/* SYSCALLS.c:660:NC */ extern chtype getattrs (WINDOW *); +/* SYSCALLS.c:661:NC */ extern int getbegx (WINDOW *); +/* SYSCALLS.c:662:NC */ extern int getbegy (WINDOW *); +/* SYSCALLS.c:663:NC */ extern chtype getbkgd (WINDOW *); +/* SYSCALLS.c:664:NC */ extern long unsigned int getbmap (void); +/* SYSCALLS.c:665:NC */ extern int getc (FILE *); +/* SYSCALLS.c:666:OC */ extern char *getcap (/* ??? */); +/* SYSCALLS.c:667:NC */ extern int getchar (void); +/* SYSCALLS.c:668:NC */ extern int getcontext (ucontext_t *); +/* SYSCALLS.c:669:NC */ extern int getcurx (WINDOW *); +/* SYSCALLS.c:670:NC */ extern int getcury (WINDOW *); +/* SYSCALLS.c:671:NC */ extern char *getcwd (char *, size_t); +/* SYSCALLS.c:672:NC */ extern struct tm *getdate (const char *); +/* SYSCALLS.c:673:NC */ extern int getdents (int, struct dirent *, unsigned int); +/* SYSCALLS.c:674:OC */ extern char **getdev (/* ??? */); +/* SYSCALLS.c:675:OC */ extern char **getdgrp (/* ??? */); +/* SYSCALLS.c:676:NC */ extern int getdomainname (char *, int); +/* SYSCALLS.c:677:NC */ extern int getdtablesize (void); +/* SYSCALLS.c:678:NC */ extern gid_t getegid (void); +/* SYSCALLS.c:679:NC */ extern char *getenv (const char *); +/* SYSCALLS.c:680:OC */ extern struct errhdr *geterec (/* ??? */); +/* SYSCALLS.c:681:OC */ extern struct errhdr *geteslot (/* ??? */); +/* SYSCALLS.c:682:NC */ extern uid_t geteuid (void); +/* SYSCALLS.c:683:NC */ extern gid_t getgid (void); +/* SYSCALLS.c:684:NC */ extern struct group *getgrent (void); +/* SYSCALLS.c:685:NC */ extern struct group *getgrgid (gid_t); +/* SYSCALLS.c:686:NC */ extern struct group *getgrnam (const char *); +/* SYSCALLS.c:687:NC */ extern int getgroups (int, int *); +/* SYSCALLS.c:688:OC */ extern struct hostent *gethostbyaddr (/* ??? */); +/* SYSCALLS.c:689:OC */ extern struct hostent *gethostbyname (/* ??? */); +/* SYSCALLS.c:690:OC */ extern struct hostent *gethostent (/* ??? */); +/* SYSCALLS.c:694:NC */ extern long int gethostid (void); +/* SYSCALLS.c:696:NC */ extern int gethostname (char *, size_t); +/* SYSCALLS.c:697:NC */ extern int getitimer (int, struct itimerval *); +/* SYSCALLS.c:698:NC */ extern char *getlogin (void); +/* SYSCALLS.c:699:NC */ extern int getmaxx (WINDOW *); +/* SYSCALLS.c:700:NC */ extern int getmaxy (WINDOW *); +/* SYSCALLS.c:701:NC */ extern int getmntany (FILE *, struct mnttab *, struct mnttab *); +/* SYSCALLS.c:702:OC */ extern int getmntent (/* ??? */); +/* SYSCALLS.c:703:NC */ extern long unsigned int getmouse (void); +/* SYSCALLS.c:704:NC */ extern int getmsg (int, struct strbuf *, struct strbuf *, int *); +/* SYSCALLS.c:705:OC */ extern struct netent *getnetbyaddr (/* ??? */); +/* SYSCALLS.c:706:OC */ extern struct netent *getnetbyname (/* ??? */); +/* SYSCALLS.c:707:NC */ extern struct netconfig *getnetconfig (void *); +/* SYSCALLS.c:708:NC */ extern struct netconfig *getnetconfigent (char *); +/* SYSCALLS.c:709:OC */ extern struct netent *getnetent (/* ??? */); +/* SYSCALLS.c:710:NC */ extern struct netconfig *getnetpath (void *); +/* SYSCALLS.c:711:NC */ extern int getopt (int, char *const *, const char *); +/* SYSCALLS.c:712:NC */ extern int getpagesize (void); +/* SYSCALLS.c:713:NC */ extern int getparx (WINDOW *); +/* SYSCALLS.c:714:NC */ extern int getpary (WINDOW *); +/* SYSCALLS.c:715:NC */ extern char *getpass (const char *); +/* SYSCALLS.c:716:NC */ extern pid_t getpgid (pid_t); +/* SYSCALLS.c:717:NC */ extern pid_t getpgrp (void); +/* SYSCALLS.c:718:NC */ extern pid_t getpgrp2 (pid_t); +/* SYSCALLS.c:719:NC */ extern pid_t getpid (void); +/* SYSCALLS.c:720:NC */ extern int getpmsg (int, struct strbuf *, struct strbuf *, int *, int *); +/* SYSCALLS.c:721:NC */ extern pid_t getppid (void); +/* SYSCALLS.c:722:NC */ extern int getpriority (int, int); +/* SYSCALLS.c:723:OC */ extern struct protoent *getprotobyname (/* ??? */); +/* SYSCALLS.c:724:OC */ extern struct protoent *getprotobynumber (/* ??? */); +/* SYSCALLS.c:725:OC */ extern struct protoent *getprotoent (/* ??? */); +/* SYSCALLS.c:726:NC */ extern int getpw (int, char *); +/* SYSCALLS.c:727:NC */ extern struct passwd *getpwent (void); +/* SYSCALLS.c:728:NC */ extern struct passwd *getpwnam (const char *); +/* SYSCALLS.c:729:NC */ extern struct passwd *getpwuid (uid_t); +/* SYSCALLS.c:730:NC */ extern int getrlimit (int, struct rlimit *); +/* SYSCALLS.c:731:NC */ extern int getrnge (char *); +/* SYSCALLS.c:732:NC */ extern struct rpcent *getrpcbyname (const char *); +/* SYSCALLS.c:733:NC */ extern struct rpcent *getrpcbynumber (int); +/* SYSCALLS.c:734:NC */ extern struct rpcent *getrpcent (void); +/* SYSCALLS.c:735:NC */ extern int getrusage (int, struct rusage *); +/* SYSCALLS.c:736:NC */ extern char *gets (char *); +/* SYSCALLS.c:737:OC */ extern struct servent *getservbyname (/* ??? */); +/* SYSCALLS.c:738:OC */ extern struct servent *getservbyport (/* ??? */); +/* SYSCALLS.c:739:OC */ extern struct servent *getservent (/* ??? */); +/* SYSCALLS.c:740:NC */ extern pid_t getsid (pid_t); +/* SYSCALLS.c:741:NC */ extern struct spwd *getspent (void); +/* SYSCALLS.c:742:NC */ extern struct spwd *getspnam (const char *); +/* SYSCALLS.c:743:NC */ extern int getsubopt (char **, char *const *, char **); +/* SYSCALLS.c:744:NC */ extern int gettmode (void); +/* SYSCALLS.c:745:NC */ extern char *gettxt (const char *, const char *); +/* SYSCALLS.c:746:NC */ extern uid_t getuid (void); +/* SYSCALLS.c:747:NC */ extern struct utmp *getutent (void); +/* SYSCALLS.c:748:NC */ extern struct utmp *getutid (const struct utmp *); +/* SYSCALLS.c:749:NC */ extern struct utmp *getutline (const struct utmp *); +/* SYSCALLS.c:750:NC */ extern void getutmp (const struct utmpx *, struct utmp *); +/* SYSCALLS.c:751:NC */ extern void getutmpx (const struct utmp *, struct utmpx *); +/* SYSCALLS.c:752:NC */ extern struct utmpx *getutxent (void); +/* SYSCALLS.c:753:NC */ extern struct utmpx *getutxid (const struct utmpx *); +/* SYSCALLS.c:754:NC */ extern struct utmpx *getutxline (const struct utmpx *); +/* SYSCALLS.c:755:NC */ extern int getvfsany (FILE *, struct vfstab *, struct vfstab *); +/* SYSCALLS.c:756:NC */ extern int getvfsent (FILE *, struct vfstab *); +/* SYSCALLS.c:757:NC */ extern int getvfsfile (FILE *, struct vfstab *, char *); +/* SYSCALLS.c:758:NC */ extern int getvfsspec (FILE *, struct vfstab *, char *); +/* SYSCALLS.c:759:OC */ extern int getvol (/* ??? */); +/* SYSCALLS.c:760:NC */ extern int getw (FILE *); +/* SYSCALLS.c:761:NC */ extern char *getwd (char *); +/* SYSCALLS.c:762:NC */ extern void getwidth (eucwidth_t *); +/* SYSCALLS.c:763:NC */ extern WINDOW *getwin (FILE *); +/* SYSCALLS.c:764:NC */ extern int gmatch (const char *, const char *); +/* SYSCALLS.c:765:NC */ extern struct tm *gmtime (const time_t *); +/* SYSCALLS.c:766:NC */ extern int gsignal (int); +/* SYSCALLS.c:767:NC */ extern int halfdelay (int); +/* SYSCALLS.c:768:NC */ extern bool has_colors (void); +/* SYSCALLS.c:769:NC */ extern int has_ic (void); +/* SYSCALLS.c:770:NC */ extern int has_il (void); +/* SYSCALLS.c:771:OC */ extern long int hashinc (/* ??? */); +/* SYSCALLS.c:772:OC */ extern char *hasmntopt (/* ??? */); +/* SYSCALLS.c:773:NC */ extern int hcreate (size_t); +/* SYSCALLS.c:774:NC */ extern void hdestroy (void); +/* SYSCALLS.c:775:NC */ extern int hide_panel (PANEL *); +/* SYSCALLS.c:776:NC */ extern int host2netname (char *, char *, char *); +/* SYSCALLS.c:777:NC */ extern int hrtalarm (hrtcmd_t *, int); +/* SYSCALLS.c:778:NC */ extern int hrtcancel (const long int *, int); +/* SYSCALLS.c:779:NC */ extern int hrtcntl (int, int, interval_t *, hrtime_t *); +/* SYSCALLS.c:780:NC */ extern int hrtsleep (hrtcmd_t *); +/* SYSCALLS.c:781:NC */ extern ENTRY *hsearch (ENTRY, ACTION); +/* SYSCALLS.c:782:NC */ extern long unsigned int htonl (long unsigned int); +/* SYSCALLS.c:783:NC */ extern short unsigned int htons (unsigned int); +/* SYSCALLS.c:784:NC */ extern double hypot (double, double); +/* SYSCALLS.c:785:NC */ extern void idcok (WINDOW *, int); +/* SYSCALLS.c:786:NC */ extern int idlok (WINDOW *, int); +/* SYSCALLS.c:787:NC */ extern void immedok (WINDOW *, int); +/* SYSCALLS.c:788:NC */ extern char *index (const char *, int); +/* SYSCALLS.c:789:OC */ extern long unsigned int inet_addr (/* ??? */); +/* SYSCALLS.c:790:OC */ extern struct in_addr inet_makeaddr (/* ??? */); +/* SYSCALLS.c:791:OC */ extern long unsigned int inet_network (/* ??? */); +/* SYSCALLS.c:792:OC */ extern char *inet_ntoa (/* ??? */); +/* SYSCALLS.c:793:NC */ extern int init_color (int, int, int, int); +/* SYSCALLS.c:794:NC */ extern int init_pair (int, int, int); +/* SYSCALLS.c:795:NC */ extern int initgroups (const char *, gid_t); +/* SYSCALLS.c:796:OC */ extern WINDOW *initscr (/* ??? */); +/* SYSCALLS.c:797:NC */ extern WINDOW *initscr32 (void); +/* SYSCALLS.c:798:NC */ extern char *initstate (unsigned int, char *, int); +/* SYSCALLS.c:799:NC */ extern void insque (struct qelem *, struct qelem *); +/* SYSCALLS.c:800:NC */ extern int intrflush (WINDOW *, int); +/* SYSCALLS.c:801:NC */ extern int ioctl (int, int, ...); +/* SYSCALLS.c:802:NC */ extern int is_linetouched (WINDOW *, int); +/* SYSCALLS.c:803:NC */ extern int is_wintouched (WINDOW *); +/* SYSCALLS.c:804:NC */ extern int isalnum (int); +/* SYSCALLS.c:805:NC */ extern int isalpha (int); +/* SYSCALLS.c:806:NC */ extern int isascii (int); +/* SYSCALLS.c:807:NC */ extern int isatty (int); +/* SYSCALLS.c:808:NC */ extern int iscntrl (int); +/* SYSCALLS.c:809:NC */ extern int isdigit (int); +/* SYSCALLS.c:810:NC */ extern int isencrypt (const char *, size_t); +/* SYSCALLS.c:811:NC */ extern int isendwin (void); +/* SYSCALLS.c:812:NC */ extern int isgraph (int); +/* SYSCALLS.c:813:NC */ extern int isinf (double); +/* SYSCALLS.c:814:NC */ extern int islower (int); +/* SYSCALLS.c:815:NC */ extern int isnan (double); +/* SYSCALLS.c:816:NC */ extern int isnand (double); +/* SYSCALLS.c:817:NC */ extern int isnanf (float); +/* SYSCALLS.c:818:NC */ extern int isprint (int); +/* SYSCALLS.c:819:NC */ extern int ispunct (int); +/* SYSCALLS.c:820:NC */ extern int isspace (int); +/* SYSCALLS.c:821:NC */ extern int isupper (int); +/* SYSCALLS.c:822:NC */ extern int isxdigit (int); +/* SYSCALLS.c:823:NC */ extern int item_count (MENU *); +/* SYSCALLS.c:824:NC */ extern char *item_description (ITEM *); +/* SYSCALLS.c:825:NC */ extern int item_index (ITEM *); +/* SYSCALLS.c:826:NC */ extern PTF_void item_init (MENU *); +/* SYSCALLS.c:827:NC */ extern char *item_name (ITEM *); +/* SYSCALLS.c:828:NC */ extern OPTIONS item_opts (ITEM *); +/* SYSCALLS.c:829:NC */ extern int item_opts_off (ITEM *, OPTIONS); +/* SYSCALLS.c:830:NC */ extern int item_opts_on (ITEM *, OPTIONS); +/* SYSCALLS.c:831:NC */ extern PTF_void item_term (MENU *); +/* SYSCALLS.c:832:NC */ extern char *item_userptr (ITEM *); +/* SYSCALLS.c:833:NC */ extern int item_value (ITEM *); +/* SYSCALLS.c:834:NC */ extern int item_visible (ITEM *); +/* SYSCALLS.c:835:OC */ extern long int itol (/* ??? */); +/* SYSCALLS.c:836:NC */ extern double j0 (double); +/* SYSCALLS.c:837:NC */ extern double j1 (double); +/* SYSCALLS.c:838:NC */ extern double jn (int, double); +/* SYSCALLS.c:839:NC */ extern long int jrand48 (short unsigned int *); +/* SYSCALLS.c:840:NC */ extern char *keyname (int); +/* SYSCALLS.c:841:NC */ extern int keypad (WINDOW *, int); +/* SYSCALLS.c:842:NC */ extern int kill (pid_t, int); +/* SYSCALLS.c:843:NC */ extern char killchar (void); +/* SYSCALLS.c:844:NC */ extern int killpg (int, int); +/* SYSCALLS.c:845:NC */ extern void l3tol (long int *, const char *, int); +/* SYSCALLS.c:846:NC */ extern char *l64a (long int); +/* SYSCALLS.c:847:NC */ extern long int labs (long int); +/* SYSCALLS.c:848:OC */ extern dl_t ladd (/* ??? */); +/* SYSCALLS.c:849:NC */ extern int lchown (const char *, uid_t, gid_t); +/* SYSCALLS.c:850:NC */ extern int lckpwdf (void); +/* SYSCALLS.c:851:NC */ extern void lcong48 (short unsigned int *); +/* SYSCALLS.c:852:NC */ extern int ldaclose (struct ldfile *); +/* SYSCALLS.c:853:NC */ extern int ldahread (struct ldfile *, archdr *); +/* SYSCALLS.c:854:NC */ extern struct ldfile *ldaopen (const char *, struct ldfile *); +/* SYSCALLS.c:855:NC */ extern int ldclose (struct ldfile *); +/* SYSCALLS.c:856:NC */ extern double ldexp (double, int); +/* SYSCALLS.c:857:NC */ extern int ldfhread (struct ldfile *, struct filehdr *); +/* SYSCALLS.c:858:NC */ extern char *ldgetname (struct ldfile *, const struct syment *); +/* SYSCALLS.c:859:NC */ extern ldiv_t ldiv (long int, long int); +/* SYSCALLS.c:860:OC */ extern dl_t ldivide (/* ??? */); +/* SYSCALLS.c:861:NC */ extern int ldlinit (struct ldfile *, long int); +/* SYSCALLS.c:862:NC */ extern int ldlitem (struct ldfile *, unsigned int, struct lineno *); +/* SYSCALLS.c:863:NC */ extern int ldlread (struct ldfile *, long int, unsigned int, struct lineno *); +/* SYSCALLS.c:864:NC */ extern int ldlseek (struct ldfile *, unsigned int); +/* SYSCALLS.c:865:NC */ extern int ldnlseek (struct ldfile *, const char *); +/* SYSCALLS.c:866:NC */ extern int ldnrseek (struct ldfile *, const char *); +/* SYSCALLS.c:867:NC */ extern int ldnshread (struct ldfile *, const char *, struct scnhdr *); +/* SYSCALLS.c:868:NC */ extern int ldnsseek (struct ldfile *, const char *); +/* SYSCALLS.c:869:NC */ extern int ldohseek (struct ldfile *); +/* SYSCALLS.c:870:NC */ extern struct ldfile *ldopen (const char *, struct ldfile *); +/* SYSCALLS.c:871:NC */ extern int ldrseek (struct ldfile *, unsigned int); +/* SYSCALLS.c:872:NC */ extern int ldshread (struct ldfile *, unsigned int, struct scnhdr *); +/* SYSCALLS.c:873:NC */ extern int ldsseek (struct ldfile *, unsigned int); +/* SYSCALLS.c:874:NC */ extern long int ldtbindex (struct ldfile *); +/* SYSCALLS.c:875:NC */ extern int ldtbread (struct ldfile *, long int, struct syment *); +/* SYSCALLS.c:876:NC */ extern int ldtbseek (struct ldfile *); +/* SYSCALLS.c:877:NC */ extern int leaveok (WINDOW *, int); +/* SYSCALLS.c:878:OC */ extern dl_t lexp10 (/* ??? */); +/* SYSCALLS.c:879:NC */ extern void *lfind (const void *, const void *, size_t *, size_t, int (*) (const void *, const void *)); +/* SYSCALLS.c:880:NC */ extern double lgamma (double); +/* SYSCALLS.c:881:NC */ extern int link (const char *, const char *); +/* SYSCALLS.c:882:NC */ extern FIELD *link_field (FIELD *, int, int); +/* SYSCALLS.c:883:NC */ extern FIELDTYPE *link_fieldtype (FIELDTYPE *, FIELDTYPE *); +/* SYSCALLS.c:884:OC */ extern char **listdev (/* ??? */); +/* SYSCALLS.c:885:OC */ extern char **listdgrp (/* ??? */); +/* SYSCALLS.c:886:OC */ extern dl_t llog10 (/* ??? */); +/* SYSCALLS.c:887:OC */ extern dl_t lmul (/* ??? */); +/* SYSCALLS.c:888:NC */ extern struct lconv *localeconv (void); +/* SYSCALLS.c:889:NC */ extern struct tm *localtime (const time_t *); +/* SYSCALLS.c:890:NC */ extern int lock (int, int, long int); +/* SYSCALLS.c:891:NC */ extern int lockf (int, int, off_t); +/* SYSCALLS.c:892:NC */ extern double log (double); +/* SYSCALLS.c:893:NC */ extern double log10 (double); +/* SYSCALLS.c:894:NC */ extern float log10f (float); +/* SYSCALLS.c:895:NC */ extern double logb (double); +/* SYSCALLS.c:896:NC */ extern float logf (float); +/* SYSCALLS.c:897:NC */ extern char *logname (void); +/* SYSCALLS.c:898:NC */ extern void longjmp (jmp_buf, int); +/* SYSCALLS.c:899:NC */ extern char *longname (void); +/* SYSCALLS.c:900:NC */ extern long int lrand48 (void); +/* SYSCALLS.c:901:NC */ extern void *lsearch (const void *, void *, size_t *, size_t, int (*) (const void *, const void *)); +/* SYSCALLS.c:902:NC */ extern off_t lseek (int, off_t, int); +/* SYSCALLS.c:903:OC */ extern dl_t lshiftl (/* ??? */); +/* SYSCALLS.c:904:NC */ extern int lstat (const char *, struct stat *); +/* SYSCALLS.c:905:OC */ extern dl_t lsub (/* ??? */); +/* SYSCALLS.c:906:NC */ extern void ltol3 (char *, const long int *, int); +/* SYSCALLS.c:907:NC */ extern int m_addch (int); +/* SYSCALLS.c:908:NC */ extern int m_addstr (char *); +/* SYSCALLS.c:909:NC */ extern int m_clear (void); +/* SYSCALLS.c:910:NC */ extern int m_erase (void); +/* SYSCALLS.c:911:NC */ extern WINDOW *m_initscr (void); +/* SYSCALLS.c:912:NC */ extern int m_move (int, int); +/* SYSCALLS.c:913:NC */ extern SCREEN *m_newterm (char *, FILE *, FILE *); +/* SYSCALLS.c:914:NC */ extern int m_refresh (void); +/* SYSCALLS.c:915:NC */ extern int maillock (char *, int); +/* SYSCALLS.c:916:NC */ extern int mailunlock (void); +/* SYSCALLS.c:917:NC */ extern major_t major (dev_t); +/* SYSCALLS.c:918:OC */ extern datum makdatum (/* ??? */); +/* SYSCALLS.c:919:NC */ extern void makecontext (ucontext_t *, void (*) (/* ??? */), int, ...); +/* SYSCALLS.c:920:NC */ extern dev_t makedev (major_t, minor_t); +/* SYSCALLS.c:921:NC */ extern struct utmpx *makeutx (const struct utmpx *); +/* SYSCALLS.c:922:NC */ extern struct mallinfo mallinfo (void); +/* SYSCALLS.c:923:NC */ extern void *malloc (size_t); +/* SYSCALLS.c:924:NC */ extern int mallopt (int, int); +/* SYSCALLS.c:925:NC */ extern int map_button (long unsigned int); +/* SYSCALLS.c:926:NC */ extern int matherr (struct exception *); +/* SYSCALLS.c:927:NC */ extern int mbftowc (char *, wchar_t *, int (*) (/* ??? */), int *); +/* SYSCALLS.c:928:NC */ extern int mblen (const char *, size_t); +/* SYSCALLS.c:929:NC */ extern size_t mbstowcs (wchar_t *, const char *, size_t); +/* SYSCALLS.c:930:NC */ extern int mbtowc (wchar_t *, const char *, size_t); +/* SYSCALLS.c:931:NC */ extern void *memalign (size_t, size_t); +/* SYSCALLS.c:932:NC */ extern void *memccpy (void *, const void *, int, size_t); +/* SYSCALLS.c:933:NC */ extern void *memchr (const void *, int, size_t); +/* SYSCALLS.c:934:NC */ extern int memcmp (const void *, const void *, size_t); +/* SYSCALLS.c:935:NC */ extern void *memcpy (void *, const void *, size_t); +/* SYSCALLS.c:936:OC */ extern int memlock (/* ??? */); +/* SYSCALLS.c:937:OC */ extern int memlocked (/* ??? */); +/* SYSCALLS.c:938:NC */ extern void *memmove (void *, const void *, size_t); +/* SYSCALLS.c:939:NC */ extern void *memset (void *, int, size_t); +/* SYSCALLS.c:940:OC */ extern int memunlock (/* ??? */); +/* SYSCALLS.c:941:NC */ extern chtype menu_back (MENU *); +/* SYSCALLS.c:942:NC */ extern int menu_driver (MENU *, int); +/* SYSCALLS.c:943:NC */ extern chtype menu_fore (MENU *); +/* SYSCALLS.c:944:NC */ extern void menu_format (MENU *, int *, int *); +/* SYSCALLS.c:945:NC */ extern chtype menu_grey (MENU *); +/* SYSCALLS.c:946:NC */ extern PTF_void menu_init (MENU *); +/* SYSCALLS.c:947:NC */ extern ITEM **menu_items (MENU *); +/* SYSCALLS.c:948:NC */ extern char *menu_mark (MENU *); +/* SYSCALLS.c:949:NC */ extern OPTIONS menu_opts (MENU *); +/* SYSCALLS.c:950:NC */ extern int menu_opts_off (MENU *, OPTIONS); +/* SYSCALLS.c:951:NC */ extern int menu_opts_on (MENU *, OPTIONS); +/* SYSCALLS.c:952:NC */ extern int menu_pad (MENU *); +/* SYSCALLS.c:953:NC */ extern char *menu_pattern (MENU *); +/* SYSCALLS.c:954:NC */ extern WINDOW *menu_sub (MENU *); +/* SYSCALLS.c:955:NC */ extern PTF_void menu_term (MENU *); +/* SYSCALLS.c:956:NC */ extern char *menu_userptr (MENU *); +/* SYSCALLS.c:957:NC */ extern WINDOW *menu_win (MENU *); +/* SYSCALLS.c:958:NC */ extern int meta (WINDOW *, int); +/* SYSCALLS.c:959:NC */ extern void mfree (struct map *, size_t, u_long); +/* SYSCALLS.c:960:NC */ extern int mincore (caddr_t, size_t, char *); +/* SYSCALLS.c:961:NC */ extern minor_t minor (dev_t); +/* SYSCALLS.c:962:NC */ extern int mkdir (const char *, mode_t); +/* SYSCALLS.c:963:NC */ extern int mkdirp (const char *, mode_t); +/* SYSCALLS.c:964:NC */ extern int mkfifo (const char *, mode_t); +/* SYSCALLS.c:965:NC */ extern int mknod (const char *, mode_t, dev_t); +/* SYSCALLS.c:966:NC */ extern int mkstemp (char *); +/* SYSCALLS.c:967:NC */ extern char *mktemp (char *); +/* SYSCALLS.c:968:NC */ extern time_t mktime (struct tm *); +/* SYSCALLS.c:969:OC */ extern caddr_t mmap (/* ??? */); +/* SYSCALLS.c:970:NC */ extern double modf (double, double *); +/* SYSCALLS.c:971:NC */ extern float modff (float, float *); +/* SYSCALLS.c:972:NC */ extern struct utmpx *modutx (const struct utmpx *); +/* SYSCALLS.c:973:NC */ extern void monitor (int (*) (/* ??? */), int (*) (/* ??? */), WORD *, int, int); +/* SYSCALLS.c:974:NC */ extern int mount (const char *, const char *, int, ...); +/* SYSCALLS.c:975:NC */ extern int mouse_off (long int); +/* SYSCALLS.c:976:NC */ extern int mouse_on (long int); +/* SYSCALLS.c:977:NC */ extern int mouse_set (long int); +/* SYSCALLS.c:978:NC */ extern int move_field (FIELD *, int, int); +/* SYSCALLS.c:979:NC */ extern int move_panel (PANEL *, int, int); +/* SYSCALLS.c:980:OC */ extern int mprotect (/* ??? */); +/* SYSCALLS.c:981:NC */ extern long int mrand48 (void); +/* SYSCALLS.c:982:NC */ extern int msgctl (int, int, ...); +/* SYSCALLS.c:983:NC */ extern int msgget (key_t, int); +/* SYSCALLS.c:984:NC */ extern int msgrcv (int, void *, size_t, long int, int); +/* SYSCALLS.c:985:NC */ extern int msgsnd (int, const void *, size_t, int); +/* SYSCALLS.c:986:OC */ extern int munmap (/* ??? */); +/* SYSCALLS.c:987:NC */ extern int mvcur (int, int, int, int); +/* SYSCALLS.c:988:NC */ extern int mvderwin (WINDOW *, int, int); +/* SYSCALLS.c:989:NC */ extern int mvprintw (int, int, ...); +/* SYSCALLS.c:990:NC */ extern int mvscanw (int, int, ...); +/* SYSCALLS.c:991:NC */ extern int mvwin (WINDOW *, int, int); +/* SYSCALLS.c:992:NC */ extern int mvwprintw (WINDOW *, int, int, ...); +/* SYSCALLS.c:993:NC */ extern int mvwscanw (WINDOW *, int, int, ...); +/* SYSCALLS.c:994:NC */ extern int napms (int); +/* SYSCALLS.c:995:NC */ extern void netdir_free (char *, int); +/* SYSCALLS.c:996:NC */ extern int netdir_getbyaddr (struct netconfig *, struct nd_hostservlist **, struct netbuf *); +/* SYSCALLS.c:997:NC */ extern int netdir_getbyname (struct netconfig *, struct nd_hostserv *, struct nd_addrlist **); +/* SYSCALLS.c:998:NC */ extern int netdir_options (struct netconfig *, int, int, char *); +/* SYSCALLS.c:999:NC */ extern void netdir_perror (char *); +/* SYSCALLS.c:1000:OC */ extern char *netdir_sperror (/* ??? */); +/* SYSCALLS.c:1001:NC */ extern FIELD *new_field (int, int, int, int, int, int); +/* SYSCALLS.c:1002:NC */ extern FIELDTYPE *new_fieldtype (PTF_int, PTF_int); +/* SYSCALLS.c:1003:NC */ extern FORM *new_form (FIELD **); +/* SYSCALLS.c:1004:NC */ extern ITEM *new_item (char *, char *); +/* SYSCALLS.c:1005:NC */ extern MENU *new_menu (ITEM **); +/* SYSCALLS.c:1006:NC */ extern int new_page (FIELD *); +/* SYSCALLS.c:1007:NC */ extern PANEL *new_panel (WINDOW *); +/* SYSCALLS.c:1008:NC */ extern int newkey (char *, int, int); +/* SYSCALLS.c:1009:NC */ extern WINDOW *newpad (int, int); +/* SYSCALLS.c:1010:NC */ extern SCREEN *newscreen (char *, int, int, int, FILE *, FILE *); +/* SYSCALLS.c:1011:NC */ extern SCREEN *newterm32 (char *, FILE *, FILE *); +/* SYSCALLS.c:1012:NC */ extern WINDOW *newwin (int, int, int, int); +/* SYSCALLS.c:1013:NC */ extern double nextafter (double, double); +/* SYSCALLS.c:1014:NC */ extern datum nextkey (datum); +/* SYSCALLS.c:1015:NC */ extern int nftw (const char *, int (*) (const char *, const struct stat *, int, struct FTW *), int, int); +/* SYSCALLS.c:1016:NC */ extern int nice (int); +/* SYSCALLS.c:1017:NC */ extern int nl (void); +/* SYSCALLS.c:1018:NC */ extern char *nl_langinfo (nl_item); +/* SYSCALLS.c:1019:NC */ extern int nlist (const char *, struct nlist *); +/* SYSCALLS.c:1020:NC */ extern int nocbreak (void); +/* SYSCALLS.c:1021:NC */ extern int nocrmode (void); +/* SYSCALLS.c:1022:NC */ extern int nodelay (WINDOW *, int); +/* SYSCALLS.c:1023:NC */ extern int noecho (void); +/* SYSCALLS.c:1024:NC */ extern int nonl (void); +/* SYSCALLS.c:1025:NC */ extern int noraw (void); +/* SYSCALLS.c:1026:NC */ extern int notimeout (WINDOW *, int); +/* SYSCALLS.c:1027:NC */ extern long int nrand48 (short unsigned int *); +/* SYSCALLS.c:1028:OC */ extern int ns_close (/* ??? */); +/* SYSCALLS.c:1029:OC */ extern struct nssend *ns_rcv (/* ??? */); +/* SYSCALLS.c:1030:OC */ extern int ns_send (/* ??? */); +/* SYSCALLS.c:1031:OC */ extern int ns_setup (/* ??? */); +/* SYSCALLS.c:1032:NC */ extern long unsigned int ntohl (long unsigned int); +/* SYSCALLS.c:1033:NC */ extern short unsigned int ntohs (unsigned int); +/* SYSCALLS.c:1034:NC */ extern int nuname (struct utsname *); +/* SYSCALLS.c:1035:NC */ extern int open (const char *, int, ...); +/* SYSCALLS.c:1036:NC */ extern DIR *opendir (const char *); +/* SYSCALLS.c:1037:OC */ extern int openprivwait (/* ??? */); +/* SYSCALLS.c:1038:OC */ extern int openwait (/* ??? */); +/* SYSCALLS.c:1039:NC */ extern int overlay (WINDOW *, WINDOW *); +/* SYSCALLS.c:1040:NC */ extern int overwrite (WINDOW *, WINDOW *); +/* SYSCALLS.c:1041:NC */ extern int p2close (FILE **); +/* SYSCALLS.c:1042:NC */ extern int p2open (const char *, FILE **); +/* SYSCALLS.c:1043:NC */ extern int p32echochar (WINDOW *, chtype); +/* SYSCALLS.c:1044:OC */ extern char *p_cdname (/* ??? */); +/* SYSCALLS.c:1045:OC */ extern char *p_class (/* ??? */); +/* SYSCALLS.c:1046:OC */ extern char *p_rr (/* ??? */); +/* SYSCALLS.c:1047:OC */ extern char *p_type (/* ??? */); +/* SYSCALLS.c:1048:NC */ extern int pair_content (int, short int *, short int *); +/* SYSCALLS.c:1049:NC */ extern PANEL *panel_above (PANEL *); +/* SYSCALLS.c:1050:NC */ extern PANEL *panel_below (PANEL *); +/* SYSCALLS.c:1051:NC */ extern char *panel_userptr (PANEL *); +/* SYSCALLS.c:1052:NC */ extern WINDOW *panel_window (PANEL *); +/* SYSCALLS.c:1053:NC */ extern long int pathconf (const char *, int); +/* SYSCALLS.c:1054:NC */ extern char *pathfind (const char *, const char *, const char *); +/* SYSCALLS.c:1055:NC */ extern int pause (void); +/* SYSCALLS.c:1056:NC */ extern int pclose (FILE *); +/* SYSCALLS.c:1057:NC */ extern void perror (const char *); +/* SYSCALLS.c:1058:OC */ extern struct pfdat *pfind (/* ??? */); +/* SYSCALLS.c:1059:OC */ extern int pglstlk (/* ??? */); +/* SYSCALLS.c:1060:OC */ extern int pglstunlk (/* ??? */); +/* SYSCALLS.c:1061:NC */ extern int pid_slot (proc_t *); +/* SYSCALLS.c:1062:NC */ extern int pipe (int *); +/* SYSCALLS.c:1063:NC */ extern int plock (int); +/* SYSCALLS.c:1064:OC */ extern struct pmaplist *pmap_getmaps (/* ??? */); +/* SYSCALLS.c:1065:OC */ extern u_short pmap_getport (/* ??? */); +/* SYSCALLS.c:1066:OC */ extern enum clnt_stat pmap_rmtcall (/* ??? */); +/* SYSCALLS.c:1067:OC */ extern int pmap_set (/* ??? */); +/* SYSCALLS.c:1068:OC */ extern int pmap_unset (/* ??? */); +/* SYSCALLS.c:1069:NC */ extern int pnoutrefresh (WINDOW *, int, int, int, int, int, int); +/* SYSCALLS.c:1070:NC */ extern int poll (struct pollfd *, long unsigned int, int); +/* SYSCALLS.c:1071:NC */ extern FILE *popen (const char *, const char *); +/* SYSCALLS.c:1072:NC */ extern int pos_form_cursor (FORM *); +/* SYSCALLS.c:1073:NC */ extern int pos_menu_cursor (MENU *); +/* SYSCALLS.c:1074:NC */ extern int post_form (FORM *); +/* SYSCALLS.c:1075:NC */ extern int post_menu (MENU *); +/* SYSCALLS.c:1076:NC */ extern double pow (double, double); +/* SYSCALLS.c:1077:NC */ extern float powf (float, float); +/* SYSCALLS.c:1078:NC */ extern int prefresh (WINDOW *, int, int, int, int, int, int); +/* SYSCALLS.c:1079:NC */ extern int printf (const char *, ...); +/* SYSCALLS.c:1080:NC */ extern int printw (char *, ...); +/* SYSCALLS.c:1081:OC */ extern void privsig (/* ??? */); +/* SYSCALLS.c:1082:NC */ extern void profil (short unsigned int *, size_t, int, unsigned int); +/* SYSCALLS.c:1083:NC */ extern void psiginfo (siginfo_t *, char *); +/* SYSCALLS.c:1084:NC */ extern void psignal (int, const char *); +/* SYSCALLS.c:1085:NC */ extern int ptrace (int, pid_t, int, int); +/* SYSCALLS.c:1086:NC */ extern int putc (int, FILE *); +/* SYSCALLS.c:1087:NC */ extern int putchar (int); +/* SYSCALLS.c:1088:NC */ extern int putenv (char *); +/* SYSCALLS.c:1089:NC */ extern int putmsg (int, const struct strbuf *, const struct strbuf *, int); +/* SYSCALLS.c:1090:NC */ extern int putp (char *); +/* SYSCALLS.c:1091:NC */ extern int putpmsg (int, const struct strbuf *, const struct strbuf *, int, int); +/* SYSCALLS.c:1092:NC */ extern int putpwent (const struct passwd *, FILE *); +/* SYSCALLS.c:1093:NC */ extern int puts (const char *); +/* SYSCALLS.c:1094:NC */ extern int putspent (const struct spwd *, FILE *); +/* SYSCALLS.c:1095:NC */ extern struct utmp *pututline (const struct utmp *); +/* SYSCALLS.c:1096:NC */ extern struct utmpx *pututxline (const struct utmpx *); +/* SYSCALLS.c:1097:NC */ extern int putw (int, FILE *); +/* SYSCALLS.c:1098:NC */ extern int putwin (WINDOW *, FILE *); +/* SYSCALLS.c:1099:NC */ extern void qsort (void *, size_t, size_t, int (*) (const void *, const void *)); +/* SYSCALLS.c:1100:NC */ extern int raise (int); +/* SYSCALLS.c:1101:NC */ extern int rand (void); +/* SYSCALLS.c:1102:NC */ extern long int random (void); +/* SYSCALLS.c:1103:NC */ extern int raw (void); +/* SYSCALLS.c:1104:NC */ extern int read (int, void *, size_t); +/* SYSCALLS.c:1105:NC */ extern struct dirent *readdir (DIR *); +/* SYSCALLS.c:1106:NC */ extern int readlink (const char *, char *, size_t); +/* SYSCALLS.c:1107:NC */ extern void *realloc (void *, size_t); +/* SYSCALLS.c:1108:NC */ extern char *realpath (char *, char *); +/* SYSCALLS.c:1109:NC */ extern int redrawwin (WINDOW *); +/* SYSCALLS.c:1110:NC */ extern char *regcmp (const char *, ...); +/* SYSCALLS.c:1111:NC */ extern char *regex (const char *, const char *, ...); +/* SYSCALLS.c:1112:NC */ extern double remainder (double, double); +/* SYSCALLS.c:1113:OC */ extern int remio (/* ??? */); +/* SYSCALLS.c:1114:NC */ extern int remove (const char *); +/* SYSCALLS.c:1115:NC */ extern void remque (struct qelem *); +/* SYSCALLS.c:1116:NC */ extern int rename (const char *, const char *); +/* SYSCALLS.c:1117:NC */ extern int replace_panel (PANEL *, WINDOW *); +/* SYSCALLS.c:1118:NC */ extern int request_mouse_pos (void); +/* SYSCALLS.c:1119:OC */ extern struct reservdev **reservdev (/* ??? */); +/* SYSCALLS.c:1120:NC */ extern int reset_prog_mode (void); +/* SYSCALLS.c:1121:NC */ extern int reset_shell_mode (void); +/* SYSCALLS.c:1122:NC */ extern int resetty (void); +/* SYSCALLS.c:1123:NC */ extern int restartterm (char *, int, int *); +/* SYSCALLS.c:1124:NC */ extern void rewind (FILE *); +/* SYSCALLS.c:1125:NC */ extern void rewinddir (DIR *); +/* SYSCALLS.c:1126:OC */ extern int rf_falloc (/* ??? */); +/* SYSCALLS.c:1127:NC */ extern char *rindex (const char *, int); +/* SYSCALLS.c:1128:NC */ extern double rint (double); +/* SYSCALLS.c:1129:NC */ extern int ripoffline (int, int (*) (WINDOW *, int)); +/* SYSCALLS.c:1130:NC */ extern int rmdir (const char *); +/* SYSCALLS.c:1131:NC */ extern int rmdirp (char *, char *); +/* SYSCALLS.c:1132:OC */ extern enum clnt_stat rpc_broadcast (/* ??? */); +/* SYSCALLS.c:1133:OC */ extern enum clnt_stat rpc_call (/* ??? */); +/* SYSCALLS.c:1134:OC */ extern int rpcb_getaddr (/* ??? */); +/* SYSCALLS.c:1135:OC */ extern RPCBLIST *rpcb_getmaps (/* ??? */); +/* SYSCALLS.c:1136:OC */ extern int rpcb_gettime (/* ??? */); +/* SYSCALLS.c:1137:OC */ extern enum clnt_stat rpcb_rmtcall (/* ??? */); +/* SYSCALLS.c:1138:OC */ extern int rpcb_set (/* ??? */); +/* SYSCALLS.c:1139:OC */ extern char *rpcb_taddr2uaddr (/* ??? */); +/* SYSCALLS.c:1140:OC */ extern struct netbuf *rpcb_uaddr2taddr (/* ??? */); +/* SYSCALLS.c:1141:OC */ extern int rpcb_unset (/* ??? */); +/* SYSCALLS.c:1142:OC */ extern void rpctest_service (/* ??? */); +/* SYSCALLS.c:1143:NC */ extern int run_crypt (long int, char *, unsigned int, int *); +/* SYSCALLS.c:1144:NC */ extern int run_setkey (int *, const char *); +/* SYSCALLS.c:1145:NC */ extern int savetty (void); +/* SYSCALLS.c:1146:NC */ extern void *sbrk (int); +/* SYSCALLS.c:1147:NC */ extern double scalb (double, double); +/* SYSCALLS.c:1148:NC */ extern int scale_form (FORM *, int *, int *); +/* SYSCALLS.c:1149:NC */ extern int scale_menu (MENU *, int *, int *); +/* SYSCALLS.c:1150:NC */ extern int scanf (const char *, ...); +/* SYSCALLS.c:1151:NC */ extern int scanw (char *, ...); +/* SYSCALLS.c:1152:NC */ extern int scr_dump (char *); +/* SYSCALLS.c:1153:NC */ extern int scr_init (char *); +/* SYSCALLS.c:1154:NC */ extern int scr_restore (char *); +/* SYSCALLS.c:1155:NC */ extern int scroll (WINDOW *); +/* SYSCALLS.c:1156:NC */ extern int scrollok (WINDOW *, int); +/* SYSCALLS.c:1157:NC */ extern int scrwidth (wchar_t); +/* SYSCALLS.c:1158:NC */ extern int sdfree (char *); +/* SYSCALLS.c:1159:NC */ extern char *sdget (char *, int, ...); +/* SYSCALLS.c:1160:NC */ extern short unsigned int *seed48 (short unsigned int *); +/* SYSCALLS.c:1161:NC */ extern void seekdir (DIR *, long int); +/* SYSCALLS.c:1162:NC */ extern int semctl (int, int, int, ...); +/* SYSCALLS.c:1163:NC */ extern int semget (key_t, int, int); +/* SYSCALLS.c:1164:NC */ extern int semop (int, struct sembuf *, unsigned int); +/* SYSCALLS.c:1165:NC */ extern int send (int, char *, int, int); +/* SYSCALLS.c:1166:NC */ extern int set_current_field (FORM *, FIELD *); +/* SYSCALLS.c:1167:NC */ extern int set_current_item (MENU *, ITEM *); +/* SYSCALLS.c:1168:NC */ extern int set_field_back (FIELD *, chtype); +/* SYSCALLS.c:1169:NC */ extern int set_field_buffer (FIELD *, int, char *); +/* SYSCALLS.c:1170:NC */ extern int set_field_fore (FIELD *, chtype); +/* SYSCALLS.c:1171:NC */ extern int set_field_init (FORM *, PTF_void); +/* SYSCALLS.c:1172:NC */ extern int set_field_just (FIELD *, int); +/* SYSCALLS.c:1173:NC */ extern int set_field_opts (FIELD *, OPTIONS); +/* SYSCALLS.c:1174:NC */ extern int set_field_pad (FIELD *, int); +/* SYSCALLS.c:1175:NC */ extern int set_field_status (FIELD *, int); +/* SYSCALLS.c:1176:NC */ extern int set_field_term (FORM *, PTF_void); +/* SYSCALLS.c:1177:NC */ extern int set_field_type (FIELD *, FIELDTYPE *, ...); +/* SYSCALLS.c:1178:NC */ extern int set_field_userptr (FIELD *, char *); +/* SYSCALLS.c:1179:NC */ extern int set_fieldtype_arg (FIELDTYPE *, PTF_charP, PTF_charP, PTF_void); +/* SYSCALLS.c:1180:NC */ extern int set_fieldtype_choice (FIELDTYPE *, PTF_int, PTF_int); +/* SYSCALLS.c:1181:NC */ extern int set_form_fields (FORM *, FIELD **); +/* SYSCALLS.c:1182:NC */ extern int set_form_init (FORM *, PTF_void); +/* SYSCALLS.c:1183:NC */ extern int set_form_opts (FORM *, OPTIONS); +/* SYSCALLS.c:1184:NC */ extern int set_form_page (FORM *, int); +/* SYSCALLS.c:1185:NC */ extern int set_form_sub (FORM *, WINDOW *); +/* SYSCALLS.c:1186:NC */ extern int set_form_term (FORM *, PTF_void); +/* SYSCALLS.c:1187:NC */ extern int set_form_userptr (FORM *, char *); +/* SYSCALLS.c:1188:NC */ extern int set_form_win (FORM *, WINDOW *); +/* SYSCALLS.c:1189:NC */ extern int set_item_init (MENU *, PTF_void); +/* SYSCALLS.c:1190:NC */ extern int set_item_opts (ITEM *, OPTIONS); +/* SYSCALLS.c:1191:NC */ extern int set_item_term (MENU *, PTF_void); +/* SYSCALLS.c:1192:NC */ extern int set_item_userptr (ITEM *, char *); +/* SYSCALLS.c:1193:NC */ extern int set_item_value (ITEM *, int); +/* SYSCALLS.c:1194:NC */ extern int set_max_field (FIELD *, int); +/* SYSCALLS.c:1195:NC */ extern int set_menu_back (MENU *, chtype); +/* SYSCALLS.c:1196:NC */ extern int set_menu_fore (MENU *, chtype); +/* SYSCALLS.c:1197:NC */ extern int set_menu_format (MENU *, int, int); +/* SYSCALLS.c:1198:NC */ extern int set_menu_grey (MENU *, chtype); +/* SYSCALLS.c:1199:NC */ extern int set_menu_init (MENU *, PTF_void); +/* SYSCALLS.c:1200:NC */ extern int set_menu_items (MENU *, ITEM **); +/* SYSCALLS.c:1201:NC */ extern int set_menu_mark (MENU *, char *); +/* SYSCALLS.c:1202:NC */ extern int set_menu_opts (MENU *, OPTIONS); +/* SYSCALLS.c:1203:NC */ extern int set_menu_pad (MENU *, int); +/* SYSCALLS.c:1204:NC */ extern int set_menu_pattern (MENU *, char *); +/* SYSCALLS.c:1205:NC */ extern int set_menu_sub (MENU *, WINDOW *); +/* SYSCALLS.c:1206:NC */ extern int set_menu_term (MENU *, PTF_void); +/* SYSCALLS.c:1207:NC */ extern int set_menu_userptr (MENU *, char *); +/* SYSCALLS.c:1208:NC */ extern int set_menu_win (MENU *, WINDOW *); +/* SYSCALLS.c:1209:NC */ extern int set_new_page (FIELD *, int); +/* SYSCALLS.c:1210:NC */ extern int set_panel_userptr (PANEL *, char *); +/* SYSCALLS.c:1211:NC */ extern int set_top_row (MENU *, int); +/* SYSCALLS.c:1212:NC */ extern void setbuf (FILE *, char *); +/* SYSCALLS.c:1213:NC */ extern int setcontext (ucontext_t *); +/* SYSCALLS.c:1214:NC */ extern SCREEN *setcurscreen (SCREEN *); +/* SYSCALLS.c:1215:NC */ extern TERMINAL *setcurterm (TERMINAL *); +/* SYSCALLS.c:1216:NC */ extern FILE *setexportent (void); +/* SYSCALLS.c:1217:NC */ extern int setgid (gid_t); +/* SYSCALLS.c:1218:NC */ extern void setgrent (void); +/* SYSCALLS.c:1219:NC */ extern int setgroups (int, const gid_t *); +/* SYSCALLS.c:1220:NC */ extern int sethostname (char *, int); +/* SYSCALLS.c:1221:NC */ extern int setitimer (int, struct itimerval *, struct itimerval *); +/* SYSCALLS.c:1222:NC */ extern int setjmp (jmp_buf); +/* SYSCALLS.c:1223:NC */ extern void setkey (const char *); +/* SYSCALLS.c:1224:NC */ extern char *setlocale (int, const char *); +/* SYSCALLS.c:1225:NC */ extern FILE *setmntent (char *, char *); +/* SYSCALLS.c:1226:NC */ extern void *setnetconfig (void); +/* SYSCALLS.c:1227:NC */ extern void *setnetpath (void); +/* SYSCALLS.c:1228:NC */ extern int setpgid (pid_t, pid_t); +/* SYSCALLS.c:1229:NC */ extern pid_t setpgrp (void); +/* SYSCALLS.c:1230:NC */ extern int setpgrp2 (pid_t, pid_t); +/* SYSCALLS.c:1231:NC */ extern int setpriority (int, int, int); +/* SYSCALLS.c:1232:OC */ extern int setprivwait (/* ??? */); +/* SYSCALLS.c:1233:NC */ extern void setpwent (void); +/* SYSCALLS.c:1234:NC */ extern int setregid (gid_t, gid_t); +/* SYSCALLS.c:1235:NC */ extern int setreuid (uid_t, uid_t); +/* SYSCALLS.c:1236:NC */ extern int setrlimit (int, struct rlimit *); +/* SYSCALLS.c:1237:NC */ extern int setrpcent (int); +/* SYSCALLS.c:1238:NC */ extern pid_t setsid (void); +/* SYSCALLS.c:1239:NC */ extern void setspent (void); +/* SYSCALLS.c:1240:NC */ extern char *setstate (char *); +/* SYSCALLS.c:1241:NC */ extern int setsyx (int, int); +/* SYSCALLS.c:1242:NC */ extern int setterm (char *); +/* SYSCALLS.c:1243:NC */ extern int setuid (uid_t); +/* SYSCALLS.c:1244:NC */ extern int setupterm (char *, int, int *); +/* SYSCALLS.c:1245:NC */ extern void setutent (void); +/* SYSCALLS.c:1246:NC */ extern void setutxent (void); +/* SYSCALLS.c:1247:NC */ extern int setvbuf (FILE *, char *, int, size_t); +/* SYSCALLS.c:1248:NC */ extern long int sgetl (const char *); +/* SYSCALLS.c:1249:NC */ extern void *shmat (int, void *, int); +/* SYSCALLS.c:1250:NC */ extern int shmctl (int, int, ...); +/* SYSCALLS.c:1251:NC */ extern int shmdt (void *); +/* SYSCALLS.c:1252:NC */ extern int shmget (key_t, int, int); +/* SYSCALLS.c:1253:NC */ extern int show_panel (PANEL *); +/* SYSCALLS.c:1254:NC */ extern int sigaction (int, const struct sigaction *, struct sigaction *); +/* SYSCALLS.c:1255:NC */ extern int sigaddset (sigset_t *, int); +/* SYSCALLS.c:1256:NC */ extern int sigaltstack (const stack_t *, stack_t *); +/* SYSCALLS.c:1257:NC */ extern int sigblock (int); +/* SYSCALLS.c:1258:NC */ extern int sigdelset (sigset_t *, int); +/* SYSCALLS.c:1259:NC */ extern int sigemptyset (sigset_t *); +/* SYSCALLS.c:1260:NC */ extern int sigfillset (sigset_t *); +/* SYSCALLS.c:1261:NC */ extern int sighold (int); +/* SYSCALLS.c:1262:NC */ extern int sigignore (int); +/* SYSCALLS.c:1263:NC */ extern int siginterrupt (int, int); +/* SYSCALLS.c:1264:NC */ extern int sigismember (const sigset_t *, int); +/* SYSCALLS.c:1265:NC */ extern void siglongjmp (sigjmp_buf, int); +/* SYSCALLS.c:1266:NC */ extern void (*signal (int, void (*) (int))) (int); +/* SYSCALLS.c:1267:NC */ extern int sigpause (int); +/* SYSCALLS.c:1268:NC */ extern int sigpending (sigset_t *); +/* SYSCALLS.c:1269:NC */ extern int sigprocmask (int, const sigset_t *, sigset_t *); +/* SYSCALLS.c:1270:NC */ extern int sigrelse (int); +/* SYSCALLS.c:1271:NC */ extern int sigsend (idtype_t, id_t, int); +/* SYSCALLS.c:1272:NC */ extern int sigsendset (const procset_t *, int); +/* SYSCALLS.c:1273:NC */ extern void (*sigset (int, void (*) (int))) (int); +/* SYSCALLS.c:1274:NC */ extern int sigsetjmp (sigjmp_buf, int); +/* SYSCALLS.c:1275:NC */ extern int sigsetmask (int); +/* SYSCALLS.c:1276:NC */ extern int sigsuspend (sigset_t *); +/* SYSCALLS.c:1277:NC */ extern double sin (double); +/* SYSCALLS.c:1278:NC */ extern float sinf (float); +/* SYSCALLS.c:1279:NC */ extern double sinh (double); +/* SYSCALLS.c:1280:NC */ extern float sinhf (float); +/* SYSCALLS.c:1281:NC */ extern unsigned int sleep (unsigned int); +/* SYSCALLS.c:1282:NC */ extern int slk_attroff (chtype); +/* SYSCALLS.c:1283:NC */ extern int slk_attron (chtype); +/* SYSCALLS.c:1284:NC */ extern int slk_attrset (chtype); +/* SYSCALLS.c:1285:NC */ extern int slk_clear (void); +/* SYSCALLS.c:1286:NC */ extern int slk_init (int); +/* SYSCALLS.c:1287:NC */ extern char *slk_label (int); +/* SYSCALLS.c:1288:NC */ extern int slk_noutrefresh (void); +/* SYSCALLS.c:1289:NC */ extern int slk_refresh (void); +/* SYSCALLS.c:1290:NC */ extern int slk_restore (void); +/* SYSCALLS.c:1291:NC */ extern int slk_set (int, char *, int); +/* SYSCALLS.c:1292:NC */ extern int slk_start (int, int *); +/* SYSCALLS.c:1293:NC */ extern int slk_touch (void); +/* SYSCALLS.c:1294:NC */ extern int socket (int, int, int); +/* SYSCALLS.c:1295:OC */ extern void *sprayproc_clear_1 (/* ??? */); +/* SYSCALLS.c:1296:OC */ extern spraycumul *sprayproc_get_1 (/* ??? */); +/* SYSCALLS.c:1297:OC */ extern void *sprayproc_spray_1 (/* ??? */); +/* SYSCALLS.c:1298:NC */ extern int sprintf (char *, const char *, ...); +/* SYSCALLS.c:1299:NC */ extern void sputl (long int, char *); +/* SYSCALLS.c:1300:NC */ extern double sqrt (double); +/* SYSCALLS.c:1301:NC */ extern float sqrtf (float); +/* SYSCALLS.c:1302:NC */ extern void srand (unsigned int); +/* SYSCALLS.c:1303:NC */ extern void srand48 (long int); +/* SYSCALLS.c:1304:NC */ extern void srandom (int); +/* SYSCALLS.c:1305:NC */ extern int sscanf (const char *, const char *, ...); +/* SYSCALLS.c:1306:NC */ extern int (*ssignal (int, int (*) (int))) (int); +/* SYSCALLS.c:1307:NC */ extern int start_color (void); +/* SYSCALLS.c:1308:NC */ extern int stat (const char *, struct stat *); +/* SYSCALLS.c:1309:NC */ extern int statfs (const char *, struct statfs *, int, int); +/* SYSCALLS.c:1310:NC */ extern int statvfs (const char *, struct statvfs *); +/* SYSCALLS.c:1311:NC */ extern int step (const char *, const char *); +/* SYSCALLS.c:1312:NC */ extern int stime (const time_t *); +/* SYSCALLS.c:1313:NC */ extern struct netbuf *stoa (char *, struct netbuf *); +/* SYSCALLS.c:1314:NC */ extern void store (datum, datum); +/* SYSCALLS.c:1315:NC */ extern char *strcadd (char *, const char *); +/* SYSCALLS.c:1316:NC */ extern int strcasecmp (const char *, const char *); +/* SYSCALLS.c:1317:NC */ extern char *strcat (char *, const char *); +/* SYSCALLS.c:1318:NC */ extern char *strccpy (char *, const char *); +/* SYSCALLS.c:1319:NC */ extern char *strchr (const char *, int); +/* SYSCALLS.c:1320:OC */ extern void strclearctty (/* ??? */); +/* SYSCALLS.c:1321:OC */ extern void strclearpg (/* ??? */); +/* SYSCALLS.c:1322:OC */ extern void strclearsid (/* ??? */); +/* SYSCALLS.c:1323:NC */ extern int strcmp (const char *, const char *); +/* SYSCALLS.c:1324:NC */ extern int strcoll (const char *, const char *); +/* SYSCALLS.c:1325:NC */ extern char *strcpy (char *, const char *); +/* SYSCALLS.c:1326:NC */ extern size_t strcspn (const char *, const char *); +/* SYSCALLS.c:1327:NC */ extern char *strdup (const char *); +/* SYSCALLS.c:1328:NC */ extern char *streadd (char *, const char *, const char *); +/* SYSCALLS.c:1329:NC */ extern char *strecpy (char *, const char *, const char *); +/* SYSCALLS.c:1330:NC */ extern char *strerror (int); +/* SYSCALLS.c:1331:NC */ extern int strfind (const char *, const char *); +/* SYSCALLS.c:1332:NC */ extern size_t strftime (char *, size_t, const char *, const struct tm *); +/* SYSCALLS.c:1333:NC */ extern size_t strlen (const char *); +/* SYSCALLS.c:1334:NC */ extern int strncasecmp (const char *, const char *, size_t); +/* SYSCALLS.c:1335:NC */ extern char *strncat (char *, const char *, size_t); +/* SYSCALLS.c:1336:NC */ extern int strncmp (const char *, const char *, size_t); +/* SYSCALLS.c:1337:NC */ extern char *strncpy (char *, const char *, size_t); +/* SYSCALLS.c:1338:NC */ extern char *strpbrk (const char *, const char *); +/* SYSCALLS.c:1339:NC */ extern char *strrchr (const char *, int); +/* SYSCALLS.c:1340:NC */ extern char *strrspn (const char *, const char *); +/* SYSCALLS.c:1341:NC */ extern size_t strspn (const char *, const char *); +/* SYSCALLS.c:1342:NC */ extern char *strstr (const char *, const char *); +/* SYSCALLS.c:1343:NC */ extern double strtod (const char *, char **); +/* SYSCALLS.c:1344:NC */ extern char *strtok (char *, const char *); +/* SYSCALLS.c:1345:NC */ extern long int strtol (const char *, char **, int); +/* SYSCALLS.c:1346:NC */ extern long unsigned int strtoul (const char *, char **, int); +/* SYSCALLS.c:1347:NC */ extern char *strtrns (const char *, const char *, const char *, char *); +/* SYSCALLS.c:1348:NC */ extern size_t strxfrm (char *, const char *, size_t); +/* SYSCALLS.c:1349:NC */ extern WINDOW *subpad (WINDOW *, int, int, int, int); +/* SYSCALLS.c:1350:NC */ extern WINDOW *subwin (WINDOW *, int, int, int, int); +/* SYSCALLS.c:1351:OC */ extern int svc_create (/* ??? */); +/* SYSCALLS.c:1352:OC */ extern SVCXPRT *svc_fd_create (/* ??? */); +/* SYSCALLS.c:1353:OC */ extern void svc_getreqset (/* ??? */); +/* SYSCALLS.c:1354:OC */ extern SVCXPRT *svc_raw_create (/* ??? */); +/* SYSCALLS.c:1355:OC */ extern int svc_reg (/* ??? */); +/* SYSCALLS.c:1356:OC */ extern SVCXPRT *svc_tli_create (/* ??? */); +/* SYSCALLS.c:1357:OC */ extern SVCXPRT *svc_tp_create (/* ??? */); +/* SYSCALLS.c:1358:OC */ extern void svc_unreg (/* ??? */); +/* SYSCALLS.c:1359:OC */ extern SVCXPRT *svc_vc_create (/* ??? */); +/* SYSCALLS.c:1360:OC */ extern void svcerr_systemerr (/* ??? */); +/* SYSCALLS.c:1361:OC */ extern SVCXPRT *svcfd_create (/* ??? */); +/* SYSCALLS.c:1362:OC */ extern SVCXPRT *svcraw_create (/* ??? */); +/* SYSCALLS.c:1363:OC */ extern SVCXPRT *svctcp_create (/* ??? */); +/* SYSCALLS.c:1364:OC */ extern SVCXPRT *svcudp_bufcreate (/* ??? */); +/* SYSCALLS.c:1365:OC */ extern SVCXPRT *svcudp_create (/* ??? */); +/* SYSCALLS.c:1366:NC */ extern void swab (const char *, char *, int); +/* SYSCALLS.c:1367:NC */ extern int swapcontext (ucontext_t *, ucontext_t *); +/* SYSCALLS.c:1368:NC */ extern int symlink (const char *, const char *); +/* SYSCALLS.c:1369:NC */ extern void sync (void); +/* SYSCALLS.c:1370:NC */ extern int syncok (WINDOW *, int); +/* SYSCALLS.c:1371:NC */ extern int syscall (int, ...); +/* SYSCALLS.c:1372:NC */ extern long int sysconf (int); +/* SYSCALLS.c:1373:NC */ extern int sysfs (int, ...); +/* SYSCALLS.c:1374:NC */ extern int sysinfo (int, char *, long int); +/* SYSCALLS.c:1375:NC */ extern int system (const char *); +/* SYSCALLS.c:1376:NC */ extern char *taddr2uaddr (struct netconfig *, struct netbuf *); +/* SYSCALLS.c:1377:NC */ extern double tan (double); +/* SYSCALLS.c:1378:NC */ extern float tanf (float); +/* SYSCALLS.c:1379:NC */ extern double tanh (double); +/* SYSCALLS.c:1380:NC */ extern float tanhf (float); +/* SYSCALLS.c:1381:NC */ extern int tcdrain (int); +/* SYSCALLS.c:1382:NC */ extern int tcflow (int, int); +/* SYSCALLS.c:1383:NC */ extern int tcflush (int, int); +/* SYSCALLS.c:1384:NC */ extern int tcgetattr (int, struct termios *); +/* SYSCALLS.c:1385:NC */ extern pid_t tcgetpgrp (int); +/* SYSCALLS.c:1386:NC */ extern pid_t tcgetsid (int); +/* SYSCALLS.c:1387:NC */ extern int tcsendbreak (int, int); +/* SYSCALLS.c:1388:NC */ extern int tcsetattr (int, int, const struct termios *); +/* SYSCALLS.c:1389:NC */ extern int tcsetpgrp (int, pid_t); +/* SYSCALLS.c:1390:NC */ extern void *tdelete (const void *, void **, int (*) (const void *, const void *)); +/* SYSCALLS.c:1391:NC */ extern long int telldir (DIR *); +/* SYSCALLS.c:1392:NC */ extern char *tempnam (const char *, const char *); +/* SYSCALLS.c:1393:NC */ extern chtype termattrs (void); +/* SYSCALLS.c:1394:NC */ extern void termerr (void); +/* SYSCALLS.c:1395:NC */ extern char *termname (void); +/* SYSCALLS.c:1396:NC */ extern void *tfind (const void *, void *const *, int (*) (const void *, const void *)); +/* SYSCALLS.c:1397:NC */ extern int tgetent (char *, char *); +/* SYSCALLS.c:1398:NC */ extern int tgetflag (char *); +/* SYSCALLS.c:1399:NC */ extern int tgetnum (char *); +/* SYSCALLS.c:1400:NC */ extern char *tgetstr (char *, char **); +/* SYSCALLS.c:1401:NC */ extern char *tgoto (char *, int, int); +/* SYSCALLS.c:1402:NC */ extern char *tigetstr (char *); +/* SYSCALLS.c:1403:NC */ extern time_t time (time_t *); +/* SYSCALLS.c:1404:NC */ extern clock_t times (struct tms *); +/* SYSCALLS.c:1405:NC */ extern char *timezone (int, int); +/* SYSCALLS.c:1406:NC */ extern void tinputfd (int); +/* SYSCALLS.c:1407:NC */ extern FILE *tmpfile (void); +/* SYSCALLS.c:1408:NC */ extern char *tmpnam (char *); +/* SYSCALLS.c:1409:NC */ extern int toascii (int); +/* SYSCALLS.c:1410:NC */ extern int tolower (int); +/* SYSCALLS.c:1411:NC */ extern int top_panel (PANEL *); +/* SYSCALLS.c:1412:NC */ extern int top_row (MENU *); +/* SYSCALLS.c:1413:NC */ extern int touchline (WINDOW *, int, int); +/* SYSCALLS.c:1414:NC */ extern int touchwin (WINDOW *); +/* SYSCALLS.c:1415:NC */ extern int toupper (int); +/* SYSCALLS.c:1416:OC */ extern char *tparm (/* ??? */); +/* SYSCALLS.c:1417:NC */ extern int tputs (char *, int, int (*) (char)); +/* SYSCALLS.c:1418:NC */ extern int traceoff (void); +/* SYSCALLS.c:1419:NC */ extern int traceon (void); +/* SYSCALLS.c:1420:NC */ extern int truncate (const char *, off_t); +/* SYSCALLS.c:1421:NC */ extern void *tsearch (const void *, void **, int (*) (const void *, const void *)); +/* SYSCALLS.c:1422:NC */ extern char *ttyname (int); +/* SYSCALLS.c:1423:NC */ extern int ttyslot (void); +/* SYSCALLS.c:1424:NC */ extern void twalk (void *, void (*) (void *, VISIT, int)); +/* SYSCALLS.c:1425:NC */ extern int typeahead (int); +/* SYSCALLS.c:1426:NC */ extern void tzset (void); +/* SYSCALLS.c:1427:NC */ extern struct netbuf *uaddr2taddr (struct netconfig *, char *); +/* SYSCALLS.c:1428:NC */ extern int uadmin (int, int, int); +/* SYSCALLS.c:1429:NC */ extern unsigned int ualarm (unsigned int, unsigned int); +/* SYSCALLS.c:1430:NC */ extern int ulckpwdf (void); +/* SYSCALLS.c:1431:NC */ extern long int ulimit (int, ...); +/* SYSCALLS.c:1432:NC */ extern mode_t umask (mode_t); +/* SYSCALLS.c:1433:NC */ extern int umount (const char *); +/* SYSCALLS.c:1434:NC */ extern int uname (struct utsname *); +/* SYSCALLS.c:1435:NC */ extern char *unctrl (int); +/* SYSCALLS.c:1436:NC */ extern void undial (int); +/* SYSCALLS.c:1437:NC */ extern int ungetc (int, FILE *); +/* SYSCALLS.c:1438:NC */ extern int ungetch (int); +/* SYSCALLS.c:1439:NC */ extern int unlink (const char *); +/* SYSCALLS.c:1440:NC */ extern int unordered (double, double); +/* SYSCALLS.c:1441:NC */ extern int unpost_form (FORM *); +/* SYSCALLS.c:1442:NC */ extern int unpost_menu (MENU *); +/* SYSCALLS.c:1443:OC */ extern int unremio (/* ??? */); +/* SYSCALLS.c:1444:NC */ extern int untouchwin (WINDOW *); +/* SYSCALLS.c:1445:NC */ extern void update_panels (void); +/* SYSCALLS.c:1446:NC */ extern void updwtmp (const char *, struct utmp *); +/* SYSCALLS.c:1447:NC */ extern void updwtmpx (const char *, struct utmpx *); +/* SYSCALLS.c:1448:NC */ extern void use_env (int); +/* SYSCALLS.c:1449:NC */ extern unsigned int usleep (unsigned int); +/* SYSCALLS.c:1450:NC */ extern int ustat (dev_t, struct ustat *); +/* SYSCALLS.c:1451:NC */ extern int utime (const char *, const struct utimbuf *); +/* SYSCALLS.c:1452:NC */ extern int utmpname (const char *); +/* SYSCALLS.c:1453:NC */ extern int utmpxname (const char *); +/* SYSCALLS.c:1454:NC */ extern void va_end (__gnuc_va_list); +/* SYSCALLS.c:1455:NC */ extern int vadvise (int); +/* SYSCALLS.c:1456:NC */ extern void *valloc (size_t); +/* SYSCALLS.c:1457:NC */ extern pid_t vfork (void); +/* SYSCALLS.c:1458:NC */ extern int vfprintf (FILE *, const char *, __gnuc_va_list); +/* SYSCALLS.c:1459:NC */ extern int vhangup (void); +/* SYSCALLS.c:1460:NC */ extern int vid32attr (chtype); +/* SYSCALLS.c:1461:NC */ extern int vid32puts (chtype, int (*) (char)); +/* SYSCALLS.c:1462:NC */ extern void vidupdate (chtype, chtype, int (*) (char)); +/* SYSCALLS.c:1463:OC */ extern int vn_close (/* ??? */); +/* SYSCALLS.c:1464:NC */ extern int vprintf (const char *, __gnuc_va_list); +/* SYSCALLS.c:1465:NC */ extern int vsprintf (char *, const char *, __gnuc_va_list); +/* SYSCALLS.c:1466:NC */ extern int vwprintw (WINDOW *, char *, void *); +/* SYSCALLS.c:1467:NC */ extern int vwscanw (WINDOW *, char *, void *); +/* SYSCALLS.c:1468:NC */ extern int w32addch (WINDOW *, chtype); +/* SYSCALLS.c:1469:NC */ extern int w32attroff (WINDOW *, chtype); +/* SYSCALLS.c:1470:NC */ extern int w32attron (WINDOW *, chtype); +/* SYSCALLS.c:1471:NC */ extern int w32attrset (WINDOW *, chtype); +/* SYSCALLS.c:1472:NC */ extern int w32echochar (WINDOW *, chtype); +/* SYSCALLS.c:1473:NC */ extern int w32insch (WINDOW *, chtype); +/* SYSCALLS.c:1474:NC */ extern int waddchnstr (WINDOW *, chtype *, int); +/* SYSCALLS.c:1475:NC */ extern int waddnstr (WINDOW *, char *, int); +/* SYSCALLS.c:1476:NC */ extern int waddstr (WINDOW *, char *); +/* SYSCALLS.c:1477:NC */ extern pid_t wait (int *); +/* SYSCALLS.c:1478:NC */ extern pid_t wait3 (union wait *, int, struct rusage *); +/* SYSCALLS.c:1479:NC */ extern int waitid (idtype_t, id_t, siginfo_t *, int); +/* SYSCALLS.c:1480:NC */ extern pid_t waitpid (pid_t, int *, int); +/* SYSCALLS.c:1481:OC */ extern void *wallproc_wall_1 (/* ??? */); +/* SYSCALLS.c:1482:NC */ extern int wbkgd (WINDOW *, chtype); +/* SYSCALLS.c:1483:NC */ extern void wbkgdset (WINDOW *, chtype); +/* SYSCALLS.c:1484:NC */ extern int wborder (WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype); +/* SYSCALLS.c:1485:NC */ extern int wclear (WINDOW *); +/* SYSCALLS.c:1486:NC */ extern int wclrtobot (WINDOW *); +/* SYSCALLS.c:1487:NC */ extern int wclrtoeol (WINDOW *); +/* SYSCALLS.c:1488:NC */ extern size_t wcstombs (char *, const wchar_t *, size_t); +/* SYSCALLS.c:1489:NC */ extern int wctomb (char *, wchar_t); +/* SYSCALLS.c:1490:NC */ extern void wcursyncup (WINDOW *); +/* SYSCALLS.c:1491:NC */ extern int wdelch (WINDOW *); +/* SYSCALLS.c:1492:NC */ extern int wdeleteln (WINDOW *); +/* SYSCALLS.c:1493:NC */ extern int werase (WINDOW *); +/* SYSCALLS.c:1494:NC */ extern int wgetch (WINDOW *); +/* SYSCALLS.c:1495:NC */ extern int wgetnstr (WINDOW *, char *, int); +/* SYSCALLS.c:1496:NC */ extern int wgetstr (WINDOW *, char *); +/* SYSCALLS.c:1497:NC */ extern int whline (WINDOW *, chtype, int); +/* SYSCALLS.c:1498:NC */ extern chtype winch (WINDOW *); +/* SYSCALLS.c:1499:NC */ extern int winchnstr (WINDOW *, chtype *, int); +/* SYSCALLS.c:1500:NC */ extern int winchstr (WINDOW *, chtype *); +/* SYSCALLS.c:1501:NC */ extern int winnstr (WINDOW *, char *, int); +/* SYSCALLS.c:1502:NC */ extern int winsdelln (WINDOW *, int); +/* SYSCALLS.c:1503:NC */ extern int winsertln (WINDOW *); +/* SYSCALLS.c:1504:NC */ extern int winsnstr (WINDOW *, char *, int); +/* SYSCALLS.c:1505:NC */ extern int winstr (WINDOW *, char *); +/* SYSCALLS.c:1506:NC */ extern int wisprint (wchar_t); +/* SYSCALLS.c:1507:NC */ extern void wmouse_position (WINDOW *, int *, int *); +/* SYSCALLS.c:1508:NC */ extern int wmove (WINDOW *, int, int); +/* SYSCALLS.c:1509:NC */ extern int wnoutrefresh (WINDOW *); +/* SYSCALLS.c:1510:NC */ extern int wprintw (WINDOW *, ...); +/* SYSCALLS.c:1511:NC */ extern int wredrawln (WINDOW *, int, int); +/* SYSCALLS.c:1512:NC */ extern int wrefresh (WINDOW *); +/* SYSCALLS.c:1513:NC */ extern int write (int, const void *, size_t); +/* SYSCALLS.c:1514:NC */ extern int wscanw (WINDOW *, ...); +/* SYSCALLS.c:1515:NC */ extern int wscrl (WINDOW *, int); +/* SYSCALLS.c:1516:NC */ extern int wsetscrreg (WINDOW *, int, int); +/* SYSCALLS.c:1517:NC */ extern int wstandend (WINDOW *); +/* SYSCALLS.c:1518:NC */ extern int wstandout (WINDOW *); +/* SYSCALLS.c:1519:NC */ extern void wsyncdown (WINDOW *); +/* SYSCALLS.c:1520:NC */ extern void wsyncup (WINDOW *); +/* SYSCALLS.c:1521:NC */ extern void wtimeout (WINDOW *, int); +/* SYSCALLS.c:1522:NC */ extern int wtouchln (WINDOW *, int, int, int); +/* SYSCALLS.c:1523:NC */ extern int wvline (WINDOW *, chtype, int); +/* SYSCALLS.c:1524:OC */ extern bool xdr_datum (/* ??? */); +/* SYSCALLS.c:1525:OC */ extern int xdr_double (/* ??? */); +/* SYSCALLS.c:1526:OC */ extern int xdr_exports (/* ??? */); +/* SYSCALLS.c:1527:OC */ extern int xdr_fhstatus (/* ??? */); +/* SYSCALLS.c:1528:OC */ extern int xdr_float (/* ??? */); +/* SYSCALLS.c:1529:OC */ extern int xdr_keybuf (/* ??? */); +/* SYSCALLS.c:1530:OC */ extern int xdr_mountlist (/* ??? */); +/* SYSCALLS.c:1531:OC */ extern int xdr_netbuf (/* ??? */); +/* SYSCALLS.c:1532:OC */ extern int xdr_path (/* ??? */); +/* SYSCALLS.c:1533:OC */ extern int xdr_pmap (/* ??? */); +/* SYSCALLS.c:1534:OC */ extern int xdr_pmaplist (/* ??? */); +/* SYSCALLS.c:1535:OC */ extern int xdr_pointer (/* ??? */); +/* SYSCALLS.c:1536:OC */ extern int xdr_reference (/* ??? */); +/* SYSCALLS.c:1537:OC */ extern int xdr_rmtcall_args (/* ??? */); +/* SYSCALLS.c:1538:OC */ extern int xdr_rmtcallres (/* ??? */); +/* SYSCALLS.c:1539:OC */ extern int xdr_rpcb (/* ??? */); +/* SYSCALLS.c:1540:OC */ extern int xdr_rpcb_rmtcallargs (/* ??? */); +/* SYSCALLS.c:1541:OC */ extern int xdr_rpcb_rmtcallres (/* ??? */); +/* SYSCALLS.c:1542:OC */ extern int xdr_rpcblist (/* ??? */); +/* SYSCALLS.c:1543:OC */ extern int xdr_sprayarr (/* ??? */); +/* SYSCALLS.c:1544:OC */ extern int xdr_spraycumul (/* ??? */); +/* SYSCALLS.c:1545:OC */ extern int xdr_spraytimeval (/* ??? */); +/* SYSCALLS.c:1546:OC */ extern int xdr_u_char (/* ??? */); +/* SYSCALLS.c:1547:OC */ extern int xdr_utmparr (/* ??? */); +/* SYSCALLS.c:1548:OC */ extern int xdr_utmpidlearr (/* ??? */); +/* SYSCALLS.c:1549:OC */ extern int xdr_vector (/* ??? */); +/* SYSCALLS.c:1550:OC */ extern int xdr_yp_buf (/* ??? */); +/* SYSCALLS.c:1551:OC */ extern bool xdr_yp_inaddr (/* ??? */); +/* SYSCALLS.c:1552:OC */ extern bool xdr_ypall (/* ??? */); +/* SYSCALLS.c:1553:OC */ extern int xdr_ypdelete_args (/* ??? */); +/* SYSCALLS.c:1554:OC */ extern bool xdr_ypdomain_wrap_string (/* ??? */); +/* SYSCALLS.c:1555:OC */ extern bool xdr_ypmap_parms (/* ??? */); +/* SYSCALLS.c:1556:OC */ extern bool xdr_ypmap_wrap_string (/* ??? */); +/* SYSCALLS.c:1557:OC */ extern bool xdr_ypowner_wrap_string (/* ??? */); +/* SYSCALLS.c:1558:OC */ extern bool xdr_yppushresp_xfr (/* ??? */); +/* SYSCALLS.c:1559:OC */ extern bool xdr_ypreq_key (/* ??? */); +/* SYSCALLS.c:1560:OC */ extern bool xdr_ypreq_newxfr (/* ??? */); +/* SYSCALLS.c:1561:OC */ extern bool xdr_ypreq_nokey (/* ??? */); +/* SYSCALLS.c:1562:OC */ extern bool xdr_ypreq_xfr (/* ??? */); +/* SYSCALLS.c:1563:OC */ extern bool xdr_ypresp_key_val (/* ??? */); +/* SYSCALLS.c:1564:OC */ extern bool xdr_ypresp_maplist (/* ??? */); +/* SYSCALLS.c:1565:OC */ extern bool xdr_ypresp_master (/* ??? */); +/* SYSCALLS.c:1566:OC */ extern bool xdr_ypresp_order (/* ??? */); +/* SYSCALLS.c:1567:OC */ extern bool xdr_ypresp_val (/* ??? */); +/* SYSCALLS.c:1568:OC */ extern int xdr_ypupdate_args (/* ??? */); +/* SYSCALLS.c:1569:OC */ extern void xdrrec_create (/* ??? */); +/* SYSCALLS.c:1570:OC */ extern int xdrrec_endofrecord (/* ??? */); +/* SYSCALLS.c:1571:OC */ extern int xdrrec_eof (/* ??? */); +/* SYSCALLS.c:1572:OC */ extern int xdrrec_skiprecord (/* ??? */); +/* SYSCALLS.c:1573:OC */ extern void xdrstdio_create (/* ??? */); +/* SYSCALLS.c:1574:OC */ extern void xprt_register (/* ??? */); +/* SYSCALLS.c:1575:OC */ extern void xprt_unregister (/* ??? */); +/* SYSCALLS.c:1576:NC */ extern double y0 (double); +/* SYSCALLS.c:1577:NC */ extern double y1 (double); +/* SYSCALLS.c:1578:NC */ extern double yn (int, double); +/* SYSCALLS.c:1579:NC */ extern int yp_all (char *, char *, struct ypall_callback *); +/* SYSCALLS.c:1580:NC */ extern int yp_bind (const char *); +/* SYSCALLS.c:1581:NC */ extern int yp_first (char *, char *, char **, int *, char **, int *); +/* SYSCALLS.c:1582:NC */ extern int yp_get_default_domain (char **); +/* SYSCALLS.c:1583:NC */ extern int yp_master (char *, char *, char **); +/* SYSCALLS.c:1584:NC */ extern int yp_match (char *, char *, char *, int, char **, int *); +/* SYSCALLS.c:1585:NC */ extern int yp_next (char *, char *, char *, int, char **, int *, char **, int *); +/* SYSCALLS.c:1586:NC */ extern int yp_order (char *, char *, int *); +/* SYSCALLS.c:1587:NC */ extern void yp_unbind (const char *); +/* SYSCALLS.c:1588:NC */ extern char *yperr_string (int); +/* SYSCALLS.c:1589:NC */ extern int ypprot_err (unsigned int); +/* SYSCALLS.c:1590:OC */ extern u_int *ypu_change_1 (/* ??? */); +/* SYSCALLS.c:1591:OC */ extern u_int *ypu_delete_1 (/* ??? */); +/* SYSCALLS.c:1592:OC */ extern u_int *ypu_insert_1 (/* ??? */); +/* SYSCALLS.c:1593:OC */ extern u_int *ypu_store_1 (/* ??? */); diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/cc1.exe b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/cc1.exe new file mode 100644 index 0000000..b780941 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/cc1.exe differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/crtbegin.o b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/crtbegin.o new file mode 100644 index 0000000..5874e43 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/crtbegin.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/crtend.o b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/crtend.o new file mode 100644 index 0000000..897a97a Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/crtend.o differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/libgcc.a b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/libgcc.a new file mode 100644 index 0000000..a13e895 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/libgcc.a differ diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/specs b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/specs new file mode 100644 index 0000000..a1931dd --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/MinGW32/lib/gcc-lib/mingw32/3.2.3/specs @@ -0,0 +1,136 @@ +*asm: +--traditional-format + +*asm_debug: +%{g*:--gstabs} + +*asm_final: + + +*asm_options: +%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O} + +*invoke_as: +%{!S:-o %{|!pipe:%g.s} | + as %(asm_options) %{!pipe:%g.s} %A } + +*cpp: +%(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__fastcall=__attribute__((__fastcall__)) %{!ansi:-D_stdcall=__attribute__((__stdcall__)) -D_cdecl=__attribute__((__cdecl__)) -D_fastcall=__attribute__((__fastcall__))} -D__declspec(x)=__attribute__((x)) + +*cpp_options: +%(cpp_unique_options) %{std*} %{d*} %{W*} %{w} %{pedantic*} %{fshow-column} %{fno-show-column} %{fsigned-char&funsigned-char} %{fleading-underscore} %{fno-leading-underscore} %{fno-operator-names} %{ftabstop=*} + +*cpp_unique_options: +%{C:%{!E:%eGNU C does not support -C without using -E}} %{nostdinc*} %{C} %{v} %{I*} %{P} %{$} %I %{MD:-MD %{!o:%b.d}%{o*:%.d%*}} %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}} %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}} %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3 -D__GXX_ABI_VERSION=102} %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs} %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}} %{fno-inline|O0|!O*:-D__NO_INLINE__} %{ffast-math:-D__FAST_MATH__} %{ffreestanding:-D__STDC_HOSTED__=0} %{fno-hosted:-D__STDC_HOSTED__=0} %{!ffreestanding:%{!fno-hosted:-D__STDC_HOSTED__=1}} %{remap} %{g3:-dD} %{H} %C %{fshort-wchar:-U__WCHAR_TYPE__ -D__WCHAR_TYPE__=short\ unsigned\ int} %{D*&U*&A*} %{i*} %Z %i %{E|M|MM:%W{o*}} + +*trad_capable_cpp: +%{traditional|ftraditional|traditional-cpp:trad}cpp0 + +*cc1: +%(cc1_cpu) + +*cc1_options: +%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*} %{g*} %{O*} %{W*} %{w} %{pedantic*} %{std*} %{ansi} %{traditional} %{v:-version} %{pg:-p} %{p} %{f*} %{Qn:-fno-ident} %{--help:--help} %{--target-help:--target-help} %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}} %{fsyntax-only:-o %j} %{-param*} + +*cc1plus: + + +*link_gcc_c_sequence: +%G %L %G + +*endfile: +crtend%O%s + +*link: +%{mwindows:--subsystem windows} %{mconsole:--subsystem console} %{shared: %{mdll: %eshared and mdll are not compatible}} %{shared: --shared --enable-auto-image-base} %{mdll:--dll} %{static:-Bstatic} %{!static:-Bdynamic} %{shared|mdll: -e _DllMainCRTStartup@12} + +*lib: +%{pg:-lgmon} %{mwindows:-lgdi32 -lcomdlg32} -luser32 -lkernel32 -ladvapi32 -lshell32 + +*libgcc: +%{mthreads:-lmingwthrd} -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt + +*startfile: +%{shared|mdll:dllcrt2%O%s} %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} crtbegin%O%s + +*switches_need_spaces: + + +*predefines: +-D_WIN32 -D__WIN32 -D__WIN32__ -DWIN32 -D__MINGW32__ -D__MSVCRT__ -DWINNT -D_X86_=1 -Asystem=winnt + +*cross_compile: +0 + +*version: +3.2.3 + +*multilib: +. ; + +*multilib_defaults: + + +*multilib_extra: + + +*multilib_matches: + + +*multilib_exclusions: + + +*multilib_options: + + +*linker: +collect2 + +*link_libgcc: +%D + +*md_exec_prefix: + + +*md_startfile_prefix: + + +*md_startfile_prefix_1: + + +*cpp_cpu_default: +-D__tune_i586__ -D__tune_pentium__ + +*cpp_cpu: +%(cpp_cpu32) %(cpp_cpucommon) + +*cpp_cpu32: +-Acpu=i386 -Amachine=i386 %{!ansi:%{!std=c*:%{!std=i*:-Di386}}} -D__i386 -D__i386__ %(cpp_cpu32sizet) + +*cpp_cpu64: +-Acpu=x86_64 -Amachine=x86_64 -D__x86_64 -D__x86_64__ %(cpp_cpu64sizet) + +*cpp_cpu32sizet: + + +*cpp_cpu64sizet: + + +*cpp_cpucommon: +%{march=i386:%{!mcpu*:-D__tune_i386__ }}%{march=i486:-D__i486 -D__i486__ %{!mcpu*:-D__tune_i486__ }}%{march=pentium|march=i586:-D__i586 -D__i586__ -D__pentium -D__pentium__ %{!mcpu*:-D__tune_i586__ -D__tune_pentium__ }}%{march=pentium-mmx:-D__i586 -D__i586__ -D__pentium -D__pentium__ -D__pentium__mmx__ %{!mcpu*:-D__tune_i586__ -D__tune_pentium__ -D__tune_pentium_mmx__}}%{march=pentiumpro|march=i686|march=pentium2|march=pentium3:-D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ %{!mcpu*:-D__tune_i686__ -D__tune_pentiumpro__ }}%{march=pentium2|march=pentium3: -D__pentium2 -D__pentium2__ %{!mcpu*:-D__tune_pentium2__ }}%{march=pentium3: -D__pentium3 -D__pentium3__ %{!mcpu*:-D__tune_pentium3__ }}%{march=k6:-D__k6 -D__k6__ %{!mcpu*:-D__tune_k6__ }}%{march=k6-2:-D__k6 -D__k6__ -D__k6_2__ %{!mcpu*:-D__tune_k6__ -D__tune_k6_2__ }}%{march=k6-3:-D__k6 -D__k6__ -D__k6_3__ %{!mcpu*:-D__tune_k6__ -D__tune_k6_3__ }}%{march=athlon|march=athlon-tbird:-D__athlon -D__athlon__ %{!mcpu*:-D__tune_athlon__ }}%{march=athlon-4|march=athlon-xp|march=athlon-mp:-D__athlon -D__athlon__ -D__athlon_sse__ %{!mcpu*:-D__tune_athlon__ -D__tune_athlon_sse__ }}%{march=pentium4:-D__pentium4 -D__pentium4__ %{!mcpu*:-D__tune_pentium4__ }}%{m386|mcpu=i386:-D__tune_i386__ }%{m486|mcpu=i486:-D__tune_i486__ }%{mpentium|mcpu=pentium|mcpu=i586|mcpu=pentium-mmx:-D__tune_i586__ -D__tune_pentium__ }%{mpentiumpro|mcpu=pentiumpro|mcpu=i686|mcpu=pentium2|mcpu=pentium3:-D__tune_i686__ -D__tune_pentiumpro__ }%{mcpu=k6|mcpu=k6-2|mcpu=k6-3:-D__tune_k6__ }%{mcpu=athlon|mcpu=athlon-tbird|mcpu=athlon-4|mcpu=athlon-xp|mcpu=athlon-mp:-D__tune_athlon__ }%{mcpu=athlon-4|mcpu=athlon-xp|mcpu=athlon-mp:-D__tune_athlon_sse__ }%{mcpu=pentium4:-D__tune_pentium4__ }%{march=athlon-xp|march=athlon-mp|march=pentium3|march=pentium4|msse|msse2:-D__SSE__ }%{march=pentium-mmx|march=k6|march=k6-2|march=k6-3|march=athlon|march=athlon-tbird|march=athlon-4|march=athlon-xp|march=athlon-mp|march=pentium2|march=pentium3|march=pentium4|mmx|msse|m3dnow: -D__MMX__ }%{march=k6-2|march=k6-3|march=athlon|march=athlon-tbird|march=athlon-4|march=athlon-xp|march=athlon-mp|m3dnow: -D__3dNOW__ }%{march=athlon|march=athlon-tbird|march=athlon-4|march=athlon-xp|march=athlon-mp: -D__3dNOW_A__ }%{march=pentium4|msse2: -D__SSE2__ }%{!march*:%{!mcpu*:%{!m386:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}}}} + +*cc1_cpu: +%{!mcpu*: %{m386:-mcpu=i386 %n`-m386' is deprecated. Use `-march=i386' or `-mcpu=i386' instead. +} %{m486:-mcpu=i486 %n`-m486' is deprecated. Use `-march=i486' or `-mcpu=i486' instead. +} %{mpentium:-mcpu=pentium %n`-mpentium' is deprecated. Use `-march=pentium' or `-mcpu=pentium' instead. +} %{mpentiumpro:-mcpu=pentiumpro %n`-mpentiumpro' is deprecated. Use `-march=pentiumpro' or `-mcpu=pentiumpro' instead. +}} %{mintel-syntax:-masm=intel %n`-mintel-syntax' is deprecated. Use `-masm=intel' instead. +} %{mno-intel-syntax:-masm=att %n`-mno-intel-syntax' is deprecated. Use `-masm=att' instead. +} + +*mingw_include_path: +mingw32 + +*link_command: +%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:} %{L*} %(link_libgcc) %o %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}} %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}} + diff --git a/一些非必要的资料/linux-0.11-quickstart/MinGW32/sync.c b/一些非必要的资料/linux-0.11-quickstart/MinGW32/sync.c new file mode 100644 index 0000000..0eefc1c --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/MinGW32/sync.c @@ -0,0 +1,3 @@ +int main() +{ +} \ No newline at end of file diff --git a/一些非必要的资料/linux-0.11-quickstart/doc/PE文件格式详解.chm b/一些非必要的资料/linux-0.11-quickstart/doc/PE文件格式详解.chm new file mode 100644 index 0000000..64eafd4 Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/doc/PE文件格式详解.chm differ diff --git a/一些非必要的资料/linux-0.11-quickstart/doc/pecoff_v8.doc b/一些非必要的资料/linux-0.11-quickstart/doc/pecoff_v8.doc new file mode 100644 index 0000000..18924cf Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/doc/pecoff_v8.doc differ diff --git a/一些非必要的资料/linux-0.11-quickstart/doc/保护模式教程.chm b/一些非必要的资料/linux-0.11-quickstart/doc/保护模式教程.chm new file mode 100644 index 0000000..56ab9ff Binary files /dev/null and b/一些非必要的资料/linux-0.11-quickstart/doc/保护模式教程.chm differ diff --git a/一些非必要的资料/linux-0.11-quickstart/readme.txt b/一些非必要的资料/linux-0.11-quickstart/readme.txt new file mode 100644 index 0000000..c70f48e --- /dev/null +++ b/一些非必要的资料/linux-0.11-quickstart/readme.txt @@ -0,0 +1,54 @@ +: + +1). ѹĬϵļλD:\Linux-0.11,㲻ǽļѹĿ¼, + Ҫ޸MinGW32Ŀ¼µMinGW32.batļ,PATHָMinGW32binĿ¼. +2). Linux-0.11Ŀ¼,˫MinGW32.batݷʽ,򿪿̨. +3). make һ,1.44MBoot.img̾,Ҫ"make clean" +4). װbochs,ֱ˫bochsrc.bxrcLinux-0.11. +5). ҲBoot.img,Kernel panic,Ӳɾ +6). ڳInsert root floppy and press ENTERԺ,rootimage-0.11.img,س + +windows±Linux 0.11,Cygwin,Ҳ,ʹMinGW. +Windows±Linux 0.11Ͷԭļ޸: + +1.ԾʿѾõC(ǶC)»ȥ,MinGWgccΪWindowsµıּ,ʶЩ»ߵC,ðԭѾڻȥ»ߵC»,ͬʱҲҪѱCõĻеı». + +2.MinGWвas86,bootĿ¼ԭas86bootsect.ssetup.s޸ijnasmij.ҸΪbootsect.asmsetup.asm. + +3.MakefileҪ޸: + LDFLAGSм--image-base 0x0000 elf_i386iji386pe + cd make ֮;ij&,cd kernel ; make ijcd kernel & make + MinGWûsync,԰ע͵,򵥵İ취дһsync.c,sync.cֻһյmain,sync.exe + ΪƵԭ,make dep + +4.ɵsystemļPEʽ(PEPortable Executableļ),windowsµĿִļĸʽ,ȻDzֱִе,ת.ʵַͨʽת. +1)дһTrans.cppsystem.exeĴݴPEļ,һsystem.binļ,ļܱsetupģֱӼص.ѾLinux-0.11toolsĿ¼,Ҫ΢ı. +2)ԼдһPE Loader,ַʽȽ鷳,ԼҲһPE Loader,гɾ͸е,һ򵥵Loader.ǼLinux-0.11-With-PE-Loader\bootĿ¼µsetup.asmļ,ϸע. + + +5.toolsµbuild.c޸,ʹɿ1.44M̾ļBoot.img + +6.LinkĹ,initĿ¼µmain.c´: +boot/head.o(.text+0x540c):fake: undefined reference to `_main' +init/main.o(.text+0x16f):main.c: undefined reference to `_alloca' +init/main.o(.text+0x174):main.c: undefined reference to `__main' +make: *** [tools/system.exe] Error 1 +һһ󻹺,мǸǾĪ,ΪLinux 0.11û,gccıѡҲ-nostdinc .һmainһͨĺ,MinGW gccĴ.İ취ʵҲܼ,main.cmainΪ_main,Ǹɴijһ,͸ijstart.ǵðhead.s_mainҲ. + + ,ҪлԼдϵͳԨʵҲȽԭֻLinux±ԴMinGWֲWindows±ĹвWindows±Linux 0.11ԴģWindows±Linux 0.11Դľ飬ֲ߰汾Դ룬0.12,0.95,0.96ȵȰ汾Ӧò̫鷳ˡ + ҲҪлLinuxںȫע͵Ծʿ˲ϵͳϵͳߵľ. + ,ҲdzͲϵͳǹͬĵ,ҲϣܶʶһЩ. + ҵ:flyfish + ҵQQ:785606288 + E-mail:I2CBus@126.com + ,Ҫת뱣ֱļ,ر˵Ͷʵ. +޸־: + 08/3/29 +޸һMakefile,ɵMakefileijЩļº󻹻±롣 +޸Trans.cppеһdug,dugtranslate MinGW gccijʱܻMinGW gcc ijVirtualAddressʽ0xFFC1000ʽʵ0x1000VirtualAddress + 08/4/2 + ޸MinGW32.bat,Ѿ·ˡ + 08/4/4 + Trans.cppдVirtualAddress>0xffffôɵsystem.binʹˣbochsʱһֱ + Ȩ֮ƣ0xffffٸij0x3ffffVirtualAddressͲܴ0x3ffff,֪˭иõĽ +