lqx[ - oldlinux.org -- linux plinuxoldlinux.org/download/clk011c-3.0.pdf · /lqx[ » n  # h $...
TRANSCRIPT
Linux v0.11Linux Linux
LINUX LinuxLinux 0.11
0.95 Linux PCC 80X86
Linux
Linux 0.11www.oldlinux.org
Linux
. , .
[email protected] [email protected] , :200092
© 2002 - 2007 by Zhao Jiong © 2002 - 2007 .
................................................................................ 1
........................................................ 1.................................................... 1
........................................ 2........................ 2
............................ 3.................................... 3
........................................ 4EXT2 MINIX ......................... 4
1 .................................................................. 5
1.1 LINUX ........................................... 51.2 ........................................................... 121.3 ........................................................... 16
2 .................................... 17
2.1 ........................................ 172.2 I/O .......................... 192.3 BIOS CMOS ................ 212.4 ................................................ 232.5 ........................................................... 31
3 .................................... 32
3.1 AS86 ....................................................... 323.2 GNU AS ...................................................... 383.3 C ......................................................... 483.4 C ................................. 553.5 LINUX 0.11 ................................. 633.6 MAKE MAKEFILE ........................... 72
4 80X86 ............................ 75
4.1 80X86 ........................ 754.2 ............................................ 814.3 ........................................................... 854.4 ........................................................... 964.5 ................................................................... 994.6 .............................................. 1104.7 ......................................................... 1204.8 ...................................... 1284.9 .......................... 131
5 LINUX ................................ 141
5.1 LINUX ............................................... 1415.2 LINUX ............................... 1425.3 LINUX ................... 1445.4 ......................................................... 157
5.5 LINUX ........................................... 1605.6 .............................................. 1625.7 LINUX ............................................... 1645.8 LINUX ....................... 1725.9 LINUX 0.11 ............................ 1765.10 LINUX ..................... 1775.11 ........................ 1845.12 LINUX/MAKEFILE .................................... 1845.13 ........................................................ 189
6 BOOT ........................... 191
6.1 .......................................................... 1916.2 BOOTSECT.S ............................................... 1936.3 SETUP.S ..................................................... 2036.4 HEAD.S ...................................................... 2216.5 .......................................................... 234
7 (INIT) ....................................... 235
7.1 MAIN.C ...................................................... 2357.2 .............................................. 2477.3 .......................................................... 249
8 (KERNEL)................................... 251
8.1 .......................................................... 2518.2 MAKEFILE ................................................. 2548.3 ASM.S ........................................................ 2568.4 TRAPS.C ..................................................... 2628.5 SYSTEM_CALL.S ........................................ 2678.6 MKTIME.C .................................................. 2798.7 SCHED.C .................................................... 2818.8 SIGNAL.C ................................................... 3008.9 EXIT.C ....................................................... 3118.10 FORK.C .................................................... 3188.11 SYS.C ....................................................... 3268.12 VSPRINTF.C .............................................. 3338.13 PRINTK.C ................................................. 3418.14 PANIC.C ................................................... 3428.15 ........................................................ 343
9 (BLOCK DRIVER)......... 345
9.1 .......................................................... 3469.2 MAKEFILE ................................................. 3499.3 BLK.H ........................................................ 3519.4 HD.C .......................................................... 3559.5 LL_RW_BLK.C ........................................... 3789.6 RAMDISK.C ................................................ 3849.7 FLOPPY.C ................................................... 390
10 (CHAR DRIVER) ..... 417
10.1 ....................................................... 41710.2 MAKEFILE ............................................... 42710.3 KEYBOARD.S .......................................... 42910.4 CONSOLE.C .............................................. 44810.5 SERIAL.C ................................................. 47410.6 RS_IO.S ................................................... 48310.7 TTY_IO.C ................................................. 48710.8 TTY_IOCTL.C ........................................... 499
11 (MATH).............................. 507
11.1 MAKEFILE ............................................... 50711.2 MATH-EMULATION.C ................................ 509
12 (FS)............................................. 511
12.1 ....................................................... 51112.2 MAKEFILE ............................................... 52712.3 BUFFER.C ................................................ 53012.4 BITMAP.C ................................................. 54712.5 TRUNCTE.C .............................................. 55312.6 INODE.C .................................................. 55512.7 SUPER.C .................................................. 56712.8 NAMEI.C .................................................. 57712.9 FILE_TABLE.C .......................................... 60112.10 BLOCK_DEV.C ....................................... 60112.11 FILE_DEV.C ............................................ 60512.12 PIPE.C .................................................... 60812.13 CHAR_DEV.C ......................................... 61212.14 READ_WRITE.C ...................................... 61512.15 OPEN.C .................................................. 62112.16 EXEC.C .................................................. 62712.17 STAT.C ................................................... 64712.18 FCNTL.C ................................................ 64912.19 IOCTL.C ................................................. 652
13 (MM) .......................................... 655
13.1 ....................................................... 65513.2 MAKEFILE ............................................... 66113.3 MEMORY.C ............................................... 66213.4 PAGE.S ..................................................... 679
14 (INCLUDE) ................................... 683
14.1 INCLUDE/ ................................. 68314.2 A.OUT.H ................................................... 68414.3 CONST.H .................................................. 69514.4 CTYPE.H .................................................. 69514.5 ERRNO.H ................................................. 69714.6 FCNTL.H .................................................. 69914.7 SIGNAL.H ................................................ 70114.8 STDARG.H ................................................ 70314.9 STDDEF.H ................................................ 70414.10 STRING.H ............................................... 70514.11 TERMIOS.H ............................................ 715
14.12 TIME.H ................................................... 72214.13 UNISTD.H ............................................... 72414.14 UTIME.H ................................................ 72914.15 INCLUDE/ASM/ ....................... 73114.16 IO.H ....................................................... 73114.17 MEMORY.H ............................................. 73214.18 SEGMENT.H ............................................ 73314.19 SYSTEM.H .............................................. 73514.20 INCLUDE/LINUX/ .................... 73914.21 CONFIG.H ............................................... 73914.22 FDREG.H ............................................ 74114.23 FS.H ....................................................... 74414.24 HDREG.H ................................................ 74914.25 HEAD.H ................................................. 75214.26 KERNEL.H .............................................. 75314.27 MM.H ..................................................... 75414.28 SCHED.H ................................................ 75414.29 SYS.H .................................................... 76114.30 TTY.H ..................................................... 76314.31 INCLUDE/SYS/ ......................... 76614.32 STAT.H ................................................... 76614.33 TIMES.H ................................................. 76714.34 TYPES.H ................................................. 76814.35 UTSNAME.H ........................................... 76914.36 WAIT.H ................................................... 770
15 (LIB)............................................... 773
15.1 MAKEFILE ............................................... 77415.2 _EXIT.C ................................................... 77615.3 CLOSE.C .................................................. 77715.4 CTYPE.C .................................................. 77715.5 DUP.C ...................................................... 77815.6 ERRNO.C .................................................. 77915.7 EXECVE.C ................................................ 77915.8 MALLOC.C ............................................... 78015.9 OPEN.C .................................................... 78915.10 SETSID.C ................................................ 79015.11 STRING.C ................................................ 79115.12 WAIT.C ................................................... 79115.13 WRITE.C ................................................ 792
16 (TOOLS) .................................... 795
16.1 BUILD.C ................................................... 795
17 ........................ 802
17.1 BOCHS ............................................ 80217.2 BOCHS LINUX 0.11 ............... 80617.3 ........................ 81317.4 ........................ 81517.5 BOCHS ................................... 81717.6 ........................................ 82417.7 ............................................ 82717.8 LINUX 0.11 0.11 ........... 83417.9 REDHAT 9 LINUX 0.11 .. 835
17.10 + 83817.11 SHOELACE .... 84317.12 GDB BOCHS ...... 846
.................................................................... 853
............................................................................ 855
1 ............................................ 855
2 ASCII ................................................. 8633 C0 C1 ......................... 8644 ........................ 8655 1 ................................ 868
............................................................................ 869
Linux
Linuxlinux
linuxLinux
UNIXLinux
Linux Linux Redhat 7.0 2.2.16Fedora Core 4 2.6.11 Linux
2.2.20 268 LinuxLinux
Scott Maxwell Linux LinuxLinux
(*.h)make
LinuxLinux
John Lions UNIX UNIXUNIX V6 PDP-11
A.S.TanenbaumMINIX Linux
LinuxLinux
Linux LinuxLinux
1991 10 Linux Linus Torvalds Linux 0.03LINUX--a free unix-386 kernel 1 Linux
GNU Hurd” Linux GNU Hurd
LinuxLinux
LinuxLinux
Linux DJJ x86Uclinux www.linux.org Linux
LinuxLinux Linux
Leland L. Beck(SIC)
Linux LelandLinux Linux
LinuxVFS a.out
Linux
LinuxRTFSC – Read The Fucking Source Code
M.J.Bach UNIX UNIX
ASTI/O
LinuxLinux
0.11 Linux
Linux 2.6.0 5920.11 2
Linux 0.11 GNU gcc
VFS ext2 ext3
C Intel CPU CBrain W. Kernighan Dennis M. Ritchie The C Programming Language
Intel CPUGNU gcc Internet
5.580x86
80x86 INTEL 80386 Programmer's Reference Manual 80x86
LinuxLinux M.J.Bach UNIX
Linus Linux MINIX LinuxMINIX 1.0 A.S.Tanenbaum
TanenbaumLinux
Linux Linux TanenbaumLinux is obsolete Linux
Ext2 MINIX
Linux Ext2 Ext3 1.xLinux Linux
Linux 0.11 MINIX 1.0Linux
LinuxLinux
2007.6.
1
Linux LinuxLinux
1.1 Linux
Linux UNIX 1991 10 5Internet
UNIX Linux UNIX MINIX
GNU POSIX Internet LinuxLinux Linus
Torvalds Linux0.01 hacker 1.0
LinuxLinux 2.6.x Linux
2.6.12 2 Linux
1.1.1 UNIX Linux UNIX UNIXKen.Thompson Dennis Ritchie 1969 DEC PDP-7 Ken Thompson PDP-7 Space travel
1969 UNIXBCPL Dennis Ritchie 1972 C
UNIX
1.1.2 MINIX MINIX Andrew S. Tanenbaum AST AST Amsterdam Vrije
ACM IEEE ( )100 5
AST (1914 ) M.I.TBerkeley
Vrije AmsterdamAST
MINIX 1987 1991 1.51.5 2.0
MINIX FTPLinux Linus Linux
MINIX MINIXLinus Linux Linus
MINIX Chacker
1.1.3 GNU GNU FSF(the Free Software Foundation) Richard M. Stallman 1984
UNIX GNU GNU "GNU's Not Unix" "guh-NEW" Linux GNU
"Linux" Stallman GNU/Linux
90 GNU emacsbash shell gcc gdb Linux
Linux LinuxGNU/Linux”
1.1.4 POSIX POSIX Portable Operating System Interface for Computing Systems IEEE ISO/IEC
UNIX1980 UNIX
(usr/group) UNIX AT&T System V Berkeley CSRG BSD 1984 /usr/group 1985 IEEE TCOS-SS ANSI IEEE
1986 4 IEEE1988 9 IEEE 1003.1-1988
POSIX.11989 POSIX ISO/IEC 15 ISO 1990
POSIX.1 C IEEE 1003.1-1990 ANSI ISO/IEC 9945-1:1990 POSIX.1 API
IEEE POSIX300 (POSIX.2)
POSIX.3 API POSIX.4 1990 25 16X/Open AT&T OSF
90 POSIX 1991-1993 LinuxUNIX Linux Linux
UNIX Linux 0.01 0.11Linux POSIX Linux 0.01 /include/unistd.h
POSXI Linus OK
1991 7 3 comp.os.minix post POSIXPOSIX
1.1.5 Linux1981 IBM IBM PC 1981-1991 MS-DOS
Apple MACsUNIX UNIX
UNIX PC Bell LabsUNIX PC
MINIX AST
Linux Linus Benedict Torvalds(1991 ) Linus Benedict Torvaldshacker 21
GNU GNU CGNU MINIXGNU HURD
Linus386 MINIX MINIX Linus
Intel 80386 Modem80386 CPU
MINIX MINIXLinus
GNUGNU C GNU HURD
Linus1991 4
Intel 386 LinuxLinus comp.os.minix
MINIX Linux Linus 1 comp.os.minix 1991 3 29 gcc on minix-386 doesn't optimize”, gcc MINIX-386 MINIX-386 Bruce Evans Intel 386 32 MINIX Linus 1991
MINIX MINIX MINIXIntel 80386
MINIX “RTFSC (Read the F**ing Source Code :-)”
1991 4 Linus MINIX-386 (Hacking the kernel)GNU (GNU gcc bash gdb ) 4 13 comp.os.minix
bash MINIX shellLinux 1991 7 3 comp.os.minix
Linux Linus FREAX FREAXLinux POSIX
Linus (1991 8 25 comp.os.minix) MINIXMINIX ”( What would you like to see in minix? )
( )386(486) GNUMINIX
MINIX MINIXbash(1.08 ) gcc(1.40 )
Linus MINIX 386AT Linux
Linus Linux1991 10 5 Linus comp.os.minix Linux
Free minix-like kernel sources for 386-AT Linux10 5 Linux Linux
RedHat
1.1.6 Linux Linux 1.0 1 1 Linus 2003
9 BitKeeper 1.0Linux 0.00 Linus 80386
Linux 0.01 1991 9 17 Linusinclude/string.h
8MB Linus 0.02 0.03
/
0.00 1991.2-4 ’AAA...’ ’BBB...’
0.01 1991.9.17 Linux
0.02 1991.10.5 0.03
0.10 1991.10 Ted Ts’o Linux boot
as86 gas
0.11 1991.12.8
0.12 1992.1.15 swapping
0.95.x
( 0.13)1992.3.8
MINIX
MINIX Linux
CDROM
0.96.x 1992.5.12
UNIX Socket ext alpha SCSI
X-Windows
C 0.95
0.97.x 1992.8.1 SCSI msdos ext
3GB
0.98.x 1992.9.28
TCP/IP 0.8.1 extfs
mm 4GB 1GB 0.98.4
256 32
0.99.x 1992.12.13 4G
NFS
1.0 1994.3.14
0.10 Ted Ts'o LinusGNU gcc
/ mount/umount Linus"(C) 1991 Linus Torvalds" boot/boot.sboot/bootsect.s boot/setup.s 16MB
dev/port dev/nullkernel/signal.c sigaction()
0.10 Linux 0.11
/etc/rc Ted Ts'oGalen Hunt John T Kohl kernel/console.c
KILL Linux 0.12 Linus 1991
2MB gccLinus 1.0 0.13
0.95 Linus 1.0 0.950.95 Linux
Linus0.12
Ted Ts'oIO
Peter MacDonald Linux UNIXselect() Peter MacDonald MINIX
MINIX Linus
0.95 GNU GPL Linux 3 19923 8 1 0.95 10 3 170.95a 1 4 9 0.95c+
VFS MINIXMINIX MINIX 0.95
Ross Biro ptraceCtrl-Alt-Del swapon()
4 James Wiegand
0.95 Linus2005
11 9 2.6.14 16000 gz 47MB1–2
( gz )
2.0.40 2004.2.8 7.2 MB
2.2.26 2004.2.25 19 MB
2.4.31 2005.6.1 37 MB
2.6.14 2005.11.9 47 MB
1.1.7 Linux Linux Linux Linus FREAX
ftp.funet.fi Ari LemkeLinus Linux
LinuxLinus Just for Fun Linus 2
LinuxFreax Makefile -
- Freax”
Ari Lemke ftp Freax(Linux)
1.1.8 LinuxLinux Linux Linus
Theodore Ts'o (Ted Ts'o) 1990 MITHacking on Linux
IBMIETF
Linux Linux
linux Maillist Linux LinuxLinux Linux 0.10 ramdisk.c
kmalloc.c) Linux Linuxftp tsx-11.mit.edu Linux Linux
ext2 Linuxext3 97
2002 5 Linux Journal IBM LinuxLinux LSB(Linux Standard Base)
Linux Alan Cox (Swansea University College) MUD Multi-User Dungeon or Dimension
90 games.mud postsMUD (rec.games.mud 1992 3 9 A history of MUD)
MUD
MINIX Linux 0.11 386BSD386SX 386BSD Intel 386SX CPU
Linux Linux LinuxLinux
Linux (beautifully) Linux 0.95 Linux
Linus Linux TCP/IPLinux Linux Linux
Linus Microsoft 2001Linux 2.4.x Linus ( 2.5.x
)The Linux Kernel Hackers' Guide Michael K. Johnson
Linux ( 0.97 ) Linux Linux Document Project - LDPLinux Journal RedHat
Linux LinuxLinux CREDITS
Linux 400 email
Linux UNIX -- UNIX 1969 Bell Linux UNIX UNIX
MINIX -- MINIX UNIX 1987Andrew S. Tanenbaum MINIX ( )
UNIX Linux MINIX 1991 GNU -- Linux Linux GNU Linux
GNU ( bash shell) Linux POSIX -- Linux Linux
INTERNET -- Intenet Linux0.13(0.95)
1.2
Linux 0.11 Linux-0.11 1991 12 8
bootimage.Z rootimage.Z Image bootimage ImagePC ROM BIOS
rootimage
Linux UNIXDOS
as86.tar.Z 16 linux-0.11.tar.Z Linux 0.11INSTALL-0.11 Linux 0.11
rootimage.Z InternetLinux 0.11 rootimage-0.11 0.11
gcc 1.40 oldlinux.org
http://oldlinux.org/Linux.old/images/ bootimagerootimage
http://oldlinux.org/Linux.old/kernels/ Linux 0.11http://oldlinux.org/Linux.old/bochs/ bochs
Linuxhttp://oldlinux.org/Linux.old/Linux-0.11/ Linux 0.11
linux-0.11Makefile
shell
C GNU C/ Intel 8259A
Linux 0.11 Linux Linux-0.11325K Linux 2.6.XX
200Linux 0.01 240K 0.01
0.110.11
(bootimage) (rootimage)
Linux 0.11TCP/IPLinux Linux
Linux
Linux 1.1linux
1-1 Linux/
1 4
Linux Intel 80X86 5 7 32
8 13
8 14 1617
PC Bochs Linux 0.112 Linux IBM PC/AT386
3 Linux 0.11 Linux 0.11 GNU C as86 GNU as
GNU CC C
Makefile4 80X86 CPU
80X86 CPU Linux 80X86
5 LinuxLinux
Linux/Makefile make
6 boot/ bootsect.s BIOSsetup.s 32 head.s
32
7 init/ main.cshell
main.cLinux
8 kenel/ schedule() sleep_on()
C 39 kernel/blk_drv/
10 kernel/chr_drv/0.11
11 kernel/math/
12 fs/Andrew S. Tanenbaum MINIX Linux
MINIX Linux 0.1113 mm/ Intel 80X86
80X86 4
Linux14 include/
15 Linux 0.11 lib/
0.1116 tools/ build.c Image
kernelimage
17 BochsLinux Linux 0.11RedHat 9
Linux
PC
Linux LDP Linux Document ProjectHOWTO LDP
Linus Linux 3 M. J. Bach UNIXUNIX System V Linus
LinuxJohn H. Crawford Programming the 80386
80x86 Andrew S.Tanenbaum MINIX1 Linus MINIX 1.0 Linux
Tanenbaum
C
LinuxLinux Linux
1.0Linux 2.6.12
patch
1.3
Linux UNIX LinuxRichard Stallman GNU Linux
POSIX Linux A.S.T MINIX LinuxInternet Linux
2
2-1
/2-1 (b)
/Intel 80X86 CPU -- Central Processing Unit IBM PC
CPULinux
Linux 0.11 PC/AT 80386CPU IBM PC PC IBM PC/XT
2.180386 CPU PC
2-2 CPUI/O /
CPU I/O /80386 CPU PC 32 32232 0 4GB
Intel 8259A DMA
Intel 8237A Intel 8253/8254 Intel 8042
ISA Industry Standard Architecture EISA Extented ISAPCI Peripheral Component Interconnect AGP Accelerated Graphics Port
PCIE PCI Express80386 ISA I/O 16
PC2-3 CPU PC 2
Chipsets Northbridge SouthbridgeCPU AGP
Intel MCH Memory Controller HubPCI IDE USB ICH I/O Controller Hub
Intel PCCPU
PC PCPC Intel PC
PC PC2-2
2.2 I/O
2.2.1 I/O CPU I/O
I/O I/O
I/OCPU
I/O I/OI/O I/O
IBM PC I/OISA PC I/O 0x000 -- 0x3FF 1024 I/O
2-1
IBM PC CGA0xB800 -- 0xBC00
0x000 -- 0x01F 8237A DMA 1
0x020 -- 0x03F 8259A 1
0x040 -- 0x05F 8253/8254A
0x060 -- 0x06F 8042
0x070 -- 0x07F CMOS RAM/ RTC Real Time Clock
0x080 -- 0x09F DMA
0x0A0 -- 0x0BF 8259A 2
0x0C0 -- 0x0DF 8237A DMA 2
0x0F0 -- 0x0FF
0x170 -- 0x177 IDE 1
0x1F0 -- 0x1F7 IDE 0
0x278 -- 0x27F 2
0x2F8 -- 0x2FF 2
0x378 -- 0x37F 1
0x3B0 -- 0x3BF MDA
0x3C0 -- 0x3CF CGA
0x3D0 -- 0x3DF EGA/VGA
0x3F0 -- 0x3F7
0x3F8 -- 0x3FF 1
EISA PCI PC 64KB I/O Linux/proc/ioports I/O
[root@plinux root]# cat /proc/ioports
2.2.2 PC I/O DMA
CPUCPU
Linux
I/O CPUCPU I/O
CPU I/O CPU
Linux I/O
DMA Direct Memory Access I/ODMA CPU
Linux DMA
2.3 BIOS CMOS
2.3.1 1981 IBM PC 640KB RAM 8088/8086 CPU 20 1024KB 1MB DOS 640K
1MB512MB Intel 32 CPU PC/AT
CPU 4GB CPU 64GBPC 1MB
PC ROM BIOS CPUBIOS BIOS Shadow BIOS
2-40 0xA0000 0xFFFFF
640K 1M 384K 0xFFFE0000 0xFFFFFFFF 4G 64KI/O BIOS 16MB
Linux 0.1x 0--640K Linux BIOSBIOS 640K-- 1M 384K 0xA0000
128K ROM BIOS 0xF00001M ROM BIOS 1M--16M
640K -- 1M
2.3.2 / BIOSROM BIOS
DOS BIOSBIOS
Linux BIOSCPU CS 0xF000
0xFFFF0000 64KB IP 0xFFF0 CPU0xFFFFFFF0 4G 64K 16 ROM BIOS
BIOS JMP BIOS 64KBPC/AT BIOS 1MB 2MB Flash Memory ROM
BIOS 64KB 0--1M BIOSBIOS 32 Big Mode
4G 64K 0 4G BIOSPC 64KB BIOS 1M
64K CPU 2-5 BIOS0x7c00
2.3.3 CMOSPC/AT ROM BIOS 64 128
CMOS Complementary Metal Oxide SemiconductorReal Time Chip
CMOS I/O
2.4
2.4.1 IBM PC/AT 80X86 8259A
I/O 15 2-6ROM BIOS 8259A 15
0x000-0xFFF IntelLinux 8259A
PC ROM BIOS 2-2Linux PC Linux
BIOS
IRQ0 0x08 8 8253 100HZ
IRQ1 0x09 9
IRQ2 0x0A 10
IRQ3 0x0B 11 2
IRQ4 0x0C 12 1
IRQ5 0x0D 13 2
IRQ6 0x0E 14
IRQ7 0x0F 15 1
IRQ8 0x70 112
IRQ9 0x71 113 INT 0x0A
IRQ10 0x72 114
IRQ11 0x73 115
IRQ12 0x74 116 PS/2
IRQ13 0x75 117
IRQ14 0x76 118
IRQ15 0x77 119
2.4.2 DMADMA
Intel 8237 DMACPU CPU
PC/AT 8237 DMA 8 416 DMA 2
DMA8 16
2.4.3 / Intel 8253/8254 / PIT - Programmable Interval Timer
3 16
CPU 8253/8254 82538253/8254 CPU
PC/AT 8254 3 /DRAM Linux 0.11 0
3 10 IRQ0Linux 0.11
2.4.4IBM 1984 PC/AT AT-PS/2
101 104 Intel 8048
Make codeBreak code
Scan Code Set
-- XT -- AT -- PS/2 IBM PS/2
AT PC/XT2-7
XT
Intel 8042 PC8042 11
1 2--9 8 10 1111
PC/XT IRQ1 CPU CPUXT
XT
A 30 0x1EXT 0x80 7
A 0x80 + 0x1E = 0x9EPC/XT 83 AT Ctrl
Alt 2 4 1 0xE0Ctrl 1 0x1D Ctrl 2
0xE0 0x1D 0xE0 0x9D 2-3
A 0x1E 0x9E
9 0x0A 0x8A
F9 0x43 0xC3
0xe0, 0x4D 0xe0, 0xCD
Ctrl 0xe0, 0x1D 0xe0, 0x9D
Shift + G 0x2A, 0x22 0xAA, 0xA2 Shift
8042 P2 P20 CPU P21A20 1 P21 1 A20
0 A20 80428042 8042
2.4.51.
// /
/
/2-8
word
2.2-9
0 5--81 1 1.5 2
1 MARK 0 SPACE
MARK 1
3.PC 2 RS-232C /
UART Universal Asyncronous Receiver/TransmitterPC 25 9 DB-25 DB-9 MODEM
RS-232C MODEMPC NS8250 NS16450 UART PC 16650A
NS8250/16450 NS8250/16450 16650A 16650AFIFO UART 16
CPU PC RESET NS8250 MRUART UART
UART
2.4.6
2-42-10
D6D5D4 D2D1D0
0 0 0 0 0 0 0x00
0 0 0 1 1 1 0x07 Normal
0 0 0 0 0 1 0x01 Underline
1 1 1 0 0 0 0x70 Reverse
1 1 1 1 1 1 0x77
2-10
2-5
I R G B I R G B
0 0 0 0 0x00 Black 1 0 0 0 0x08 Dark grey
0 0 0 1 0x01 Blue 1 0 0 1 0x09 Light blue
0 0 1 0 0x02 Green 1 0 1 0 0x0a Light green
0 0 1 1 0x03 Cyan 1 0 1 1 0x0b Light cyan
0 1 0 0 0x04 Red 1 1 0 0 0x0c Light red
0 1 0 1 0x05 Magenta 1 1 0 1 0x0d Light magenta
0 1 1 0 0x05 Brown 1 1 1 0 0x0e Yellow
0 1 1 1 0x07 Light grey 1 1 1 1 0x0f White
2.4.7 PC
PCPC
300 / 2
2 4 48 2-11 4500 / 10000 /
/
0 1
2-12 GAP GAP12 0
CPUCPU /
2-12/
PC/AT FDC Floppy Disk Controller NEC PD765CPU 2-13
/ --
I/OPC/AT DMA
DMA AT DMA
U
2.5
Linux GNU gcc
3
Linux 0.11Linux 0.11 GNU C as86 GNU as
GNU CC C
Linux 0.11 a.outMakefile
Linux
3.1 as86Linux 0.1x Assembler 16 as86ld86 GNU gas as GNU ld
as86 as as86 ld86 MINIX-386 Bruce Evans Intel 8086 80386
Linux Linus Linux 8038632 Linux 16 boot/bootsect.s
boot/setup.s GNU gasGNU as
MASM Borland Turbo ASM NASM IntelGNU as
as86 MINIX MINIX PC/IXPC/IX Intel 8086 CPU UN*X Andrew S. Tanenbaum
PC/IX MINIX Bruce Evans MINIX 32 Linux Linus Torvalds
Linux Linus Bruce Evans UNIX MINIXMINIX Linus Intel 80386
Linus BruceLinux Bruce Evans
FTP ftp.funet.fi www.oldlinux.orgLinux as86/ld86 RPM dev86-0.16.3-8.i386.rpm Linux
as86 ld86 16 bootsect.s setup.s
3.1.1 as86
01
0
3.1.2 as86boot.s as86
as86 ld86bootsect.s
20
1 175 " " 27
3 as86
40
46
Linux
5 11 3 3
C
14
BIOS0x7c00 CS 0
CS:IP=0x0000:0x7c00 CS 0x7c0 CS:IP = 0x07C0:0x0005 DS ES 0x7c0
20 MOV ah 0x7c0 0x07 msg1
21--25msg1
bootsec.s setup.s
4--1132--37
3.1.3 as86boot.s boot
1 as86 boot.s boot.o 2 ld86MINIX boot -0 8086 16
-a GNU as ld -s-o
boot 51232 32 MINIX
32
boot 32Linux RedHat 9 as86 MINIX
man as86Linux dd
3 dd boot 32Bochs Bochs PCBochs 3-1
3.1.4 as86 ld86 as86 ld86
3.2 GNU as
C gas C80X86 CPU Linux
GNU as as asas
10% Linux 32as
C GNU gcc as gccas as gcc
as C
GNU as BSD 4.2 asas
Linux 0.11
3.2.1 asas as
as as
as as
as
as as
asCtrl-D as
as
3.2.2 as
3.2.2.1 as
as gcc CPP
as C
3.2.2.2
3-1
3-1
\b Backspace 0x08
\f FormFeed 0x0C
\n Newline 0x0A
\r Carriage-Return 0x0D
\NNN 3
\xNN... 16
\\
\" '"'
3.2.3
3.2.3.1 AT&T
3-2
AT&T Intel
cbtw cbw %al %ax
cwtl cwde %ax %eax
cwtd cwd %ax %dx:%ax
cltd cdq %eax %edx:%eax
3.2.3.2
3-3
cs, ds, ss, es, fs, gs :
data16, addr16 / 32 /
16 / as 16
lock80X86
wait80386/80387
rep, repe, repne %ecx
3.2.3.3
3.2.3.4
3.2.4
ld
3.2.4.1
3-2
3.2.4.2text data
as subsection0--8192
text
3.2.4.3 bss bss bss
bss
3.2.5Symbol
Label
3.2.5.1
3.2.5.2
3.2.6 as
3.2.6.1 .align abs-expr1, abs-expr2, abs-expr3
3.2.6.2 .ascii "string"...
3.2.6.3 .asciz "string"...
3.2.6.4 .byte expressions
3.2.6.5 .comm symbol, length
3.2.6.6 .data subsection
3.2.6.7 .desc symbol, abs-expr
3.2.6.8 .fill repeat, size, value
3.2.6.9 .global symbol .globl symbol
3.2.6.10 .int expressions
3.2.6.11 .lcomm symbol, length
3.2.6.12 .long expressions
3.2.6.13 .octa bignums
3.2.6.14 .org new_lc, fill
3.2.6.15 .quad bignums
3.2.6.16 .short expressions .word expressions
3.2.6.17 .space size, fill
3.2.6.18 .string "string"
3.2.6.19 .text subsection
3.2.6.20 .word expressions
3.2.7 16
3.2.8 AS
3.3 C GNU gcc ISO C89 C ISO C99
gcc
3.3.1 Cgcc C
3-3
gcc C C CPP C
C
Linux make
3.3.2C C
1 asm
CC
” gccgcc /
22
10
__res 10'\'
1 get_seg_byte(seg,addr) 3__res
eax “ ” "asm""__asm__" 4 "__asm__" 4 7 4 AT&T
gcc
8 eax __res"=a" "a" "="
9 seg eax "0"(*(addr))
"%0"%0 %1 …%9 %0
("0" (seg)) %1 %2 6 %2 (*(addr))
4—7 fs eaxfs fs:(*(addr)) al
eax __resseg addr
1-3 "\n\t" gccC gcc
CC (
) "\n\t"4 5 count-1 ecx
"c" fill_value eax dest edi gccgcc
fill_value eax gcc eaxmovl
gcc gccgcc 3-4
a eax m
b ebx o
c ecx I 0-31
d edx J 0-63
S esi K 0-255
D edi L 0-65535
qeax ebx ecx edx
M 0-3
r N 1 0-255
geax ebx ecx edx
O 0-31
A eax edx (64 ) =
+ &earlyclobber
gcc
” ” 1 ”” x 5 "%0" "%1" gcc
"%1" x "%0"0 gcc r
eax
GCC asm
gccgcc gcc
mm/memory.c
include/string.h strncmp() "\n\t"gcc
3.3.3 ”{...}”
”({...})” GNU C loop switch
”3 + z”void
init/main.c CMOS
include/asm/io.h I/O port _v inb()
3.3.4 GNU C CPUCPU 2
asm gccgcc
gcc asm volatile
LinuxGNU C
ax resgcc
gcc
asm
3.3.5gcc
/
gcc
” ”” ”
fs/inode.c
malloca() gotogcc
gcc
ISO C99 gccISO C99
C99 inline static gcc C99
gcc
ISO C99 static static
.h
Linux 0.1x
strcpy()
3.4 C
C
3.4.1 CLinux
CC C
Intel 80x86 CPU
3.4.1.1CPU
Stack frame 3-4 ebpframe pointer esp stack pointer esp
ebp
A B B A A B AA B
ebp
B CPU
C '&'B
esp push pop
CALL RET CALLCALL
RETCALL
eax
Intel CPU eax edx ecx
B A B Aebx esi edi B
Aebp esp
3.4.1.2C
C3-5
ebpgdb 2
a b -4 -8
C
3--55 esp 4 c
6--15 swap 6--8 1 &aecx 9--12 2 &b
1 13--15 c2 16--17 leave
swap() esp ebp ret19--21 main() main() a b
22--23 24-28 main() swap()leal b a swap()
1 call 29--30eax
C C
3.4.1.3 main()gcc 1.40 gcc
C main() crt0.scrt0.s stub crt C run-time
Linux 0.11 crt0.s_environ
gcc gcc'-v'
stub crt0.o ldgld exch.o exch crt0.o
crt0.oELF gcc 2.x crt0
crt1.o crti.o crtbegin.o crtend.o crtn.o crt1.o crti.o crtbegin.ocrtbeginS.o crtend.o crtendS.o crtn.o gcc specfile
ctr1.o crti.o crtn.o C C crtbegin.o crtend.oC++ gcc crt1.o crt0.o main()
crtbegin.o crtend.o C++ constructordestructor crtbeginS.o crtendS.o crti.o
crtn.o
boot/head.s 136--140 init/main.c main() 139140 main() head.s 218
ret main() init/main.c
3.4.2 CC C
swap()C
1 3-6 CALL
CALL CPU CALL EIPCPU
Linux CALLCALL
C C3-6 3
EIP1 2 3 p3 p2
Linux 0.1x217 68
5 17
C copy_process()5 copy_process() 5 eax nr
ebp edi esi gs
none 9474
83--88 ebx ecx edx fs es ds 5 CPUeip cs eflags esp ss
CPU C5
C CALL JMP
JMP RETLinux
62 do_int3()
3.4.3 CC C Linux
C
1 0x804
int 0x80 %eax4 %ebx %ecx %edx fd buf count mywrite()
sys_write()2 res
0res
Linux RedHat 9'_' C
mywrite()myadd() a b 3 res mywrite()
myadd() 0
3.5 Linux 0.11Linux 0.11 as86
ld86 16GNU as gas C gcc
gld
Linux 0.11
Image Linux 0.11 a.out as86ld86 MINIXMINIX a.out
John R. Levine Linkers & Loaders
3.5.1Linux 0.11 GNU gcc gas
UNIX a.out Assembly & linker editor outputa.out
Text section Data section3-7
a.out 7exec header exec
ld
text segment
data segment
text relocations
data relocationssymbol table
string table
Linux 0.11 Intel CPU64MB
3.5.1.132 exec
a.out include/a.out.h
a.out a.out Linux 0.11OMAGIC Old Magic a.out
0x107 0407 ZMAGIC a.outdemang-paging load on demand
0x10b 041332 ZMAGIC 1024
32 0 1024OMAGIC .o 32
a_text a_data a_bssbss Linux
bssbss bss
a_entry a_syms a_trsize a_drsize
03.5.1.2 Linux 0.11 a.out
8
4r_address 2
r_length 0 3 1 2 4 8r_pcrel PCr_extern r_symbolnum 0
r_symbolnum1 r_symbolnum
3.5.1.3
GNU gcc12 null
n_type1
n_type a.out.h
text data bbsabsundef 0
bssbss
Common block
3.5.2 Linux 0.11Linux 0.11 objdump
hello.o
hello.o 0407 OMAGIC0x28 3 0x10
0 hello 0413 ZMAGIC1024 0x3000 0x1000 141
strip hellohello 0 hello 20591
17412
a.out 3-8 Linux 0.1164MB ZMAGIC a.out
Linux 0.11 Demand-pagingfs/execve()
bss bss 10 heap
3.5.3
a.out a.out
3-9 text data bss
bssbss
Linux 0.11 ZMAGIC a.out0 bss
Linux 0.11ZMAGIC
Loadon demand
Linux 0.11 Makefile makemake tools/ build.c
build ROM BIOSbuild
bootsect setup system Image
3.5.4ld ld86
etext _etextedata _edata end _end
_etext etext 1 _edata edata1 _end end bss 1
brk _end sys_brk()malloc() / brk sbrk()
Linux 0.1X
Linux RedHat 9 Linux0x08048000 0x41b
Linux 0.1x fs/buffer.c _endImage
3.5.5 System.mapGNU gld ld
link map
System.map_etext _edata _end
System.map
1 2sections 3
2 3-5
110--185
A Absolute
B BSS section BSS
C Common
D Data
G Global
I Inderect
N Debugging
R Read only
S Small
T Text
U Undefined 0
- Stabs a.out stab
? Unknwon
klogdklogd klogd
3.6 Make Makefile Makefile makefile make Make
MakefileMakefile GNU make
make Makefile make Makefilemake Makefile make
make Makefile Makefile
make
make CC
Makefile
make
make
’$<’ foo.c $@ foo.o make
makemake
make
target'clean' delete
make
Makefile Makefile
Makefile makemake
3.7as86 GNU as
Linux CLinux 0.11 a.out
Intel 80X86
Linux 0.11
4 80X86
Linux Intel 80X86 PC 80X86 CPUIntel IA-32 Intel
3 80X86 CPUIntel
80X86 CPU 80X86 CPU Linux1. 80X86 2. 3. 4.
5. 6. 7.Linux 0.11
Linux
Linux
4.1 80X86 80X86 EFLAGS
EFLAGS
4.1.1EFLAGS IOPL I/O
-8086 4-1 EFLAGSCF PF AF ZF SF DF OF
EFLAGS
TF 8 Trap Flag
POPF POPFD IRET TF
IOPL 13-12 I/O I/O Privilege Level I/OIOPL CPL IOPL I/O CPL
0 POPF IRET IOPL IF
NT 14 Nested TaskCALL IRET
NT POPF/POPFD
RF 16 Resume FlagRF
IRETDEFLAGS RF
VM 17 -8086 Virtual-8086 Mode -8086
4.1.24 GDTR LDTR IDTR TR
4-2
GDTR LDTR IDTR TR GDTR IDTRLDTR TR TSS Task State Segment TSS
1. GDTR GDTR GDT 32 16 GDT
0 GDT LGDT SGDTGDTR 0
0xFFFF GDTR2. IDTR
GDTR IDTR IDT 32 16LIDT SIDT IDTR
0 0xFFFF3. LDTR LDTR LDT 32 16LLDT SLDT LDTR LDT GDT
LLDT LDT LDTR LDTLDTR LDT
LDTR0 0xFFFF
4. TR TR TSS 16 32 16
GDT TSS LTR STR TRLTR TSS
TSSTR
4.1.3CR0 CR1 CR2 CR3
4-3 CR0 CR1 CR2CR3 PDBR
Page-Directory Base address Register
1. CR0 CR0 4 ET TS EM MP 80X86
11 CR0 ET80387 80287 TS MP
EM WAIT DNA Device Not Available
ET CR0 4 Extension Type 1 8038732 ET=0 80287 EM=1
ET80387 ET 1 80287 ET 0
TS CR0 3 Task Switched
TS CR0 EM 0DNA Device Not Available TS CR0 MP
EM WAIT/FWAITEM TS 4-1
TS
CLTS TS
EM CR0 2 EMulation
MP CR0 1 Monitor Coprocessor Math Present WAIT/FWAITTS MP=1 TS=1 WAIT
MP=0 TS WAIT
CR0
EM MP TS WAIT/FWAIT
0 0 0
0 0 1 DNA
0 1 0
0 1 1 DNA DNA
1 0 0 DNA
1 0 1 DNA
1 1 0 DNA
1 1 1 DNA DNA
2. CR0PE CR0 0 Protection Enable
PE PGPG CR0 31 Paging
PEPE PG
WP Intel 80486 CPU CR0 16 Write Proctect0
UNIX Copy on WriteNE Intel 80486 CPU CR0 5 Numeric Error
X87 PCX87 NE CPU IGNNE
X87 NE CPU IGNNEX87 FERR
WAIT/FWAIT CPU FERR80387 ERROR NE
IGNNE FERR PCPE Protected Enable 0 PG Paging 31
PE PE=1PE=0 8086 PG
PG=1 PG=-0
PE=0 PG=0 PG=0 PE=1PG=1 PE=0
PG=1 PE=1
PE PGPG
PG=1 CPU TLB - Translation Lookaside
BuffersPE
PEPE=0 PG=0
3. CR2 CR3 CR2 CR3 CR3 CR3 PDBR
20 12CR3 12 0MOV CR3
TLB Translation Lookaside Buffer TLB
CR0 PG PG=0 CR3CR3 CR3
CR2 CR2CR2
4.1.4
0 4-2
LLDT Load LDT Register LDTR LDT
LDTR
SLDT Store LDT Regiter LDTR LDTR LDT
LGDT Load GDT Register GDTR GDT
GDTR
SGDT Store GDT Register GDTR GDTR IDT
LTR Load Task Register TR TSS
STR Store Task Register TR TR TSS
LIDT Load IDT Register IDTR IDT
IDTR
SIDT Store IDT Register IDTR IDTR IDT
MOV CRn Move Control Registers CR0 CR1 CR2 CR3
LMSW Load Machine State Word CR0 15--0
80286
SMSW Store Machine State Word 80286
CLTS Clear TS flag CR0 TS
LSL Load Segment Limit
HLT Halt Processor
4.2
4.2.1
80X86 1 2 1 4
1 0 80X86 CPU32 2^32 4G
4G 280X86 80X86 CPU Little Endium
80X86 CPU Opcode Oprand80X86
80X86 Segment
16 14 2^14 1638432 0 4G 4G
16 32 4832
80X86 6 CS DS ES SS FS GS CSSS CS
EIPCS:[EIP] CS EIP
SS ESP SS:[ESP]4 DS
80X86
= + x +
4.2.2
80X86 4-4
1.
4-5TSS
LDT
GDT1
16K 4GB64TB 246 4GB 232
2.
RAM ROM
4KB
80X86
4.2.3 80X86
1.80X86
80X86
Global address space LinuxLocal address space
2.4 Privilege Levels
0 3 0 3
CSCurrent Privilege Level CPL
CPL
CPL
4.3
4.3.180X86 4GB
0 0xFFFFFFFFI/O
80386
1. Base address0
2. limit3. Attributes
0 limit base base + limit
803864-6 Linux 0.1x
Segment Descriptor
Descriptor table
1632 4-7
32 4GB 0 0xFFFFFFFF
1. GDT LDT
2.3.
4.3.24-8 8192 8GDT Global descriptor table LDT Local
descriptor table
GDT LDT214 213 GDT
LDT GDT LDT
LDT LDT GDT GDTLDT
GDT LDTLDT
4-9 GDT LDT 6A B LDT
A A LDTA CodeA DataA B BLDTB CodeB DataB CodeOS DataOS GDT
LDT LDTA LDTB GDT
A LDTA CodeA DataA GDTCodeOS DataOS B LDTB CodeB DataB GDT
LDTA B A B
B A LDT
GDT LDTLDT LDT
GDT GDTGDTR GDT 8 GDT
0 18 GDT 8 1 8N-1
GDT 1DS ES FS GS
LDT LDT GDT LDT LDTLDT GDT LDT GDT
LDT LDT LDTLDTR
GDTR SGDT 483 MOD 4 = 2
4SIDT
IDTR LDTR SLTRSTR MOD 4 = 0
4.3.316 4-10
3RPL Requested Privilege LevelTI Table Index
Index
RPL TIGDT LDT TI=0 GDT TI=1 LDT
GDT LDT
4-11(a) 0x08 GDT RPL=0 1 1 TI 0GDT 4-11(b) 0x10 GDT RPL=0 2 2 TI
0 GDT 4-11(c) 0x0f LDT RPL=3 1 1TI 1 LDT 4-11(d) 0x17 LDT RPL=3 22 TI 1 LDT 4-11 4 (a) (b) (c) (d) Linux 0.1x
4-11(e) 0xffffLDT RPL=3 8191 0b1111111111111 8191 TI 1 LDT
GDT 1 GDT 0 TI 04-11(f) CS SS
CS SS
6 4-12
CS DS SSES FS GS
6
6
1. MOV POP LDS LES LSS LGS LFS2. CALL JMP RET IRET INTn INTO INT3
CS MOV
4.3.4GDT LDT
84-13
LIMIT Segment limit fieldLimit 20
G Limit G=0 Limit1 1MB G=1 Limit 4KB 4GB
4KBE Limit
0 Limit LimitLimit
B Limit 0xFFFFFFFF 0xFFFFLimit
80X86
BASE Base address field4GB 0 332 16
16TYPE Type field
GateS TYPE
4-14S Descriptor type flag
S S=0 S=1DPL Descriptor privilege level
DPL 0 3 0 3 DPL
P Segment presentP P=1 P=0 P
0
4-15 P=0 P 0Avaliable
D/B / /Default operation size/default stack pointer size and/or upper bound
32 1 160
D32 32 8
0 16 16 8 0x660x67
SS B BigPUSH POP CALL 32
ESP 0 16 SPB
B0xFFFFFFFF 4GB 0xFFFF
64KBG Granularity
Limit 04KB
G12 G=1 0 0 4095
Available and reserved bits2 20 21 0
4.3.5S
2 113 8 9 10 A Accessed
W Write-enable E Expansion-direction 4-3W
TYPE
11 10 9 8
E W A
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0 /
3 0 0 1 1 /
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0 /
7 0 1 1 1 /
C R A
8 1 0 0 0
9 1 0 0 1
10 1 0 1 0 /
11 1 0 1 1 /
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0 /
15 1 1 1 1 /
/ SS
3 A Accessed R Read-enable CConforming R /
ROM / CSDS ES FS GS
GDT LDT ROM ROMROM
ROM
4.3.6S 0
LDTTSS
LDT TSS
TSS 4-4
TYPE
11 10 9 8
0 0 0 0 0 Reserved
1 0 0 0 1 16-Bit TSS (Available) 16 TSS
2 0 0 1 0 LDT LDT
3 0 0 1 1 16-Bit TSS (Busy) 16 TSS
4 0 1 0 0 16-Bit Call Gate 16
5 0 1 0 1 Task Gate
6 0 1 1 0 16-Bit Interrupt Gate 16
7 0 1 1 1 16-Bit Trap Gate 16
8 1 0 0 0 Reserved
9 1 0 0 1 32-Bit TSS (Available) 32 TSS
10 1 0 1 0 Reserved
11 1 0 1 1 32-Bit TSS (Busy) 32 TSS
12 1 1 0 0 32-Bit Call gate 32
13 1 1 0 1 Reserved
14 1 1 1 0 32-Bit Interrupt Gate 32
15 1 1 1 1 32-Bit Trap Gate 32
TSS
4.480X86
/ -
CR0 PG PG=1PG=0
4-16
80X86 4K 212 4KB 4K232 4GB 220 1M = 1048576
4K4K 12 12
20 20
present80X86 4GB RAM
Demand-paged4KB
/
TLB Translation Lookaside Buffer TLBTLB
4.4.1page table
220
20 124K
12 0 20 12
32 20 12
4.4.1.1220 1M 4 4MB
80X86 2010
page directory 1 4K 210 1K 410 31--22
210
page table 1 1K 4 420 10 21--12
20 20 12
4-17 CR3 1010
20 12 12 32
4.4.1.24MB
4MB
present
2
4.4.24-18 31--12 20
12
P -- 0 Present P=1 P=0P=0
4-18(b)
R/W -- 1 / Read/Write 1 00 1 2 R/W
R/WU/S -- 2 / User/Supervisor 1
0 0 1 2U/S
A -- 5 Accessed1 1
D -- 6 DirtyD D
AVL --
4.4.3P
P=1P = 0
P=1A D A
D=0 D 0D=1
4.5
2CPL Current Privilege Level CPL
CR0 PE 0
0
CR0 PG 31
/ R/W / U/S/
RPL CPLR/W U/S
4.5.180X86 4 2
4.5.1.1 Limit
G E B/ E
G 20 LimitLimit 0 0xFFFFF 1MB G 4KB Limit
4K Limit 0xFFF 0xFFFFFFFF 4GBG 12 Limit Limit 0
0 0xFFFLimit
1
B +1 0xFFFF FFFF B+1 0xFFFF 0
GDTR IDTR LDTR16
8 N 8N-10 GDT
4.5.1.2 TYPE
S TYPE
S TYPE 4TYPE
TYPE
1.
CS
SS2.
4.5.1.34 0 3 4-19
20 3
CPL Current Privilege Level CPL
CS SS 0 1 CPLCPL conforming
CPLDPL CPL
CPL DPLDPL Descriptor Privilege Level DPL
DPL DPL CPLRPL DPL
Data Segment DPLDPL 1 CPL 0 1
Nonconforming code segment DPLDPL 0 CPL
0Call Gate DPL
DPLDPL 2 CPL 0
TSS DPL TSS
RPL Request Privilege Level RPL0 1 RPL CPL
CPL RPLRPL CPL RPL CPL RPL
RPL CPLRPL
4.5.2DS ES FS GS
SS MOV POP LDS LES LFS LGS LSS4-20
CPL RPL DPL DPL CPLRPL
CPL CPL 0CPL 1 1 3 CPL 3
3ROM
1.2.3. CS CS
1 2 CPLDPL 3 CS DPL CPL
SSCPL CPL RPL DPL RPL DPLCPL
4.5.3
CSCS
EIPJMP RET INT IRET
JMP CALL RET JMP CALL
TSS TSSTSS TSS
4.5.3.1 JMP CALL RET
JMP CALL RET
4 4-21
CPL CPLCPL
DPLRPL
CCPL RPL DPL C C=0
CPL DPLRPL RPL CPL
CSCPL RPL CPL
C=1 CPL DPL CPL < DPL RPL
DPLCPL DPL CPL
CPL DPL CPL
4.5.3.2
4Call Gate TYPE=12Trap Gate TYPE=15Interrupt Gate TYPE=14Task Gate TYPE=5
4-22 GDT LDTIDT
DPLP Param Count
Linux
4.5.3.3CALL JMP
CPU 4-23
CPU
CPU 44-24
CPLRPL
DPLDPL
C
CALL JMP 4-5 DPL
CPL DPL RPL CPLRPL DPL
CALLCPL<= DPL RPL<= DPL
DPL<=CPL
JMPCPL<= DPL RPL<= DPL
DPL<=CPL DPL=CPL
CPU CPLDPL CALL JMP CALL
DPL CPLJMP DPL CPL CALL
JMP DPL CPL
CPLDPLCPL
I/O
4.5.3.4CPU
4 32 1 0 3 0
3 3 SS ESP
0 1 2 TSS TSSCPU CPU
TSS
TSS
SS ESP CS EIP
EFLAGS
CPU4-25
1. DPL CPL TSS TSS
TSS2. TSS3. SS ESP SS ESP
SS ESP4.
31 05. CS EIP CS
EIP
4.5.3.5RET near return far return
CALL CPUCPU
CALL CPU
DPLCPL CPU CS RPL RPL
CPL CPU1. CS RPL2. CS EIP
RPL3. RET CS EIP
ESP ESPSS ESP
4. SS ESP SS ESPSS ESP
5. RET ESP
6. DS ES FS GS DPL CPLCPU NULL
4.5.4R/W / U/S
0 1 2 3/ / /
/ / 4-60 1 2
// /
U/S R/W
0 0 / /
0 1 / /
1 0 / / /
1 1 / / / /
80X86
33
/ //
4-7U/S R/W U/S R/W
AND
U/S U/S U/S R/W R/W R/W
0 0 0 0 0 0
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 1 1 1
4.5.4.1
TLB Translation Lookaside Buffer 80X86
CR3
P 0 1
4.5.5CPU CPU
R/W
4.6Interrupt Exception
interrupt handler exception handler/
INT n0
80X86
4.6.1
vector IDT InterruptDescriptor Table
0 255 0 31 80X86
32 255 I/O4-8 80X86 NMI
NMI
0 #DE DIV IDIV
1 #DB / INT 1
2 -- NMI
3 #BP INT 3
4 #OF INTO
5 #BR BOUND
6 #UD UD2 Pro
7 #NM WAIT/FWAIT
8 #DF 0 NMI INTR
9 -- 386 CPU
10 #TS TSS TSS
11 #NP
12 #SS SS
13 #GP
14 #PF
15 -- Intel
16 #MF x87 FPU x87 FPU WAIT/FWAIT
17 #AC 0
18 #MC CPU
19 #XF SIMDSSE SSE2 PIII
20-31 -- Intel
32-255 -- INT n
4.6.24.6.2.1
INTR NMI INTR8259A NMI
2 INTR0 255 EFLAGS IF
INT n INT 0x80Linux 0x80 0 255 INT
NMI NMINMI 2 INT NMI
NMI
EFLAGS IF INT4.6.2.2
80X86 faults traps aborts
INTO INT 3 BOUNDINT 3
INT n INT n 80X86
INT EIP
4.6.3Fault
Trap AbortFault Fault
FaultFault Fault
Trap TrapTrapAbort
Abort
4.6.4Abort
Fault Page-fault
TrapTrap
JMP Trap JMP JMP
Abort
4.6.5EFLAGS IF Interrupt enable Flag INTR
IF=0 INTR IF=1 INTR
IF NMI EFLAGSIF IF=0
IF STI CLI CPL<=IOPLIF
PUSHF EFLAGS POPFEFLAGS
POPF IRET EFLAGS IFIF
IF
4.6.64-9
/
1 RESET
2 TSS T
3
4
5 NMI
6
7
8 >15
9TSS
4.6.7IDT Interrupt Descriptor Table
GDT LDT IDT 8 GDT 1IDT *8 256
IDT 256 IDT 256IDT 0
IDT IDTR IDT
IDT 32 16 4-26 IDT 8IDT
LIDT SIDT IDTR LIDTIDTR CPL 0 IDT
SIDT IDTR
IDT
4.6.8 IDT IDT
Interrupt gateTrap gateTask gate
4-27
EFLAGS IF IDT GDT LDTTSS /
4.6.9CALL
IDTCALL
CALL4-28
GDT LDT
0TSS
tss.ss0 tss.esp04-29EFLAGS CS EIP
EFLAGS CS EIP
IRET IRET RET IRETEFLAGS CPL 0 EFLAGS IOPL
CPL<=IOPL IFIRET
1.
CPL
RPL RPLINT n INT 3 INTO
DPL CPL DPL 3
DPL
3
0CPL
2.
EFLAGSEFLAGS TF TF IRET
EFLAGS TFEFLAGS IF
IF IRETEFLAGS IF IF
3.IDT
IDT GDT TSSLinux
4.6.10IDT
TSS 0 00
LDT
IDT GDT TSS 4-30TSS
4.6.11
4-31 3 TI RPL 30 EXT External event
1 IDT Descriptor locationIDT GDT LDT
2 GDT/LDT TI 1 IDT=0 TI=1LDT TI=0 GDT
IDT GDT LDT16 0
Page-fault 4-32 3U/S W/R P
0 P P=0 P=1
1 W/R W/R=0 W/R=1
2 U/S CPU U/S=0 CPU U/S=1CPU
CR2
IRET
INT n
4.7Task
80X86
80X86
EFLAGSTask state segment
4.7.1TSS Task-state segment
4-33TSS
TSS
TSSTSS TR Task Register
CR3
EFLAGS EIP CR3 LDTR
I/O I/O TSS0 1 2 TSS
TSS
4.7.2
CALLJMP Linux
TSSCALL JMP TSS
TSS IDTTSS
TSSEIP
TSSTSS 80X86
LDT LDTCR3
80X86
4.7.3
TSSTSS
TR
EFLAGS NT
4.7.3.1TSS Task state segment
4-34 32 CPU TSS TSS
1.EAX ECX EDX EBX ESP EBP ESI EDI
ES CS SS DS FS GSEFLAGS EFLAGS
EIP EIPTSS
Back link field IRET2.
LDT LDTCR3 CR3
PDBR Page directory base register0 1 2 SS0 SS1 SS2
ESP0 ESP1 ESP2SS ESP
Debug Trap T 0x64 0
I/O TSS I/O 16TSS 104
TSSTSS TSS
4.7.3.2 TSSTSS 4-35 TSS TSS
GDT
TYPE B0b1001 0b1011
B
DPL GG=0 103 0x67 TSS 104TSS I/O TSS TSS
TSSTSS TSS
CPL TSS DPL TSS DPL3 TSS
DPL 3TSS TSS
TSSTI LDT TSS
4.7.3.3TR Task Register 16 TSS
GDT TSS TRTSS
LTR STR TSS LTR0 LTR TR 0 TSS
TR4.7.3.4
Task gate descriptorGDT LDT IDTTSS GDT TSS TSS RPL
DPL TSSCPL RPL DPL
TSS DPLTSS 4-36 LDT GDT IDT
4.7.44
1. GDT TSS JMP CALL2. GDT LDT JMP CALL3. IDT4. EFLAGS NT IRET
JMP CALL IRETTSS NT IRET
JMP CALL TSS4-37
IDTIDT
NT
NTTSS TSS
1. JMP CALL TSSIRET TSS
2. JMP CALLCPL RPL TSS DPL
TSS DPL INT nIRET INT n DPL
3. TSS P=1 TSS 0x67
4. JMP IRET TSSB CALL B
5. IRET EFLAGS NTCALL JMP NT
6. TSS TSSTSS
EFLAGS EIP7. CALL EFLAGS
NT JMP IRET EFLAGS8. CALL JMP TSS
B IRET B9. TSS TR CR0
TS10. TSS LDTR PDBR CR3 EFLAGS
EIP
11.
EIPCS CPL
TSSTSS
CR0 TSTS TS
4.7.5 TSS Backlink EFLAGS NT NT
TSS 4-38
CALL TSS TSSEFLAGS NT NT TSS
TSS IRET NTNT
JMP NT 0JMP
4-10 B TSS NT TS
CR0 NTNT IRET TSS
TSS 0
JMP CALL IRET
B
B
NT TSS TSS
NT
TSS
CR0 TS
4.7.6TSS
TSS LDT LDTLDT
LDT
GDTTSS CR3
4.7.6.1
PDBR CR3
TSSTSS TSS
GDTGDT
4.7.6.2
GDT GDT GDT
LDT LDT TSS LDT LDTLDT LDT
GDTLDT
LDT
LDT
4.880X86 8086
0xFFFFFFF0 EPROMIDT
4.8.1
bootsect.s setup.s head.s
IDTGDT
TSSLDT
GDTRIDTR
CR1--CR3CR0 PE
04.8.1.1
GDTGDT 1
GDTLGDT GDT GDTR
LDT LDTGDT LDT
LinuxLDT
4.8.1.2IDT
TSSIDT
IDT LIDT IDT IDTR4.8.1.3
CR0 PG 0PG PG
CR3 PDBRPG PE
PG PEPG JMP MOV CR0 JMP
80X86 PentiumBTB Branch Target Buffer
PG JMP
4.8.1.4/ TSS
TSS 0 1 2 TSS TSSLDT
TSS GDTLTR TSS TR
TSS B=1 TSS0 1 2 TSS
TSSLTR LDT TSS
TSS
4.8.2
-8086
4.8.2.1
CR0 PE MOV CR0CR0 PG
01. CLI NMI
2. LGDT GDT GDTR3. CR0 PE PG MOV CR0 4. MOV CR0 JMP CALL
5. LLDT LDT LDTR6. LTR
TR TSS7. 4 JMP CALL
CS
8. LIDT IDT IDTR9. STI NMI
MOV CR0 JMP CALLMOV CR0 JMP CALL
JMP CALL4.8.2.2
MOV CR0 CR0 PE 0
1. CLI NMI
2.
GDT IDTCR0 PG
CR3 0x00 TLB3. 64KB 0xFFFF
CS4. SS DS ES FS GS
Limit = 64KB G=0
E=0W=1P=1
5. LIDT 1MB6. CR0 PE7. CS
8. SS DS ES FS GS9. STI NMI
4.9
3RAM
boot.s head.s
4.9.12 as86 boot.s
GNU ashead.s 3
A B 0 1
4-39
4-40
4-41
4-42
4-43
4-43
4.9.2 boot.s16 head
ROM BIOS 8 LinuxLinux 8259A
0x20
4.9.3 head.shead.s IDT GDT
Linux 0.11boot.s IDT GDT
5 Linux
Linux Linux
Linux/ Makefile
80X86
45-1 Internet
LinuxX shell
Linux
Linux 0.11 LinuxLinux 0.11
5.1 Linux
Linux 0.11
(int x80) CPU User Mode Kernel Model
CPU
5-2
5.2 Linux
Linux 5
CPUCPU
Linux
5-3Linux 0.11 Linux 0.95
0.96
3
NFS ramdisk
Linux 0.115-4
5.3 Linux
Linux 0.11 Linux 0.11CPU
Linux 0.11
5.3.1Linux 0.11
5-5
LinuxROM BIOS 640K--1MB
RAM
CPUIntel 80386 CPU
Segmentation System Paging SystemLinux
5.3.2 Linux 0.11 3a. b. CPU c.
Virtual Address
GDTLDT 13 GDT LDT 1
Intel 80X86 CPU 16384 4G16384 * 4G = 64T
Logical Address Intel
Linear Address
Intel 80386 4G
Physical Address CPU
Virtual Memory
3
Linux 0.11 64MB0x0000000 0x4000000
5.3.34GB 232
CPU 4-4
CPU
CPU80386
CPU CR2
SwapperLinux 0.11 mm/memory.c
Intel CPU SegmentCPU
32ds
64KB si5-7 (a)
Segment Descriptor Table
Segment Selector
16 5-7 (b)CPU
84GB
3 GDT Global Descriptor Table IDT InterruptDescriptor Table IDT 8086
80X86 CPU GDT IDTLDT Local Descriptor Table
LDT GDT LDTCPU
GDT IDT LDT CPU GDTR IDTR LDTR32 -1
CPU 16 80X86 CPU3 13 8192
0--8191 2 TI 0 GDTLDT
Linux 0.11 CPUGDT LDT GDT LDT
5-8
LDT GDTLDT
24 TSS GDTTSS
idt Linux 0.11
5-10 5-11 TSS Task State Segment CPU CPU
CPU TSS CPUTSS 4-37 Linux 0.11
TSS Linux 0.11 GDT4 syscall include/linux/sched.h 150
Linus
5.3.4
,
CPU 4096 1
80X86CR0 31
803864
1024 1D Dirty
5-9 CR3CR3 PDBR 32
1 1024 1024 * 4KB = 4MB1024 1024 1024 * 4MB = 4GB
Linux 0.1x
Intel 80386 CPU 4GCPU PDT
PTLinux 0.11
64MB ( )*64MB
Linux 0.11 GDT 256 2
2 (256-4)/2 =126 ((256-4)/2)* 64MB 8G 0.11 NR_TASKS = 64
64M ( )*64MB64MB*64 =4G 5-10 4
16MB1 0
00 640KB
Linux 0.11 I Instruction D DataI&D
1 64MB 640KB2 3 128MB 192MB
64MB 4G CPU0 1 64MB
4GB 0.11
5-114GB
2 3
Code Section Data Section CPU
CPU4GB
5.3.5 CPU Intel 80X86 CPU 4 0 3 Linux 0.11
CPU 0 3
5-13CPU CPU 0 3
1 2
0
3
5.3.6CPU Linux 0.11
0 1
Linux 0.11 head.s16MB 0
0xFFFFFF 16MB GDT IDT TSS1 0
0--16MB 44
5-14
Linux 0.11 16MB 40964KB
GDT IDTsetup.s GDT
IDT 0x902000 0x90200
1 head.s GDTRIDTR GDT IDT
0
1
Linux 0.11 16MB4MB 2MB Linux 0.11 4MB
4MB--16MBCPU
4MB--16MB16MB init/main.c
16MB 0--16MB16MB
init/main.c32MB 8
32MB
00 640KB
0 640KB
TSS0 0 sched.h113 TSS0 sched.c 104 5-23
0 5-15
0head.s
0b111 user_stack[]0
10 1 0
fork() 1 init 10 1
1 64MB--128MB 64MB--64MB+640KB0--640KB 1 640KB
11 PCB 1
TSS 5-16
1 0--640KB 0user_stack[] kernel/sched.c 67--72 1
1 1 0user_stack[] 1 1 1 user_stack[]
1
2 init 1Linux 0.11 64 2
2 nr nrnr*64MB 2 = nr*64MB = 2 * 64MB = 128MB
64MB 2 128MB--192MB 64MB/4MB = 16
5-17 22 execve() shell 1
2 128MB--128MB+640KB 21 2 init() execve()
shell 1shell 5-17 2 shell2 1 shell
execve()2 64MB 2
Load on demand
Linux 0.99 4GLinux 2.x
5.3.7C malloc()
C malloc()0 1 CPU 4G 64MB
64MB
brkmalloc() brk()
malloc() brk
CPU
C malloc()
free() C
malloc() free() lib/malloc.c
5.4 Linux
Linuxsetup.s
5.4.1
Interrupt IRQ - Interrupt Request ISR - Interrupt Service Routine
PIC - Programmable Interrupt ControllerIRQ
PIC PIC
PICPIC INT
PIC PIC32
intPC/AT 256
5.4.2 80X8680X86 8259A 8259A
8 8259A 64 PC/AT8259A 15 5-18
INT IR2 8259A 8259A IRQ28259A 0x20 0xA0 IRQ9 PC/XT IRQ2
PC/AT IRQ2 IRQ2 PIC IRQ9BIOS IRQ9 int 71 IRQ2 int 0x0A
IRQ2 PC/XT 8 PC/AT PC
8259A CPU IN OUT8259A
IRQ0 – IRQ15CPU
INT CPU CPU D7-D0CPU
5.4.3CPU
CPU 3280X86 256
80X86 4 41024 80X86 ROM BIOS
0x0000:0x0000BIOS N
0x0000:N*40x0000:N*4
BIOS 8259A 16 BIOS0x10—0x1f
DOS0x20—0x2f Linux
BIOS setup.s 8259A
head.s BIOS
Intel CPU 32 IDT Interrupt Descriptor TableIDT Intel 8086 -- 80186 CPU
Linux 80X86
5.4.4 LinuxLinux ( ) 0-255
int0--int31(0x00--0x1f) Intel, Intel CPU
(Fault) (traps) int32--int255 (0x20--0xff)CPU 5–1
CPU
Maskable CPU INTR eflags IF
Nonmaskable CPU NMI
Fault CPU
Trap CPU
Abort
Linux int32--int47 0x20--0x2f 8259AIRQ0--IRQ15 5–2 system call int128 0x80
IRQ0 0x20 32 8253 100HZ
IRQ1 0x21 33
IRQ2 0x22 34
IRQ3 0x23 35 2
IRQ4 0x24 36 1
IRQ5 0x25 37 2
IRQ6 0x26 38
IRQ7 0x27 39 1
IRQ8 0x28 40
IRQ9 0x29 41
IRQ10 0x2a 42
IRQ11 0x2b 43
IRQ12 0x2c 44 PS/2
IRQ13 0x2d 45
IRQ14 0x2e 46
IRQ15 0x2f 47
head.sInterrupt Descriptor Table - IDT 256 boot/head.s 78
boot/head.s 150Unknown interrupt 256
A gerneal protection fault ( 13) IDT 256CPU
13 CPU1(0xff) IDT 256
init/main.cint0 --int 31 traps.c
kernl/traps.c 181 int128kernel/sched.c 385
IDT LinuxEFLAGS IF IF
iret IFIF 11 include/asm/system.h
5.4.5Linux 0.11 cli sti
cli CPU clisti CPU
clisti CPU
/ cli CPU sticli sti cli
5.5 Linux
5.5.1syscalls Linux 5-4
int 0x80 eax
C 5-19
0errno perror()
Linuxinclude/unistd.h 60 write 4 __NR_write
include/linux/sys.h sys_call_table[]write() 4sys_call_table[]
'sys_' read() sys_read()
5.5.2int 0x80
eax ebx ecx edx Linux 0.11int 0x80
kernel/system_call.s system_callinclude/unistd.h 133—183
_syscalln() n 0 3 3read()
int read(int fd, char *buf, int n);
_syscall3() read() CC
include/unistd.h 2+2*n 12
C
__NR_read 3 Linux 0x80 eax __res0 errno
-1kernel/system_call.s system_call eax
sys_call_table[]
call _sys_call_table(,%eax, 4) // kernel/system_call.s 94
_sys_call_table + %eax * 4 sys_call_table[]4 4
5.5.3 LinuxLinux Linux
ebx ecx edx
LinusIntel CPU System Call gate
5.6
5.6.1PC/AT
RT Real Time CMOS RAM
RT/CMOS RAM PC/AT MotorolaMC146818
Linux 0.11 init/main.c time_init()kernel/mktime.c kernel_mktime() 1970 1 1 0
UNIXstartup_time time()
startup_time stime()jiffies
10include/linux/sched.h 142
HZ = 100 CURRENT_TIME startup_timejiffies/100 i
5.6.2Linux 0.11 PC Intel 8253 8254 0
3 LATCH 10 0OUT 8254 1.193180MHz
LATCH=1193180/100 11931 OUT 010 IRQ0
1 1timer_interrupt
timer_interrupt jiffiesjiffies 1 C do_timer()
CPL CSCPL do_timer() CPL=0
stime 11 floppy.c
01 CPU
0 do_timer()0 CPU
0 do_timer() schedule()do_timer() Linux
nonpreemptive 1 preemptiveLinux
Dynamic TimerLinux 0.11 64 sched.c 264--336
5.7 Linux
process LinuxCPU
(time slice)CPU
15 =150Linux 0.11 64
fork child processparent process process ID pid
CPU
Linux kernel mode user mode
Linux task
5.7.1Linux
task_struct include/linux/sched.hPCB Process Control Block PD Processor Descriptor
long state CPUstate TASK_RUNNING state
TASK_INTERRUPTIBLE TASK_UNINTERRUPTIBLETASK_INTERRUPTIBLE TASK_UNINTERRUPTIBLE
TASK_STOPPEDSIGSTOP SIGTTIN
SIGTTOU ptraceTASK_ZOMBIE
long counter counter
counter counterpriority
long priority counter Linux 0.11 15 15priority counter sched.c fork.c
prioritylong signal 32
= +1 Linux 32
struct sigaction sigaction[32]
long blocked signal
int exit unsigned long start_code CPU Linux 0.1x
64MBunsigned long end_codeunsigned long end_data + unsigned long brk bss 10-6 brk
malloc() brk
unsigned long start_stack 10-6
long pid long father long pgrp long session long leader 4unsigned short uid idunsigned short euid unsigned short suid ID set-user-ID
suid uid suid euidunsigned short gid idunsigned short egid unsigned short sgid ID set-group-ID
sgid gid sgid egid 5sys.c
long alarm alarm() alarm()kernel/sched.c 338
alarmSIGALRM signal()
sigaction()long utime long stime long cutime long cstime long start_time unsigned short used_math int tty tty -1unsigned short umask struct m_inode * pwd i
chdirstruct m_inode * root i
chroot
struct m_inode * executable ii
executable->i_count 1exec()
exec() i exit()i 1 memory.c
share_page() executable2
1 execve() executable 00 1 1 execve()
executable 0 0executable 0
fork() 1 executable 0 execve() executablei 0
unsigned long close_on_exec execve() include/fcntl.h
fork() execve()
close_on_exec execve()
struct file * filp[NR_OPEN] 32
struct desc_struct ldt[3] 0 1 2
struct tss_struct tss TSS Task State Segmenttss_struct CPU CPU
CPUswitch
Linux
5.7.25-20
stateLinux
TASK_RUNNINGCPU
running CPU 5-20 0
TASK_RUNNING0
TASK_INTERRUPTIBLE
TASK_UNINTERRUPTIBLE
wake_up()
TASK_STOPPEDSIGSTOP SIGTSTP SIGTTIN SIGTTOU
SIGCONT Linux 0.11
TASK_ZOMBIEwait()
wait()
sleep_on() interruptible_sleep_on()
CPUTASK_UNINTERRUPTIBLE TASK_INTERRUPTIBLE
5.7.3boot/
init/main.c
0 0 fork() 1 1shell 0 0 pause()
0 move_to_user_mode include/asm/system.h main.c0 3 0sched_init() 0
0 include/linux/sched.h 0TSS LDT tr
ldtr0 0
0 0 640KB0 16MB 0
main.c 0 00 main.c move_to_user_mode 03
0 move_to_user_modeCPU CPU 3
IRET
0 3 iret CPU0 3 5-21
031
move_to_user_mode 00
iretiret CPU CS:EIP CPU
3 0 CPUSS:ESP DS ES FS GS
CPU iret3 0
PAGE_SIZE + (long)&init_task0 0
1 1
5.7.4 Linux fork() 0 0
64 fork()
TASK_UNINTERRUPTIBLE
15 150TSS 0 tss.eax = 0
tss.esp0 tss.ss0tss.ldt GDT
tss.i387
Copy On Write1 GDT
TSS LDT tss ldt
exec() exec()
CPU FaultCPU
5.7.5
CPULinux TASK_RUNNING CPU
Linux 0.11
schedule() TASK_RUNNINGcounter
TASK_RUNNINGpriority counter
prioritycountercounter2
counter schedule()TASK_RUNNING
switch_to()0 Linux 0.11 0 pause()
schedule() schedule() 00
schedule() include/asm/system.hswitch_to() CPU
switch_to()current TSS
CPU CPUTR TSS tss
tss CPU5-22
5.7.6
exit() do_exit()
i initSIGHUP
TASK_ZOMBIESIGCHLD do_exit()
wait() waitpid()
5.8 Linux
Linux
Linux 0.11
0
CPU CPU0 3TSS 0 tss.ss0 tss.esp0
5.8.1(bootsect.s setup.s)
bootsect ROM BIOS 0x7c00bootsect 0x9000:0 SS 0x9000
esp 0xff00 0x9000:0xff00 boot/bootsect.s 61 62 setup.sbootsect
(head.s)head.s 0x10esp user_stack head.s 31 1 4K
user_stack sched.c 67--72 10245-23
system.map
(main.c)init/main.c move_to_user_mode() 0
move_to_user_mode() main.c 0fork() main.c init() 1 1 main() “ ”
0 0 0
5.8.2
CPU4096 – 3K
64MB
0 1 64MB64MB
5-24CPU Linux Copy
on Writepush
0 1
TSS ss0 esp0 ss0 esp0
task_structfork() tss (tss.esp0 tss.ss0)
kernel/fork.c 93
p tsstask_struct tss task_struct tss.ss0
0x10 tss.esp0 task_struct 5-25tss.esp0 Intel CPU
esp esp
tss.ss0 0x10head.s
16MB Linux 0.11 head.s 110
CPU TSStss.ss0 tss.esp0 esp0 CPU
0 10 idle 1 init 0
1 640KB 00 1 64MB
0--640KBmove_to_user_mode() 0 1
0 sched.c user_stack[]1 0 0 1
1 1 user_stack[] 12 1
1 01 0
00
move_to_user_mode() iret 5-21
0 0IRET 0 3 0
esp user_stack ss0x17 LDT 0 0x0f
CS EIP IRET0
5.8.3Linux 0.11
CPU 3 0 CPUCPU TSS
0 48 TSS ss0 esp0CPU ss esp
eflags cs eip
eflagsiret eflags
5-26
CPUCPU eflags
cs eip
5.9 Linux 0.11
LinuxLinux UNIX
etc/ dev/ bin/ sh mkfs fdiskusr/ usr/bin var/
Windows2000 CWindows2000 NTFS FAT32
Linux 0.11 MINIX 1.0 Linuxext2 ext3
1 Linux 0.11 2 bootimagerootimage bootimage Image
rootimageDOS
Linux 509 510ROOT_DEV 0
5.10 Linux
Linux
Linux
tar linux-0.11.tar.gz linux/5-27
14 102
5.10.1 linux linux 14
Makefile make make
make linux Makefile Makefile linux
makelinux make
5.10.2 boot boot 3 3
32bootsect.s setup.s as86 as86
head.s GNU as AT&T
bootsect.s 00 1 PC ROM BIOS BIOS 0x7C00 setup.s system head.s system
5.10.3 fs Linux 0.11 1.0 MINIX Linux MINIX
MINIX MINIX LinuxMINIX Linux MINIX MINIX
Linux LinuxLinux MINIX
Linuxsleep()
fs/ 17 C5-28 .c
buffer.cfile_table.c ioctl.c
kernel/chr_drv/tty.c io exec.cdo_execve() exec() fcntl.c i/oread_write.c / stat.c
open.cchar_dev.c rw_char() pipe.c
file_dev.c i namei.cblock_dev.c inode.c
i truncate.cbitmap.c i super.c
buffer.c ll_rw_blockfs kernel/blk_drv/ll_rw_block.c
ll_rw_block()
5.10.4 include32 .h 13 asm 4 linux
10 sys 5
<a.out.h> a.out a.out<const.h> i i_mode<ctype.h> <errno.h> (Linus minix )<fcntl.h> <signal.h> <stdarg.h> - va_list
va_start, va_arg va_end vsprintf vprintf vfprintf<stddef.h> NULL, offsetof(TYPE, MEMBER)<string.h> <termios.h> <time.h> tm<unistd.h> Linux__LIBRARY__ _syscall0()<utime.h> utime()
include/asmCPU 4
<asm/io.h> io io<asm/memory.h> memcpy()<asm/segment.h> <asm/system.h> /Linux include/linux<linux/config.h> HD_TYPE<linux/fdreg.h> <linux/fs.h> file,buffer_head,m_inode<linux/hdreg.h> <linux/head.h> head<linux/kernel.h> <linux/mm.h> <linux/sched.h> task_struct 0 <linux/sys.h> 72 C , 'sys_'<linux/tty.h> tty tty_io
include/sys <sys/stat.h> stat{}<sys/times.h> tms times()<sys/types.h> <sys/utsname.h> <sys/wait.h> wait() waitpid()
5.10.5 initmain.c
shell
task 0fork()
init()shell
5.10.6 kernel linux/kernel 12 Makefile 3
kernel/ fork exitget_hd_block tty_write
5-29
asm.s traps.ctraps.c C
exit.c
fork.c sys_fork() C find_empty_process()copy_process() mktime.c mktime() 1970 1 1 0
init/main.c panic.c panic() printk.c printk() sched.c (sleep_on wakeup schedule )
signal.c 4
do_signal() sys.c system_call.s Linux int 0x80
C Linux vsprintf.c
kernel/blk_drv
blk_drv 4 c 1 blk.hC 5-30
blk.h 3 C hd.c/ do_hd__request() floppy.c
/ do_fd_request() ll_rw_blk.c /ll_rw_block()
fs/buffer.ckernel/chr_drv
4 C 2rs-232 5-31
tty_io.c tty tty_read() tty_write()C do_tty_interrupt()
console.c con_write() ttycon_init()
rs_io.s0x3fa 0x2fa 4
do_tty_interrupt() serial.c UART
tty rs_write() tty_ioctl.c tty io tty_ioctl() termio(s) io
sys_ioctl() fs/ioctl.c keyboard.S keyboard_interrupt
kernel/mathC math_emulate.c math_emulate() int7
C CPU
SIGFPE
5.10.7 libC
C lib/init/main.c 0 1
libc lib/ 12 Ctytso malloc.c
_exit() close(fd) dup()open() write() execve() malloc()
wait() setsid() include/string.h
5.10.8 mm2
Linux 386 4G 6464MB
fork
page.s int 14
memory.c mem_init() page.sdo_no_page() do_wp_page()
5.10.9 toolsbuild.c Linuximage
5.11
Linux 5int 0x80 12
0 1lib/
C libc5-4
libc API
ID
UNIX POSIX API Linux APIPOSIX API
APIPOSIX
API
include/unistd.h
Linux LSB Linux Standard BaseLinux 2
C /I/O fopen fclose open
close
3
5.12 linux/Makefile
linux Makefile
5.12.1Makefile make
Makefile make Makefile
makemake Makefile
Makefilemake make
Makefile (last-modification time)Makefile Makefile
'#' '='Makefile make tools/ build
image boot/bootsect.s setup.s 8086
GNU gcc/gas system buildimage build tools/build.c
/ 5-32
5.12.25-1 linux/Makefile
5.13
Linux Linux 0.11
Linux 0.11 Linux makefile
Linux 0.11
6 boot
boot/ 6-1bootsect.s setup.s 16
Intel Intel 8086 as86 ld86 head.sGNU GNU as gas
AT&T Linus Intel x86 Linus GNU
i386 CPU16 1994 GNU as 16 .code16
GNU Using as - The GNU Assembler 80386 162.4.X bootsect.s setup.s as
6-1 linux/boot/
8086 Intel 80X86PC 80386 32
6.1
Linux PC 80x86CPU 0xFFFF0 ROM-BIOS
PC BIOS 0512 0x7C00
Linux 8086 boot/bootsect.s BIOS0x7C00 31KB 0x90000 576KB
2KB boot/setup.s 0x90200 system0x10000 64KB 6-1
system 0x80000 512KB bootsect system0x10000 0x90000 576KB bootsect setup
setup system system6-2 Linux
"Loading..." boot/setup.s
VGA0x10000 0x0000 0x0000
32 : IDT GDT LDTinit/main.c main() boot/head.s
bootsect 0x0000 setup
setup ROM BIOSBIOS
0x400 (1KB) BIOSLinux Linux
Linux 0.11 MINIX 1.0
bootsect.s 43509 510 0x1fc--0x1fd
6.2 bootsect.s
6.2.1 bootsect.s 0 0
1 PC ROM BIOS ROM BIOS bootsect0x7C00 bootsect 0x90000
2 4 setup setup.sbootsect 0x90200 BIOS 0x13
Loading system...” setupsystem 0x10000
1.44M A root_dev(508 ) setup 0x90200 setup
setup system 6-3
Linux 0.11 1.44MB 1.44MB 28801 setup 4 0.11 system
240 2630
6.2.26-1 linux/boot/bootsect.s
6.2.3bootsect.s Alessandro Rubini
Linux (http://oldlinux.org/Linux.old/docs/)38680x86
Linux 0.11 bootsect
6.2.3.1 Linux 0.113 1-
2- 3- 4- 5- 6- 7- 1 1--4=
*256 + 6–1
6–1
0x300 /dev/hd0 10x301 /dev/hd1 1 10x304 /dev/hd4 1 40x305 /dev/hd5 20x306 /dev/hd6 2 10x309 /dev/hd9 2 4
Linux 0.95
6.2.3.2
Shoelace LILO Grub bootsect.sbootsect Image
Image
1 MBR - Master Boot Record BIOS 0x7c00 0x600
MBR 1 0x7c00
Image
Image 4bootsect.s Image
Image
bochs
6.3 setup.s
6.3.1 setup.s ROM BIOS
0x90000 bootsect6 2 console.c tty_io.c
( )
0x90000 2 0x00- 0x00-
0x90002 2 1MB KB
0x90004 2
0x90006 1
0x90007 1
0x90008 2 ??
0x9000A 1 (0x00-64k,0x01-128k,0x02-192k,0x03=256k)
0x9000B 1 0x00- ,I/O=0x3dX 0x01- ,I/O=0x3bX
0x9000C 2
...
0x90080 16 1
0x90090 16 2
0x901FC 2 bootsec.s
setup system 0x10000-0x8ffff system512KB 0x00000 (idtr)
(gdtr) A20 8259A0x20 - 0x2f CPU CR0 32
system head.shead.s 32 IDT
GDT GDT head.s
Linux 6-44
Global descriptor table – GDT Local descriptor table – LDTGDTR LDTR GDT LDT
lgdt sgdt GDTR lldt sldt LDTRlgdt 6 GDTR
4 LDTR lldt 2GDT GDT
setup.s GDT 207--2160x00C09A00000007FF 8MB =(0x7FF + 1) * 4KB 1 0
0 0x9A0 32 4KB
0x00C09200000007FF 8MB 0 0x920 32
4KB
6-5
Index 8192 213 8Table Indicator - TI
0 GDT 1 LDT Requestor's Privalege Level - RPL
GDT ( 0) 0 0GDT (null) CS
SS
GDTlgdt CPU GDT gdtr
32
6.3.2 6-2 linux/boot/setup.s
6.3.3BIOS
BIOS A20Intel 32
6.3.3.1setup.s system 0x0000 0x90000
6-6
NULL0x0000 setup.s
'jmp 0,8 ' 193 head.s '8'gdt '0'
6.3.3.2 BIOS 0x10ROM BIOS
/
ah =0x12
bl =0x10
bh0x00 – I/O 0x3DX
0x01 – I/O 0x3BX
X 0 – f
bl00 = 64K, 01 = 128K, 02 = 192K, 03 = 256K
ch
0 1 2
1 0 2
2 1 1
3 0 1
4-7 ( 0)
cl
0 1
1 2
2 3
3 4
4-7
EGA/VGA :
0x00 MDA/HGC
0x01-0x03 MDA/HGC
0x04 CGA 40x25
0x05 CGA 80x25
0x06 EGA+ 40x25
0x07-0x09 EGA+ 80x25
0x0A EGA+ 80x25
0x0B EGA+ 80x25
6.3.3.3 INT 0x41int 0x41 4 * 0x41 =0x0000:0x0104
100% BIOSF000h:E401h int 0x46
0x00 cyl
0x02 head
0x03 ( PC XT 0)
0x05 wpcom 4
0x07 ECC XT 0
0x08 ctl
0
1 (0) ( IRQ)
2
3 8 1
4 (0)
5 +1 1
6 ECC
7
0x09 XT 0
0x0A XT 0
0x0B XT 0
0x0C lzone ( )
0x0E sect
0x0F
6.3.3.4 A20 1981 8 IBM IBM PC CPU Intel 8088
20 (A0 – A19) RAM KB 1MB 200xffff:0xffff 0x10ffef 0x100000(1MB)
0x0ffef IBM 1985 AT Intel 80286 CPU 2416MB 8088 1MB
8088IBM 0x100000
8042 P2 P21A20 20
A20
A20 setup.s 138-144A20
A20A20
A20 (Fast Gate A20) I/O 0x92 A200x92
0xee A20 A20
6.3.3.5 8259A2 PC/AT
8259A 8259A Linux
1. 8259APC/AT 8259A PIC
15 2-20 INT IR2 8259A0x20 0xA0 8259A 6-7
IRR Interrupt Request Register8 D7—D0 IR7—IR0 IMR Interrup Mask
Register 8 81 IMR IRR IRR
PR Priority ResolverIRR ISR In-Service
Register ISR CPU8259A ICW Initialization Command
Words OCW Operation Command Words 8259A A0 PC/AT
A0 0 0x20 0xA0 A0=1 0x21 0xA1
8259A IR0—IR7IRR
IMR8259A CPU INT CPU
8259A INTA 8259AISR ISR
IRRCPU 8259A 2 INTA 8259A
8259A 8 CPUCPU 8259A AEOI Automatic End of Interrupt2 INTA ISR
8259A 8259AEOI ISR 2 8259A
EOI 8259A
2.8259A 4
8259A 8259A8259A 8259A 4 ICW1—ICW4
8259A 3 OCW1—OCW38259A 8259A
6-8 ICW1 ICW28259A ICW3 ICW1
ICW4 ICW1
(1) ICW1 5 D4 =1 A0=0 ICW1 PC/AT
8259A 0x20 0xA0 ICW16–5
D7 A7
D6 A6
D5 A5
A7—A5 MCS80/85
ICW2 A15—A8 8086/88
D4 1 1
D3 LTIM 1 - 0 –
D2 ADI MCS80/85 CALL 8086/88
D1 SNGL 1 – 8259A 0 –
D0 IC4 1 – ICW4 0 –
Linux 0.11 ICW1 0x11 8259AICW4
(2) ICW2 5 ICW1 A0=1 ICW2PC/AT 8259A 0x21
0xA1 ICW2 6–6
MCS80/85 D7—D0 A15—A8 ICW1 A7-A58086/88 T7—T3 5 8259A
3 8 8259A 2 INTA CPU
Linux 0.11 ICW2 0x20 0 —70x20—0x27 ICW2 0x28 8 —150x28—0x2f
(3) ICW3 8259A 8 Slave Register ICW36–7
S7—S0 1 IR
IRID2—ID0
CAS2—CAS0 ID2—ID0
Linux 0.11 8259A ICW3 0x04 S2=1 0 IR2ICW3 0x02 2 IR2
0 8—15 3—7
(4) ICW4 ICW1 0 IC4 ICW4 A0=1 ICW46–8
D7 0 0
D6 0 0
D5 0 0
D4 SFNM 1 – 0 –
D3 BUF 1 – 0 –
D2 M/S 1 – 0 –
D1 AEOI 1 – 0 –
D0 PM 1 – 8086/88 0 – MCS80/85
Linux 0.11 8259A ICW4 0x01 8259A8086
3.8259A 8259A
OCW1—OCW3 8259A8259A
(1) OCW1 8259A IMR / A0 1OCW1 6–9
D7—D0 8 7 —0 M7—M0 M=1M=0
Linux 0.11
0x21 8259A ~0x40 6kernel/blk_drv/floppy.c 461
(2) OCW2 EOI D4D3 = 00 A0=0
OCW2 OCW2 6–10
D7 R
D6 SL
D5 EOI
D4 0 0
D3 0 0
D2 L2
D1 L1
D0 L0
L2—L0 3 IRQ0--IRQ7
IRQ8—IRQ15
D7—D5 6–11 * L2--L0ISR
R(D7) SL(D6) EOI(D5)
0 0 1 EOI
0 1 1 * EOI
1 0 1 EOI
1 0 0 AEOI
0 0 0 AEOI
1 1 1 * EOI
1 1 0 *
0 1 0
Linux 0.11 8259A EOIOCW2 0x20 EOI
(3) OCW3 IRR ISR D4D3=01 A0=0OCW3 / Linux 0.11 OCW3 6–12
D7 0 0
D6 ESMM
D5 SMM D6—D5 11 – 10 –
D4 0 0
D3 1 1
D2 P 1 – POLL 0 –
D1 RR RD
D0 RIS D1—D0 11 – ISR 10 – IRR
4. 8259A8259A 8259A
8259A(1)
8259A0 7 0 CPU
ISREOI ICW4 AEOI ISR
CPU 2 INTA ISR
IMR 88259A IR0 IR7
Linux 0.11 8259A(2) EOI
ISRICW4 AEOI CPU 2 INTA
AEOIEOI EOI
EOIEOI EOI EOI
EOI EOIEOI ISR EOI OCW2 3
011 3 Linux EOIEOI ISR
ISR OCW2 3001 Linux 0.11 EOI
(3)ICW4 D4=1
a. CPU
b. EOI ISR
0 0 EOI 0EOI(4) 8259A 864 3 3
8259AICW3 2 EOI
(5)OCW2 8259A
7(6)
IMR 8259AOCW1 IMR IMR D7--D0 IR7 -- IR0
EOI 8259A8259A
OCW3 D6 D5 OCW1
(7) 8259A 3 IMR IRR ISR CPU IMR
OCW1 IRR ISR OCW3 IRR ISR
6.4 head.s
6.4.1 head.s system system
(head) system setup6 Linux 0.11 system
120KB 240heads.s
AT&T GNU gas gld7
0idt 256
ignore_int 8 6-9
P DPL head.s0x0008 ignore_int head.s
head.s 00 P=1 DPL=00
5 4 0x8E00gdt GDT
setup.s GDT 8MB 16MBsetup.s 16MB
GDT GDT gdtGDT 0x902XX
0 1MB A201MB CPU IP MOD 1Mb
0PC 80287 80387 CR0
016MB 4
6-10 P R/WU/S / A D 20
20
0x07 P=1 U/S=1 R/W=1CPU
U/S R/W PL
PL CPU CPL < 30 CPU Supervisor
CPL = 3 CPU User UserU/S=1 W/R = 1U/S=0 0 1
0x7
head.s /init/main.c main()
6.4.26-3 linux/boot/head.s
6.4.36.4.3.1 head.s
idt gdt 1KB system6-11
6.4.3.2 Intel 32Intel 386 32
8086 CPU 80x86 CPU
gdtr idtr lgdt lidt CPU 0x9000
64KB
8
eip32
GDT IDTLDT CPU GDT IDT GDTR
IDTR 0 8191 GDTLDT LDTR LDTR
GDT LDT GDTLDT GDT
LDT Linux 0.11 64GDT 64 LDT
IDT GDT Linux GDT 2568 GDT 0-1 6-7
2-3 4-56-12 Linux GDT
GDT LDT0 TSS0TSS LDT
DSDS:ESI
6.4.3.3 align 3 align .align
CPU
.align val1, val2, val3
1 val1 20 3 val3
val3 2 val23 val3
ELF Intel 80X86 CPU 1 val1 '.align 8' 8 8
a.out 1 val1 0 22^Val1 head.s '.align 3' 8
8 GNU as gasgas
6.5
bootsect.s setup.s system setup.s0x90000 0x90200 setup system
head.s setup ROM BIOS 0x90000
system 0x00000 systemhead.s 0x00000 32
CR0system head.s CPU 32
Head.s 256 A20
system init/main.cinit/main.c
7 (init)
init/ main.c boot/ head.smain.c
LinuxC C
Brian W. Kernighan Dennis M. Ritchie CC GNU gcc
gcc inlineC '//'
*.h
7.1 main.c
7.1.1 main.c setup.s
RAMDISK 7-1
ROM BIOS1K 1024 mm
4Kmm
ttytask 0
0
0 CPU 03 main.c 0 fork()
init() init 7-2
main.c
0 0fork() 1 init init()
shell 0 0idle 0 pause()
init() 4rc shell
setup()
init() tty0 stdin stdoutstderr
init() 2shell /bin/sh etc/rc rc
DOS AUTOEXEC.BAT 0/etc/rc stdin etc/rc
/bin/sh /etc/rc/bin/sh 2
init() shell/bin/sh 2 init 2
shell /bin/sh shell
shell shell /bin/sh argv[]shell 0 1 '-' /bin/sh
shell /bin/shLinux exit logout
shell shell
1 init() init
fork()init 0 0
1 0 main.c 00 fork() gcc
23
_syscall0() unistd.h Linux int 0x80include/unistd.h 133
int fork()
gcc fork() fork()syscall0 0 1 1 1_syscall1()
INT
init 1 0 init1MB 640KB
init0 0 640KB
1 640KB 11
0 11 / 0 1
0 1 init0 1 0
0 fork() pause() 0 1
init 2 execve() 28 Copy on Write
Linux shelllib/ string.c
7.1.27-1 linux/init/main.c
7.1.37.1.3.1 CMOS PC CMOS 64 128 RTC Real Time Chip 64 CMOS IBM PC-XT
BCD 14
CMOS 0x700x71 0x70 0x71 OUT
0x70 IN 0x710x70
0x71 main.c 70 0x80 CMOS
128 0x80Linus CMOS CMOS
0x801.0 ( 1.0
drivers/block/hd.c 42 ) 7–1 CMOS
0x00 ( ) 0x11
0x01 0x12
0x02 ( ) 0x13
0x03 0x14
0x04 ( ) 0x15 ( )
0x05 0x16 ( )
0x06 ( ) 0x17 ( )
0x07 ( ) 0x18 ( )
0x08 ( ) 0x19-0x2d
0x09 ( ) 0x2e ( )
0x0a RTC A 0x2f ( )
0x0b RTC B 0x30 1Mb ( )
0x0c RTC C 0x31 1Mb ( )
0x0d RTC D 0x32
0x0e POST 0x33
0x0f 0x34-0x3f
0x10
7.1.3.2 fork()fork (
exec()fork fork()
PID fork() 0fork() 0
7-3
init fork() 179 194execve() sh
186 202exit()
wait()
7.1.3.3 (session)2 process
pid(Porcess ID)fork() shell
[plinux root]# cat main.c | grep for | more
cat grep moregid Group
ID gid pidgid setpgid()
Ctrl-C
Sessionshell Session leader
Controlling Terminal Controlling process logout
setsid()7-4
Foreground process groupBackground process group
/dev/tty/dev/tty
7.2
183 200 init()shell /bin/sh
init.c/etc/
agetty getty getty login:getty login login
shell shell 7-5
init, getty, login, shell
init /etc/rc /etc/inittabfork()
agetty9 getty init wait()wait() pid
agetty
init agettyLinux
init
getty tty/etc/issue
getty plinux login: login
login passwdgetpass() ”password:”
pw_passwdlogin 1
init wait() pidagetty
login Current Work Directory/
ID HOME= shell SHELL=USER= LOGNAME= PATH= /etc/motd
message-of-the-day loginID shell bash csh
/etc/passwd shell /bin/sh/ login
fork()
exec()
exec()
1
Linux man 8 login shell
shellshell shell
login shell argv[0] ’-’ shellshell shell shell
/etc/profile .profile shell ENVshell .profile shell
.profile shellENV ENV
.profile
ENV=$HOME/.anyfilename; export ENV
shell shellshell $1 $2
shellshell Linux sh
7.3
0.11 MINIX/etc/rc /bin/sh /dev/* /etc/ /dev/ /bin/ /home/ /home/root/
Linuxmain.c
1032
Intel 80x86
Linux
sched.cschedule() system_call.s _timer_interrupt
10 do_timer()
sleep_on() schedule() CPUschedule()
do_timer()CPU
schedule()
8 (kernel)
linux/kernel/ 10 C 2 kernelMakefile 8-1
1312
8-1 linux/kernel/
8.1
8-1 2-17
8.1.1asm.s traps.c asm.s
traps.c asm.s csystem_call.s mm/page.s PC 8259A5-21
CPU 12 EFLAGS CSEIP 8-2(a)
CPU80386
CPU
CPUEFLAGS 8-2(c) (d)
asm.s Intel int0--int16 int17-int31 IntelIRQ int32-int47 16
Linux int128(0x80)kernel/system_call.s
CPU int 8 int10 - int 14
8-2 (b)asm.s
8-3
8.1.2 Linux int 0x80 eax
ebx ecx edxsystem_call.s fork.c signal.c sys.c exit.c
system_call.s asm.sfork.c signal.c traps.c
C fork.c C find_empty_process() copy_process() signal.cdo_signal() 4
sys_xxx() sys.c exit.c sys_xxx() sys_xxx()
sys_execve() Csignal.c 4
'do_' C'sys_'
do_signal()sys_pause() sys_execve() C
8.1.3schedule.c mktime.c panic.c printk.c vsprintf.c
schedule.c schedule() sleep_on() wakeup()
mktime.c mktime() init/main.cpanic.c panic() printk.c vsprintf.c
printk() vsprintf()
8.2 Makefile
8.2.1linux/kernel/ make
5 Makefile 5-1
8.2.28-1 linux/kernel/Makefile
8.3 asm.s
8.3.1 asm.s CPU FPU
kernel/traps.ctraps.c C
8-44 8-4(a)
esp ( esp0 ) C do_divide_error()C esp1 , eax
eax esp2do_divide_error() eip esp0
esp3 8 esp2CPU 8-4(b)
esp0 C do_double_fault() Cesp1 eax ebx esp0
esp1 eax ebx8-4(a)
do_divide_error() esp0 esp0C do_divide_error() traps.c
void do_divide_error(long esp, long error_code)
C
8.3.28-2 linux/kernel/asm.s
esp0esp1
esp3
esp2
esp0
esp1
esp3
esp2
8.3.38.3.3.1 Intel
Intel 8–1
8.4 traps.c
8.4.1 traps.c asm.s C
die()trap_init() init/main.c
asm.sC
8.4.28-3 linux/kernel/traps.c
8.5 system_call.s
8.5.1Linux 0.11 int 0x80 eax
libc forkfork() libc fork() int 0x80
include/linux/sys.h int 0x80
(system_call) int 0x80 80sys_execve sys_fork
(int 16) (int7) (int32) (int46) (int38)
(system_call coprocessor_error device_not_available)C 3 ebx
ecx edx CC linux
include/linux/sys.hIRQ 8259A
EOI C
(int 0x80) “ ”C “Bottom half”
eaxLinux ds,es fssys_call_table C C
Ccounter==0 schedule()
jmp _schedule "jmp _schedule" ret_from_sys_callschedule() ret_from_sys_call
ret_from_sys_call0
1
do_signal()
“ ” system_call8-5
int 0x80 LinuxLinux 0.11 ebx ecx edx 3
eax
ds es fsLinux fs
CPU get_fs_byte() put_fs_byte()include/asm/segment.h
Linus
Y
Y
Y
N
Y
8.5.28-4 linux/kernel/system_call.s
8.5.38.5.3.1 GNU 32 GNU AT&T 32
AT&T: immed32(basepointer, indexpointer, indexscale) Intel: [basepointer + indexpointer*indexscal + immed32]
immed32 + basepointer + indexpointer * indexscale immed32 basepointer
o C AT&T: _booga Intel: [_booga]
C (booga) o AT&T: (%eax) Intel: [eax] o AT&T: _variable(%eax) Intel: [eax + _variable] o 4 AT&T: _array(,%eax,4) Intel: [eax*4 + _array] o
C *(p+1) p char * AT&T: AT&T 1(%eax) eax p Intel: [eax+1]
o 8 eax ebx
AT&T: _array(%ebx,%eax,8) Intel: [ebx + eax*8 + _array]
8.5.3.2Linux
ioctl()
Linux 0.11
sys_sethostname()kernel/sys.c thisname
sys_uname() thisname 218-220
include/unistd.h 131251
include/linux/sys.h sys_call_table
system_call.s 61 nr_system_calls 1lib/ libc sethostname()
8.5.3.3Linus as86 GNU as asm.s
Linux crt0.o
4 - sys_write() 1 - sys_exit()C sys_write(int fd, char *buf, int len) fs/read_write.c 83 3
3 ebx ecx edx
8.6 mktime.c
8.6.1kernel_mktime() 1970 1 1 0
C mktime()
tm UNIX
8.6.28-5 linux/kernel/mktime.c
8.6.38.6.3.1
y 4 100 400 y
8.7 sched.c
8.7.1 sched.c (sleep_on()wakeup() schedule() ) getpid()
do_timer() Linus
schedule() schedule()
alarmalarm (alarm<jiffies), SIGALRM alarm
jiffies 10ms/ sched.hTASK_INTERRUPTIBLE
TASK_RUNNING
counterswitch_to()
prioritycounter
sleep_on() wake_up()schedule() sleep_on()
tmp
*p tmp current *pi i_wait buffer_wait tmp
current 8-6
*p
*pNULLtmp
CPU sleep_on() tmp
tmp8-7 sleep_on()
sleep_on() schedule()
wake_up()
sleep_on()
interruptible_sleep_on() sleep_on()
0.12
include/linux/sched.h
8.7.28-6 linux/kernel/sched.c
“ ”
8.7.38.7.3.1
6 floppy.c4
1.2M
I/O
0x3f2 ( )
0x3f4
0x3f5 /
FDC
FDC
0x3f7
0x3f7 ( )
8 /FDC / DMA
FDC 8 FDC FDDCPU FDC FDC
FDC FDC
0x3f5 DIO0 CPU FDC FDC
715
CPU FDC0--8
FDC CPU FDCCPU FDC FDC DMA
1 DMA DMA FDCDMA FDC FDC
CPUCPU FDC FDC
0--7 FDC
8.7.3.2 /1. Intel 8253 8254 Intel 8253 8254 / PIT - Programmable Interval Timer
316
8254 8253 8254 82538253 8254
8253 8253 82548-8
3 8 Data Bus Buffer / Read/Write Logic A1 A0
/ 3 Control Word RegisterA0,A1 RD WR CS CPU 8253
CPU 8254Read-Back Command 3
CLK8253 2.6MHz 8254 10MHz GATE
OUT
8-8(b) Status RegisterNULL Null Count Flag
CE 16 OL Output Latch OLmOLl 8
CECPU CE CE
OL 8-8(b) CR Count Register 8 CPU
CECR CE GATE
CLK 1 0 OUT
2. 8253 82548253 8253
8–3
7 SC1
6 SC0
SC1 SC0 0-2 SC - Select Counter
00 - 0 01 - 1 02 - 2 11 - 8254
5 RW1
4 RW0
RW1 RW0 RW - Read Write
00 - 01 - LSB
10 - MSB 11 -
3 M2
2 M1
1 M0
M2-M0 M - Method
000 - 0 001 - 1 010 - 2
011 - 3 100 - 4 101 - 5
0 BCD 0 - 16 1 - 4 BCD
CPU A1 A0 11 PC 0x43
A1 A0 00 01 10 PC 0x40 0x41 0x42 3
BCD
8254 31 GATE
2D5 D4 00
CEOL CPU OL OL
CPU OLCE 3 8254
NULL 2CPU OL CE
3. 8253/8254 3 6(1) 0 - Interrupt on terminal count
OUT 0 OUT0
GATE
(2) 1 - Hardware Retriggerable One-shotOUT CPU
GATE OUT 0OUT GATE
GATE(3) 2 - Rate Generator
N OUT1 OUT CLK
N NGATE GATE
(4) 3 - Square Wave Mode2 OUT N
CLK N 1 1 N
(5) 4 - Software Triggered StrobeOUT OUT
“ ” GATE1 OUT
(6) 5 - Hardware Triggered StrobeOUT GATE OUT
CLKGATE CLK
PC/AT 8254 3 /DRAM 3
1.193180MHz PC/AT 8254 8-9 A1 A0A1 A0 A9--A2 0b0010000 8254 PC/AT
8254 IO 0x40--0x43 0x40--0x42 0--2 0x43
0 GATE BIOS3 0 65536 0--65535 OUT0
18.2HZ 1.193180MHz/65536 OUT0 82590 54.9ms 1000ms/18.2
1 GATE 218 PC/XT DMA 2
PC/AT RAM 15 1.19318/18 = 66.288KHz
2 GATE TIME2GATE 8255A B D08-9 SPK DATA 8255A B 0x61 D1
8255A
Linux 0.11 8254 0 3LATCH 1193180/100 0 10
IRQ0 8254 0x36 0b00110110(LATCH & 0xff) (LATCH
>> 8) Linux 0.11
8.8 signal.c
8.8.1 signal.c UNIX
ctrl-C SIGINT SIGnal INTerrupt
SIGALRMkill()
UNIX UNIX
POSIX32
32 Linux 22 20 POSIX.12 Linux SIGUNUSED SIGSTKFLT
22include/signal.h
1. SIGKILL SIGSTOP
02.
SIGTERMSIGTERM kill
3.
sys_ssetmask() sys_sgetmask()sys_signal() signal()
sys_sigaction()( sigaction())do_signal() send_sig() tell_father()
exit.c sig signal signal() sigaction() handler , signal()
signal() sigaction()sigaction[]
sigaction[]
include/signal.h 55 signal()
signal() signrvoid (*handler)(int)
signal()
signal()
signal() signr handlerSIG_IGN SIG_DFL
SIG_IGNSIG_DFL
signal()SIG_DFL
include/signal.h 45 SIG_DFL SIG_IGN
signal() 0 1signal()
SIGKILL SIGSTOP94—98
SIG_DFL SIG_IGNfork()
signal()
signal()
sigaction() sigactionsignal()
include/signal.h 66
sig sigactionact NULL act oldact
sigaction
sa_handler SIG_DFLSIG_IGN sa_handler sa_mask
signal()signal() sigaction sa_flagsinclude/signal.h 36-39 sigaction sys_signal() restorer
Libc eax
do_signal() (int 0x80)
8-10
do_signal()longs 106 8-11
do_signal() 104CPU 8-11
SS ESP CS EIPdo_signal() system_call.s 118
8-12 do_signal()
do_signal() SIG_IGN SIG_DFLsa_handler 104 do_signal()
eip old_eip eipsa_handler eip sa_handler
esp longs 7 8
7 8 old_eip eipeflags edx ecx
eaxblocked signr
sa_restorersignal() signr handler
SIGINT Ctrl-CSIGINT
handler() SIGINTSIGINT Ctrl-C SIG_DFL
sa_restorer Linux Libc 2.2.2misc/
signrLibc sa_restorer()
sa_restorer()
do_signel() system_call.s eipiret CPU cs:eip eflags ss:esp
eipret CPU sa_restorer
sa_restorersignr eax ecx edx eflags
CPU sa_restorer ret eipold_eip
8.8.28-7 linux/kernel/signal.c
8.8.38.8.3.1
18 SIGCHILD
Linux 0.11 8–4
1 SIGHUP
(Hangup)
Xterm modem
SIGHUP
(Abort)
2 SIGINT (Interrupt) ^C (Abort)
3 SIGQUIT (Quit) ^\ (Dump)
dump core
4 SIGILL (Illegal Instruction) (Dump)
dump core
5 SIGTRAP (Breakpoint/Trace Trap)
6 SIGABRT (Abort)(Dump)
dump core
7 SIGIOT (IO Trap) SIGABRT (Dump)
dump core
8 SIGUNUSED (Unused)
9 SIGFPE (Floating Point Exception) (Dump)
dump core
10 SIGKILL (Kill)
9(Abort)
11 SIGUSR1 (User defined Signal 1) (Abort)
12 SIGSEGV (Segmentation Violation) (Dump)
dump core
13 SIGUSR2 (User defined Signal 2) IPC (Abort)
14 SIGPIPE (Pipe)
(Abort)
15 SIGALRM (Alarm) alarm
(Abort)
16 SIGTERM
(Terminate) kill
SIGKILL (Abort)
17 SIGSTKFLT (Stack fault on coprocessor) (Abort)
18 SIGCHLD (Child)(Ignore)
19 SIGCONT (Continue) SIGSTOP (Continue)
20 SIGSTOP (Stop) (Stop)
21 SIGTSTP (Terminal Stop) (Stop)
22 SIGTTIN
(TTY Input on Background)
SIGCONT (Stop)
23 SIGTTOU
(TTY Output on Background)
SIGCONT (Stop)
8.9 exit.c
8.9.1
send_sig() tell_father()
release()
kill_session()sys_kill() pid
do_exit() exitfather 1
1 init ) 1SIGCHLD
SIGCHLDwaitpid() pid
pid
8.9.28-8 linux/kernel/exit.c
8.10 fork.c
8.10.1 fork() Linux 0 0 sys_fork()
kernel/system_call.s 208 sys_fork()C find_empty_process() copy_process()
verify_area() copy_mem() copy_process()
TSS0 tss.eax = 0 tss.esp0
tss.ss0 tss.ldtGDT
tss.i387
1 GDT TSS LDTtss ldt8-13 verify_area()
write_verify() 4096 write_verify()
fork.c fork()fork() PCB
copy_process() TSSnr * 64MB CPU
Linux 0.11Linux 0.11
fork()
8.10.28-9 linux/kernel/fork.c
8.10.38.10.3.1 TSS
8-14 TSS Task State Segment TSStask_struct 4
CPU (task state segment - TSS)80386 TSS
TSS 1 CPUEAX ECX EDX EBX ESP EBP ESI EDI ES, CS, SS, DS, FS, GS
EFLAGS EIP TSS2 CPU LDT
PDBR 0-2 CPU (debug)T- I/O TSS TSS
TSS TR LTR STR
I/O 1 1 I/O 41 I/O +5
1 1 I/O IN INS OUT OUTS CPUIOPL I/O CPU
TSS I/OI/O
I/O TSS TSS I/OCPL>IOPL I/O Linux 0.11 I/O
0x8000 TSS 104 Linux 0.11 I/OLinux 0.11 SS0:ESP0 SS1:ESP1 SS2:ESP2
1 2 LinuxSS:ESP
8.11 sys.c
8.11.1 sys.c -ENOSYS Linux
include/linux/sys.hID pid ID pgrp pgid ID uid ID gid
ID ruid ID euid ID session ID
ID uid ID gid ID passwd IDID ruid ID rgid i ID
ID3 ID ID 8–5
ID ID
uid - ID gid - ID
euid - ID egid - ID
suid - ID
ID set-user-ID suid
uid suid euid
sgid - ID ID
set-group-ID sgid
gid sgid egid
uid gid ID ID ID ruidID rgid set_uid() set_gid() ID ID
ID suid ID sgid set-user-ID set-group-IDeuid ID egid ID
set-user-IDID ID
ID suid set-group-ID
set-user-IDID euid ID 0
Linux passwd set-user-Id/etc/passwd
passwd set-user-IDID pid ID pgrp pgid
ID session 3 ID ID ID
8.11.28-10 linux/kernel/sys.c
8.12 vsprintf.c
8.12.1vsprintf() C
vsprintf() C
8.12.28-11 linux/kernel/vsprintf.c
8.12.38.12.3.1 vsprintf()
int vsprintf(char *buf, const char *fmt, va_list args)
vsprintf() printf()fmt
printf stdout cprintf fprintfprintf 'v' ( vfprintf) va_arg va_list args printf 's'
null buf buf
1. printf
2.
%[flags][width][.prec][|h|l|L][type] (%)
[flags] [width] [.prec] (precision) [h|l|L] [type] ( )
flags27-33 # (o)
(x X) '0x' '0X' e,E,f,F,g Gg G
0 d,i,o,u,x,X,e,E,f,g G0 - 0 0
- -- n
' ' + + -
widthflags
'*'width
precision d,I,o,u,x Xe,E,f F g G
s S
d,i,o,u,xX hh h l ll L e,E,f,F,g G
type d,I (precision)
1 o,u,x,X (o) (u) (xX) x abcdef X ABCDEF
1 e,E [-]d.ddde+dd
6 0 E E2 0 00
f,F [-]ddd.ddd6 0
1 g,G f e G F E
6 0 1-4 e
c s null
null p
n
% % %%
8.12.41.2
8.13 printk.c
8.13.1 printk() C printf()
fsfs tty_write() fs
printk()ds printk() fs
printk() vsprintf() fstty_write()
8.13.28-12 linux/kernel/printk.c
8.14 panic.c
8.14.1 panic()
panic()UNIX
panic Douglas Adams Hitch hikers Guide to the GalaxyDon't Panic!” linux
8.14.28-13 linux/kernel/panic.c
8.15
linux/kernel 12
9 (block driver)
block device (character device)
Linux 0.117 7 0 6
9–1
0
1 / ram,
2 fd,
3 hd,
4 ttyx
5 tty
6 lp
Linux 0.11
9-1
9-1 linux/kernel/blk_drv
: 1. hd.c 2. floppy.c
3. ramdisk.cll_rw_blk.c blk.h
ll_rw_blk.c
9.1
1024 512
ll_rw_block()
9.1.1ll_rw_block()
blk_dev[]blk.h
do_hd_request() do_floppy_request()NULL
init/main.cLinus Linux 0.11 7 9–2
1 2 3NULL
0 NULL
1 / ram, do_rd_request()
2 fd, do_fd_request()
3 hd, do_hd_request()
4 ttyx NULL
5 tty NULL
6 lp NULL
ll_rw_block()do_XX_request()
'XX' 'rd' 'fd' 'hd'32
next 9-1
Elevator Algorithm 9-1 41
ll_rw_block()current_request
ll_rw_block()
2/3 1/3
9.1.2
/
Linux 0.1x --
I/O Linux 0.1x I/OLinux 2.6.x I/O
9.1.3IO
9-2/
C
C /
hd_out()DRQ DRQ
C write_intr()
C
/
C read_intr()
0
do_rd_request()/
ll_rw_block()IO fs/buffer.c bread()
267 ll_rw_block() wait_on_buffer()IO end_request()
9.2 Makefile
9.2.1makefile
9.2.29-1 linux/kernel/blk_drv/Makefile
9.3 blk.h
9.3.1
request
"extern inline" GNU CC 10
inline extern
inline extern macro
inline extern
9.3.29-2 linux/kernel/blk_drv/blk.h
9.4 hd.c
9.4.1 hd.c
5sys_setup() hd_init()
hd_out()do_hd_request()C read_intr() write_intr() bad_rw_intr() recal_intr()
do_hd_request() read_intr() write_intr()controler_ready() drive_busy() win_result() hd_out()
reset_controler() sys_setup() boot/setup.s
hd_init()
hd_out() Cdo_hd
read_intr() 0x1f0 0x1f7WIN_DIAGNOSE
WIN_SPECIFYCPU system_call.s 221 do_hd_request()
INIT_REQUEST
reset recalibrateWIN_SPECIFY
WIN_RESTOREC recal_intr() recal_intr()
C write_intr()DRQ
bad_rw_intr()
C read_intr()
write_intr() CCPU
win_result()bad_rw_intr()
port_write() end_request()
do_hd_request() read_intr() C
write_intr() win_result()write_intr()
port_read()
end_request()
do_hd_request()
9-3 9-4
4 hd_out() do_hd_request() read_intr()write_intr() 4
hd_out() / hd_out()do_hd_request() do_hd_request()
add_request() ll_rw_block()fs/buffer.c bread() IO
9.4.29-3 linux/kernel/blk_drv/hd.c
9.4.39.4.3.1 AT AT 9–3 include/linux/hdreg.h
0x1f0 HD_DATA --
0x1f1 HD_ERROR,HD_PRECOMP (HD_ERROR) (HD_PRECOMP)
0x1f2 HD_NSECTOR --
0x1f3 HD_SECTOR --
0x1f4 HD_LCYL --
0x1f5 HD_HCYL --
0x1f6 HD_CURRENT / -- / (101dhhhh, d= ,h= )
0x1f7 HD_STATUS,HD_COMMAND (HD_STATUS) (HD_COMMAND)
0x3f6 HD_CMD --- (HD_CMD)
0x3f7 1.2M ---
HD_DATA 0x1f016 PIO CPU
1 'rep outsw' 'rep insw' / cx=256/ HD_ERROR 0x1f1
8 (HD_STATUS 0x1f7) 0=19–4
0x05 4
0x01
0x02 0
0x03
0x04 ECC
0x05
0x10 ID
0x40 ECC
0x80
0x05 4HD_NSECTOR 0x1f2
1
1 0 0 256HD_SECTOR 0x1f3
1 1HD_LCYL HD_HCYL 0x1f4 0x1f5
8 2/ (HD_CURRENT 0x1f6)
101dhhhh101 ECC 512 d 0 1 hhhh
9–5
0 HS0 0
1 HS1 1
2 HS2 2
3 HS3 3
4 DRV 0 - 0 1 - 1
5 Reserved 1
6 Reserved 0
7 Reserved 1
/ HD_STATUS/HD_COMMAND 0x1f7) 8
9–6
0 ERR_STAT 0x01
1 INDEX_STAT 0x02
2 ECC_STAT 0x04 ECC
3 DRQ_STAT 0x08
4 SEEK_STAT 0x10
5 WRERR_STAT 0x20
6 READY_STAT 0x40
7 BUSY_STAT 0x80 RESET SRST 400
30
400
512 5
CPU 8 9–7
4 D3 D2 D1 D0
WIN_RESTORE ( ) 0x1 R R R R 0x10
WIN_READ 0x2 0 0 L T 0x20
WIN_WRITE 0x3 0 0 L T 0x30
WIN_VERIFY 0x4 0 0 0 T 0x40
WIN_FORMAT 0x5 0 0 0 0 0x50
WIN_INIT 0x6 0 0 0 0 0x60
WIN_SEEK 0x7 R R R R 0x70
WIN_DIAGNOSE 0x9 0 0 0 0 0x90
WIN_SPECIFY 0x9 0 0 0 1 0x91
4 R R=0 35us R=1 0.5ms R=0 L L=0 / 512 L=1 / 512 4 ECC
L=0 T T=0 T=1 T=0
(1) 0x1X -- WIN_RESTORE Recalibrate/ 0
BUSY_STAT 0BUSY_STAT(2) 0x20 -- WIN_READ 0x21 --
1 256 9–90 256 BUSY_STAT
ID
IDID ID
ID DataAddress Mark
DRQ_STAT DRQ_STAT
DRQ_STATBUSY_STAT DRQ_STATBUSY_STAT BUSY_STAT
(3) 0x30 -- WIN_WRITE 0x31 -- 1 256 9–9
0 256 DRQ_STAT
DRQ BUSY_STATDRQ_STAT
BUSY_STAT DRQ_STAT
IDID ECC
BUSY_STAT
DRQ_STAT BUSY_STATDRQ BUSY BUSY_STAT
DRQ_STAT
(4) 0x40 -- WIN_VERIFY 0x41 -- DRQ_STAT
BUSY_STATBUSY_STAT
(5) 0x50 -- WIN_FORMATDRQ_STAT
DRQ_STAT BUSY_STAT
(6) 0x60 -- WIN_INIT(7) 0x7X -- WIN_SEEK
BUSYSEEK_STAT DSC -
BUSY_STAT
(8) 0x90 -- WIN_DIAGNOSE0 400ns
BUSY_STAT2 1 0
1 5 1 00x80 0 1
/ (0x1f6) 4 1 11 0
1 0 BUSY_STAT
(9) 0x91 -- WIN_SPECIFY
BUSY_STAT/ -1 4
HD_CMD 0x3f60x08
9–8
0x08
0
1 (0) ( IRQ)
2
3 8 1
4 (0)
5 +1 1
6 ECC
7
9.4.3.2 AT9–9
6 1 70x1f1 -- 0x1f7
0x1f1
0x1f2
0x1f3
0x1f4
0x1f5
0x1f6 /
0x1f7
CPU (HD_CMD)0x3f6
1. CPU 7 BUSY_STAT 0hd.c 161
controller_ready()2. CPU 6 READY_STAT 1
1 hd.c 202 drive_busy()3. hd.c 180 hd_out()
4. CPU IRQ14 -- int46/ hd.c
237--293 5 55. CPU 0 0
(HD_ERROR) hd.c 202 win_result()
9.4.3.3int 0x41 4 * 0x41 =0x0000:0x0104
9–10 100% BIOSF000h:E401h int 0x46
0x00
0x02
0x03 ( PC XT 0)
0x05 4
0x07 ECC XT 0
0x08 0
1 (0) ( IRQ)
2
3 8 1
4 (0)
5 +1 1
6 ECC
7
0x09 XT 0
0x0A XT 0
0x0B XT 0
0x0C ( )
0x0E
0x0F
9.4.3.43
1- ,2- ,3- ,4-ttyx,5-tty,6- ,7-1 1--4
= *256 + dev_no = (major<<8) + minor
9–11
0x300 /dev/hd0 1
0x301 /dev/hd1 1 1
0x302 /dev/hd2 1 2
0x303 /dev/hd3 1 3
0x304 /dev/hd4 1 4
0x305 /dev/hd5 2
0x306 /dev/hd6 2 1
0x307 /dev/hd7 2 2
0x308 /dev/hd8 2 3
0x309 /dev/hd9 2 4
0x300 0x305linux 0.95
9.4.3.5PC ROM BIOS
1 0x7c00MBR Master Boot Record 9-12
0x000 MBR 446
0x1BE 1 16 1 16
0x1CE 2 16 2 16
0x1DE 3 16 3 16
0x1EE 4 16 4 16
0x1FE 2 0x55, 0xAA
446 MBR 40 0 1 0x1BE--0x1FD
1--416 9–13
0x00 boot_ind 4
0x00- 0x80-
0x01 head 0--255
0x02 sector ( 0-5) 1--63 2 ( 6-7)
0x03 cyl 8 0--1023
0x04 sys_ind 0x0b-DOS; 0x80-Old Minix; 0x83-Linux …
0x05 end_head 0--255
0x06 end_sector ( 0-5) 1--63 2 ( 6-7)
0x07 end_cyl 8 0--1023
0x08-0x0b start_sect 0
0x0c-0x0f nr_sects
head sector cyl0--255 sector 6 1--63
sector 2 cyl 10 0--1023 end_headend_sector end_cyl H
S C CHS H = head; S = sector & 0x3f; C = (sector & 0xc0) << 2) + cyl;
start_sect 4 0CHS 0 0 1 0, 0, 1
0MAX_HD MAX_SECT CHS
phy_sector phy_sector = (C * MAX_HEAD + H) * MAX_SECT + S - 1
1 0 0 1boot 0x7c00 0x6000 0x7c00
10x7c00
1
9.4.3.6track_secs dev_heads sector
tracks cyl sec headsector
sector / track_secs = tracks sectracks / dev_heads = cyl head
1 sec 1cyl sec head
sector = (cyl * dev_heads + head) * track_secs + sec -1
9.5 ll_rw_blk.c
9.5.1/
ll_rw_block()
request_fn() do_hd_request() do_fd_request()do_rd_request() ll_rw_block()
request_fn()
request_fn()request_fn() C read_intr()
write_intr() request_fn()
request_fn() request_fn()9-5
do_rd_request()
9.5.29-4 linux/kernel/blk_drv/ll_rw_blk.c
9.6 ramdisk.c
9.6.1Ram Disk Theodore Ts'o
linux/Makefile RAMDISK
init/main.c 123 16MB4MB RAMDISK KB
RAMDISK=512 9-6
3 rd_init() init/main.cdo_rd_request()
rd_load()
256Bootimage Rootiamge
DOS Linux14
rd_load() 257
ROOT_DEV 0x0101 rd_load()9-7
Linux 0.11 linux/Makefile RAMDISKRAMDISK 256
1KB 2 257RAMDISK
shell256
1.44MB 2569-8
9.6.29-5 linux/kernel/blk_drv/ramdisk.c
9.7 floppy.c
9.7.1
do_fd_request()
0.5
3
Linus 100
kernel/sched.c 201-262
do_fd_request()
include/linux/fdreg.h
9.7.29-6 linux/kernel/blk_drv/floppy.c
9.7.39.7.3.1
Linux 2 = TYPE*4 + DRIVE DRIVE 0-3A B C D TYPE 2 1.2M 7 1.44M floppy.c 85
floppy_type[] 9–14
0
1 360KB PC
2 1.2MB AT
3 360kB 720kB
4 3.5" 720kB
5 360kB 1.2MB
6 720kB 1.2MB
7 1.44MB
7 1.44MB 0 A 7*4 + 0 = 28 (2,28) 1.44M A , 0x021c /dev/fd0 /dev/PS0 2 1.22MB
2*4 + 0 = 8 (2,8) 1.2M A 0x0208 /dev/at0
9.7.3.2FDC 4
1.2M 9–15
I/O
0x3f2 DOR ( )
0x3f4 FDC (STATUS)
0x3f5 / FDC (DATA)
DIR0x3f7
(DCR)( )
DOR 8/ FDC / DMA 9–16
7 MOT_EN3 D 1- 0-
6 MOT_EN2 C 1- 0-
5 MOT_EN1 B 1- 0-
4 MOT_EN0 A 1- 0-
3 DMA_INT DMA 0- DMA
2 RESET FDC 0- FDC
1 DRV_SEL1
0 DRV_SEL0 00-11 A-D
FDC 8 FDC FDDCPU FDC FDC
FDC 9–17
7 RQM FDC
6 DIO 1- FDC CPU 0- CPU FDC
5 NDM DMA 1- DMA 0- DMA
4 CB FDC
3 DDB D
2 DCB C
1 DBB B
0 DAB A
FDC0x3f5 DIO
0 CPU FDC FDC7
DIR 7 D7
(DCR) 2 D1D000 500kbps 01 300kbps 10 250kbps Linux 0.11 DMA
DMA 386 PCIR6 0x26 DMA 2 DMA
9.7.3.315
CPU FDC0--8
FDC CPU FDCCPU FDC FDC DMA
1 DMA DMA FDCDMA FDC FDC
CPUCPU FDC FDC
0--7 FDC
Linux 0.11 6
1. FD_RECALIBRATE0
0x07 0—39–18
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 1 1 1 0x07
1 0 0 0 0 0 0 US1 US2
0
2. FD_SEEK1 0-1
2 29–19
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 1 1 1 1 0x0F
1 0 0 0 0 0 HD US1 US2
2 C
3. FD_READDMA
4 R 1 DMA9–20
C R R1 R EOT
1 R 1
D7 D6 D5 D4 D3 D2 D1 D0
0 MT MF SK 0 0 1 1 0 0xE6 MT=MF=SK=1
1 0 0 0 0 0 0 US1 US2
2 C
3 H
4 R
5 N
6 EOT
7 GPL 3
8 DTL N=0
1 ST0 0
2 ST1 1
3 ST2 2
4 C
5 H
6 R
7 N
MT MF SK MT MT=1 MF MF=1 MFM FM SK SK=1
3 ST0 ST1 ST2 9–21 9–22 9–23
7
6ST0_INTR
00 – 01 –
10 – 11 –
5 ST0_SE Seek End
4 ST0_ECE Equip. Check Error
3 ST0_NR Not Ready
2 ST0_HA Head Address
1
0ST0_DS
Drive Select
00 – 11 0—3
7 ST1_EOC EOT End of Cylinder
6 0
5 ST1_CRC CRC
4 ST1_OR DMA Over Run
3 0
2 ST1_ND No Data - unreadable
1 ST1_WP Write Protect
0 ST1_MAM ID AM Missing Address Mask
7 0
6 ST2_CM SK=0 Control Mark = deleted
5 ST2_CRC CRC
4 ST2_WC ID C Wrong Cylinder
3 ST2_SEH Scan Equal Hit
2 ST2_SNS Scan Not Satisfied
1 ST2_BC ID C=0xFF Bad Cylinder
0 ST2_MAM DATA AM Missing Address Mask
4. FD_WRITE
DMA1
DMA 9–24
D7 D6 D5 D4 D3 D2 D1 D0
0 MT MF 0 0 0 1 0 1 0xC5 MT=MF=1
1 0 0 0 0 0 0 US1 US2
2 C
3 H
4 R
5 N
6 EOT
7 GPL 3
8 DTL N=0
1 ST0 0
2 ST1 1
3 ST2 2
4 C
5 H
6 R
7 N
5. FD_SENSEI1 2 ST0 PCN
CPUDMA
9–25
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 1 0 0 0 0x08
1 ST0 0
2 C
6. FD_SPECIFY
SRT / HLT/HUT DMA9–26 500KB/S Linux 0.11
1 floppy.c 95 spec1 2 spec2315 spec2 6 HLT=3 ND=0
6 DMA
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 0 1 1 0x03
1 SRT 1ms HUT 16ms
2 HLT 2ms ND DMA
9.7.3.4PC NEC PD765 Intel 8287A Intel 82078
MSRoutput_byte(byte)
9-9RQM 1 DIO 0 CPU FDC
10000Linux 0.1x 0.9x
PC 16MHz -- 40MHzLinux
FDC CPU result()reply_buffer[]
DOR 2 FDC 0 1SPECIFY floppy.c
reset_floppy() C reset_interrupt() DOR 2SPECIFY
transfer()DCR
250KpbsDOR
FD_RECALIBRATE (FD_SEEK)/
MSR
DOR DOR9-10
/
DMA9-11
3300ms 5 500ms floppy.c
500msDCR
FD_SEEK
15ms HLT500Kbps HLT=8
16msDMA DMA
TCEOT
DMA
Linux 0.1111
500ms
ID DMA DMAC H R
9 2 512 1 7DMA 36 9 x 4 7,1,1,27,1,2,2 7,1,3,2 ... 7,1,9,2
SEEK
9.7.3.5 DMA DMA Direct Memory Access) “ ” DMA
Intel 8237DMA CPU
CPU DMA1 DMA
DMA DMADMA
PCDMA 2 Linux 0.11
Intel 8237 16 8 64KB1MB DMA 1MB 169–27 DMA
64KB
DMA 64KB
0x0 0x00000 - 0x0FFFF
0x1 0x10000 - 0x1FFFF
0x2 0x20000 - 0x2FFFF
0x3 0x30000 - 0x3FFFF
0x4 0x40000 - 0x4FFFF
0x5 0x50000 - 0x5FFFF
0x6 0x60000 - 0x6FFFF
0x7 0x70000 - 0x7FFFF
0x8 0x80000 - 0x8FFFF
0x9 0x90000 - 0x9FFFF
0xA 0xA0000 - 0xAFFFF
0xB 0xB0000 - 0xBFFFF
0xC 0xC0000 - 0xCFFFF
0xD 0xD0000 - 0xDFFFF
0xE 0xE0000 - 0xEFFFF
0xF 0xF0000 - 0xFFFFF
2DMA DMA 2 DMA
3DMA EOP
CPU
PC/AT DMA 8 4 16DMA 2
DMA 816
9–28
DMA
0 0x87 0x00 0x01
1 0x83 0x02 0x03
2 0x81 0x04 0x05
3 0x82 0x06 0x07
4 0x8F 0xC0 0xC2
5 0x8B 0xC4 0xC6
6 0x89 0xC8 0xCA
7 0x8A 0xCC 0xCE
DMA 4 DMA9–29 Linux 0.11
3 0x0A, 0x0B, 0x0C
0-3 4-7
0x08 0xD0
0x09 0xD2
0x0A 0xD4
0x0B 0xD6
0x0C 0xD8
DMA DMALinux 0.11 ROM BIOS
9–30 DMA
7 DMA DACK 0-DACK 1-DACK
6 DMA DREQ 0-DREQ 1-DREQ
5 0- 1- X- 3=1
4 DMA 0- 1-
3 DMA 0- 5 1- 3 X- 0=1
2 DMA 0- 1-
1 0 0- 0 1- 0 X- 0=0
0 0- 1-
DREQ DREQ1 DMA 0 DMA DREQ
DMA PC DMA2 DREQ Linux
9–31
7 -3
2 0 - 1 - 0
1
000-11 0-3
0x0A 16 0xD4DMA DREQ DMA DMA
9–32
7 -3
2 1 - 0 -
1
000-11 0-3
DMA Linux 0.11 0x460x4A 9–33
7
6 00- 01- 10- 11-
5 0- 1-
4 0- 1-
3
2 00-DMA 01-DMA 10-DMA 11-
1
000-11 0-3
16
0x0C / DMA0 1
0x0C 0DMA DMA
1.2. 0x0A DMA
23. 0x0C4. 0x0B5. 0x04 DMA
6. 0x81 DMA7. 0x05 DMA -1
DMA 1024DMA 1023 0x3FF
8. 0x0A DMA9.
10 (char driver)
linux 0.11M.J.Bach UNIX
10 3
10-1 linux/kernel/chr_drv
10.1
RS-232 rs_io.s serial.ckeyboard.S console.c
tty_io.c tty_ioctl.c
10.1.1
Raw data
canonicalTAB 8
backspace (line discipline)(raw)
10-1
10.1.2 Linuxtty tty Teletype
Teletype Teletype Linux 0.1x/dev/
1. /dev/ttySn
/dev/ttyS0 /dev/ttyS1 4,64 4,65DOS COM1 COM2
echo test > /dev/ttyS1 ”test”ttyS1
2. /dev/ptyp /dev/ttypPseudo Terminals Pseudo - TTY PTY
shell X Window
Master PTY Slave PTYptyp1 ttyp1 ptyp1 ttyp1
/dev/ptyp3 /dev/ttyp3 ttyp3 /ptyp3 ptyp3
ttyp3
telnet telnetptyp2 getty ttyp2 telnet
ptyp2 ttyp2 getty getty ttyp2 ptyp2 telnet”login:” telnet
Linux 16 ttyp ttyp0—ttypf Linuxptm - pty master /dev/ptm3 /dev/pts/3
pty Linux /dev/pts devpts/dev/pts/3
3. /dev/tty/dev/tty Controlling Terminal 5
0 /dev/tty ”ps –ax”shell /dev/tty 5,0
”tty” /dev/tty
/dev/tty TIOCNOTTYTerminal IO Control NO TTY ioctl()
4. /dev/ttyn, /dev/consoleLinux Console VT200 Linux
TERM=Linux tty0 tty1 tty2tty1 Alt+[F1—F6] tty2 tty3 tty1 –
tty6 tty0 Linuxtty0
root /dev/tty0 /dev/console Linux 0.12/dev/console 1 tty1
5.Linux
ISDN /dev/ttyIn
10.1.3tty_struct
ID IO include/linux/tty.h
Linux tty_table[]tty_struct Linux 0.11
termios io pgrppgrp
stopped *write()
3 tty_queue
1K read_qraw write_q
ICANON secondary read_q(cooked) backspace
tty_read()secondary
C copy_to_cooked()copy_to_cooked()
read_q read_qsecondary L_ECHO write_q
termios
tty_struct termios include/termios.h
c_iflag Linux 0.11 POSIX.1 11 termios.h
NL CRLinux 0.11 tty_io.c
copy_to_cooked() termios.h 83 -- 96 c_oflagtty_io.c tty_write() termios.h 99 -- 129 c_cflag
termios.h 132 -- 166 c_lflag Echo
copy_to_cooked() tty_read() ICANONISIG INTR QUIT
SUSP termios.h 169 -- 1834 unsigned long
32 termios.h c_cc[] ^C
NCCS c_cc[] include/linux/tty.hV VINTR VMIN
termios.h 64 -- 80ioctl (tcsetattr()) termios
read readtermios VTIME VMIN VMIN
VTIMEstty termios Linux 0.1x
stty
Linux ’stty -a’
10-2
10.1.410.1.4.1
c_lflag ICANONNL
EOL EOL2 EOF EOF
ERASE KILL EOF EOL REPRINT WERASEEOL2
ERASE Backspace copy_to_cooked()NL
KILL EOF copy_to_cooked() EOL EOL2
EOF REPRINT WERASE REPRINTWERASE Linux 0.1110.1.4.2
ICANONMIN
TIME c_cc[]
MIN TIME 1/10
1. MIN>0 TIME>0TIMEMIN MIN
secondary
2. MIN>0 TIME=0MIN
3. MIN=0 TIME>0TIME
04. MIN=0 TIME=0
0
MIN MINtty_io.c
tty_read()
10.1.5Linux 0.11
keyboard.s console.c
tty_io.ckeyboard.s tty_io.c
rs_io.s tty_io.c keyboard.s console.c Linux
ROMPC
keyboard.s console.c DEC VT100
10-3
10.1.5.1Linux 0.11 keyboard.S console.c keyboard.S
read_q copy_to_cooked() read_qsecondary console.c
IRQ1,INT 33
tty read_q C do_tty_interrupt()copy_to_cooked() tty secondary
tty write_q con_write() echodo_tty_interrupt() copy_to_cooked() tty_io.c
10-4
tty write_qwrite_q write_q
write_q tty_struct write_qcon_write() console.c
keyboard.Sread_q console.c write_q
10-5
10.1.5.2serial.c rs_io.s serial.c
rs_io.s4
a. modem b.c. d.
read_q copy_to_cooked()secondary
write_q
/read_q
11 1 tty read_q
C do_tty_interrupt() copy_to_cooked()tty secondary tty write_q
1 rs_write() echo
tty_structrs_write()
write_q
write_qrs_write() serial.c rs_io.s
10-6
rs_io.sconsole.c keyboard.S
10.1.6
i i
tty_io.ctty_read() tty_write() copy_to_cooked() tty_ioctl.c
tty_ioctl()termios include/termios.h
Linux 0.11termios 'c_line' 0
10.2 Makefile
10.2.1Make
10.2.210-1 linux/kernel/chr_drv/Makefile
10.3 keyboard.S
10.3.1make break
( )Alt Shift Ctrl Caps
moderead_q C do_tty_interrupt() tty_io.c
342 copy_to_cooked()read_q secondary
write_q
AT0xf0 2 AT
PC/XT PC/XT
gas '.S'as GNU C CPP C"#include" "#if"
10.3.210-2 linux/kernel/chr_drv/keyboard.S
10.3.310.3.3.1 PC/AT PC
Intel 804210-7 8042
8042 P20 P20 CPU 1 P21 A20
1 1 A20 0 A20A20
IO 0x60-0x6f IBM CP/AT 0x60 0x640x61 0x62 0x63 XT 10-1
4
/
0x60
8
0 = 1 IRQ1
0 = 1
0x60/
10 1=0
0x61 /
0x61 8255A B / 8255A PC
7=1 =0
6=0
5-0 (PPI)
0x64
8
7=1
6=1 ( IRQ1)
5=1 ( )
4=1 [?? =0 ]
3=1 ( 0x64)
=0 ( 0x60)
2 0 = 1 =
1=1 (0x60/64 8042 )
0=1 ( 0x60 )
0x640x60
12
10.3.3.20x60 1 20ms
10-20xfa (ACK)
0xed
/ 1 0
7-3 0
2 = caps-lock
1 = num-lock
0 = scroll-lock
0xee 0xee
0xef
0xf0
/
0x00 -
0x01 - 1( PCs PS/2 30 )
0x02 - 2( AT PS/2 )
0x03 - 3
0xf1
0xf2 ( 2 ) AT 0xfa
0xf3
7 0
6-5 C= 6-5 =(1+C)*250ms
4-0 B= 4-3 A= 2-0
=1/((8+A)*2^B*0.00417)
0x2c
0xf4
0xf5
0xf6
0xf7-0xfd
0xfe
0xff
(BAT)
1. 0xfa
2.
3. BAT
4. 0xaa 0xfd
10.3.3.3( 0x64) 1 0x60
10-3
0x20 0x60
0x21-0x3f 5 RAM
0x60-0x7f
0x5d
7 0
6 IBM PC ( PC )
5 PC
4
3 (override)
2 1
1 0
0
0xaa 0x55 0xfc
0xab
0x00
0x01 ( )
0x02
0x03
0x04
0xac 804x 16 RAM
0xad 4=1
0xae 4=0
0xc0 804x P1 0x60
0xd0 804x P2 0x60
0xd1804x P2 IBM PC 2 A20
0( )
0xe0T0 T1
1 0
0xed
LED 1 0
7-3 0
2 = caps-lock
1 = num-lock
0 = scroll-lock
0xf0-0xff
P20-23
(6 ) 0 4
0xfe(P20 )
10.3.3.4 PC PC XT
AT(make) (break) XT
10-4
7 6-0 77=0 7=1 ESC
1 1 ESC 1+0x80=129
PC PC/XT 83 1A 30 30 0x1e 0x80
0x9e AT 84/101/102 PC/XT
0xe0 PC/XTctrl 29 0x1d ctrl
0xe0 0x1d altPrtScn Pause/Break PrtScn
2 42 0x2a 55 0x37 0xe0 0x2a 0xe0 0x370xaa 0xe0 0x2a 0xe0 0x37 0xe0 0xaa
0x80 0xe0 0xb7 0xe0 0xaa prtscn shiftctrl 0xe0 0x37 0xe0 0xb7 alt
PrtScn 0x54Pause/Break ctrl 70
0x46 0xe1 0x1d 0x45 0xe1 0x9d 0xc5
0xe0 0xe1 2AT PC/XT
0xf0 2 8049AT AT PC/XT
AT (83 0xe0 )1 shift caps ctrl
alt 21 2 0xe0 0xe1 ctrl
0x1d( PC/XT) 0xe0 0x1d PC/XT
0xe1 0xe0
10.4 console.c
10.4.1
con_write()con_write()
vt102telnet Linux TERM=vt102
TERM=console Linux vt102con_write()
tty_structwrite_q
con_init()con_write()
include/linux/tty.htty_queue tty_struct
10-14
10.4.210-3 linux/kernel/chr_drv/console.c
10.4.310.4.3.1
MDA CGA EGA VGA
CGA MC6845 10-5CGA/EGA/VGA (0x3d0-0x3df) MDA 0x3b0 - 0x3bf
0--17 0x3d4(r0-r17) 0x3d5
10-6
/
0x3d4 CRT(6845) 0x3d5 (r0-r17)
0x3d5CRT(6845) r14-r17
10-6
0x3d8 /
7-6
5=1
4=1 640*200
3=1
2=1
1=1 =0
0=1 80*25 =0 40*25
0x3d9 /
CGA
7-6
5=1 (cyan) (magenta) (white)
=0 (red) (green) (blue)
4=1
3=1 40*25 320*200 640*200
2=1 40*25 320*200 640*200
1=1 40*25 320*200 640*200
0=1 40*25 320*200 640*200
0x3da
CGA
7-4
3=1
2=1 =0
1=1
0=1 =0
0x3db
0x3dc /
/ 40*25 80*25
r0
r1
r2
0x38
0x28
0x2d
0x71
0x50
0x5a
0x38
0x28
0x2d
r3 0x0a 0x0a 0x0a
r4
r5
r6
r7
0x1f
0x06
0x19
0x1c
0x1f
0x06
0x19
0x1c
0x7f
0x06
0x64
0x70
r8 / 0x02 0x02 0x02
r9 0x07 0x07 0x01
r10
r11
0x06
0x07
0x06
0x07
0x06
0x07
r12
r13
( )
( )
0x00
0x00
0x00
0x00
0x00
0x00
r14
r15
( )
( )
/
/
r16
r17
( )
( )
10.4.3.2( scroll up) (
scroll down)
origin
(video_mem_start) video_mem_end
(video_mem_end)
(video_mem_start)
origin(video_mem_end)
(video_mem_start) 10-8(a) (b)
10.4.3.3( ) ( )
ANSILinux console.c keyboard.s
console.cROM ASCII
1.ANSI American National Standards Institute ISO International
Organization for Strndardization 8 7 ANSIISO ANSI X3.4-1977 ISO 646-1977
ASCII ANSI X3.41-1974 ISO 2022.2 7 8ANSI X3.32 ANSI X3.64-1979 ASCII
Linux 0.1x DEC Compaq HP VT100VT102 7
82. ASCII 7 8 7 128 10-7
7 4 3 4 1 'A' 80101 65 0x41
1 2 Control characters
Graphic characters
DEL 0x7F 0x20ANSI
ANSI CR Carriage Return FF Form Feed CANCancel 7 8 10-7 8
7
0 1 2 3 4 5 6 7 8 9 A B C D E F
0 NUL DLE SP 0 @ P ` p
1 SOH DC1 ! 1 A Q a q
2 STX DC2 " 2 B R b r
3 ETX DC3 # 3 C S c s
4 EOT DC4 $ 4 D T d t IND
5 ENQ NAK % 5 E U e u NEL
6 ACK SYN & 6 F V f v SSA
7 BEL ETB ' 7 G W g w ESA
8 BS CAN ( 8 H X h x HTS
9 HT EM ) 9 I Y i y HTJ
A LF SUB * : J Z j z VTS
B VT ESC + ; K [ k { PLD CSI
C FF FS , < L \ l | PLU ST
D CR GS - = M ] m } RI OSC
E SO RS . > N ^ n ~ SS2 PM
F SI US / ? O _ o DE
LSS3 APC
C0 GL C1 GR
7 8
7 8 256 7 84 4 0-- 7 78 0 8-- 15 8 1
8 8 C0 C1GL Graphic Left GR Graphic Right
C0 C1 GL / GR
DEC DEC ASCII DECDEC NCR National Replacement Character
DEC3.
ANSI
ANSIANSI
C0 C1 C0C1 8 Linux
VT100 C0Escape Sequences Control Sequences
Device Control Strings ANSIANSI ANSI
4.Escape Seguences
C0 ESC 0x1b ASCII ANSI
ESC ANSI Escape Sequence Introducer ESC
Intermediate Characters ESC 0x20 -- 0x2f ASCII 2
Final Character ESC 0x30 -- 0x7e ASCII 3 -- 7
ANSI 0x40 -- 0x7e ASCII4 -- 7 0x30 -- 0x3f ASCII
3 G0 ASCII
7 7 8
7 ANSI 27 C1 7
C1 CSI IND 7
2 8C1 2 C1 0x40 64
ESC 2 0x40 2 0x40 -- 0x5f8
5.Control Sequences CSI 0x9b 1 ASCII
ANSI
Control Sequence Introducer C1 CSI 0x9b CSI7 'ESC [' 2 '['
CSIParameter Characters CSI 0x30 -- 0x3f ASCII 3
'< = > ?' 0x3c -- 0x3f
Pn 0 -- 9 Ps ';' 0x3b
Intermediate Characters CSI 0x20 -- 0x2f ASCII 2
Final Character CSI 0x40 -- 0x7e ASCII 4 -- 7
ANSI 0x40 -- 0x6f ASCII4 -- 6 0x70 -- 0x7e ASCII
7 5 9
10-9 ESC [ 0;4;7m
6.
ASCII
C0 C1C0 C1
Linux 0.1x console.c
10.5 serial.c
10.5.1rs_init()
rs_write()
rs_write() /dev/tty64sys_write() fs/read_write.c
rw_char() fs/char_dev.crw_tty()
rs_write() rs_write() UART
rs_io.s
10.5.210-4 linux/kernel/chr_drv/serial.c
10.5.310.5.3.1 UART
10-100
5--8 1 1 1.5 2
1 MARK 0 SPACE
MARK 1
1. UARTPC 2 RS-232C /
UART Universal Asyncronous Receiver/Transmitter PC25 9 DB-25 DB-9 MODEM
RS-232C MODEM RS-232C MODEMUART
PC NS8250 NS16450 UART PC16650A NS8250/16450 NS8250/16450 16650A16650A FIFO UART 16
CPU Linux 0.11NS8250/16450 FIFO PC UART 10-11 3
D7 -- D0 A0 -- A2 CPU DISTR DOSTRMR INTRPT / OUT2
OUT2 1 UART
UART RS-232 /MODEM SOUT SIN
DSR MODEM UARTDTR MODEM
RTS MODEM CTS MODEMDCD MODEM
RI MODEMUART UART XTAL1 XTAL2
XTAL1 PCXTAL1 1.8432MHz UART 16 BAUDOUT
RCLK PC8259A UART
UART UART 10-12
NS8250 CPU 10 A2--A08 NS8250 7
LSB MSB 7 DLAB Divisor Latch Access Bit10-8
/
0x3f8 (0x2f8) DLAB=0 THR
DLAB=0 RBR
/ DLAB=1 / LSB
0x3f9 (0x2f9) / DLAB=1 / MSB
/ DLAB=0
/ IER
7-4 0
3=1 modem
2=1
1=1
0=1
0x3fa (0x2fa)
IIR 4
7-3 0
2-1
= 11
= 10 2
= 01 3
= 00 MODEM 4 MODEM
0=0 =1
0x3fb (0x2fb)
LCR
7=1 (DLAB)
= 0
6=1
5=1
4=1 =0
3=1 =0
2=1 5
1.5 6 7 8 2
= 0 1
1-0
= 00 5
= 01 6
= 10 7
= 11 8
0x3fc (0x2fc)
modem MCR
7-5 0
4=1
3=1 2 INTRPT
2=1 1 PC
1=1 RTS
0=1 DTR
0x3fd (0x2fd)
LSR
7=0
6=1
5=1
4=1
3=1
2=1
1=1
0=1
0x3fe (0x2fe)
MODEM MSR
7=1 (CD)
6=1 (RI)
5=1 (DSR)
4=1 CTS
3=1
2=1
1=1 (DSR)
0=1 (CTS)
2. UARTPC RESET NS8250 MR UART
UART UARTPC 1 port
= 0x3f8 UART INTRPT IRQ4IDT
a)LSB MSB 16
LCR 8DLAB=1 port+3 0x3fb 0x80 port 0x3f8 port+1 0x3f9
LSB MSB 2400bps
48162400
1843200162400
8432.116
UART MHz
2400pbs LSB 0x30 MSB 0DLAB
b)LCR
8 1 LCR0x03 LCR 2 11 8c) MODEM
UART MODEM UARTUART
PC ROM BIOS LinuxUART
MCR 4 UART UARTSIN SOUTUART
MODEMUART INTRPT CPU
IER UART 8259AMODEM MCR 3 OUT2 PC
INTRPT 8259A 10-11MODEM MCR 3 OUT2 UART
/ MCR 3=0 MODEMUART INTRPTIIR 8259A LSR
IIR UART MCR 1 0 MODEM UART DTR
RTSUART DTR RTS MODEM
0x0b 01011d)
IER 410-8 1
IIR 2-- 1UART IER 0 0=0
Linux 0.11 3 0x0d MODEM
tty_write() rs_write()
UART UART
3. UART Linux /
tty_io.cUART RBRUART THR
UART 4
IIRjmp_table[] 10-13
rs_io.s
IIR 0 0 = 02 1
UART 0 = 0 IIR 0 0
UART IIR0 = 1
10.6 rs_io.s
10.6.1rs232
read_qwrite_q
4 a. modem b.c. d.
read_q copy_to_cooked()secondary
write_q
include/linux/tty.htty_queue tty_struct
10-14
10.6.210-5 linux/kernel/chr_drv/rs_io.s
10.7 tty_io.c
10.7.1tty 3 read_q write_q
secondary tty_struct include/linux/tty.htail
(head)10-14
/ tty_read() tty_write()copy_to_cooked()
tty_read() tty_write() /dev/ttysys_read() fs/read_write.crw_char() fs/char_dev.c
rw_tty() tty_read() copy_to_cooked() do_tty_interrupt() termios
/ INLCR OUCLC read_qsecondary
tty_read() L_ECHOwrite_q rs_write()serial.c 53 rs_write()
copy_to_cooked()
1. 102. read_q3. CR NL termios ICRNL INLCR
INOCR ICRNL
4. IUCLC5. ICANON
a. ^U secondary
b. ^H secondaryc. ^S stopped=1d. ^Q
6. ISIG7. NL ^D secondary data 18. write_q
9. secondary 110.
include/linux/tty.h tty
ASCII
10.7.210-6 linux/kernel/chr_drv/tty_io.c
10.7.310.7.3.1 VTIME VMIN
MINTIME
MIN MINMIN MIN
TIMEtermios.h
10.8 tty_ioctl.c
10.8.1tty_ioctl()
termios tty_ioctl() fs/ioctl.c sys_ioctl()
10.8.210-7 linux/kernel/chr_drv/tty_ioctl.c
10.8.310.8.3.1
= 1.8432MHz /(16 X ) 10-9
MSB,LSB MSB,LSB
50 0x09,0x00 2304 1200 0x00,0x60 96
75 0x06,0x00 1536 1800 0x00,0x40 64
110 0x04,0x17 1047 2400 0x00,0x30 48
134.5 0x03,0x59 857 4800 0x00,0x18 24
150 0x03,0x00 768 9600 0x00,0x1c 12
200 0x02,0x40 576 19200 0x00,0x06 6
300 0x01,0x80 384 38400 0x00,0x03 3
600 0x00,0xc0 192
11 (math)
11-1
11-1 linux/kernel/math
11.1 Makefile
11.1.1 math
11.1.211-1 linux/kernel/math/Makefile
11.2 math-emulation.c
11.2.1
C math_emulate()
11.2.211-2 linux/kernel/math/math_emulate.c
12 (fs)
linux Linux 0.11Linus Andrew S.Tanenbaum MINIX
1.0 MINIX MINIXM.J.Bach UNIX
12-1 linux/fs
12.1
2 Linux 2-28 fs
buffer.ci
MINIX
12.1.1 MINIXMINIX 2.0 2.0 1.5
linux MINIX 1.0 1.0
MINIX UNIX 6 360K12-1
1KB 360MINIX 1.0
1KB 360KB 360
ROM BIOS
MINIX1
12-2 4 FAT32 NTFS MINIXEXT2
kernel/blk_drv/hd.c
12-3s_ninodes i s_nzones s_imap_blocks
s_zmap_blocks i s_firstdatazone
s_log_zone_size 2MINIX 1.0 0 1KB s_max_size
s_magicMINIX 1.0 0x137f
Linux 0.11 super_block[]8 Linux 0.11 8 super.c mount_root()
read_super() put_super()
1 01
00 1
8 s_zmap[8]1024 8192 8
65536 MINIX 1.0 64MB i i i 1K
8192 i ii 0 i 1 0 i
0 i 0 1i 8191 i
i ii id(uid) id gid
32 12-4
i_mode 15-12 11-98-0 12-5 include/sys/stat.h
20—50 include/fcntl.h
ii i_zone[] i_zone[] i
i_zone[0] i_zone[6] 77K i
i_zone[7] MINIX 512512 i_zone[8]
512*512 12-6/dev/
0 i izone[0]
i i 0 i i0 i 0 i 0
PC 512 MINIX2 1024
02 1 2 4 8
linux
12.1.212.1.2.1 UNIX 6 shell "ls -l"
12-7
'-''-'
'd' UNIX
's'
'p''c' tty
'b' UNIX/dev
linux i i_mode 4S_ISBLK S_ISDIR include/sys/stat.h
'rwx''755'
/ / linux 0.11i i_mode 9 mode
include/fcntl.h' ' ' '
' '12.1.2.2 Linux 0.11 MINIX 1.0 UNIX
include/linux/fs.hroot/
root/ i 1 i
-rwxr-xr-x 1 ftpadm ftp 479 10 26 17:28 README
14 2 i1024/16=64 i i
ii
i i12-8 /usr/bin/vi i
i 1 i 1 usr/usr i i /usr
bin /usr/bin i /usr/binvi /usr/bin/vi i
i i
12-9i
i ii i
ii i_nlinks i
2 i 0i
ii
'.' '..' '.'i '..' i
../kernel/Makefile'..' i
i2 '..'
mydir12-10
i 56 mydir i 123mydir '.' i 123 '..' i 56
i 2+
12.1.2.3Linux 0.11 bochs Linux 0.11
'.' '..' hexdump '.' '..'
'hexdump .' 1 ii 14 i 0
'.' '..' i 1
etc/ etc/ hexdump etc/
etc/ i'.' i etc/ i 4 '..' i etc/ i 1
12.1.3
I/O CPUbuffer cache
linux2-5
Linux buffer.cbread() breada()
bread_page() 4
12.1.45
bitmap.c i ifree_inode() new_inode() free_block() new_block()
truncate.c 0 truncate() i0
inode.c i iget() i iput() ibmap()
namei.c namei() iget() iput() bmap()i
super.c get_super() put_super() free_super()/ sys_mount()
12-11
12.1.55 12-12 block_dev.c file_dev.c
char_dev.c pipe.c read_write.c 4read_write.c read() write()
block_dev.c block_read() block_write()
file_dev.c file_read() file_write() i
pipe.c read_pipe() write_pipe()pipe()
openpipe() read() write() close() pipe
i i
read() write() char_dev.c rw_char()tty (ttyx)
file file_table[] i inode_table[]include/linux/fs.h file
i i f_modei i_mode f_flags open()
flag include/fcntl.h
file f_count if_inode i ilinux 0.11 64 64
filp[NR_OPEN]NR_OPEN = 20 20
filp[0] 0
i inode_table[NR_INODE] i NR_INODE = 3232 i
i 12-13 01
12.1.612-14 5
open.croot
exec.c shelldo_execve() (int 0x80) __NR_execve() C exec()
fcntl.c fcntl() dup() dup2() dup2()dup() /
ioctl.c / ioctl() tty_ioctl() I/O stat.c stat() fstat() stat() fstat()
( )
12.1.7 360KB12-1 Linux 0.11 360KB
MINIX 1.0 hello.cbochs
2 mkfs MINIX120 i 360
8 1024 268966912mount MINIX /mnt
hello.c MINIXbochs 2 diskb.img
Linux 0.11 hexdumpbochs UltraEdit
/dev/fd1 hexdump
12-1 MINIX 1.0 10 0x0000 - 0x03ff 1KB
mkfs
1 0x0400 - 0x07ff 1KB MINIX 12-312–1 18
ing 0 MINIX
s_ninodes i 0x0078 = 120
s_nzones 0x0168 = 360
s_imap_blocks i 0x0001
s_zmap_blocks 0x0001
s_firstdatazone 0x0008
s_log_zone_size Log2 / 0x0000
s_max_size 0x10081c00 = 268966912
s_magic 0x137f
2 0x0800 - 0x0bff 1KB i 120 i1 i 1KB 120/8 = 15
0 i 1mkfs 1
2 1 0x07 0b0000111 i 31 0 2 3
1 i 2 i i 2 i1 i 2 i hello.c
i3 0x0c00 - 0x0fff 1KB 360KB
360 360/8 = 451 + 1 + 1i + 1 + 4i
= 8 360 - 8 = 352 440 353 45 0xfe 1
0nr
block nr + 8 -1 block = nr + s_firstdatazone - 1 blocknr nr = block - s_firstdatazone +1
i 1 3 1 0 23 2 11 1 i 2 2 2
i ii i i 4--7
4--7 0x1000 - 0x1fff 4KB 4 i 120i i 32 12-4 120 x 32 = 3840 4
32 1 i 322 i 12–2 12–3
i
i_mode 0x41ed drwxr-xr-x
i_uid id 0x0000
i_size 0x00000030 48
i_mtime 0x421cc200 Feb 23 17:48
i_gid id 0x00
i_nlinks 0x02
i_zone[9] zone[0] = 0x0008 0
i
i_mode 0x8180 -rw-------
i_uid id 0x0000
i_size 0x0000004a 74
i_mtime 0x421cc200 Feb 23 17:48
i_gid id 0x00
i_nlinks 0x01
i_zone[9] zone[0] = 0x0009 0
1 i 1 8 1
30 16 0x10 3 0x302
2 i 1 2 974 hello.c
8 0x2000 - 0x23ff 1KB 1 i 48 312–4
1 0x0001 0x2e .
2 0x0001 0x2e,0x2e ..
3 0x0002 0x68,0x65,0x6c,0x6c,0x6f,0x2e,0x63 hello.c
9 0x2400 - 0x27ff 1KB hello.c 74
12.2 Makefile
12.2.1 makefile make
12.2.212-1 linux/fs/Makefile
12.3 buffer.c
fs/ 241 buffer.c
12.3.1 buffer.c ( )
12-15
end end ldsystem ld end
data_start + datasize + bss_size bss 1etext edata 1
11024
hash12-16
1024 buffer_headinclude/linux/fs.h 68
buffer_head 12-17 free_list
b_prev_free
b_lockblk_drv/ll_rw_block.c
b_count buffer
0 b_count = 0 b_count = 0free
hash b_count 1 b_count++b_count 1
b_count-- b_lockb_lock b_count 0
b_dirtb_uptodate
0 b_dirt = 1b_uptodate = 0 b_uptodate = 1
b_dirt b_uptodate 1
devblock bread() bread_page() breada()
getblk()brelse()
12-18
buffer.c307 buffer_head hash Hash
hash ( ^ ) Mod 30712-17 b_prev b_next hash hash
Unix 3 hash12-19
hashfree_list
LRU Least Recently Usedgetblk()
getblk()get_hash_table() hash
getblk()
hash hash hash
getblk()1
hash
LRUgetblk() 12-20
free_listhash
free_list
hashfree_list
b_dirt b_lock 0b_dirt b_lock
b_dirtb_lock 0 getblk()
getblk()bread()
ll_rw_block()
NULL 12-21 bread() breada()bread_page() bread()
brelse()
=0
bread() ll_rw_block()bread()
ll_rw_block()12-22
Synchronizationsync_inodes i inode_table i
1. 2. sync_inodes()
sync_inodes() isync_indes()
inode
12.3.212-2 linux/fs/buffer.c
12.4 bitmap.c
25 super.c bitmap.c truncate.c inode.c namei.c super.c bitmap.c
i truncate.c 0 truncate() inode.ci namei.c
i
super.c /inode.c
12.4.1i
i free_inode() new_inode() free_block()new_block()
free_block() dev block blockdev
blockblock
1 ( )
new_block() dev blockdev 0
0 1 0 1
free_inode() i i new_inode()dev i i i i
i i
12.4.2 12-3 linux/fs/bitmap.c
12.5 truncate.c
12.5.1i
0 i12-23
12.5.212-4 linux/fs/truncate.c
12.6 inode.c
12.6.1i iget() iput() bmap() iget()
iput() bmap() namei.c i namei() iget() dev nr i i_count 1
12-24 dev i ii nr i i i
ii
i i 1 i
i i
ii i i 1
ii i
i ii i i i
i i iput() iget() i 1
i i i i0 i i i i_count
1 i 1 ii_count=0 iget()
i iput() ii_count
iput()i i_count 1
namei() dir_namei() open_namei()iget() new_inode() get_empty_inode()
ipwd root executalbe
i i iiput()
i pwd i rootexecutable iput()
_bmap() inode iblock create
create=0 bmap() create=1 create_block()i
i _bmap() ii_zone[] i_zone[]
12-6 i_zone[0] i_zone[6]i_zone[7] i_zone[8]
7K i 77K+512K i_zone[7]
i_zone[8] linux
12.6.2 12-5 linux/fs/inode.c
12.6.3
12.7 super.c
12.7.1
get_super() put_super() read_super() 2 /sys_umount() sys_mount() mount_root()
buffer.c12-3
get_super()mount
NULL put_super() i
super_block[] umount()
read_super()i
sys_umount() sys_mount()
mount_root()12-25
file_table[]i
mount_root() main.c 0 1init() setup() setup()
/kernel/blk_drv/hd.c 71
12.7.2 12-6 linux/fs/super.c
12.8 namei.c
12.8.1Linux 0.11 700
i namei()
Linux 0.11 MINIX 1.0 UNIXinclude/linux/fs.h
root/ root/i 1
14 2 ii i
i i
i/usr/bin/vi i i 1
i 1 usr /usr ii /usr bin/usr/bin i /usr/bin vi
/usr/bin/vi i i i
'.' '..' '.'
i '..' i../kernel/Makefile
'..' i
12.8.2 12-7 linux/fs/namei.c
12.9 file_table.c
12.9.1
12.9.2 12-8 linux/fs/file_table.c
12.10 block_dev.c
3 5 block_dev.c char_dev.c pipe.c file_dev.cread_write.c 4 read_write.c read_write.c
sys_write() sys_read() 5” 12-26 sys_write()
sys_read()/
12.10.1 block_dev.c block_read() block_write()
, read() write()
block_write()pos bread()
breada()chars
offset 0 12-27
block_read() block_write()
12.10.2 12-9 linux/fs/block_dev.c
12.11 file_dev.c
12.11.1file_read() file_write() read() write()
block_dev.ci i
file
/dev/fd0
12.11.2 12-10 linux/fs/file_dev.c
12.12 pipe.c
12.12.1read_pipe() write_pipe()
sys_pipe() read() write()read_write.c
i 4KBi i_size i_zone[0]
i_zone[1]
12-28
read_pipe()
write_pipe()
sys_pipe()
i
PIPE_HEAD() PIPE_TAIL()include/linux/fs.h 57--64
12.12.212-11 linux/fs/pipe.c
12.13 char_dev.c
12.13.1 char_dev.c rw_ttyx() rw_tty() rw_memory() rw_char()
rw_ttyx() 4 tty
rw_tty() 5 rw_ttyx()
rw_memory() 1 linux 0.110 1 2 0.96 1 2
rw_char()open() read()
12.13.2 12-12 linux/fs/char_dev.c
12.14 read_write.c
12.14.1read() write() lseek() read() write()
4 4 lseek()
read() ipipe.c char_dev.c rw_char()
block_dev.cfile_dev.c file_read() write() read()
lseek()
12.14.2 12-13 linux/fs/read_write.c
12.14.3
Linux System Calls libc.a
bsd
Linux
Linux
open file
file escriptor MS-DOS file handle
read write read write
int read(int fd, char *buf, int n); int write(int fd, char *buf, int n);
0 -1
_syscall3() unistd.h 172
__NR_read 3 Linux 0x80 eax__res 0
errno -1Linux read_write.c
read_write.c 55 sys_read() sys_read()
int sys_read(unsigned int fd, char *buf, int count)
0
buf buf
i
read_pipe() fs/pipe.crw_char() fs/char_dev.c
block_read() fs/block_dev.cfs/buffer.c bread()
ll_rw_block()file_read() fs/file_read.c
ll_rw_block() file_read()
read()0 errno
-1 read() 12-29
12.15 open.c
45 open.c exec.c stat.c fcntl.c ioctl.c
open.c exec.c execve() stat.cfcntl.c ioctl.c
12.15.1
root
12.15.2 12-14 linux/fs/open.c
12.16 exec.c
12.16.1shell
do_execve() int 0x80 __NR_execve() C exec()5 exec
fork() exec()
execve()
-- (NULl) i
-- iShell #! Shell
Shell
-- i
execve()
execve() fork()
Load on demandID
IDclose on exec linux/fs/fcntl.c
close_on_execclose_on_exec execve()
fcntl() execve
ls -l /home/john/
shell /bin/ls /bin/ls ls-l /home/john/ C main()
int main(int argc, char *argv[])
argc argument countargv -- argument vector argvargv[0] argc 1 argc=3
argv[0] argv[1] argv[2] 'ls' '-l' '/home/john/' argv[3] = NULL 12-30
main() enviroment variableNULL
main()
int main(int argc, char *argv[], char *envp[])
VAR_NAME=somevalue
VAR_NAMEshell set
execve()MAX_ARG_PAGES 128kB
128kB(128kB-4 ) p 12-31
p copy_string()copy_string()
copy_string() 333 p12-32 p'
64MB (128KB - p) p' create_tables()p'
sp
create_tables() p argcenvc
sp 12-33
do_execve() 344 345 eipesp
CPU 12-3464MB
start_code CPU
12.16.2 12-15 linux/fs/exec.c
12.16.312.16.3.1 a.out Linux 0.11 a.out(Assembley & link editor output)
ELF Executable and Link Formata.out
<a.out.h>
(exec header)
(ld)(text segment)
(data segment)
(text relocations)
(data relocations)
(simbol table)
(string table)
exec structure
a_midmag - N_GETFLAG() N_GETMID N_GETMAGIC()N_GETMID() (machine-id)
N_GETMAGIC()
OMAGIC -
NMAGIC - OMAGIC
ZMAGIC -
a_text - a_data - a_bss - bss break brk
a_syms - a_entry - a_trsize - a_drsize -
a.out.h exec
N_BADMAG(exec) a_magicN_TXTOFF(exec) N_DATOFF(exec) N_DRELOFF(exec) N_TRELOFF(exec) N_SYMOFF(exec) N_STROFF(exec)
(relocation_info)
r_address -
r_symbolnum - r_extern 0
r_pcrel - pc
r_length - 2 0 1 1 2 2 4 r_extern -
0r_baserel r_symbolnum
n_type r_baserel - r_symbolnum (Global Offset Table) r_jmptable - r_symbolnum (Procedure Linkage Table) r_relative -
r_copy - r_address
nlist
n_un.n_strx - nlist()n_un.n_name
n_type - (bitmasks) n_typeN_EXT
N_TYPEN_UNDF -
n_typeBSS n_value
N_ABS - N_TEXT -
N_DATA - N_TEXT
N_BSS - BSSN_FN -
N_STAB - ( gdb) stab() n_other - n_type n_other
4 AUX_FUNC AUX_OBJECT <link.h> AUX_FUNCAUX_OBJECT
ld n_desc -
n_value - BSS
u_int32_t null32 1 4
12.17 stat.c
12.17.1stat() fstat()
stat() fstat() ( )
12.17.2 12-16 linux/fs/stat.c
12.18 fcntl.c
12.18.1
fcntl.c fcntl() dup() dup2()dup2() dup() fcntl()
/include/fcntl.h
dup() dup2()dup() dup2() 3
12-35
dupfd() dup() dup2()close_on_exec exec() dup()
AT&T III fcntl()cmd 4
cmd = F_DUPFD fcntl() 3
dup(fd) fcntl(fd,F_DUPFD,0) dup2(fd,newfd)close(newfd); fcntl(fd,F_DUPFD,newfd);
cmd = F_GETFD F_SETFD close_on_exec3
cmd = F_GETFL F_SETFL RDONLYO_WRONLY O_RDWR O_APPEND O_NONBLOCK include/fcntl.h
3 O_APPENDO_NONBLOCK
cmd = F_GETLK F_SETLK F_SETLKW Linux 0.11
12.18.2 12-17 linux/fs/fcntl.c
12.19 ioctl.c
12.19.1 ioctl.c / ioctl() ioctl() ioctl
IO ttytty_ioctl() I/O POSIX.1 termios
tty include/termios.h tcflow()libc.a ioctl()
12.19.2 12-18 linux/fs/ioctl.c
13 (mm)
Intel 80x86 Linux
4KLinux 0.11 13-1
13-1
page.s int 14memory.c
13.1
Intel 80X86 CPU
—CPU 32Linux
13.1.1Intel 80x86 13-1
13-44 4
10241024 80386 1024 X 1024 X
4096 = 4G Linux 0.1116MB 4 4 4
head.s 109--12516MB 16MB
32
13-2
31-22 10 21-1212
13-2
13-30 4
CPU CR3 Linux
13-1 4G
13-4
(PAGE FRAME ADDRESS) 4K12 0 12
PRESENT – P P=1P=0
CPU P=0
Accessed – A Dirty – D
D DirtyCPU
/ Read/Write – R/W / User/Supervisor – U/SCPU
13.1.2 LinuxLinux Linux 0.11
Linux 0.11 16M 16MB80x86 Linux end
4M ROM BIOSRAM
13-5
Linux head.s head.s0 4 4
0 0
fork()
page.s int 14memory.c do_no_page() do_wp_page() do_no_page()
do_wp_page() copy on write
13.1.3 Linux
5-12
nr*64MB nr64MB 128K
bss bss
13.1.4PG=1 CPU
int 14P 0
CPUerror code 32 3
U/S W/R P0 P P=0 P=1
1 W/R W/R=0 W/R=1
2 U/S CPU U/S=0 CPUU/S=1 CPU
CR2 CPU CR2
page.s
memory.c do_no_page() do_wp_page()
13.1.5 copy on write
A fock BB A
fork() B AA memory.c copy_page_tables()
A B(page_fault int14) CPU do_wp_page()
do_wp_page() un_wp_page() ,A B
( )CPU
-> -> ->
verify_area()write_verify()
Linux 0.11 <1MB fork()0 idle 1 init
1 1
fork() execve()
13.1.6 Load on demandexecve() CPU 4G
64MB
CPU
CPU
CPU
Load on demanddemand-paging
execve()I/O
ZMAGIC
13.2 Makefile
13.2.1mm make
13.2.213-1 linux/mm/Makefile
13.3 memory.c
13.3.1
1MB mem_map[]0
11MB
PAGING_PAGES mem_map[] 100 mem_map[]1MB
mem_map[]13-5 16MB 512KB mem_map[]
(16MB - 1MB)/4KB = 3840 3840 (16MB-4.5MB)/4KB = 2944 mem_map[] 2944 896 1MB
mem_map[] 896 1002944 0 13-7
get_free_page() free_page()
get_free_page()mem_map[] 0 0
0 1
free_page() <1M1M
: (addr - 1M)/4K mem_map[]0 0 1 “ ”
free_page_tables() copy_page_tables() 4M
free_page_tables()4M =0“ ”
sizesize
copy_page_tables()
4Mbfrom_dir, to_dir
mem_map[]1
put_page()1M
P=1
do_wp_page() mm/page.sCopy
on Writedo_no_page()
+1
get_empty_page() get_free_page()put_page()
13.3.2 13-2 linux/mm/memory.c
13.4 page.s
13.4.114
do_no_page(error_code, address)do_wp_page(error_code, address) (error_code) CPU
CR2 CR2
13.4.2 13-3 linux/mm/page.s
13.4.313.4.3.1
14 o CPU Present 0 o
CPU(1)
CPU 323
2(U/S) - 0 11(W/R) - 0 10(P) - 0 1
(2) CR2( 2) CPU CR2
CR2
14 (include)
header filemacros #include
filename # include <filename>
filename > " ' \ /* filename
# include "filename"filename
" ' \ /* >
/usr/include/libc.a
linker
C 15I/O Plauger
The Standard C Library
blk.h Linux 0.11 include/ Linux 0.11 /usr/include/ tools/build.c
0.95 /usr/include/linux
14.1 include/
include/ 11.1Linus C
CLinux
Linus CLinux 14-1
asm/ linux/ sys/ C/usr/include
asm/ Intel CPU IO io.h system.h linux/ Linux
sched.h mm.htty.h sys/ 0.98
sys/ linux/ Linux 0.11 32 (*.h) asm/ 4 linux/ 10sys/ 5 include/ 13
14-1 linux/include/
14.2 a.out.h
14.2.1Linux a.out.h fs/exec.c
C Linux/usr/include/
a.out Assembley out Linux 0.11 .o
a.out.h
1—108109—185186—217
0.96 Linux GNU a.out.h Linux 0.9xLinux 0.1x a.out
0.9x 0.1x Linux 0.11 a.out.h GNU exec a_magicGNU a_info 3 Flags Machine Type Magic Number N_MACHTYPE N_FLAGS
14-1
Linux 0.9x4
0x0b, 0x01, 0x64, 0x00
Linux 0.1x a.out4
0x0b, 0x01, 0x00, 0x00
GNU a.out Linux 0.1xLinux 0.9x a.out 3
0.1x 0.1xLinux 0.1x
GNU a.out.h a.out.h
14.2.2 14-1 linux/include/a.out.h
14.2.314.2.3.1 a.out Linux 0.11 a.out(Assembley out)
ELF Executable and Link Formata.out
a.out.hLinux 0.11a.out 7
a) exec header exec(ld)
b) text segment
c) data segmentd) text relocations
e) data relocations
f) simbol table
g) string tableexec structure
a_magic 11-1 Linux 0.11
N_MAGIC()
OMAGIC OMAGIC 0407
NMAGIC OMAGIC
ZMAGIC
ZMAGIC 0413 0x10ba_text a_data a_bss bss break brk
a_syms a_entry a_trsize a_drsize
a.out.h exec
N_BADMAG(exec) a_magic
N_TXTOFF(exec) N_DATOFF(exec) N_DRELOFF(exec) N_TRELOFF(exec) N_SYMOFF(exec) N_STROFF(exec)
(relocation_info)
r_address
r_symbolnum r_extern
0r_pcrel pc
r_length 2 0 1 1 2 2 4
r_extern 0
r_symbolnumn_type
r_pad Linux 4 0
nlist
n_un.n_strx nlist()n_un.n_name
n_type 146--154 bitmasks8 n_type 14-2 N_EXT
N_TYPEN_UNDF
n_typeBSS
n_value
N_ABS N_TEXT
N_DATA N_TEXT
N_BSS BSSN_FN
N_STAB ( gdb) stab()n_other n_typen_other 4 AUX_FUNC AUX_OBJECT<link.h> AUX_FUNC AUX_OBJECT
ldn_desc
n_value BSS
unsigned long null32 1 4
14.3 const.h
14.3.1i i_mode
14.3.214-2 linux/include/const.h
14.4 ctype.h
14.4.1C
c isdigit(c) isspace(c)lib/ctype.c ASCII
_ctype[]
__abc _SP
14.4.214-3 linux/include/ctype.h
14.5 errno.h
14.5.1C errno C C
X3J11 errno errno.h”
/
null pid -1-1 C
errno CLinux C
lib/open.c unistd.h -1errno
Linux LinusPOSIX SCO
Linux 2003 1210 Linux Linus Alan Cox H.J.Lu Mitchell Blank Jr 2.4.x errno.h 0.96c
Linus H.J.Lu Libc 2.xSCO UNIX V6 V7
14.5.2 14-4 linux/include/errno.h
14.6 fcntl.h
14.6.1fcntl()
fcntl() linux/fs/fcntl.c 47cmd
14.6.2 14-5 linux/include/fcntl.h
14.7 signal.h
14.7.1
signal() sigaction()Linux POSIX.1 20 Linux
kernel/signal.c
14.7.2 14-6 linux/include/signal.h
14.8 stdarg.h
14.8.1 C
stdarg.h stdarg.h C BSD varargs.h
stdarg.h - (va_list)(va_start, va_arg va_end) vsprintf vprintf vfprintf
kernel/vsprintf.c
14.8.214-7 linux/include/stdarg.h
14.9 stddef.h
14.9.1 stddef.h C X3J11 std (def)
stdlib.h stdlib.h
C CC C C
4 float.h limits.h stdarg.h stddef.h stddef.h
float.hlimits.h stdarg.h
stddef.hNULL 4
stddef.h NULL undef 14C
Linux 0.11
14.9.2 14-8 linux/include/stddef.h
14.10 string.h
14.10.1
NULL SIZE_TC C
string.h Linus'extern' 'inline'
lib/lib/string.c string.c 'extern' 'inline' string.h
string.c string.h
14.10.214-9 linux/include/string.h
14.11 termios.h
14.11.1I/O termios
idLinux POSIX
termio termios UNIX termioAT&T V termios POSIX termio
termiossgtty
14.11.214-10 linux/include/termios.h
14.11.314.11.3.1 TIME MIN
MINTIMEDE MIN TIME 1/10
MIN > 0 TIME > 0TIME 1
MIN TIME
MIN MINTIME
( ) (MIN > 0 TIME > 0) 1 MIN TIME
MIN > 0 TIME = 0TIME 0 MIN
MIN ( MIN )IO
MIN = 0 TIME > 0MIN=0 TIME
( )TIME*0.10 0
MIN = 0 TIME = 0
MINTIME
MIN TIMEMIN MIN TIME
14.12 time.h
14.12.1 time.h MINIX
GMT UTCUssher(1581-1656 ) 4004 10 12 9UNIX GMT 1970 1 1 ( )
C UNIXUNIX UNIX C
1 4Linux 0.11 init/main.c kernel/mktime.c tmCMOS
1970 1 1 0 startup_time
C
14.12.214-11 linux/include/time.h
14.13 unistd.h
14.13.1
__LIBRARY__ _syscall0()
14.13.214-12 linux/include/unistd.h
14.14 utime.h
14.14.1utimbuf{} utime()
14.14.214-13 linux/include/utime.h
14.15 include/asm/
14-2 linux/include/asm/
14.16 io.h
14.16.1IO outb() inb() outb_p() inb_p()
jmp
14.16.214-14 linux/include/asm/io.h
14.17 memory.h
14.17.1memcpy() string.h memcpy()
C
14.17.214-15 linux/include/asm/memory.h
14.18 segment.h
14.18.1Intel CPU Linux
ds esGDT ( 0x10) ds es fs
LDT 0x17 fs system_call.s89--93
get_fs_byte() put_fs_byte()
14.18.214-16 linux/include/asm/segment.h
14.19 system.h
14.19.1/ move_to_user_mode()
0 03 iret
CPU 0 14-3
CPU CPU 3
IRET0
0 iret11.2 esp esp1 0 iret 0
0 3 ss:esp iret espesp0 iret CPU
NT sched_init() NT iret CPU0
031
0 0640K SS ESP
IDT _set_gate()set_intr_gate() set_trap_gate() set_system_gate()
IDT Interrupt Gate Trap Gate 14-4
P DPL EFLAGSIF IF
IRET IFIF
_set_gate(gate_addr,type,dpl,addr) gate_addrtype 14-4 6 4
type=14 0x0E type=15 0x0F dplDPL addr 32
0x0008 eax system.h GDT
14.19.214-17 linux/include/asm/system.h
14.20 include/linux/
14-3 linux/include/linux/
14.21 config.h
14.21.1HD_TYPE
14.21.214-18 linux/include/linux/config.h
14.22 fdreg.h
14.22.1I/O
(FDC)
4 1.2M 14–1
I/O
0x3f2
0x3f4
0x3f5 /
( )
FDC
FDC
0x3f7
0x3f7 ( )
8 /FDC / DMA
FDC 8 FDC FDDCPU FDC FDC
FDC FDC
0x3f5 DIO0 CPU FDC FDC
7
15CPU FDC
0--8 FDC CPUFDC CPU FDC FDC
DMA 1 DMA DMA FDCDMA FDC
FDC CPU CPU FDCFDC 0--7
FDC
14.22.214-19 linux/include/linux/fdreg.h
14.23 fs.h
14.23.1 fs.hMINIX 1.0 i
14.23.214-20 linux/include/linux/fs.h
14.24 hdreg.h
14.24.1
14.24.214-21 linux/include/linux/hdreg.h
14.24.314.24.3.1
1--44 16
14–2 0 0 10x1BE--0x1FD
0x00 boot_ind 4
0x00- 0x80-
0x01 head
0x02 sector ( 0-5) 2 ( 6-7)
0x03 cyl 8
0x04 sys_ind 0x0b-DOS; 0x80-Old Minix; 0x83-Linux …
0x05 end_head
0x06 end_sector ( 0-5) 2 ( 6-7)
0x07 end_cyl 8
0x08--0x0b start_sect
0x0c--0x0f nr_sects
14.25 head.h
14.25.1 head Intel CPU
14.25.214-22 linux/include/linux/head.h
14.26 kernel.h
14.26.1
14.26.214-23 linux/include/linux/kernel.h
14.27 mm.h
14.27.1 mm.h
14.27.214-24 linux/include/linux/mm.h
14.28 sched.h
14.28.1task_struct 0
switch_to()switch_to(n) 171 'struct {long a,b;} __tmp'
8 TSSTSS
__tmp 4 __tmp
%ecx current currentecx
__tmp ljmp TSS __tmp CPUTSS
__tmp 5 2-22ljmp TSS CPU
ljmp ecx
clts CR0 TS CPULinux TS
14.28.214-25 linux/include/linux/sched.h
14.29 sys.h
14.29.1 sys.h
14.29.214-26 linux/include/linux/sys.h
14.30 tty.h
14.30.1
14.30.214-27 linux/include/linux/tty.h
14.31 include/sys/
14-4 linux/include/sys/
14.32 stat.h
14.32.1stat()
14.32.214-28 linux/include/sys/stat.h
14.33 times.h
14.33.1tms times() time_t
sys/types.h times()
14.33.214-29 linux/include/sys/times.h
14.34 types.h
14.34.1 types.h size_t
off_t pid_t
14.34.214-30 linux/include/sys/types.h
14.35 utsname.h
14.35.1 utsname.h utsname uname()utsname POSIX
null utsname9 utsname Unix Timesharing System name
14.35.214-31 linux/include/sys/utsname.h
14.36 wait.h
14.36.1wait() waitpid()
14.36.214-32 linux/include/sys/wait.h
15 (lib)
c library Linuxc
_exit() close() dup() open()write() execve() malloc() wait()
setsid() include/string.hTytso malloc.c
15-1 /linux/lib/
Makefile .o lib.alibc.a libufc.a
init/main.c init()
ar archive – 3 a.o b.o c.olibmine.a
ar -rc libmine.a a.o b.o c.o d.o dup.o
ar -rs dup.o
15.1 Makefile
15.1.1Makefile
15.1.215-1 linux/lib/Makefile
15.2 _exit.c
15.2.1
15.2.215-2 linux/lib/_exit.c
15.2.3include/unistd.h
15.3 close.c
15.3.1 close.c close()
15.3.215-3 linux/lib/close.c
15.4 ctype.c
15.4.1ctype.h
15.4.215-4 linux/lib/ctype.c
15.5 dup.c
15.5.1dup()
lseek()(close-on-exec)
15.5.215-5 linux/lib/dup.c
15.6 errno.c
15.6.1errno include/errno.h
15.6.215-6 linux/lib/errno.c
15.7 execve.c
15.7.1
15.7.215-7 linux/lib/execve.c
15.8 malloc.c
15.8.1malloc() malloc()
0.98 kmalloc() free_s() kfree_s()
GCC libc.aget_free_page()
libc.a
brk() kernel/sys.c 168malloc() calloc()
brk()
malloc() (bucket)( ) ( ) 32 32
1615-1 4096
malloc() ( )15-2
free_bucket_desc
free_bucket_desc NULL153
malloc()1.
2.freeptr NULL
a. NULL malloc()init_bucket_desc()
b. 0page
freeptrc.
NULLd.
3. freeptr freeptr1
free_s()( )
freeptr 1
15.8.215-8 linux/lib/malloc.c
15.9 open.c
15.9.1 open()
exec
flag 0_RDONLY O_WRONLY O_RDWR( fs/open.c 138 )
15.9.215-9 linux/lib/open.c
15.10 setsid.c
15.10.1setsid()
idid PID( )
15.10.215-10 linux/lib/setsid.c
15.11 string.c
15.11.1string.h 'extern' 'inline'
string.h string.c include/string.h
15.11.215-11 linux/lib/string.c
15.12 wait.c
15.12.1waitpid() wait()
wait()
waitpid() pid
pid= -1 options=0 waitpid() wait() pid optionskernel/exit.c,142
15.12.215-12 linux/lib/wait.c
15.13 write.c
15.13.1write() count
buf
15.13.215-13 linux/lib/write.c
16 (tools)
Linux tools build.clinux/ Makefile
Image boot/ bootsect.s setup.s 8086GNU gcc/gas
system build Image/ 16-1
16.1 build.c
16.1.1linux/Makefile 42 build
tools/build boot/bootsect boot/setup tools/system $(ROOT_DEV) > Image
build 4 bootsect setup systembootsect setup as86 ld86 MINIX
system GNU a.outbuild bootsect setup MINIX
system a.outImage
stat
bootsect minix512 0xAA55 508,509
512 stdout Make Imagesetup 4 0 4
stdoutsystem GCC GCC linux
a.out 0 stdout128KB Image
1 bootsect 5122 4 2 - 5 setup 46 system build.c 35
16.1.216-1 linux/tools/build.c
16.1.316.1.3.1 Minix a.out minix 2.0 01400
MINIX a_magic[]
a_flags
MINIX exec Linux 0.11 a.out Linux a.outlinux/include/a.out.h
17
Linux 0.1x 0.11 0.12 PCLinux 0.1x PC
Linux 0.1xRedHat 9 gcc 3.x
Windows
Bochs 2.2.x PCUltraEdit WinImage DOS
Linux RedHat 9 Fedora 4Bochs Linux
Linux 0.1x PC PC 3VMware VMware Workstation Connectix Virtual PC
Bochs 'box' 3 Intel x86
3 Bochs x86CPU
Virtual PC BochsVMware Workstation x86 VMware
Workstation I/O x86VMware
VMware 3 3http://www.osnews.com/story.php?news_id=1054
VMware Workstation Virtual PC
Bochs BochsBochs
Bochs Linux 0.11 Bochshttp://sourceforge.net/projects/bochs/ Bochs
17.1 Bochs
Bochs Intel x86 386 486 PentiumCPU Bochs PC
Bochs PCBochs
Bochs Kevin Lawton 1994 C++ Intel x86 PPCAlpha Sun MIPS Bochs x86
BochsBochs
Bochs
Bochs http://bochs.sourceforge.net BochsWindows C
'C:\Program Files\Bochs-2.2.1\'RedHat 9 Linux Bochs RPM
root Bochs Bochs X11Linux X Window Bochs Bochs
Bochs Linux dlx BochsBochs Linux Bochs SLS Linux
sls-0.99pl.tar.bz2 Linux 0.1xSLS Linux
www.oldlinux.org http://oldlinux.org/Linux.old/bochs/sls-1.0.zipbochsrc.bxrc 12 Bochs SLS Linux
Bochs Bochs Bochs
17.1.1 BochsBochs
bochsbios 'BIOS-bochs-latest'vga bios 'VGABIOS-lgpl-latest'
CDROM
Bochs .bxrc Sample.bxrcBochs
17.1.2 *.bxrc Bochs
Bochs2.1 Bochs '.bxrc'
Bochs 'bochsrc-0.11.bxrc' Bochs
'bochsrc-sample.txt'
1. megs 32MB 128MB
2. floppya floppyb floppya floppyb floppya
BochsLinux Windows status
ejected inserted
3. ata0 ata1 ata2 ata3 4 4 ATA IO
ata0
4. ata0-master ata0-slave ata0-master 1 ATA 0 1 ATA CDROM
ata0-slave 1 2 ATA17–1
ata0-master: type=disk, path=hd.img, mode=flat, cylinders=306, heads=4, spt=17, translation=none
ata1-master: type=disk, path=2G.cow, mode=vmware3, cylinders=5242, heads=16, spt=50, translation=echs
ata1-slave: type=disk, path=3G.img, mode=sparse, cylinders=6541, heads=16, spt=63, translation=auto
ata2-master: type=disk, path=7G.img, mode=undoable, cylinders=14563, heads=16, spt=63, translation=lba
ata2-slave: type=cdrom, path=iso.sample, status=inserted
ata0-master: type=disk, path="hdc-large.img", mode=flat, cylinders=487, heads=16, spt=63
ata0-slave: type=disk, path="..\hdc-0.11.img", mode=flat, cylinders=121, heads=16, spt=63
type [disk | cdrom]
path
mode disk[flat | concat | external | dll | sparse |
vmware3 | undoable | growing | volatile ]
cylinders disk
heads disk
spt disk
status cdrom [inserted | ejected]
biosdetect bios [none | auto], ata0 disk [cmos]
translation bios (int13), disk
[none | lba | large | rechs | auto]
model ATA
ATA type disk cdrompath CDROM iso CDROM
Linux Bochs windows
disk path cylinders heads spt cdrompath
int13 bios DOSnone 528MB 1032192large 4.2GB 8257536rechs 15 7.9GB 15482880
lba lba- 8.4GB 16450560auto
modeflatconcatexternal C++dll DLLsparsevmware3 vmware3undoablegrowingvolatile
mode=flat, biosdetect=auto, translation=auto, model=”Generic 1234”
5. boot boot CDROM
'c' 'a'
6. ips ips Instructions Per Second Bochs IPS
IPS VGA17–2
IPS
650Mhz Athlon K-7 with Linux 2.4.x 2 to 2.5 million
400Mhz Pentium II with Linux 2.0.x 1 to 1.8 million
166Mhz 64bit Sparc with Solaris 2.x 0.75 million
200Mhz Pentium with Linux 2.x 0.5 million
7. loglog Bochs Bochs
log
17.2 Bochs Linux 0.1x
LinuxLinux
Linux bootimage root fs
bootimage rootimage
Bochs Linux 0.1xLinux 0.1x
http://oldlinux.org/Linux.old/bochs/linux-0.11-devel-050518.zip
6unzip winzip rar 150MB
17.2.1linux-0.11-devel-050518.zip linux-0.11-devel-050518
20
2 Bochs 4 Bochs 5 ImageREADME
bochs-2.2.1.i586.rpm Linux BochsBochs-2.2.pre4.exe windows Bochs Linux 0.11
Bochs Bochshttp://sourceforge.net/projects/bochs/ bochsour.txt Bochs Bochs
Bochsbochsrc-fda.bxrc Bochs Bochs A /dev/fd0Linux 0.11 A
Arootimage-0.11 bootimage-0.11
Linux 0.11bochsrc-fdb.bxrc Bochs(rootimage-0.11) B /dev/fd1
bootimage-0.11-fdLinux 0.11
bochsrc-hd.bxrc A Chdc-0.11-new.img bootimage-0.11-hd
Linux 0.11bochsrc-hdboot.bxrc hdc-0.11-new.img Linux 0.11
/usr/src/linux/Imagebootimage-0.11 Image
Linux 0.11bootimage-0.11-fd Image bootimage-0.11
512 509 510 B/dev/fd1 0x021D bootimage-0.11
bootimage-0.11-hd 509 510C 1 /dev/hd1 0x0301
bootimage-0.12-fd Linux 0.12 bootimage-0.11bootimage-0.12-hd Linux 0.12 bootimage-0.11-hddebug.bat windows Bochs Bochs
Linux BochsLinux gdb Bochs
Bochsdiska.img diskb.img DOS Linux 0.11 mcopy
bochsrc-fda.bxrc bochsrc-hd.bxrc bochsrc-hdboot.bxrc Linux 0.11B diskb.img
gcclib-1.4.0.taz Linux 0.11 GNU gcc 1.40/ gcc
hdc-0.11-new.img 1 MINIX1.0 2 MINIX 1.0
mountrootimage-0.11 bochsrc-fda.bxrc bochsrc-fdb.bxrcLinux 0.11SYSTEM.MAP Linux 0.11
17.2.2 Bochsbochs-2.2.1.i586.rpm RedHat Linux Bochs Bochs-2.2.pre4.exe
windows Bochs Bochs
http://sourceforge.net/projects/bochs/
Linux rpm X window 1Bochs
Windows Bochs-2.2.pre4.exe Bochsdebug.bat
Windows Bochs
17.2.3 Linux 0.1xBochs Linux 0.1x Bochs *.bxrc
PCnotepad.exe Linux 0.11
PC ROM BIOS VGA ROM 3 PC16MB Linux 0.11 16MB
floppya PC A 1.44MBbootimage-0.11 floppyb B
ata0-master PCata0-slave 2
boot: A C A(a)
1. bochsrc-fda.bxrc Linux 0.11Linux 0.11 Linux 0.11bootimage-0.11 rootimage-0.11 bochsrc-fda.bxrc
Linux 0.11 Bochs17-1 bochsrc-fda.bxrc Linux 0.11 A
bootimage-0.11 Abootiamge-0.11
A A bootimage-0.11rootimage-0.11 OK
17-2
2. bochsrc-fdb.bxrc Linux 0.11
A bootimage-0.11-fd Brootiamge-0.11 bootimage-0.11-fd 512
B bootimage-0.11-fd 509 510B 0x021D 0x1D,0x02 B
bochsrc-fdb.bxrc Linux 0.11 17-2
3. bochsrc-hd.bxrc Linux 0.11A Linux 0.11 bootimage-0.11-hd
hdc-0.11-new.img 1 bootimage-0.11-hd 509510 C 1 0x0301 0x01,0x03
C 1 bochsrc-hd.bxrc Linux 0.1117-2
4. bochsrc-hdboot.bxrc Linux 0.11bochsrc-hdboot.bxrc Linux 0.11 Linux LiLo Grub
Linux 0.11 MINIX shoelace
/usr/src/linux/Imagebochsrc-hdboot.bxrc Linux 0.11
17-3 4 '*'Bochs PC
1 Linux 0.111 Bochs Linux 0.11 17-4
Bochs /usr/src/linux/Imageshoelace /etc/config
17.3
BochsBochs
Bochs CDROMImage
Image ImageImage
ImageImage MINIX DOS
ImageLinux
Linux loopiso
17.3.1 WinImageImage DOS
mtools mtools UNIX MSDOSMSDOS copy dir cd format del md rd
m mtools1.44MB Image
diskb.img Linux 0.11 bochs.bxrc floppya
floppyb: 1_44="diskb.img", status=inserted
2 1.44MB Image diskb.imgLinux 0.11 Linux 0.11Linux 0.11 DOS mtools hello.c 2 ImageImage Bochs mformat b:
Bochs WinImage diskb.img WinImage hello.c
WinImage DOSMINIX
17.3.2 LinuxLinux RedHat 9 loop
Image mount Imagerootimage-0.11
mount -t minix MINIX -o loop loopDOS Image mount minix
msdosImage Image
mount Image Image
Image ImageImage Image
fdiskImage hdc-0.11.img 1
http://oldlinux.org/Linux.old/bochs/linux-0.11-devel-040329.zip
loop losetuploop loop loop
hdc-0.11.img loop1 fdisk
fdisk Image 1Start Image
losetup -d hdc-0.11.img loop1hdc-0.11.img 1 losetup -o
1 1 * 512 1loop1 mount
17.4
80386 Linux 0.003 A B
Bochs
http://oldlinux.org/Linux.old/bochs/linux-0.00-050613.zip http://oldlinux.org/Linux.old/bochs/linux-0.00-041217.zip
1 2head 0x10000
1 2linux-0.00-050613.zip linux-0.00
1. linux-0.00.tar.gz - 2. linux-0.00-rh9.tar.gz - 3. Image - 4. bochsrc-0.00.bxrc - Bochs5. rawrite.exe - Windows Image6. README -
1 linux-0.00.tar.gz Linux 0.1xImage 2 RedHat 9 Linux
3 Image 1.44MB 4bochsrc-0.00.bxrc Bochs Bochs PC Bochs
PC Bochsbochsrc-0.00.bxrc Image 5 DOS Windows
RAWRITE.EXEImage 1.44MB
linux-0.00-tar.gzboot.s head.s Makefile as86/ld86
boot 32 MINIX as/ld head1024 a.out Image dd
Imagemake Image make
'make clean' make
Image A 'make disk' Bochs Linux 0.11
bootimage-0.11-hd Linux 0.11
Bochs RESET4-43 Linux 0.11
17.5 Bochs
Bochs BochsBochs 14.2 Linux 0.11 Windows
Bochs
17.5.1 BochsBochs C:\Program Files\Bochs-2.1.1\ Linux 0.11
Bochs bochsrc-hd.bxrc Imagerun.bat
bochsdbg Bochs Bochs
Bochs CPU ROM BIOS 0x000fffff0'<bochs:1>' '<bochs:1>'
'help' 'help'help 'vbreak'”
Bochs htmlinternal-debugger.html help
1.
2. seg off addr '0x' '0'
3.
4. CPU
"dump_cpu" "set_cpu"
s Selectordl Descriptor Low-dword 4dh Descriptor High-dword 4valid inhibit_int CPU
STI MOV SS"set_cpu" Error: ...”
done” "set_cpu"
OK
4.
Bochs windowsrecord filename filename %s%d %x 1 2 3playback filename filename
print-stack [num words] num 16 num 160
load-symbols [global] filename [offset] filenameglobal offset 0
filename%x %s 1 2
Bochs Linux 0x7c000x7c00
CPU boot.s 1 Bochs Boot From floppy...”'s' 'n'
Bochs
Linux 0.11 32 0 32head.s 0x0000 'c'
'help'
17.5.2system.map Image (bootimage)
system.map windows system.map 2.10.3system.map Bochs
Linux 0.11 32 0 system.mapCPU
buffer_init() system.map
0xd1ec 'c' CPU
17.6
Disk Image File
0 /
1.2MB 1.44MB
Cylinder Head
256 -- 1024512 2-11
4
= X X
PCROM BIOS
BIOSBochs
TranslationLinux 0.11 Image MINIX
1.5 64MB 64MB Linux 0.11Image 4 Linux 0.11
Image 64 x 4 = 256MB 460MB Image
spt - Sectors Per Track 1.44MB 80 2 18
512 2880 80 x 2 x 18 x 512 = 1474560
Image
17.6.1 Bochs Image Bochs Image Disk Image Creation Tool bximage.exe
Image Image Imagehd fd Image mode
flat ImageImage Image
Bochs256MB Image
Image ImageImage
Image
17.6.2 Linux dd ImageImage 0
Image dd Image520 16 63 Image
520 * 16 * 63 = 524160
17.6.3 WinImage DOS Image WinImage DOS Image DOS Image
CDROM iso WinImageImage DOS Image
a) WinImage “Options->Settings” Image Compression“None”
b) Image File->New 1.44MB
c) Image->Boot Sector properties MS-DOSd)
All files (*.*)” Image
WinImage Image BochsImage 1.44MB 1474560 Image
UltraEdit
UltraEdit Image 511 512 55,AA512 MSDOS5.0
“EB 3C 90 4D ...”img “...F6 F6 F6”
0x168000 “F6 F6 F6...”Image
17.7
oldlinux.orgImage
Linus INSTALL-0.11 rootimage-0.11bootimage-0.11
http://oldlinux.org/Linux.old/images/bootimage-0.11-20040305 http://oldlinux.org/Linux.old/images/rootimage-0.11-20040305
bootimage-0.11 rootimage-0.11Linux-0.11 rootimage-0.11bootimage-0.11
Image Linux
17.7.1 Linux
etc/ dev/ bin/ sh mkfs fdiskusr/ usr/bin var/
Windows2000 CWindows2000 NTFS FAT32
Linux 0.11 MINIX 1.0Linux 509 510
ROOT_DEV 0
Linux 0.11 17–3
Linux 0.1117–4 6 floppy.c
0x300 /dev/hd0 1
0x301 /dev/hd1 1 1
0x302 /dev/hd2 1 2
0x303 /dev/hd3 1 3
0x304 /dev/hd4 1 4
0x305 /dev/hd5 2
0x306 /dev/hd6 2 1
0x307 /dev/hd7 2 2
0x308 /dev/hd8 2 3
0x309 /dev/hd9 2 4
0x0208 /dev/at0 1.2MB A
0x0209 /dev/at1 1.2MB B
0x021c /dev/fd0 1.44MB A
0x021d /dev/fd1 1.44MB B
17.7.2Image
Image Bochs SLS LinuxImage SLS Linux
SLS-Linux 256MB Image hdc.imgMINIX Image 1 MINIX
1. SLS-Linux Linux-0.11 hdc.img2. SLS-Linux SLS Linux Bochs bochsrc.bxrc ata0-master
Image ata0-slave:type=disk, path=..\Linux-0.11\hdc.img, cylinders=520, heads=16, spt=63
3. bochsrc.bxrc SLS Linux Login 'root'Bochs
4. fdisk hdc.img 1 1 3SLS Linux MINIX2.0 81
Linux/MINIX fdisk t 80 Old MINIX
hdc.img SLS Linux 2 Linux 0.11/dev/hd5 Linux 0.95
SLS Linux 2 /dev/hdb
5. 65015SLS Linux
6. SLS Linux mkfs 1 MINIX64000 1KB
hdc.img 1Linux 0.11
17.7.3 Linux-0.11 BochsBochs Linux 0.11 bochsrc.bxrc
SLS Linux Bochs bochsrc.bxrc Linux-0.11floppya ata0-master boot 3
Bochs 17-7
A: A rootimage-0.11Bochs 'CONFIG' Bochs
17-8
1 rootimage-0.11'Continuing simulation' Bochs
Linux 0.11 17-9
17.7.4 hdc.imgLinux 0.11 Image
256MB Image hdc.imgBochs
“ata0 master: Generic 1234 ATA-2 Hard-Disk (255 Mbytes)”
Linux 0.11 bochsrc.bxrcBochs
hdc.img 1 MINIX64MB
[/usr/root]# mkfs /dev/hd1 64000
/mnt
[/usr/root]# cd / [/]# mount /dev/hd1 /mnt [/]#
[/]# cd /mnt[/mnt]# for i in bin dev etc usr tmp> do> cp +recursive +verbose /$i $i> done
'logout' 'exit' Linux 0.11
[/mnt]# cd /[/]# umount /dev/hd1[/]# logout
child 4 died with code 0000 [/usr/root]#
17.7.5 ImageImage Linux 0.11
bootimage-0.11 509 510 0x1fc 0x1fd
1. bootimage-0.11 bochsrc.bxrc bootimage-0.11-hd bochsrc-hd.bxrc2. bochsrc-hd.bxrc 'floppya:' 'bootimage-0.11-hd'3. UltraEdit winhex bootimage-0.11-hd
509 510 0x1fc 0x1fd 00 00 01 03Image 1
1
000001f0h: 00 00 00 00 00 00 00 00 00 00 00 00 01 03 55 AA ; ..............U?
bochsrc-hd.bxrc Bochs Linux 0.1117-10
17.8 Linux 0.11 0.11
gcc 1.40 Linux 0.11Bochs bochs
http://oldlinux.org/Linux.old/bochs/linux-0.11-devel-040817.zip http://oldlinux.org/Linux.old/bochs/linux-0.11-devel-040923.zip
READMEbochs bochs-hd.bxrc Image
Linux 0.11 /usr/src/linux 'make' Linux 0.11Image Image bootimage-0.11-hdbootimage-0.11-hd Bochs
bootimage-0.11-hd
[/usr/src/linux]# make [/usr/src/linux]# dd bs=8192 if=Image of=/dev/fd0 [/usr/src/linux]#
mtools Image 2 diskb.imgWinImage diskb.img 'Image'
Image rootimage-0.11Makefile # 'ROOT_DEV='
gcc '-mstring-ins'Linus gcc 1.40 gcc
Makefilegar /usr/local/bin/ ar / gar
17.9 Redhat 9 Linux 0.11
Linux Minix 1.5.10 Minix-i386Minix 1.5.10 A.S. Tanenbaum Minix 1 Prentice Hall
Minix 80386 80386 3232 Linus Bruce Evans MINIX-386
GNU gcc gld emacs bash Minix-386 LinusLinux 0.01 0.03 0.11 Linux
Linus Linux http://oldlinux.org
Minix 1.5.10Linux 0.11 RedHat 9
bootimage PC Bochsdiff
linux linux-mdf
diff -r linux linux-mdf > dif.out
dif.out RedHat 9 Linux 0.11
http://oldlinux.org/Linux.old/kernel/linux-0.11-040327-rh9.tar.gz http://oldlinux.org/Linux.old/kernel/linux-0.11-040327-rh9.diff.gz
Booting from Floppy... Loading system ...
Insert root floppy and press ENTER
Loding system...”PC vmware bochs
linux 0.11 oldlinux.org
http://oldlinux.org/Linux.old/images/rootimage-0.11-for-orig
17.9.1 makefileLinux 0.11 makefile
a. gas =>as, gld=>ld gas gld as ldb. as( gas) -c -c Linux Makefile
34c. gcc -fcombine-regs -mstring-insns Makefile
94 gcc -fcombine-regs -mstring-insns Linusgcc gcc
d. gcc -m386 RedHat 980486 CPU 80386
17.9.2 as86 c ! boot/bootsect.s C
17.9.3 alignboot align align
.align 3 (2 3 2^3=8)
.align 8
17.9.4as
CPU __asm__("ax") fs/bitmap.c 20 26fs/namei.c 65
include/string.h 84:"si","di","ax","cx");
: ); gcc
gccinclude/string.h memcpy() 342
17.9.5 cLinux 0.11 C '_'
gcc cc boot/head.s 15
.globl _idt,_gdt,_pg_dir,_tmp_floppy_area
.globl idt,gdt,pg_dir,tmp_floppy_area 31
lss _stack_start,%esp
lss stack_start,%esp
17.9.6, ROM BIOS int 0x10
check_data32()13 printk() , tty_write(),check_data32() ,
4M0 0 4M
linus
3
17.10 +
Linux 0.11kernel/blk_drv/ramdisk.c
http://oldlinux.org/Linux.old/bochs/linux-0.11-devel-040923.zip http://oldlinux.org/Linux.old/images/rootimage-0.11-for-orig
linux-0.11-devel Bochs Linux 0.11 rootimage-0.11 1.44MBLinux 0.11 'for-orig' Linux 0.11
Makefile
17.10.1Linux 0.11 “ ” Image
Linux
Linux 0.11
RAMDISK
mount 1.44MB
17.10.1.1 Linux 0.11 Makefile RAMDISK
RAMDISK 0 ROOT_DEV
Linux 0.11 linux/Makefile RAMDISKRAMDISK 256
1KB 2 257RAMDISK
shell256
17-11
17.10.1.2Linux 0.1x 120KB Linux
Linus 256KB 1.44MB256
17-12
RAMDISKLinus ramdisk.c 256
Linux 0.11 Image Image 120KB256
1440 - 256 = 1184 KBramdisk.c 75 block 130
17.10.2ramdisk.c
1024KB 1184KB1.44MB Image RAMDISK Image
1024KB 256
17.10.2.1RAMDISK Image RAMDISK 2048KB
Bochs linux-0.11-devel /usr/src/linux/Makefile
Image
17.10.2.21024KB Image rootram.img
Image Bochs bochsrc-hd.bxrc Bochs(1) 1024KB Imagerootram.img Linux
(2) Bochs linux-0.11-devel Bochs Arootimage-0.11-orign B rootram.img(3) rootram.img 1024KB A B/mnt /mnt1 /mnt1
(4) cp /mnt rootimage-0.11-orign /mnt1 /mnt11024KB
/mnt/ 1024KB /bin /usr/bindf
/mnt/etc/fstab /mnt/etc/rcfd1 /mnt1/ 1024KB
(5) umount /dev/fd0 /dev/fd1 dd /dev/fd1Linux-0.11-devel rootram-0.11 Image
Linux-0.11-devel Image /usr/src/linux/Image1024KB rootram-0.11
17.10.2.3Bochs A 1.44MB
bootroot-0.11
bs=1024 1KB seek=256 256Bochs
bootroot-0.11
17.10.3Bochs bootroot-0.11.bxrc
Bochs 17-13
http://oldlinux.org/Linux.old/bochs/bootroot-0.11-040928.zip
17.11 shoelace
Image Linux 0.11shoelace Image shoelace Linux LILO Grub
MINIX 1992 1 Linux shoelacegrub Lilo boot-HOWTO shoelace.tar.z Linux.old/bin-src/
17.11.1 shoelaceshoelace
/etc/config config boot: bootimage Image
/usr/src/linux/Image
17.11.21 shoelace
1 shoelace
"-w 1" 1 .
17.11.3fdisk Image MINIX MINIX-1.5
) hd imageLinux 0.11 fdisk MINIX fdisk
Linux-0.11-devel-XXXX.zip 2004 923 hd image MINIX
hd
127MB Image MINIX
Linux 0.11 fdisk
Linux hd image hdc.img
dd if=/dev/zero of=hdc.img bs=512 count=248280
count (=410 * 16 * 38) Image mount Linux 0.11 cp -a / Image /mnt/
0x55,0xAA 511 512UltraEdit hdc.img Image
http://oldlinux.org/Linux.old/bochs/linux-0.11-devel-040923.zip
17-14
17.12 GDB Bochs
Linux RedHat 9 Bochs gdb Linux 0.11 Linux X window Bochs
RPM Bochs gdb gdbstubBochs
gdbstub Bochs 1234 gdb gdbgdb Linux 0.11 C Linux 0.11
-g
17.12.1 gdbstub Bochs Bochs Bochs gdbstub Bochs
Bochs bochs-2.2.tar.gz
http://sourceforge.net/projects/bochs/
tar bochs-2.2--enable-gdb-stub configure make make install
./configure MakefileX window
17.12.2 Linux 0.11Bochs gdb Linux 0.11
RedHat 9 0.110.11 Makefile -g
-s
find Makefile
systemSYSSIZE = 0x3000 boot/bootsect.s 6
Makefile Image systemImage system gdb
TAB
boot/bootsect.s tools/build.c SYSSIZE 0x8000
17.12.3Linux RedHat 9 Bochs Linux 0.11
17.12.3.1 Linux Linux 0.11Linux 0.11 linux-rh9-gdb/
Makefile linux-rh9-gdb/ bochs
http://oldlinux.org/Linux.old/bochs/linux-0.11-gdb-rh9-050619.tar.gz
tar zxvf linux-gdb-rh9-050619.tar.gz
1 bochsrc-fd1-gdb.bxrc Bochs rootimage-0.11-for-orig2 bochs Linux 0.11
bochs 1234gdb
2 linux/ Linux 0.11 Makefile3 rootimage-0.11-for-orig 4
bochs1. X window2. linux-gdb-rh9/ ./run
gdb Wait for gdb connection on localhost:1234Bochs
3. linux-gdb-rh9/linux/gdb tools/system”
4. gdb break main target remote localhost:1234 gdbBochs
5. gdb cont gdb init/main.c main()gdb list
help break print/set /next/step quit gdb gdb gdbgdb
gdb gdbmemory.c: No such file or directory mm/ memory.c Makefile
ld mm/ mm.o linux/ld linux/
17.12.3.2 Linux 0.11 0.11RedHat 9 Linux Linux 0.11
Image 0.11 Redhat 9linux-0.11-devel Image
mcopy Bochs 2
WinImage mount1. Bochs Linux-0.11-devel /usr/src/ linux-gdb2. 0.11 cp -a linux linux-gdb/ linux-gdb/linux/
Makefile3. /usr/src/ tar linux-gdb/ linux-gdb.tgz4. 2 b ) mcopy linux-gdb.tgz b: b
mdel b: ” b5. windows WinImage b
FTP Redhat 9 Redhat 9Linux mount b
6. Linux 0.11 linux-gdb/linux-gdb/ bochs bochsrc-fd1-gdb.bxrc
linux-0.11-devel bochsrc-fdb.bxrc gdbstuboldlinux.org rootimage-0.11 linux-gdb/
Redhat 9 Bochs Linux 0.11
Bochs b LINUX-GD.TGZ Redhat 9 Linux
linux-gdb/ Bochs bochsrc-fd1-gdb.bxrcrootimage-0.11 bochs -q -f bochsrc-fd1-gdb.bxrc
run oldlinux.orgRedhat 9
http://oldlinux.org/Linux.old/bochs/linux-0.11-gdb-050619.tar.gz
[1] Intel Co. INTEL 80386 Programmer's Reference Manual 1986, INTEL CORPORATION,1987.
[2] Intel Co. IA-32 Intel Architecture Software Developer's Manual Volume.3:System Programming Guide.
http://www.intel.com/, 2005.
[3] James L. Turley. Advanced 80386 Programming Technigues. Osborne McGraw-Hill,1988.
[4] Brian W. Kernighan, Dennis M. Ritchie. The C programming Language. Prentice-Hall 1988.
[5] Leland L. Beck. System Software: An Introduction to Systems Programming,3nd. Addison-Wesley,1997.
[6] Richard Stallman, Using and Porting the GNU Compiler Collection,the Free Software Foundation, 1998.
[7] The Open Group Base Specifications Issue 6 IEEE Std 1003.1-2001, The IEEE and The Open Group.
[8] David A Rusling, The Linux Kernel, 1999. http://www.tldp.org/
[9] Linux Kernel Source Code http://www.kernel.org/
[10] Digital co.ltd. VT100 User Guide, http://www.vt100.net/
[11] Clark L. Coleman. Using Inline Assembly with gcc. http://oldlinux.org/Linux.old/
[12] John H. Crawford, Patrick P. Gelsinger. Programming the 80386. Sybex, 1988.
[13] FreeBSD Online Manual, http://www.freebsd.org/cgi/man.cgi
[14] Andrew S.Tanenbaum MINIX . 1990.4
[15] Maurice J. Bach UNIX . 2000.4
[16] John Lions UNIX 2000.7
[17] Andrew S. Tanenbaum 2 , 1998.8
[18] Alessandro Rubini Jonathan Linux 2002.11
[19] Daniel P. Bovet, Marco Cesati , LINUX , 2001.
[20] . (PC ) , 1992.
[21] . MS-DOS 5.0 . 1992.
[22] RedHat 9.0 . http://www.plinux.org/cgi-bin/man.cgi
[23] W.Richard Stevens UNIX . 2000.2
[24] Linux Weekly Edition News. http://lwn.net/
[25] P.J. Plauger. The Standard C Library. Prentice Hall, 1992
[26] Free Software Foundation. The GNU C Library. http://www.gnu.org/ 2001
[27] Chuck Allison. The Standard C Library. C/C++ Users Journal CD-ROM, Release 6. 2003
[28] Bochs simulation system. http://bochs.sourceforge.net/
[29] Brennan "Bas" Underwood. Brennan's Guide to Inline Assembly. http://www.rt66.com/~brennan/
[30] John R. Levine. Linkers & Loaders. http://www.iecc.com/linker/
[31] Randal E. Bryant, David R. O'Hallaron . , . . 2004
[32] Randal E. Bryant, David R. O'Hallaron. Computer Systems A programmer's Perspective. . 2004.
[33] Intel. Data Sheet: 8254 Programmable Interval Timer. 1993.9
[34] Intel. Data Sheet: 8259A Programmable Interrupt Controller. 1988.12
[35] Intel. Data Sheet: 82077A CHMOS Single-chip Floppy Disk Controller. 1994.5
[36] Robert Love Linux 2004.11
[37] Adam Chapweske. The PS/2 Keyboard Interface. http://www.computer-engineering.org/
[38] Dean Elsner, Jay Fenlason & friends. Using as: The GNU Assembler. http://www.gnu.org/ 1998
[39] Steve Chamberlain. Using ld: The GNU linker. http://www.gnu.org/ 1998
[40] Michael K. Johnson. The Linux Kernel Hackers' Guide. http://www.tldp.org/ 1995
[41]
1
1. a.out include/a.out.h 6a.out Assembly out
2. flock include/fcntl.h 43
3. sigaction include/signal.h 48 sigaction
sa_handler SIG_DFL SIG_IGN
sa_maskSA_NOMASK
sa_flagssa_restorer Libc
4. include/termios.h 36(Window size) ioctls TIOCGWINSZ
TIOCSWINSZ
5. termio(s) include/termios.h 44 AT&T V termio NCC = 8
POSIX termios 54 NCC = 17
termio termios UNIX termio AT&TV termios POSIX termio
termiossgtty
6. include/time.h 18
7. / include/utime.h 6
8. buffer_head include/linux/fs.h 68 bh buffer_head
9. include/linux/fs.h 93 i d_inode 7
10. include/linux/fs.h 116 i
11. include/linux/fs.h 124 d_super_block 8
12. include/linux/fs.h 157
13. include/linux/hdreg.h 52
1--44 16
0 0 1 0x1BE--0x1FD4
14. include/linux/head.h 4 CPU
15. i387 include/linux/sched.h 40 i387
16. include/linux/sched.h 51
17. task include/linux/sched.h 78
18. tty include/linux/tty.h 16
tty
19. tty include/linux/tty.h 45
tty
20. include/sys/stat.h 6
21. include/sys/times.h 6
22. ustat include/sys/types.h 39
ustat()
NULL
23. include/sys/utsname.h 6
24. kernel/blk_drv/blk.h 23
dev=-1
2 ASCII
3 C0 C1
NUL 0x00 Null --
ENQ 0x05 Enquiry --
BEL 0x07 Bell --
BS 0x08 Backspace --
HT 0x09 Horizontal Tabulation --
LF 0x0a Linefeed --
VT 0x0b Virtical Tabulation -- LF
FF 0x0c Form Feed -- LF
CR 0x0d Carriage Return --
SO 0x0e Shift Out -- SCS G1 G1 5
SI 0x0f Shift In -- SCS G0 G0 5
DC1 0x11 Device Control 1 -- XON
DC3 0x13 Device Control 3 -- XOFF XOFF XON
CAN 0x18 Cancel --
SUB 0x1a Substitute -- CAN
ESC 0x1b Escape --
DEL 0x7f Delete --
7B
IND 0x84 ESC D Index --
NEL 0x85 ESC H Next Line --
HTS 0x88 ESC E Horizontal Tab Set --
RI 0x8d ESC M Reverse index --
SS2 0x8e ESC N Single Shift G2 -- GL G2 G2
SCS
SS3 0x8f ESC O Single Shift G3 -- GL G3 G3
SCS
DCS 0x90 ESC P Device Control String --
CSI 0x9b ESC [ Control Sequence Introducer --
ST 0x9c ESC \ String Terminator -- DCS
4
ESC ( Ps ESC ) Ps Select Character Set (SCS) -- G0 G1 5 'ESC ( Ps'
G0 'ESC ) Ps' G1 Ps A - UK B - US
0 - 1 - ROM 2 - ROM
254 ROM 127
127 ROM 94
SCS
G0 G1 Shift In -
SI 14 G0 Shift Out - SO 15 G1
SCS
ESC [ Pn A Cursor Up (CUU) -- CUU
Pn Pn Pn ASCII
0 1
ESC [ Pn B ESC [ Pn e Cursor Down (CUD) -- CUD
1 0 1 Pn Pn
ESC [ Pn C ESC [ Pn a Cursor Forward (CUF) -- CUF
1 0 1 Pn Pn
ESC [ Pn D Cursor Backward (CUB) -- CUB
1 0 1 Pn Pn
ESC [ Pn E Cursor Next Line (CNL) -- Pn 1
ESC [ Pn F Cursor Last Line (CLL) -- Pn 1
ESC [ Pn G ESC [ Pn ` Cursor Horizon Absolute (CHA) -- Pn
ESC [ Pn ; Pn H
ESC [ Pn;Pn f
Cursor Position (CUP) Horizontal And Vertical Position(HVP) -- CUP
0 1 1
home ESC [ H
ESC [ Pn d Vertical Line Position Absolute -- Pn
ESC [ s Save Current Cursor Position -- DECSC
ESC [ u Restore Saved Cursor Position -- DECRC
ESC D Index (IND) -- 1
1
ESC M Reverse Index (RI) -- 1
1
ESC E
1
Next Line (NEL) -- 1
1
ESC 7 Save Cursor (DECSC) --
ESC 8 Restore Cursor (DECRC) --
ESC [ Ps; Ps; … ; Ps m Select Graphic Rendition (SGR) --
Ps
0 - 1 - 4 - 5 - 7 - 22 - 24 -
25 - 27 - 30--38 39 - White 40--48
- 49 - Black 30--37 40-47 Black Red Green
Yellow Blue Magenta Cyan White
ESC [ Pn L Insert Line (IL) -- 1
ESC [ Pn M Delete Line (DL) -- 1
1 Pn
ESC [ Pn @ Insert Character (ICH) -- 1
Pn 1 1
ESC [ Pn P DeleteCharacter (DCH) -- Pn
ESC [ Ps J Erase In Display (ED) --
Ps
0 - 1 - 2 -
ESC [ Ps K Erase In Line (EL) --
Ps
0 - 1 - 2 -
ESC [ Pn ; Pn r Set Top and Botttom Margins (DECSTBM)--
1 1 2 1
2
home
ESC [ Pn c ESC Z
Device Attributes (DA) --
0 DA DA ESC Z
VT101 ESC [?1;0c STP ESC [?1;1c
AVO VT100 ESC [?1;2c AVO STP ESC [?1;3c
GPO ESC [?1;4c GPO STP ESC [?1;5c
GPO AVO VT102 ESC [?1;6c GPO STP AVO ESC [?1;7c
ESC c Reset To Initial State (RIS) --
1. XON/XOFF
XOFF XON 2. 10
5 1
12 KP -- KeyPad3
/ /
___strtok include/string.h, 275, __GNU_EXEC_MACROS__ include/a.out.h, 4, __LIBRARY__ init/main.c, 7, lib/close.c, 7, lib/dup.c, 7, lib/_exit.c, 7, lib/open.c, 7, lib/execve.c, 7, lib/setsid.c, 7, lib/string.c, 13, lib/wait.c, 7, lib/write.c, 7, __NR_access include/unistd.h, 93, __NR_acctinclude/unistd.h, 111, __NR_alarm include/unistd.h, 87, __NR_break include/unistd.h, 77, __NR_brk include/unistd.h, 105, __NR_chdir include/unistd.h, 72, __NR_chmod include/unistd.h, 75, __NR_chown include/unistd.h, 76, __NR_chroot include/unistd.h, 121, __NR_close include/unistd.h, 66, __NR_creatinclude/unistd.h, 68, __NR_dup include/unistd.h, 101, __NR_dup2 include/unistd.h, 123, __NR_execve include/unistd.h, 71, __NR_exit include/unistd.h, 61, __NR_fcntl include/unistd.h, 115,
__NR_fork include/unistd.h, 62, __NR_fstat include/unistd.h, 88, __NR_ftime include/unistd.h, 95, __NR_getegid include/unistd.h, 110, __NR_geteuid include/unistd.h, 109, __NR_getgid include/unistd.h, 107, __NR_getpgrp include/unistd.h, 125, __NR_getpid include/unistd.h, 80, __NR_getppid include/unistd.h, 124, __NR_getuid include/unistd.h, 84, __NR_gtty include/unistd.h, 92, __NR_ioctl include/unistd.h, 114, __NR_kill include/unistd.h, 97, __NR_link include/unistd.h, 69, __NR_lock include/unistd.h, 113, __NR_lseek include/unistd.h, 79, __NR_mkdir include/unistd.h, 99, __NR_mknod include/unistd.h, 74, __NR_mount include/unistd.h, 81, __NR_mpx include/unistd.h, 116, __NR_niceinclude/unistd.h, 94, __NR_open include/unistd.h, 65, __NR_pause include/unistd.h, 89, __NR_phys include/unistd.h, 112,
__NR_pipe include/unistd.h, 102, __NR_prof include/unistd.h, 104, __NR_ptrace include/unistd.h, 86, __NR_read include/unistd.h, 63, __NR_rename include/unistd.h, 98, __NR_rmdir include/unistd.h, 100, __NR_setgid include/unistd.h, 106, __NR_setpgid include/unistd.h, 117, __NR_setregid include/unistd.h, 131, __NR_setreuid include/unistd.h, 130, __NR_setsid include/unistd.h, 126, __NR_setuid include/unistd.h, 83, __NR_setup include/unistd.h, 60, __NR_sgetmask include/unistd.h, 128, __NR_sigaction include/unistd.h, 127, __NR_signal include/unistd.h, 108, __NR_ssetmask include/unistd.h, 129, __NR_stat include/unistd.h, 78, __NR_stime include/unistd.h, 85, __NR_stty include/unistd.h, 91, __NR_sync include/unistd.h, 96, __NR_time include/unistd.h, 73, __NR_times include/unistd.h, 103, __NR_ulimit include/unistd.h, 118, __NR_umask include/unistd.h, 120, __NR_umount include/unistd.h, 82, __NR_uname include/unistd.h, 119, __NR_unlink include/unistd.h, 70, __NR_ustat
include/unistd.h, 122, __NR_utime include/unistd.h, 90, __NR_waitpid include/unistd.h, 67, __NR_write include/unistd.h, 64, __va_rounded_size include/stdarg.h, 9, _A_OUT_H include/a.out.h, 2, _BLK_H kernel/blk_drv/blk.h, 2, _BLOCKABLE kernel/sched.c, 24, _bmap fs/inode.c, 72, _bucket_dir lib/malloc.c, 60, struct_C include/ctype.h, 7, _CONFIG_H include/config.h, 2, _CONST_H include/const.h, 2, _ctmp include/ctype.h, 14, lib/ctype.c, 9, _ctype include/ctype.h, 13, lib/ctype.c, 10, _CTYPE_H include/ctype.h, 2, _Dinclude/ctype.h, 6, _ERRNO_H include/errno.h, 2, _exit include/unistd.h, 208, lib/_exit.c, 10, _FCNTL_H include/fcntl.h, 2, _FDREG_H include/fdreg.h, 7, _fskernel/traps.c, 34, _FS_H include/fs.h, 7, _get_base include/sched.h, 214, _hashfn fs/buffer.c, 128, _HDREG_H include/hdreg.h, 7, _HEAD_H include/head.h, 2,
_HIGH include/sys/wait.h, 7, _I_FLAG kernel/chr_drv/tty_io.c, 29, _Linclude/ctype.h, 5, _L_FLAG kernel/chr_drv/tty_io.c, 28, _LDT include/sched.h, 156, _LOW include/sys/wait.h, 6, _MM_H include/mm.h, 2, _N_BADMAG include/a.out.h, 36, _N_HDROFF include/a.out.h, 40, _N_SEGMENT_ROUND include/a.out.h, 95, _N_TXTENDADDR include/a.out.h, 97, _NSIG include/signal.h, 9, _O_FLAG kernel/chr_drv/tty_io.c, 30, _Pinclude/ctype.h, 8, _PC_CHOWN_RESTRICTED include/unistd.h, 51, _PC_LINK_MAX include/unistd.h, 43, _PC_MAX_CANON include/unistd.h, 44, _PC_MAX_INPUT include/unistd.h, 45, _PC_NAME_MAX include/unistd.h, 46, _PC_NO_TRUNC include/unistd.h, 49, _PC_PATH_MAX include/unistd.h, 47, _PC_PIPE_BUF include/unistd.h, 48, _PC_VDISABLE include/unistd.h, 50, _POSIX_CHOWN_RESTRICTED include/unistd.h, 7, _POSIX_NO_TRUNC include/unistd.h, 8, _POSIX_VDISABLE include/unistd.h, 9, _POSIX_VERSION include/unistd.h, 5, _PTRDIFF_T include/sys/types.h, 15,
include/stddef.h, 5, _Sinclude/ctype.h, 9, kernel/sched.c, 23, _SC_ARG_MAX include/unistd.h, 33, _SC_CHILD_MAX include/unistd.h, 34, _SC_CLOCKS_PER_SEC include/unistd.h, 35, _SC_JOB_CONTROL include/unistd.h, 38, _SC_NGROUPS_MAX include/unistd.h, 36, _SC_OPEN_MAX include/unistd.h, 37, _SC_SAVED_IDS include/unistd.h, 39, _SC_VERSION include/unistd.h, 40, _SCHED_H include/sched.h, 2, _set_baseinclude/sched.h, 188, _set_gateinclude/asm/system.h, 22, _set_limit include/sched.h, 199, _set_seg_desc include/asm/system.h, 42, _set_tssldt_desc include/asm/system.h, 52, _SIGNAL_H include/signal.h, 2, _SIZE_T include/sys/types.h, 5, include/time.h, 10, include/stddef.h, 10, include/string.h, 9, _SPinclude/ctype.h, 11, _STDARG_H include/stdarg.h, 2, _STDDEF_H include/stddef.h, 2, _STRING_H_ include/string.h, 2, _SYS_STAT_H include/sys/stat.h, 2, _SYS_TYPES_H include/sys/types.h, 2, _SYS_UTSNAME_H include/sys/utsname.h, 2, _SYS_WAIT_H include/sys/wait.h, 2, _syscall0
include/unistd.h, 133, _syscall1 include/unistd.h, 146, _syscall2 include/unistd.h, 159, _syscall3 include/unistd.h, 172, _TERMIOS_H include/termios.h, 2, _TIME_H include/time.h, 2, _TIME_T include/sys/types.h, 10, include/time.h, 5, _TIMES_H include/sys/times.h, 2, _TSSinclude/sched.h, 155, _TTY_H include/tty.h, 10, _Uinclude/ctype.h, 4, _UNISTD_H include/unistd.h, 2, _UTIME_H include/utime.h, 2, _Xinclude/ctype.h, 10, ABRT_ERR include/hdreg.h, 47, ACC_MODE fs/namei.c, 21, accessinclude/unistd.h, 189, acctinclude/unistd.h, 190, add_entry fs/namei.c, 165, add_requestkernel/blk_drv/ll_rw_blk.c, 64, add_timer include/sched.h, 144, kernel/sched.c, 272, alarm include/unistd.h, 191, ALRMMASK kernel/chr_drv/tty_io.c, 17, argvinit/main.c, 165, argv_rc init/main.c, 162, asctime include/time.h, 35, attrkernel/chr_drv/console.c, 77, B0
include/termios.h, 133, B110 include/termios.h, 136, B1200 include/termios.h, 142, B134 include/termios.h, 137, B150 include/termios.h, 138, B1800 include/termios.h, 143, B19200 include/termios.h, 147, B200 include/termios.h, 139, B2400 include/termios.h, 144, B300 include/termios.h, 140, B38400 include/termios.h, 148, B4800 include/termios.h, 145, B50 include/termios.h, 134, B600 include/termios.h, 141, B75 include/termios.h, 135, B9600 include/termios.h, 146, bad_flp_intr kernel/blk_drv/floppy.c, 233, bad_rw_intr kernel/blk_drv/hd.c, 242, BADNESSfs/buffer.c, 205, BBD_ERR include/hdreg.h, 50, BCD_TO_BIN init/main.c, 74, beepcount kernel/chr_drv/console.c, 697, blk_dev kernel/blk_drv/ll_rw_blk.c, 32, structkernel/blk_drv/blk.h, 50, structblk_dev_init init/main.c, 46, kernel/blk_drv/ll_rw_blk.c, 157, blk_dev_struct kernel/blk_drv/blk.h, 45, structblock_read fs/read_write.c, 18, fs/block_dev.c, 47, BLOCK_SIZE include/fs.h, 49,
BLOCK_SIZE_BITS include/fs.h, 50, block_write fs/read_write.c, 19, fs/block_dev.c, 14, bmap fs/inode.c, 140, include/fs.h, 176, bottom kernel/chr_drv/console.c, 73, bounds kernel/traps.c, 48, bread fs/buffer.c, 267, include/fs.h, 189, bread_page fs/buffer.c, 296, include/fs.h, 190, breada fs/buffer.c, 322, include/fs.h, 191, brelse fs/buffer.c, 253, include/fs.h, 188, brk include/unistd.h, 192, BRKINTinclude/termios.h, 84, BS0 include/termios.h, 122, BS1 include/termios.h, 123, BSDLY include/termios.h, 121, bucket_desc lib/malloc.c, 52, structbucket_dir lib/malloc.c, 77, buffer_block include/fs.h, 66, BUFFER_END include/const.h, 4, buffer_head include/fs.h, 68, structbuffer_init fs/buffer.c, 348, include/fs.h, 31, buffer_memory_end init/main.c, 99, buffer_wait fs/buffer.c, 33, BUSY_STAT include/hdreg.h, 31, calc_mem mm/memory.c, 413, CBAUD
include/termios.h, 132, cfgetispeed include/termios.h, 216, cfgetospeed include/termios.h, 217, cfsetispeed include/termios.h, 218, cfsetospeed include/termios.h, 219, change_ldt fs/exec.c, 154, change_speed kernel/chr_drv/tty_ioctl.c, 24, CHARSinclude/tty.h, 30, chdir include/unistd.h, 194, check_disk_change fs/buffer.c, 113, include/fs.h, 168, chmod include/sys/stat.h, 51, include/unistd.h, 195, chowninclude/unistd.h, 196, chr_dev_init init/main.c, 47, kernel/chr_drv/tty_io.c, 347, chrootinclude/unistd.h, 197, CIBAUDinclude/termios.h, 162, clear_bitfs/bitmap.c, 25, clear_block fs/bitmap.c, 13, cliinclude/asm/system.h, 17, CLOCALinclude/termios.h, 161, clock include/time.h, 30, clock_tinclude/time.h, 16, CLOCKS_PER_SEC include/time.h, 14, closeinclude/unistd.h, 198, CMOS_READ init/main.c, 69, kernel/blk_drv/hd.c, 28, CODE_SPACE mm/memory.c, 49, command kernel/blk_drv/floppy.c, 121, con_init
include/tty.h, 66, kernel/chr_drv/console.c, 617, con_write include/tty.h, 73, kernel/chr_drv/console.c, 445, controller_ready kernel/blk_drv/hd.c, 161, coprocessor_error kernel/traps.c, 58, coprocessor_segment_overrun kernel/traps.c, 52, copy_buffer kernel/blk_drv/floppy.c, 155, copy_mem kernel/fork.c, 39, copy_page mm/memory.c, 54, copy_page_tables include/sched.h, 29, mm/memory.c, 150, copy_process kernel/fork.c, 68, copy_strings fs/exec.c, 104, copy_to_cooked include/tty.h, 75, kernel/chr_drv/tty_io.c, 145, COPYBLKfs/buffer.c, 283, cp_stat fs/stat.c, 15, CPARENBinclude/termios.h, 158, CPARODD include/termios.h, 159, crkernel/chr_drv/console.c, 224, CR0 include/termios.h, 111, CR1 include/termios.h, 112, CR2 include/termios.h, 113, CR3 include/termios.h, 114, CRDLYinclude/termios.h, 110, CREADinclude/termios.h, 157, creatinclude/unistd.h, 199, include/fcntl.h, 51, create_block fs/inode.c, 145, include/fs.h, 177, create_tables
fs/exec.c, 46, CRTSCTSinclude/termios.h, 163, crw_ptrfs/char_dev.c, 19, crw_tablefs/char_dev.c, 85, CS5 include/termios.h, 152, CS6 include/termios.h, 153, CS7 include/termios.h, 154, CS8 include/termios.h, 155, csi_atkernel/chr_drv/console.c, 391, csi_Jkernel/chr_drv/console.c, 239, csi_Kkernel/chr_drv/console.c, 268, csi_Lkernel/chr_drv/console.c, 401, csi_m kernel/chr_drv/console.c, 299, csi_Mkernel/chr_drv/console.c, 421, csi_Pkernel/chr_drv/console.c, 411, CSIZEinclude/termios.h, 151, CSTOPBinclude/termios.h, 156, ctime include/time.h, 36, cur_ratekernel/blk_drv/floppy.c, 113, cur_spec1 kernel/blk_drv/floppy.c, 112, CURRENTkernel/blk_drv/blk.h, 93, CURRENT_DEVkernel/blk_drv/blk.h, 94, current_DOR kernel/sched.c, 204, kernel/blk_drv/floppy.c, 48, current_drive kernel/blk_drv/floppy.c, 115, CURRENT_TIME include/sched.h, 142, current_track kernel/blk_drv/floppy.c, 120, d_inode include/fs.h, 83, structd_super_block include/fs.h, 146, struct
daddr_t include/sys/types.h, 31, DAY kernel/mktime.c, 22, debug kernel/traps.c, 44, DECinclude/tty.h, 25, DEFAULT_MAJOR_ROOT tools/build.c, 37, DEFAULT_MINOR_ROOT tools/build.c, 38, del kernel/chr_drv/console.c, 230, delete_char kernel/chr_drv/console.c, 363, delete_line kernel/chr_drv/console.c, 378, desc_struct include/head.h, 4, structdesc_table include/head.h, 6, dev_t include/sys/types.h, 26, DEVICE_INTR kernel/blk_drv/blk.h, 72, kernel/blk_drv/blk.h, 81, kernel/blk_drv/blk.h, 97, DEVICE_NAME kernel/blk_drv/blk.h, 63, kernel/blk_drv/blk.h, 71, kernel/blk_drv/blk.h, 80, device_not_available kernel/traps.c, 50, DEVICE_NR kernel/blk_drv/blk.h, 65, kernel/blk_drv/blk.h, 74, kernel/blk_drv/blk.h, 83, DEVICE_OFF kernel/blk_drv/blk.h, 67, kernel/blk_drv/blk.h, 76, kernel/blk_drv/blk.h, 85, DEVICE_ON kernel/blk_drv/blk.h, 66, kernel/blk_drv/blk.h, 75, kernel/blk_drv/blk.h, 84, DEVICE_REQUEST kernel/blk_drv/blk.h, 64, kernel/blk_drv/blk.h, 73, kernel/blk_drv/blk.h, 82, kernel/blk_drv/blk.h, 99, die kernel/traps.c, 63, tools/build.c, 46, difftime include/time.h, 32,
DIR_ENTRIES_PER_BLOCK include/fs.h, 56, dir_entry include/fs.h, 157, structdir_namei fs/namei.c, 278, div_t include/sys/types.h, 36, divide_error kernel/traps.c, 43, DMA_READ include/fdreg.h, 68, DMA_WRITE include/fdreg.h, 69, do_bounds kernel/traps.c, 134, do_coprocessor_error kernel/traps.c, 169, do_coprocessor_segment_overrun kernel/traps.c, 149, do_debug kernel/traps.c, 124, do_device_not_available kernel/traps.c, 144, do_div kernel/vsprintf.c, 35, do_divide_error kernel/traps.c, 97, do_double_fault kernel/traps.c, 87, do_execve fs/exec.c, 182, do_exit kernel/exit.c, 102, kernel/traps.c, 39, kernel/signal.c, 13, mm/memory.c, 31, do_fd_request kernel/blk_drv/floppy.c, 417, do_floppy_timer kernel/sched.c, 245, do_general_protection kernel/traps.c, 92, do_hd_request kernel/blk_drv/hd.c, 294, do_int3 kernel/traps.c, 102, do_invalid_op kernel/traps.c, 139, do_invalid_TSS kernel/traps.c, 154, do_nmi kernel/traps.c, 119, do_no_page mm/memory.c, 365, do_overflow
kernel/traps.c, 129, do_rd_request kernel/blk_drv/ramdisk.c, 23, do_reserved kernel/traps.c, 176, do_segment_not_present kernel/traps.c, 159, do_signal kernel/signal.c, 82, do_stack_segment kernel/traps.c, 164, do_timer kernel/sched.c, 305, do_tty_interrupt kernel/chr_drv/tty_io.c, 342, do_wp_page mm/memory.c, 247, double_fault kernel/traps.c, 51, DRIVE kernel/blk_drv/floppy.c, 54, drive_busy kernel/blk_drv/hd.c, 202, DRIVE_INFO init/main.c, 59, drive_info init/main.c, 102, structDRQ_STAT include/hdreg.h, 27, dup include/unistd.h, 200, dup2 include/unistd.h, 248, dupfd fs/fcntl.c, 18, E2BIGinclude/errno.h, 26, EACCESinclude/errno.h, 32, EAGAIN include/errno.h, 30, EBADFinclude/errno.h, 28, EBUSY include/errno.h, 35, ECC_ERR include/hdreg.h, 49, ECC_STAT include/hdreg.h, 26, ECHILD include/errno.h, 29, ECHOinclude/termios.h, 172, ECHOCTL include/termios.h, 178, ECHOE
include/termios.h, 173, ECHOK include/termios.h, 174, ECHOKE include/termios.h, 180, ECHONL include/termios.h, 175, ECHOPRTinclude/termios.h, 179, EDEADLK include/errno.h, 54, EDOM include/errno.h, 52, EEXISTinclude/errno.h, 36, EFAULTinclude/errno.h, 33, EFBIGinclude/errno.h, 46, EINTRinclude/errno.h, 23, EINVALinclude/errno.h, 41, EIOinclude/errno.h, 24, EISDIR include/errno.h, 40, EMFILEinclude/errno.h, 43, EMLINKinclude/errno.h, 50, EMPTYinclude/tty.h, 26, empty_dir fs/namei.c, 543, ENAMETOOLONG include/errno.h, 55, endfs/buffer.c, 29, end_requestkernel/blk_drv/blk.h, 109, ENFILE include/errno.h, 42, ENODEV include/errno.h, 38, ENOENT include/errno.h, 21, ENOEXEC include/errno.h, 27, ENOLCKinclude/errno.h, 56, ENOMEM include/errno.h, 31, ENOSPCinclude/errno.h, 47, ENOSYS
include/errno.h, 57, ENOTBLKinclude/errno.h, 34, ENOTDIR include/errno.h, 39, ENOTEMPTY include/errno.h, 58, ENOTTY include/errno.h, 44, envpinit/main.c, 166, envp_rc init/main.c, 163, ENXIOinclude/errno.h, 25, EOF_CHAR include/tty.h, 40, EPERMinclude/errno.h, 20, EPIPE include/errno.h, 51, ERANGE include/errno.h, 53, ERASE_CHAR include/tty.h, 38, EROFSinclude/errno.h, 49, ERR_STAT include/hdreg.h, 24, errno include/unistd.h, 187, include/errno.h, 17, lib/errno.c, 7, ERRORinclude/errno.h, 19, ESPIPEinclude/errno.h, 48, ESRCHinclude/errno.h, 22, ETXTBSY include/errno.h, 45, EXDEVinclude/errno.h, 37, execinclude/a.out.h, 6, structexeclinclude/unistd.h, 204, execleinclude/unistd.h, 206, execlpinclude/unistd.h, 205, execvinclude/unistd.h, 202, execveinclude/unistd.h, 201, execvp
include/unistd.h, 203, exit include/unistd.h, 207, EXT_MEM_K init/main.c, 58, EXTA include/termios.h, 149, EXTBinclude/termios.h, 150, F_DUPFD include/fcntl.h, 23, F_GETFD include/fcntl.h, 24, F_GETFL include/fcntl.h, 26, F_GETLK include/fcntl.h, 28, F_OK include/unistd.h, 22, F_RDLCKinclude/fcntl.h, 38, F_SETFD include/fcntl.h, 25, F_SETFL include/fcntl.h, 27, F_SETLK include/fcntl.h, 29, F_SETLKW include/fcntl.h, 30, F_UNLCK include/fcntl.h, 40, F_WRLCKinclude/fcntl.h, 39, fcntl include/unistd.h, 209, include/fcntl.h, 52, FD_CLOEXEC include/fcntl.h, 33, FD_DATA include/fdreg.h, 17, FD_DCR include/fdreg.h, 20, FD_DIRinclude/fdreg.h, 19, FD_DORinclude/fdreg.h, 18, FD_READinclude/fdreg.h, 62, FD_RECALIBRATE include/fdreg.h, 60, FD_SEEK include/fdreg.h, 61, FD_SENSEI include/fdreg.h, 64, FD_SPECIFY include/fdreg.h, 65,
FD_STATUS include/fdreg.h, 16, FD_WRITE include/fdreg.h, 63, FF0include/termios.h, 128, FF1include/termios.h, 129, FFDLY include/termios.h, 127, fileinclude/fs.h, 116, structfile_read fs/read_write.c, 20, fs/file_dev.c, 17, file_table fs/file_table.c, 9, include/fs.h, 163, file_write fs/read_write.c, 22, fs/file_dev.c, 48, find_buffer fs/buffer.c, 166, find_empty_process kernel/fork.c, 135, find_entry fs/namei.c, 91, find_first_zero fs/bitmap.c, 31, FIRST_LDT_ENTRY include/sched.h, 154, FIRST_TASK include/sched.h, 7, FIRST_TSS_ENTRY include/sched.h, 153, flock include/fcntl.h, 43, structfloppy kernel/blk_drv/floppy.c, 114, floppy_change include/fs.h, 169, kernel/blk_drv/floppy.c, 139, floppy_deselect include/fdreg.h, 13, kernel/blk_drv/floppy.c, 125, floppy_init init/main.c, 49, kernel/blk_drv/floppy.c, 457, floppy_interrupt kernel/blk_drv/floppy.c, 104, floppy_off include/fs.h, 172, include/fdreg.h, 11, kernel/sched.c, 240, floppy_on include/fs.h, 171,
include/fdreg.h, 10, kernel/sched.c, 232, floppy_on_interrupt kernel/blk_drv/floppy.c, 404, floppy_select include/fdreg.h, 12, floppy_struct kernel/blk_drv/floppy.c, 82, structfloppy_type kernel/blk_drv/floppy.c, 85, flush kernel/chr_drv/tty_ioctl.c, 39, FLUSHO include/termios.h, 181, fn_ptr include/sched.h, 38, fork include/unistd.h, 210, freeinclude/kernel.h, 12, free_block fs/bitmap.c, 47, include/fs.h, 193, free_bucket_desc lib/malloc.c, 92, free_dind fs/truncate.c, 29, free_ind fs/truncate.c, 11, free_inode fs/bitmap.c, 107, include/fs.h, 195, free_list fs/buffer.c, 32, free_page include/mm.h, 8, mm/memory.c, 89, free_page_tables include/sched.h, 30, mm/memory.c, 105, free_s include/kernel.h, 10, lib/malloc.c, 182, free_super fs/super.c, 40, fstatinclude/sys/stat.h, 52, include/unistd.h, 233, FULLinclude/tty.h, 29, GCC_HEADERtools/build.c, 33, gdt include/head.h, 9, GDT_CODE include/head.h, 12,
GDT_DATA include/head.h, 13, GDT_NUL include/head.h, 11, GDT_TMP include/head.h, 14, general_protection kernel/traps.c, 56, get_base include/sched.h, 226, get_dir fs/namei.c, 228, get_ds include/asm/segment.h, 54, get_empty_inode fs/inode.c, 194, include/fs.h, 183, get_empty_page mm/memory.c, 274, get_free_page include/mm.h, 6, mm/memory.c, 63, get_fs include/asm/segment.h, 47, get_fs_byte include/asm/segment.h, 1, get_fs_long include/asm/segment.h, 17, get_fs_word include/asm/segment.h, 9, get_hash_table fs/buffer.c, 183, include/fs.h, 185, get_limit include/sched.h, 228, get_new kernel/signal.c, 40, get_pipe_inode fs/inode.c, 228, include/fs.h, 184, get_seg_byte kernel/traps.c, 22, get_seg_long kernel/traps.c, 28, get_super fs/super.c, 56, include/fs.h, 197, get_termio kernel/chr_drv/tty_ioctl.c, 76, get_termios kernel/chr_drv/tty_ioctl.c, 56, getblk fs/buffer.c, 206, include/fs.h, 186, GETCH include/tty.h, 31,
getegid include/unistd.h, 215, geteuid include/unistd.h, 213, getgid include/unistd.h, 214, getpgrp include/unistd.h, 250, getpid include/unistd.h, 211, getppid include/unistd.h, 249, getuid include/unistd.h, 212, gid_t include/sys/types.h, 25, gmtime include/time.h, 37, gotoxy kernel/chr_drv/console.c, 88, hash fs/buffer.c, 129, hash_table fs/buffer.c, 31, hdkernel/blk_drv/hd.c, 59, HD_CMD include/hdreg.h, 21, HD_COMMAND include/hdreg.h, 19, HD_CURRENT include/hdreg.h, 16, HD_DATA include/hdreg.h, 10, HD_ERROR include/hdreg.h, 11, HD_HCYL include/hdreg.h, 15, hd_i_struct kernel/blk_drv/hd.c, 45, structhd_info kernel/blk_drv/hd.c, 49, structkernel/blk_drv/hd.c, 52, structhd_init init/main.c, 48, kernel/blk_drv/hd.c, 343, hd_interrupt kernel/blk_drv/hd.c, 67, HD_LCYL include/hdreg.h, 14, HD_NSECTOR include/hdreg.h, 12, hd_out kernel/blk_drv/hd.c, 180, HD_PRECOMP include/hdreg.h, 18,
HD_SECTOR include/hdreg.h, 13, HD_STATUS include/hdreg.h, 17, hd_struct kernel/blk_drv/hd.c, 56, structheadkernel/blk_drv/floppy.c, 117, HIGH_MEMORY mm/memory.c, 52, HOUR kernel/mktime.c, 21, HUPCL include/termios.h, 160, HZinclude/sched.h, 5, I_BLOCK_SPECIAL include/const.h, 9, I_CHAR_SPECIAL include/const.h, 10, I_CRNL kernel/chr_drv/tty_io.c, 42, I_DIRECTORY include/const.h, 7, I_MAP_SLOTS include/fs.h, 39, I_NAMED_PIPE include/const.h, 11, I_NLCRkernel/chr_drv/tty_io.c, 41, I_NOCRkernel/chr_drv/tty_io.c, 43, I_REGULAR include/const.h, 8, I_SET_GID_BIT include/const.h, 13, I_SET_UID_BIT include/const.h, 12, I_TYPE include/const.h, 6, I_UCLC kernel/chr_drv/tty_io.c, 40, i387_struct include/sched.h, 40, structICANON include/termios.h, 170, ICRNLinclude/termios.h, 91, ID_ERR include/hdreg.h, 48, idt include/head.h, 9, IEXTENinclude/termios.h, 183, iget fs/inode.c, 244,
include/fs.h, 182, IGNBRKinclude/termios.h, 83, IGNCRinclude/termios.h, 90, IGNPAR include/termios.h, 85, IMAXBELinclude/termios.h, 96, immoutb_p kernel/blk_drv/floppy.c, 50, IN_ORDER kernel/blk_drv/blk.h, 40, inb include/asm/io.h, 5, inb_p include/asm/io.h, 17, INCinclude/tty.h, 24, INC_PIPE include/fs.h, 63, INDEX_STAT include/hdreg.h, 25, init init/main.c, 45, init/main.c, 168, kernel/chr_drv/serial.c, 26, init_bucket_desc lib/malloc.c, 97, INIT_C_CC include/tty.h, 63, INIT_REQUEST kernel/blk_drv/blk.h, 127, INIT_TASK include/sched.h, 113, init_task kernel/sched.c, 58, unionINLCRinclude/termios.h, 89, ino_t include/sys/types.h, 27, inode_table fs/inode.c, 15, include/fs.h, 162, INODES_PER_BLOCK include/fs.h, 55, INPCK include/termios.h, 87, insert_char kernel/chr_drv/console.c, 336, insert_into_queues fs/buffer.c, 149, insert_line kernel/chr_drv/console.c, 350, int3 kernel/traps.c, 46,
interruptible_sleep_on include/sched.h, 146, kernel/sched.c, 167, INTMASK kernel/chr_drv/tty_io.c, 19, INTR_CHAR include/tty.h, 36, invalid_op kernel/traps.c, 49, invalid_TSS kernel/traps.c, 53, invalidate mm/memory.c, 39, invalidate_buffers fs/buffer.c, 84, invalidate_inodes fs/inode.c, 43, ioctl include/unistd.h, 216, ioctl_ptr fs/ioctl.c, 15, ioctl_table fs/ioctl.c, 19, iput fs/inode.c, 150, include/fs.h, 181, iretinclude/asm/system.h, 20, irq13 kernel/traps.c, 61, is_digit kernel/vsprintf.c, 16, IS_SEEKABLE include/fs.h, 24, isalnum include/ctype.h, 16, isalpha include/ctype.h, 17, isasciiinclude/ctype.h, 28, iscntrl include/ctype.h, 18, isdigit include/ctype.h, 19, isgraph include/ctype.h, 20, ISIG include/termios.h, 169, islower include/ctype.h, 21, isprint include/ctype.h, 22, ispunct include/ctype.h, 23, isspaceinclude/ctype.h, 24,
ISTRIP include/termios.h, 88, isupper include/ctype.h, 25, isxdigit include/ctype.h, 26, IUCLCinclude/termios.h, 92, IXANY include/termios.h, 94, IXOFFinclude/termios.h, 95, IXON include/termios.h, 93, jiffiesinclude/sched.h, 139, kernel/sched.c, 60, KBD_FINNISH include/config.h, 19, kernel_mktime init/main.c, 52, kernel/mktime.c, 41, keyboard_interrupt kernel/chr_drv/console.c, 56, kill include/unistd.h, 217, include/signal.h, 57, KILL_CHAR include/tty.h, 39, kill_session kernel/exit.c, 46, KILLMASK kernel/chr_drv/tty_io.c, 18, L_CANON kernel/chr_drv/tty_io.c, 32, L_ECHO kernel/chr_drv/tty_io.c, 34, L_ECHOCTL kernel/chr_drv/tty_io.c, 37, L_ECHOE kernel/chr_drv/tty_io.c, 35, L_ECHOK kernel/chr_drv/tty_io.c, 36, L_ECHOKE kernel/chr_drv/tty_io.c, 38, L_ISIG kernel/chr_drv/tty_io.c, 33, LASTinclude/tty.h, 28, last_pid kernel/fork.c, 22, LAST_TASK include/sched.h, 8, last_task_used_math include/sched.h, 137, kernel/sched.c, 63,
LATCH kernel/sched.c, 46, ldiv_t include/sys/types.h, 37, LDT_CODE include/head.h, 17, LDT_DATA include/head.h, 18, LDT_NUL include/head.h, 16, LEFTinclude/tty.h, 27, kernel/vsprintf.c, 31, lfkernel/chr_drv/console.c, 204, link include/unistd.h, 218, ll_rw_block include/fs.h, 187, kernel/blk_drv/ll_rw_blk.c, 145, lldt include/sched.h, 158, localtime include/time.h, 38, lock_buffer kernel/blk_drv/ll_rw_blk.c, 42, lock_inode fs/inode.c, 28, lock_super fs/super.c, 31, LOW_MEM mm/memory.c, 43, lseekinclude/unistd.h, 219, ltrinclude/sched.h, 157, m_inode include/fs.h, 93, structmain init/main.c, 104, tools/build.c, 57, main_memory_start init/main.c, 100, MAJOR include/fs.h, 33, MAJOR_NR kernel/blk_drv/hd.c, 25, kernel/blk_drv/floppy.c, 41, kernel/blk_drv/ramdisk.c, 17, make_request kernel/blk_drv/ll_rw_blk.c, 88, malloc include/kernel.h, 9, lib/malloc.c, 117, MAP_NR mm/memory.c, 46,
MARK_ERR include/hdreg.h, 45, match fs/namei.c, 63, math_emulate kernel/math/math_emulate.c, 18, math_error kernel/math/math_emulate.c, 37, math_state_restore kernel/sched.c, 77, MAX fs/file_dev.c, 15, MAX_ARG_PAGES fs/exec.c, 39, MAX_ERRORS kernel/blk_drv/hd.c, 34, kernel/blk_drv/floppy.c, 60, MAX_HD kernel/blk_drv/hd.c, 35, MAX_REPLIES kernel/blk_drv/floppy.c, 65, MAY_EXEC fs/namei.c, 29, MAY_READ fs/namei.c, 31, MAY_WRITE fs/namei.c, 30, mem_init init/main.c, 50, mm/memory.c, 399, mem_map mm/memory.c, 57, mem_use kernel/sched.c, 48, memchr include/string.h, 379, memcmp include/string.h, 363, memcpy include/string.h, 336, include/asm/memory.h, 8, memmove include/string.h, 346, memory_end init/main.c, 98, memset include/string.h, 395, MIN fs/file_dev.c, 14, MINIX_HEADER tools/build.c, 32, MINOR include/fs.h, 34, MINUTEkernel/mktime.c, 20, mkdir
include/sys/stat.h, 53, mkfifo include/sys/stat.h, 54, mknod include/unistd.h, 220, mktime include/time.h, 33, mode_t include/sys/types.h, 28, moff_timer kernel/sched.c, 203, mon_timer kernel/sched.c, 202, month kernel/mktime.c, 26, mount include/unistd.h, 221, mount_root fs/super.c, 242, include/fs.h, 200, move_to_user_mode include/asm/system.h, 1, N_ABS include/a.out.h, 128, N_BADMAG include/a.out.h, 31, N_BSS include/a.out.h, 137, N_BSSADDR include/a.out.h, 107, N_COMM include/a.out.h, 140, N_DATA include/a.out.h, 134, N_DATADDR include/a.out.h, 100, N_DATOFFinclude/a.out.h, 48, N_DRELOFF include/a.out.h, 56, N_EXTinclude/a.out.h, 147, N_FN include/a.out.h, 143, N_INDR include/a.out.h, 164, N_MAGIC include/a.out.h, 18, N_SETA include/a.out.h, 178, N_SETBinclude/a.out.h, 181, N_SETD include/a.out.h, 180, N_SETTinclude/a.out.h, 179,
N_SETV include/a.out.h, 184, N_STAB include/a.out.h, 153, N_STROFFinclude/a.out.h, 64, N_SYMOFF include/a.out.h, 60, N_TEXTinclude/a.out.h, 131, N_TRELOFF include/a.out.h, 52, N_TXTADDR include/a.out.h, 69, N_TXTOFF include/a.out.h, 43, N_TYPE include/a.out.h, 150, N_UNDF include/a.out.h, 125, NAME_LEN include/fs.h, 36, namei fs/namei.c, 303, include/fs.h, 178, NCCinclude/termios.h, 43, NCCSinclude/termios.h, 53, new_block fs/bitmap.c, 75, include/fs.h, 192, new_inode fs/bitmap.c, 136, include/fs.h, 194, next_timer kernel/sched.c, 270, niceinclude/unistd.h, 222, NL0 include/termios.h, 108, NL1 include/termios.h, 109, NLDLY include/termios.h, 107, nlink_t include/sys/types.h, 30, nlist include/a.out.h, 111, structNMAGIC include/a.out.h, 25, nmi kernel/traps.c, 45, NOFLSH include/termios.h, 176, nop
include/asm/system.h, 18, NPAR kernel/chr_drv/console.c, 54, npar kernel/chr_drv/console.c, 75, NR_BLK_DEV kernel/blk_drv/blk.h, 4, NR_BUFFERS fs/buffer.c, 34, include/fs.h, 48, nr_buffers include/fs.h, 166, NR_FILE include/fs.h, 45, NR_HASH include/fs.h, 47, NR_HD kernel/blk_drv/hd.c, 50, kernel/blk_drv/hd.c, 53, NR_INODE include/fs.h, 44, NR_OPEN include/fs.h, 43, NR_REQUEST kernel/blk_drv/blk.h, 15, NR_SUPER include/fs.h, 46, NR_TASKS include/sched.h, 4, NRDEVS fs/char_dev.c, 83, fs/ioctl.c, 17, NSIG include/signal.h, 10, NULL include/sys/types.h, 20, include/unistd.h, 18, include/stddef.h, 14, include/stddef.h, 15, include/string.h, 5, include/sched.h, 26, include/fs.h, 52, number kernel/vsprintf.c, 40, O_ACCMODE include/fcntl.h, 7, O_APPEND include/fcntl.h, 15, O_CREAT include/fcntl.h, 11, O_CRNL kernel/chr_drv/tty_io.c, 47, O_EXCL include/fcntl.h, 12, O_LCUC kernel/chr_drv/tty_io.c, 49,
O_NDELAY include/fcntl.h, 17, O_NLCR kernel/chr_drv/tty_io.c, 46, O_NLRET kernel/chr_drv/tty_io.c, 48, O_NOCTTYinclude/fcntl.h, 13, O_NONBLOCK include/fcntl.h, 16, O_POSTkernel/chr_drv/tty_io.c, 45, O_RDONLY include/fcntl.h, 8, O_RDWR include/fcntl.h, 10, O_TRUNC include/fcntl.h, 14, O_WRONLY include/fcntl.h, 9, OCRNLinclude/termios.h, 102, OFDEL include/termios.h, 106, off_t include/sys/types.h, 32, offsetof include/stddef.h, 17, OFILLinclude/termios.h, 105, OLCUCinclude/termios.h, 100, OMAGIC include/a.out.h, 23, ONLCRinclude/termios.h, 101, ONLRET include/termios.h, 104, ONOCR include/termios.h, 103, oom mm/memory.c, 33, open include/unistd.h, 223, include/fcntl.h, 53, lib/open.c, 11, open_namei fs/namei.c, 337, include/fs.h, 179, OPOST include/termios.h, 99, ORIG_ROOT_DEV init/main.c, 60, ORIG_VIDEO_COLS kernel/chr_drv/console.c, 43, ORIG_VIDEO_EGA_AX
kernel/chr_drv/console.c, 45, ORIG_VIDEO_EGA_BX kernel/chr_drv/console.c, 46, ORIG_VIDEO_EGA_CX kernel/chr_drv/console.c, 47, ORIG_VIDEO_LINES kernel/chr_drv/console.c, 44, ORIG_VIDEO_MODE kernel/chr_drv/console.c, 42, ORIG_VIDEO_PAGE kernel/chr_drv/console.c, 41, ORIG_X kernel/chr_drv/console.c, 39, ORIG_Y kernel/chr_drv/console.c, 40, origin kernel/chr_drv/console.c, 69, outb include/asm/io.h, 1, outb_p include/asm/io.h, 11, output_byte kernel/blk_drv/floppy.c, 194, overflow kernel/traps.c, 47, PAGE_ALIGN include/sched.h, 186, page_exception kernel/traps.c, 41, page_fault kernel/traps.c, 57, PAGE_SIZE include/a.out.h, 79, include/a.out.h, 88, include/a.out.h, 92, include/mm.h, 4, PAGING_MEMORY mm/memory.c, 44, PAGING_PAGES mm/memory.c, 45, panic include/kernel.h, 5, include/sched.h, 35, kernel/panic.c, 16, parkernel/chr_drv/console.c, 75, parallel_interrupt kernel/traps.c, 60, PARENB include/termios.h, 165, PARMRKinclude/termios.h, 86, PARODD include/termios.h, 166, partition include/hdreg.h, 52, struct
pause include/unistd.h, 224, PENDINinclude/termios.h, 182, permission fs/namei.c, 40, pg_dir include/head.h, 8, pid_t include/sys/types.h, 23, pipe include/unistd.h, 225, PIPE_EMPTY include/fs.h, 61, PIPE_FULL include/fs.h, 62, PIPE_HEAD include/fs.h, 58, PIPE_SIZE include/fs.h, 60, PIPE_TAIL include/fs.h, 59, PLUSkernel/vsprintf.c, 29, port_readkernel/blk_drv/hd.c, 61, port_write kernel/blk_drv/hd.c, 64, poskernel/chr_drv/console.c, 71, printbuf init/main.c, 42, printf include/kernel.h, 6, init/main.c, 151, printk include/kernel.h, 7, kernel/printk.c, 21, ptrdiff_t include/sys/types.h, 16, include/stddef.h, 6, put_fs_byte include/asm/segment.h, 25, put_fs_long include/asm/segment.h, 35, put_fs_word include/asm/segment.h, 30, put_page include/mm.h, 7, mm/memory.c, 197, put_super fs/super.c, 74, PUTCH include/tty.h, 33, ques kernel/chr_drv/console.c, 76,
QUIT_CHAR include/tty.h, 37, QUITMASK kernel/chr_drv/tty_io.c, 20, quotient kernel/chr_drv/tty_ioctl.c, 18, R_OK include/unistd.h, 25, raiseinclude/signal.h, 56, rd_init init/main.c, 51, kernel/blk_drv/ramdisk.c, 52, rd_length kernel/blk_drv/ramdisk.c, 21, rd_load kernel/blk_drv/hd.c, 68, kernel/blk_drv/ramdisk.c, 71, rd_start kernel/blk_drv/ramdisk.c, 20, readinclude/unistd.h, 226, READinclude/fs.h, 26, read_inodefs/inode.c, 17, fs/inode.c, 294, read_intr kernel/blk_drv/hd.c, 250, read_pipefs/read_write.c, 16, fs/pipe.c, 13, read_super fs/super.c, 100, READA include/fs.h, 28, READY_STAT include/hdreg.h, 30, recal_interrupt kernel/blk_drv/floppy.c, 343, recal_intr kernel/blk_drv/hd.c, 37, kernel/blk_drv/hd.c, 287, recalibrate kernel/blk_drv/hd.c, 39, kernel/blk_drv/floppy.c, 44, recalibrate_floppy kernel/blk_drv/floppy.c, 362, releasekernel/exit.c, 19, relocation_info include/a.out.h, 193, structremove_from_queues fs/buffer.c, 131, reply_buffer kernel/blk_drv/floppy.c, 66,
request kernel/blk_drv/ll_rw_blk.c, 21, kernel/blk_drv/blk.h, 23, structkernel/blk_drv/blk.h, 51, reserved kernel/traps.c, 59, resetkernel/blk_drv/hd.c, 40, kernel/blk_drv/floppy.c, 45, reset_controller kernel/blk_drv/hd.c, 217, reset_floppy kernel/blk_drv/floppy.c, 386, reset_hd kernel/blk_drv/hd.c, 230, reset_interrupt kernel/blk_drv/floppy.c, 373, respond kernel/chr_drv/console.c, 323, RESPONSEkernel/chr_drv/console.c, 85, restore_cur kernel/chr_drv/console.c, 440, result kernel/blk_drv/floppy.c, 212, rikernel/chr_drv/console.c, 214, ROOT_DEV fs/super.c, 29, include/fs.h, 198, ROOT_INO include/fs.h, 37, rs_init include/tty.h, 65, kernel/chr_drv/serial.c, 37, rs_write include/tty.h, 72, kernel/chr_drv/serial.c, 53, rs1_interrupt kernel/chr_drv/serial.c, 23, rs2_interrupt kernel/chr_drv/serial.c, 24, rw_char fs/read_write.c, 15, fs/char_dev.c, 95, rw_interrupt kernel/blk_drv/floppy.c, 250, rw_kmem fs/char_dev.c, 44, rw_mem fs/char_dev.c, 39, rw_memory fs/char_dev.c, 65, rw_port fs/char_dev.c, 49, rw_ram
fs/char_dev.c, 34, rw_tty fs/char_dev.c, 27, rw_ttyx fs/char_dev.c, 21, S_IFBLKinclude/sys/stat.h, 22, S_IFCHR include/sys/stat.h, 24, S_IFDIRinclude/sys/stat.h, 23, S_IFIFO include/sys/stat.h, 25, S_IFMTinclude/sys/stat.h, 20, S_IFREGinclude/sys/stat.h, 21, S_IRGRP include/sys/stat.h, 42, S_IROTH include/sys/stat.h, 47, S_IRUSR include/sys/stat.h, 37, S_IRWXG include/sys/stat.h, 41, S_IRWXO include/sys/stat.h, 46, S_IRWXU include/sys/stat.h, 36, S_ISBLKinclude/sys/stat.h, 33, S_ISCHR include/sys/stat.h, 32, S_ISDIRinclude/sys/stat.h, 31, S_ISFIFO include/sys/stat.h, 34, S_ISGIDinclude/sys/stat.h, 27, S_ISREGinclude/sys/stat.h, 30, S_ISUIDinclude/sys/stat.h, 26, S_ISVTXinclude/sys/stat.h, 28, S_IWGRPinclude/sys/stat.h, 43, S_IWOTH include/sys/stat.h, 48, S_IWUSRinclude/sys/stat.h, 38, S_IXGRPinclude/sys/stat.h, 44, S_IXOTH include/sys/stat.h, 49, S_IXUSR
include/sys/stat.h, 39, SA_NOCLDSTOP include/signal.h, 37, SA_NOMASK include/signal.h, 38, SA_ONESHOT include/signal.h, 39, save_cur kernel/chr_drv/console.c, 434, save_old kernel/signal.c, 28, saved_x kernel/chr_drv/console.c, 431, saved_y kernel/chr_drv/console.c, 432, sbrkinclude/unistd.h, 193, sched_init include/sched.h, 32, kernel/sched.c, 385, schedule include/sched.h, 33, kernel/sched.c, 104, scr_end kernel/chr_drv/console.c, 70, scrdown kernel/chr_drv/console.c, 170, scrupkernel/chr_drv/console.c, 107, sectorkernel/blk_drv/floppy.c, 116, seekkernel/blk_drv/floppy.c, 46, SEEK_CUR include/unistd.h, 29, SEEK_END include/unistd.h, 30, seek_interrupt kernel/blk_drv/floppy.c, 291, SEEK_SET include/unistd.h, 28, SEEK_STAT include/hdreg.h, 28, seek_trackkernel/blk_drv/floppy.c, 119, segment_not_present kernel/traps.c, 54, SEGMENT_SIZE include/a.out.h, 76, include/a.out.h, 82, include/a.out.h, 85, include/a.out.h, 89, include/a.out.h, 93, selectedkernel/blk_drv/floppy.c, 122, send_break
kernel/chr_drv/tty_ioctl.c, 51, send_sig kernel/exit.c, 35, set_baseinclude/sched.h, 211, set_bit fs/super.c, 22, fs/bitmap.c, 19, set_cursor kernel/chr_drv/console.c, 313, set_fsinclude/asm/segment.h, 61, set_intr_gate include/asm/system.h, 33, set_ldt_desc include/asm/system.h, 66, set_limit include/sched.h, 212, set_origin kernel/chr_drv/console.c, 97, set_system_gate include/asm/system.h, 39, set_termio kernel/chr_drv/tty_ioctl.c, 97, set_termios kernel/chr_drv/tty_ioctl.c, 66, set_trap_gate include/asm/system.h, 36, set_tss_descinclude/asm/system.h, 65, setgid include/unistd.h, 230, setpgid include/unistd.h, 228, setpgrpinclude/unistd.h, 227, setsid include/unistd.h, 251, setuid include/unistd.h, 229, setup_DMA kernel/blk_drv/floppy.c, 160, setup_rw_floppy kernel/blk_drv/floppy.c, 269, SETUP_SECTS tools/build.c, 42, share_page mm/memory.c, 344, show_stat kernel/sched.c, 37, show_task kernel/sched.c, 26, sig_atomic_t include/signal.h, 6, SIG_BLOCK include/signal.h, 41,
SIG_DFLinclude/signal.h, 45, SIG_IGNinclude/signal.h, 46, SIG_SETMASK include/signal.h, 43, SIG_UNBLOCK include/signal.h, 42, SIGABRTinclude/signal.h, 17, sigaction include/signal.h, 48, structinclude/signal.h, 66, sigaddsetinclude/signal.h, 58, SIGALRMinclude/signal.h, 26, SIGCHLD include/signal.h, 29, SIGCONT include/signal.h, 30, sigdelset include/signal.h, 59, sigemptyset include/signal.h, 60, sigfillset include/signal.h, 61, SIGFPEinclude/signal.h, 20, SIGHUPinclude/signal.h, 12, SIGILLinclude/signal.h, 15, SIGINTinclude/signal.h, 13, SIGIOTinclude/signal.h, 18, sigismember include/signal.h, 62, SIGKILL include/signal.h, 21, SIGNkernel/vsprintf.c, 28, sigpending include/signal.h, 63, SIGPIPEinclude/signal.h, 25, sigprocmask include/signal.h, 64, SIGQUIT include/signal.h, 14, SIGSEGV include/signal.h, 23, sigset_t include/signal.h, 7, SIGSTKFLT
include/signal.h, 28, SIGSTOP include/signal.h, 31, sigsuspend include/signal.h, 65, SIGTERMinclude/signal.h, 27, SIGTRAPinclude/signal.h, 16, SIGTSTPinclude/signal.h, 32, SIGTTINinclude/signal.h, 33, SIGTTOUinclude/signal.h, 34, SIGUNUSED include/signal.h, 19, SIGUSR1 include/signal.h, 22, SIGUSR2 include/signal.h, 24, size_tinclude/sys/types.h, 6, include/time.h, 11, include/stddef.h, 11, include/string.h, 10, skip_atoi kernel/vsprintf.c, 18, sleep_if_empty kernel/chr_drv/tty_io.c, 122, sleep_if_full kernel/chr_drv/tty_io.c, 130, sleep_oninclude/sched.h, 145, kernel/sched.c, 151, SMALLkernel/vsprintf.c, 33, SPACEkernel/vsprintf.c, 30, SPECIALkernel/vsprintf.c, 32, speed_t include/termios.h, 214, ST0kernel/blk_drv/floppy.c, 67, ST0_DSinclude/fdreg.h, 30, ST0_ECEinclude/fdreg.h, 33, ST0_HAinclude/fdreg.h, 31, ST0_INTRinclude/fdreg.h, 35, ST0_NRinclude/fdreg.h, 32, ST0_SE
include/fdreg.h, 34, ST1kernel/blk_drv/floppy.c, 68, ST1_CRC include/fdreg.h, 42, ST1_EOC include/fdreg.h, 43, ST1_MAM include/fdreg.h, 38, ST1_NDinclude/fdreg.h, 40, ST1_ORinclude/fdreg.h, 41, ST1_WPinclude/fdreg.h, 39, ST2kernel/blk_drv/floppy.c, 69, ST2_BC include/fdreg.h, 47, ST2_CMinclude/fdreg.h, 52, ST2_CRC include/fdreg.h, 51, ST2_MAM include/fdreg.h, 46, ST2_SEH include/fdreg.h, 49, ST2_SNS include/fdreg.h, 48, ST2_WC include/fdreg.h, 50, ST3kernel/blk_drv/floppy.c, 70, ST3_HAinclude/fdreg.h, 55, ST3_TZinclude/fdreg.h, 56, ST3_WPinclude/fdreg.h, 57, stack_segment kernel/traps.c, 55, start_buffer fs/buffer.c, 30, include/fs.h, 165, START_CHAR include/tty.h, 41, startup_time include/sched.h, 140, init/main.c, 53, kernel/sched.c, 61, statinclude/sys/stat.h, 6, structinclude/sys/stat.h, 55, include/unistd.h, 232, statekernel/chr_drv/console.c, 74,
STATUS_BUSY include/fdreg.h, 24, STATUS_BUSYMASK include/fdreg.h, 23, STATUS_DIR include/fdreg.h, 26, STATUS_DMA include/fdreg.h, 25, STATUS_READY include/fdreg.h, 27, STDERR_FILENO include/unistd.h, 15, STDIN_FILENO include/unistd.h, 13, STDOUT_FILENO include/unistd.h, 14, stiinclude/asm/system.h, 16, stime include/unistd.h, 234, STOP_CHAR include/tty.h, 42, strinclude/sched.h, 159, strcatinclude/string.h, 54, strchrinclude/string.h, 128, strcmp include/string.h, 88, strcpyinclude/string.h, 27, strcspninclude/string.h, 185, strerror include/string.h, 13, strftime include/time.h, 39, STRINGIFY tools/build.c, 44, strleninclude/string.h, 263, strncatinclude/string.h, 68, strncmp include/string.h, 107, strncpy include/string.h, 38, strpbrk include/string.h, 209, strrchr include/string.h, 145, strspninclude/string.h, 161, strstrinclude/string.h, 236, strtok
include/string.h, 277, super_block fs/super.c, 27, include/fs.h, 124, structinclude/fs.h, 164, SUPER_MAGIC include/fs.h, 41, suserinclude/kernel.h, 21, SUSPEND_CHAR include/tty.h, 43, switch_to include/sched.h, 171, syncinclude/unistd.h, 235, sync_dev fs/buffer.c, 59, fs/super.c, 18, include/fs.h, 196, sync_inodes fs/inode.c, 59, include/fs.h, 174, sys_accessfs/open.c, 47, include/sys.h, 34, sys_acctinclude/sys.h, 52, kernel/sys.c, 77, sys_alarm include/sys.h, 28, kernel/sched.c, 338, sys_break include/sys.h, 18, kernel/sys.c, 21, sys_brkinclude/sys.h, 46, kernel/sys.c, 168, sys_call_table include/sys.h, 74, sys_chdirfs/open.c, 75, include/sys.h, 13, sys_chmod fs/open.c, 105, include/sys.h, 16, sys_chownfs/open.c, 121, include/sys.h, 17, sys_chrootfs/open.c, 90, include/sys.h, 62, sys_closefs/open.c, 192, fs/exec.c, 32, fs/fcntl.c, 16,
include/sys.h, 7, kernel/exit.c, 17, sys_creatfs/open.c, 187, include/sys.h, 9, sys_dupfs/fcntl.c, 42, include/sys.h, 42, sys_dup2fs/fcntl.c, 36, include/sys.h, 64, sys_execve include/sys.h, 12, sys_exitfs/exec.c, 31, include/sys.h, 2, kernel/exit.c, 137, sys_fcntl fs/fcntl.c, 47, include/sys.h, 56, sys_forkinclude/sys.h, 3, sys_fstatfs/stat.c, 47, include/sys.h, 29, sys_ftime include/sys.h, 36, kernel/sys.c, 16, sys_getegid include/sys.h, 51, kernel/sched.c, 373, sys_geteuid include/sys.h, 50, kernel/sched.c, 363, sys_getgid include/sys.h, 48, kernel/sched.c, 368, sys_getpgrp include/sys.h, 66, kernel/sys.c, 201, sys_getpid include/sys.h, 21, kernel/sched.c, 348, sys_getppid include/sys.h, 65, kernel/sched.c, 353, sys_getuid include/sys.h, 25, kernel/sched.c, 358, sys_gttyinclude/sys.h, 33, kernel/sys.c, 36, sys_ioctl fs/ioctl.c, 30, include/sys.h, 55,
sys_kill include/sys.h, 38, kernel/exit.c, 60, sys_linkfs/namei.c, 721, include/sys.h, 10, sys_lock include/sys.h, 54, kernel/sys.c, 87, sys_lseekfs/read_write.c, 25, include/sys.h, 20, sys_mkdir fs/namei.c, 463, include/sys.h, 40, sys_mknod fs/namei.c, 412, include/sys.h, 15, sys_mount fs/super.c, 200, include/sys.h, 22, sys_mpx include/sys.h, 57, kernel/sys.c, 92, sys_niceinclude/sys.h, 35, kernel/sched.c, 378, sys_open fs/open.c, 138, include/sys.h, 6, sys_pause include/sys.h, 30, kernel/sched.c, 144, kernel/exit.c, 16, sys_physinclude/sys.h, 53, kernel/sys.c, 82, sys_pipe fs/pipe.c, 71, include/sys.h, 43, sys_profinclude/sys.h, 45, kernel/sys.c, 46, sys_ptraceinclude/sys.h, 27, kernel/sys.c, 26, sys_read fs/read_write.c, 55, include/sys.h, 4, sys_rename include/sys.h, 39, kernel/sys.c, 41, sys_rmdir fs/namei.c, 587, include/sys.h, 41,
sys_setgid include/sys.h, 47, kernel/sys.c, 72, sys_setpgidinclude/sys.h, 58, kernel/sys.c, 181, sys_setregid include/sys.h, 72, kernel/sys.c, 51, sys_setreuid include/sys.h, 71, kernel/sys.c, 118, sys_setsidinclude/sys.h, 67, kernel/sys.c, 206, sys_setuid include/sys.h, 24, kernel/sys.c, 143, sys_setupinclude/sys.h, 1, kernel/blk_drv/hd.c, 71, sys_sgetmask include/sys.h, 69, kernel/signal.c, 15, sys_sigactioninclude/sys.h, 68, kernel/signal.c, 63, sys_signalinclude/sys.h, 49, kernel/signal.c, 48, SYS_SIZE tools/build.c, 35, sys_ssetmask include/sys.h, 70, kernel/signal.c, 20, sys_statfs/stat.c, 36, include/sys.h, 19, sys_stime include/sys.h, 26, kernel/sys.c, 148, sys_sttyinclude/sys.h, 32, kernel/sys.c, 31, sys_syncfs/buffer.c, 44, include/sys.h, 37, kernel/panic.c, 14, sys_time include/sys.h, 14, kernel/sys.c, 102, sys_times include/sys.h, 44, kernel/sys.c, 156, sys_ulimit
include/sys.h, 59, kernel/sys.c, 97, sys_umask include/sys.h, 61, kernel/sys.c, 230, sys_umount fs/super.c, 167, include/sys.h, 23, sys_uname include/sys.h, 60, kernel/sys.c, 216, sys_unlinkfs/namei.c, 663, include/sys.h, 11, sys_ustat fs/open.c, 19, include/sys.h, 63, sys_utime fs/open.c, 24, include/sys.h, 31, sys_waitpid include/sys.h, 8, kernel/exit.c, 142, sys_writefs/read_write.c, 83, include/sys.h, 5, sysbeepkernel/chr_drv/console.c, 79, kernel/chr_drv/console.c, 699, sysbeepstop kernel/chr_drv/console.c, 691, system_call kernel/sched.c, 51, TAB0include/termios.h, 116, TAB1include/termios.h, 117, TAB2include/termios.h, 118, TAB3include/termios.h, 119, TABDLYinclude/termios.h, 115, table_list kernel/chr_drv/tty_io.c, 99, task include/sched.h, 136, kernel/sched.c, 65, TASK_INTERRUPTIBLE include/sched.h, 20, TASK_RUNNING include/sched.h, 19, TASK_STOPPED include/sched.h, 23, task_struct include/sched.h, 78, struct
TASK_UNINTERRUPTIBLE include/sched.h, 21, task_union kernel/sched.c, 53, unionTASK_ZOMBIE include/sched.h, 22, tcdrain include/termios.h, 220, tcflow include/termios.h, 221, TCFLSH include/termios.h, 18, tcflush include/termios.h, 222, TCGETA include/termios.h, 12, tcgetattr include/termios.h, 223, TCGETSinclude/termios.h, 8, TCIFLUSH include/termios.h, 205, TCIOFF include/termios.h, 201, TCIOFLUSH include/termios.h, 207, TCIONinclude/termios.h, 202, TCOFLUSH include/termios.h, 206, TCOOFFinclude/termios.h, 199, TCOON include/termios.h, 200, TCSADRAIN include/termios.h, 211, TCSAFLUSH include/termios.h, 212, TCSANOWinclude/termios.h, 210, TCSBRKinclude/termios.h, 16, tcsendbreak include/termios.h, 224, TCSETAinclude/termios.h, 13, TCSETAFinclude/termios.h, 15, tcsetattrinclude/termios.h, 225, TCSETAWinclude/termios.h, 14, TCSETSinclude/termios.h, 9, TCSETSFinclude/termios.h, 11, TCSETSW
include/termios.h, 10, TCXONC include/termios.h, 17, tell_father kernel/exit.c, 83, termio include/termios.h, 44, structtermios include/termios.h, 54, structticks_to_floppy_on include/fs.h, 170, include/fdreg.h, 9, kernel/sched.c, 206, time include/unistd.h, 236, include/time.h, 31, time_init init/main.c, 76, TIME_REQUESTS kernel/sched.c, 264, time_t include/sys/types.h, 11, include/time.h, 6, timer_interrupt kernel/sched.c, 50, timer_list kernel/sched.c, 266, structkernel/sched.c, 270, times include/sys/times.h, 13, include/unistd.h, 237, TIOCEXCL include/termios.h, 19, TIOCGPGRP include/termios.h, 22, TIOCGSOFTCAR include/termios.h, 32, TIOCGWINSZ include/termios.h, 26, TIOCINQ include/termios.h, 34, TIOCM_CAR include/termios.h, 192, TIOCM_CD include/termios.h, 195, TIOCM_CTS include/termios.h, 191, TIOCM_DSR include/termios.h, 194, TIOCM_DTR include/termios.h, 187, TIOCM_LE include/termios.h, 186, TIOCM_RI include/termios.h, 196, TIOCM_RNG
include/termios.h, 193, TIOCM_RTS include/termios.h, 188, TIOCM_SR include/termios.h, 190, TIOCM_ST include/termios.h, 189, TIOCMBICinclude/termios.h, 30, TIOCMBISinclude/termios.h, 29, TIOCMGET include/termios.h, 28, TIOCMSET include/termios.h, 31, TIOCNXCL include/termios.h, 20, TIOCOUTQ include/termios.h, 24, TIOCSCTTY include/termios.h, 21, TIOCSPGRP include/termios.h, 23, TIOCSSOFTCAR include/termios.h, 33, TIOCSTI include/termios.h, 25, TIOCSWINSZ include/termios.h, 27, tm include/time.h, 18, structtmp_floppy_area kernel/blk_drv/floppy.c, 105, tms include/sys/times.h, 6, structtoascii include/ctype.h, 29, tolower include/ctype.h, 31, top kernel/chr_drv/console.c, 73, TOSTOP include/termios.h, 177, toupper include/ctype.h, 32, trackkernel/blk_drv/floppy.c, 118, transfer kernel/blk_drv/floppy.c, 309, trap_init include/sched.h, 34, kernel/traps.c, 181, TRK0_ERR include/hdreg.h, 46, truncatefs/truncate.c, 47,
include/fs.h, 173, try_to_share mm/memory.c, 292, tss_structinclude/sched.h, 51, structTSTPMASKkernel/chr_drv/tty_io.c, 21, TTY_BUF_SIZE include/termios.h, 4, include/tty.h, 14, tty_init include/tty.h, 67, kernel/chr_drv/tty_io.c, 105, tty_intr kernel/chr_drv/tty_io.c, 111, tty_ioctl fs/ioctl.c, 13, kernel/chr_drv/tty_ioctl.c, 115, tty_queue include/tty.h, 16, structtty_read fs/char_dev.c, 16, include/tty.h, 69, kernel/chr_drv/tty_io.c, 230, tty_struct include/tty.h, 45, structtty_table include/tty.h, 55, structkernel/chr_drv/tty_io.c, 51, structtty_write fs/char_dev.c, 17, include/kernel.h, 8, include/sched.h, 36, include/tty.h, 70, kernel/chr_drv/tty_io.c, 290, TYPEkernel/blk_drv/floppy.c, 53, tzsetinclude/time.h, 40, u_char include/sys/types.h, 33, uid_t include/sys/types.h, 24, ulimit include/unistd.h, 238, umask include/sys/stat.h, 56, include/unistd.h, 239, umode_t include/sys/types.h, 29, umount include/unistd.h, 240, un_wp_page mm/memory.c, 221, uname include/sys/utsname.h, 14,
include/unistd.h, 241, unexpected_floppy_interrupt kernel/blk_drv/floppy.c, 353, unexpected_hd_interrupt kernel/blk_drv/hd.c, 237, unlink include/unistd.h, 242, unlock_buffer kernel/blk_drv/ll_rw_blk.c, 51, kernel/blk_drv/blk.h, 101, unlock_inode fs/inode.c, 37, usage tools/build.c, 52, USED mm/memory.c, 47, user_stack kernel/sched.c, 67, ushort include/sys/types.h, 34, ustat include/sys/types.h, 39, structinclude/unistd.h, 243, utimbuf include/utime.h, 6, structutime include/unistd.h, 244, include/utime.h, 11, utsname include/sys/utsname.h, 6, structva_arg include/stdarg.h, 24, va_end include/stdarg.h, 22, include/stdarg.h, 21, va_list include/stdarg.h, 4, va_start include/stdarg.h, 13, include/stdarg.h, 16, VDISCARD include/termios.h, 77, VEOF include/termios.h, 68, VEOL include/termios.h, 75, VEOL2 include/termios.h, 80, VERASE include/termios.h, 66, verify_area include/kernel.h, 4, kernel/fork.c, 24, video_erase_char kernel/chr_drv/console.c, 67, video_mem_end
kernel/chr_drv/console.c, 64, video_mem_start kernel/chr_drv/console.c, 63, video_num_columns kernel/chr_drv/console.c, 59, video_num_lines kernel/chr_drv/console.c, 61, video_page kernel/chr_drv/console.c, 62, video_port_reg kernel/chr_drv/console.c, 65, video_port_val kernel/chr_drv/console.c, 66, video_size_row kernel/chr_drv/console.c, 60, video_type kernel/chr_drv/console.c, 58, VIDEO_TYPE_CGA kernel/chr_drv/console.c, 50, VIDEO_TYPE_EGAC kernel/chr_drv/console.c, 52, VIDEO_TYPE_EGAM kernel/chr_drv/console.c, 51, VIDEO_TYPE_MDA kernel/chr_drv/console.c, 49, VINTR include/termios.h, 64, VKILLinclude/termios.h, 67, VLNEXT include/termios.h, 79, VMIN include/termios.h, 70, VQUIT include/termios.h, 65, VREPRINT include/termios.h, 76, vsprintf init/main.c, 44, kernel/printk.c, 19, kernel/vsprintf.c, 92, VSTART include/termios.h, 72, VSTOP include/termios.h, 73, VSUSP include/termios.h, 74, VSWTC include/termios.h, 71, VT0 include/termios.h, 125, VT1 include/termios.h, 126, VTDLY include/termios.h, 124, VTIME
include/termios.h, 69, VWERASE include/termios.h, 78, W_OK include/unistd.h, 24, waitinclude/sys/wait.h, 20, include/unistd.h, 246, lib/wait.c, 13, wait_for_keypress fs/super.c, 19, kernel/chr_drv/tty_io.c, 140, wait_for_request kernel/blk_drv/ll_rw_blk.c, 26, kernel/blk_drv/blk.h, 52, wait_motor kernel/sched.c, 201, wait_on include/fs.h, 175, wait_on_buffer fs/buffer.c, 36, wait_on_floppy_select kernel/blk_drv/floppy.c, 123, wait_on_inode fs/inode.c, 20, wait_on_super fs/super.c, 48, wait_until_sent kernel/chr_drv/tty_ioctl.c, 46, waitpid include/sys/wait.h, 21, include/unistd.h, 245, wake_up include/sched.h, 147, kernel/sched.c, 188, WAKEUP_CHARS kernel/chr_drv/serial.c, 21, WEXITSTATUS include/sys/wait.h, 15, WIFEXITED include/sys/wait.h, 13, WIFSIGNALED include/sys/wait.h, 18, WIFSTOPPED include/sys/wait.h, 14, WIN_DIAGNOSE include/hdreg.h, 41, WIN_FORMAT include/hdreg.h, 38, WIN_INIT include/hdreg.h, 39, WIN_READ include/hdreg.h, 35, WIN_RESTORE include/hdreg.h, 34, win_result
kernel/blk_drv/hd.c, 169, WIN_SEEK include/hdreg.h, 40, WIN_SPECIFY include/hdreg.h, 42, WIN_VERIFY include/hdreg.h, 37, WIN_WRITE include/hdreg.h, 36, winsizeinclude/termios.h, 36, structWNOHANG include/sys/wait.h, 10, WRERR_STAT include/hdreg.h, 29, writeinclude/unistd.h, 247, WRITEinclude/fs.h, 27, write_inode fs/inode.c, 18, fs/inode.c, 314, write_intr kernel/blk_drv/hd.c, 269, write_pipe fs/read_write.c, 17, fs/pipe.c, 41, write_verify kernel/fork.c, 20, mm/memory.c, 261, WRITEA include/fs.h, 29, WSTOPSIG include/sys/wait.h, 17, WTERMSIG include/sys/wait.h, 16, WUNTRACED include/sys/wait.h, 11, X_OK include/unistd.h, 23, XCASE include/termios.h, 171, XTABS include/termios.h, 120, ykernel/chr_drv/console.c, 72, YEARkernel/mktime.c, 23, Z_MAP_SLOTSinclude/fs.h, 40, ZEROPAD kernel/vsprintf.c, 27, ZMAGICinclude/a.out.h, 27,