亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? linux內核原代碼boot.s部分的注釋.txt

?? 學習(編程技巧_編程知識_程序代碼),是學習編程不可多得的學習精驗
?? TXT
字號:
linux內核原代碼boot.s部分的注釋
 

--------------------------------------------------------------------------------
 
第八軍團 時間:2004-1-23 15:48:23 
   
boot.s
  |
  | boot.s is loaded at 0x7c00 by the bios-startup routines, and moves itself
  | out of the way to address 0x90000, and jumps there.
  |
  | It then loads the system at 0x10000, using BIOS interrupts. Thereafter
  | it disables all interrupts, moves the system down to 0x0000, changes
  | to protected mode, and calls the start of system. System then must
  | RE-initialize the protected mode in it's own tables, and enable
  | interrupts as needed.
  |
  | NOTE! currently system is at most 8*65536 bytes long. This should be no
  | problem, even in the future. I want to keep it simple. This 512 kB
  | kernel size should be enough - in fact more would mean we'd have to move
  | not just these start-up routines, but also do something about the cache-
  | memory (block IO devices). The area left over in the lower 640 kB is meant
  | for these. No other memory is assumed to be "physical", ie all memory
  | over 1Mb is demand-paging. All addresses under 1Mb are guaranteed to match
  | their physical addresses.
  |
  | NOTE1 abouve is no longer valid in it's entirety. cache-memory is allocated
  | above the 1Mb mark as well as below. Otherwise it is mainly correct.
  |
  | NOTE 2! The boot disk type must be set at compile-time, by setting
  | the following equ. Having the boot-up procedure hunt for the right
  | disk type is severe brain-damage.
  | The loader has been made as simple as possible (had to, to get it
  | in 512 bytes with the code to move to protected mode), and continuos
  | read errors will result in a unbreakable loop. Reboot by hand. It
  | loads pretty fast by getting whole sectors at a time whenever possible.
  | 1.44Mb disks: sectors = 18
  | 1.2Mb disks:
  | sectors = 15
  | 720kB disks:
  | sectors = 9
  .globl begtext, begdata, begbss, endtext, enddata, endbss
  .text
  begtext:
  .data
  begdata:
  .bss
  begbss:
  .text 
BOOTSEG = 0x07c0
  INITSEG = 0x9000
  SYSSEG = 0x1000 | system loaded at 0x10000 (65536).
  ENDSEG = SYSSEG + SYSSIZE | SYSSIZE在Makefile中定義的 ^_^ 

entry start
  start:
   mov ax,#BOOTSEG | 現在應仍處在REAL MODE下.
   mov ds,ax | 移動自身從BOOTSEG:0000到INITSEG:0000
   mov ax,#INITSEG | 共512字節.
   mov es,ax | 那么BOOT.S處在0x90000-0x90200.
   mov cx,#256
   sub si,si
   sub di,di
   rep
   movw
   jmpi go,INITSEG
  go: mov ax,cs
   mov ds,ax | 將DS,ES,SS均設為0x9000,所有數據都以
   mov es,ax | 0x9000為段偏移.
   mov ss,ax | 堆棧偏移0x9000
   mov sp,#0x400 | 棧頂指針0x9000:0x0400,堆棧空間512bytes??
   mov ah,#0x03 | read cursor pos
   xor bh,bh
   int 0x10
   mov cx,#24
   mov bx,#0x0007 | page 0, attribute 7 (normal)
   mov bp,#msg1 | 顯示Loading System ...
   mov ax,#0x1301 | write string, move cursor
   int 0x10 

| ok, we've written the message, now
  | we want to load the system (at 0x10000) 

mov ax,#SYSSEG
   mov es,ax | segment of 0x010000
   call read_it | 讀內核到0x10000
   call kill_motor | 殺了軟驅!? ^_^ 

| if the read went well we get current cursor position ans save it for
  | posterity. 

mov ah,#0x03 | read cursor pos
   xor bh,bh
   int 0x10 | save it in known place, con_init fetches
   mov [510],dx | it from 0x90510. 

| now we want to move to protected mode ... 

cli | no interrupts allowed ! 

| first we move the system to it's rightful place 

mov ax,#0x0000
   cld | 'direction'=0, movs moves forward
  do_move:
   mov es,ax | destination segment
   add ax,#0x1000
   cmp ax,#0x9000
   jz end_move
   mov ds,ax | source segment
   sub di,di | 置零,地址為0x1000:0000
   sub si,si | 置零,地址為0x9000:0000
   mov cx,#0x8000 | cx的作用是計數器
   rep
   movsw
   j do_move | 將位于低端0x1000:0000的內核移到內存
   | 高端0x9000:0000,覆蓋了boot.S !? 

| then we load the segment descriptors 

end_move: 

mov ax,cs | right, forgot this at first. didn't work :-)
   mov ds,ax
   lidt idt_48 | idt_48和gdt_48都是一個3個word長的數據結構
   lgdt gdt_48 | 第一個字說明(Global || Interrupt) Descriptor
   | Table有多長,因為每個Table是四個字長,所以
   | 可以得出整個DescriptorTable的entries.(見下)
   | 后兩個字指出DT的具體位置.
   | idt_48是0,0,0;應表示沒有中斷描述符entries.
   | gdt_48有256個入口,第一個是個空入口,然后
   | 定義了一個code段和一個data段.基址都是
   | 0x00000000, !?那里是什么東西???
   | *** 0x00000000 != 0x0000:0000 *** 

| that was painless, now we enable A20 

call empty_8042
   mov al,#0xD1 | command write
   out #0x64,al
   call empty_8042
   mov al,#0xDF | A20 on
   out #0x60,al
   call empty_8042 

| well, that went ok, I hope. Now we have to reprogram the interrupts :-(
  | we put them right after the intel-reserved hardware interrupts, at
  | int 0x20-0x2F. There they won't mess up anything. Sadly IBM really
  | messed this up with the original PC, and they haven't been able to
  | rectify it afterwards. Thus the bios puts interrupts at 0x08-0x0f,
  | which is used for the internal hardware interrupts as well. We just
  | have to reprogram the 8259's, and it isn't fun.
  | 初始化中斷處理器8259i
  | 初始化順序為: 1. 向主8259A寫ICW1, 0x20
  | 2. 向第二塊8259A寫ICW1, 0xA0
  | 3. 向主8259A寫ICW2, 0x21
  | 4. 向第二塊8259A寫ICW2, 0xA1
  | 5. 如果ICW1指示有級聯中斷處理器,則初始化Master&Slave
  | (在下例中只有IR2有級聯8259A), 0x21, 0xA1
  | 6. 向兩塊8259寫ICW4,指定工作模式.
  | 輸入了適當的初始化命令之后, 8259已經準備好接收中斷請求.
  | 現在向他輸入工作
  | 命令字以規定其工作方式. 8259A共有三個工作命令字,但下例中只用過OCW1.
  | OCW1將所有的中斷都屏蔽掉, OCW2&OCW3也就沒什么意義了.
  | ** ICW stands for Initialization Command Word;
  | OCW for Operation Command Word.
  1. mov al,#0x11
   out #0x20,al
   .word 0x00eb,0x00eb | jmp $+2, jmp $+2
  2. out #0xA0,al | and to 8259A-2
   .word 0x00eb,0x00eb
  3. mov al,#0x20 | 向主8259A寫入ICW2.
   out #0x21,al | 硬件中斷入口地址0x20, 并由ICW1 

| 得知中斷向量長度 = 8 bytes.
   .word 0x00eb,0x00eb
  4. mov al,#0x28 | start of hardware int's 2 (0x28)
   out #0xA1,al | 第二塊8259A的中斷入口是0x28.
   .word 0x00eb,0x00eb
  5. mov al,#0x04 | 8259-1 is master
   out #0x21,al | Interrupt Request 2有級聯處理. 

.word 0x00eb,0x00eb
   mov al,#0x02 | 8259-2 is slave
   out #0xA1,al | 于上面對應,告訴大家我就是IR2對應
   | 級聯處理器.
   .word 0x00eb,0x00eb
  6. mov al,#0x01 | 8086 mode for both
   out #0x21,al
   .word 0x00eb,0x00eb
   out #0xA1,al 

.word 0x00eb,0x00eb
   mov al,#0xFF | mask off all interrupts for now
   out #0x21,al 

.word 0x00eb,0x00eb
   out #0xA1,al 

| well, that certainly wasn't fun :-(. Hopefully it works, and we don't
  | need no steenking BIOS anyway (except for the initial loading :-).
  | The BIOS-routine wants lots of unnecessary data, and it's less
  | "interesting" anyway. This is how REAL programmers do it.
  |
  | Well, now's the time to actually move into protected mode. To make
  | things as simple as possible, we do no register set-up or anything,
  | we let the gnu-compiled 32-bit programs do that. We just jump to
  | absolute address 0x00000, in 32-bit protected mode. 

mov ax,#0x0001 | protected mode (PE) bit
   lmsw ax | This is it!
   jmpi 0,8 | jmp offset 0 of segment 8 (cs) 

| This routine checks that the keyboard command queue is empty
  | No timeout is used - if this hangs there is something wrong with
  | the machine, and we probably couldn't proceed anyway.
  empty_8042:
   .word 0x00eb,0x00eb
   in al,#0x64 | 8042 status port
   test al,#2 | is input buffer full?
   jnz empty_8042 | yes - loop
   ret 

| This routine loads the system at address 0x10000, making sure
  | no 64kB boundaries are crossed. We try to load it as fast as
  | possible, loading whole tracks whenever we can.
  |
  | in: es - starting address segment (normally 0x1000)
  |
  | This routine has to be recompiled to fit another drive type,
  | just change the "sectors" variable at the start of the file
  | (originally 18, for a 1.44Mb drive)
  |
  sread: .word 1 | sectors read of current track
  head: .word 0 | current head
  track: .word 0 | current track
  read_it:
   mov ax,es | ES當前應0x1000
   test ax,#0x0fff | 必需確保ES處在64KB段邊界上,即0x?000:XXXX.
   | 要不你就會收到一個"DMA..."什么什么的ERR.
  die: jne die | es must be at 64kB boundary
   xor bx,bx | bx is starting address within segment
  rp_read: | **** 循環入口處 ****
   mov ax,es
   cmp ax,#ENDSEG | have we loaded all yet?
   jb ok1_read
   ret
  ok1_read:
   mov ax,#sectors | 1.44M, sectors=18,linux的后續版本
   | 中已改成由操作系統來探測sectors的值.
   sub ax,sread | AX內記載需要讀的扇區數,初始sread為1,
   | 即跳過第一道的第一扇區(BOOT區)
   mov cx,ax |
   shl cx,#9 | CX算出需要讀出的扇區的字節數, ax*512.
   add cx,bx | BX是當前段內偏移.
   | 下面連續的兩個轉移指令開始還真讓人莫名其妙.
   jnc ok2_read | 這里先檢查當前段內的空間夠不夠裝ax個扇區
   | cx算出字節數,加上當前偏移試試,夠了的話,就
   | 跳到ok2_read去讀吧!
   je ok2_read | 這么巧的事也有,剛剛夠! 讀!
   | 如果到了這里就確認溢出了,看下面的:
   xor ax,ax | 這段代碼我覺得很精巧.
   sub ax,bx | 它主要目的就是算出如果當前段內空間不夠的話,
   shr ax,#9 | 那么反算出剩余空間最多能裝多少個扇區,那么
   | 就讀出多少個.(Hint,段內空間是扇區的整數倍) 

ok2_read:
   call read_track | 讀取當前磁道.
   mov cx,ax ----| | (別忙,這里暫時不關cx什么事!)
   add ax,sread | | AX是這次讀出的扇區數, sread是該磁道已
   | | 讀出的扇區,相加更新AX的值.
   cmp ax,#sectors | | 該磁道所有的扇區都讀出了嗎?
   jne ok3_read | | 尚未,還不能移到下個磁道!
   mov ax,#1 |
   sub ax,head | | head對應軟盤來說只能是0,1
   jne ok4_read | | 0,1 head都讀過了才準往下走!
   inc track | | 終于可以讀下個磁道了,真累!
  ok4_read: |
   mov head,ax |
   xor ax,ax |
  ok3_read: |
   mov sread,ax | | 如果是由于還沒讀完所有的磁道?
   | | 那么ax記載當前磁道已讀出的扇區,更新sread.
   | | 如果已讀完18個扇區,ax被上一行代碼置零.
   shl cx,#9 >,周德明.后來我發現Minix的那本
  * 書里也有一點東西,還沒來的及看.
  * 另外多謝你提供的 across reference building tool,我還沒用熟,能簡單
  * 介紹介紹嗎? ^_^
  * 杜曉明 98.11.17
  **/
  @@ 1,你搞錯了,boot在讀完system到0x10000之后,又將它這么一移到0x0。:-)
  @@ 2.絕對地址0x00000里面 system.實模式中斷不能再用了
  @@ !)在整個初始化過程完畢后,系統jump: jmpi 0,8 這是個長跳轉 cs=8 eip=0
  @@ cs=8不是實模式的段,而是gdt表中第一 (0開始),就是你定義的初始的兩個GDT
  @@  中的第一項,所以,現在系統跳到絕對0,即head.s的startup
  @@ 3.用lxr的across reference building tool先解開后,基本上按INSTLL說明
  @@   make install
  @@ edit $(安裝目錄)/http/lxr.conf
  @@ baseurl 改為你的url
  @@ 我是這樣設的  http://192.168.1.3/lxr/
  @@ 同一目錄下設.htaccess INSTALL有
  @@      配置 httpd server
  @@ httpd.conf 加一行  Alias /lxr $(安裝目錄)/http/
  @@ cd $(安裝目錄)/source 產生標識符庫 ../bin/genxref $(kernel source目錄)
  @@ kernel source: /linux/0.01/....
  @@ /0.10/...
  @@ 你還可用global http://zaphod.ethz.ch/linux/
  @@ 我裝過,可是最后裝好后沒有搜索,不然應該會更好用。?
  @@ 4.內核調試我用過gdbstub,但是我發現調試好象的是gdbstub.c程序,而不是內核,只
  @@ 看到gdbstub.c的原代碼,沒有內核的原代碼,或許有個步驟我沒做導致如此.

 
 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区三区四区在线观看| 亚洲一区二区中文在线| 亚洲第一电影网| 欧美性大战久久久久久久 | 国产成人夜色高潮福利影视| 精品va天堂亚洲国产| 国产麻豆精品在线| 国产精品久久久久久久久快鸭 | 日本不卡一二三区黄网| 粉嫩高潮美女一区二区三区| 欧美激情综合网| 色呦呦网站一区| 丝袜美腿亚洲色图| 这里只有精品视频在线观看| 精品一区二区三区在线播放| 欧美经典三级视频一区二区三区| 91网站黄www| 亚洲一区二区不卡免费| 欧美一级欧美一级在线播放| 国产超碰在线一区| 国产精品第四页| 欧洲精品在线观看| 国产精品18久久久久久久久久久久 | 国产精品午夜免费| 欧美视频一区二区三区在线观看 | 丰满放荡岳乱妇91ww| 亚洲小少妇裸体bbw| 欧美激情一区在线观看| 91精品国产麻豆| 99久久精品免费| 精品一区二区三区在线观看国产 | 欧美成人a视频| 91免费国产在线观看| 激情综合网天天干| 亚洲第一会所有码转帖| 国产精品久久久久久久浪潮网站| 欧美精品aⅴ在线视频| 成人免费毛片片v| 国产制服丝袜一区| 日韩成人一区二区| 亚洲综合清纯丝袜自拍| 亚洲视频中文字幕| 国产欧美日本一区视频| 精品国产一区二区三区久久久蜜月 | 午夜精品免费在线| 亚洲免费观看高清| 国产精品免费网站在线观看| 欧美一二三四区在线| 欧美日本国产一区| 欧美视频一区二区三区四区| 91黄色免费看| 色综合天天综合网国产成人综合天| 国产一区二区剧情av在线| 激情综合网av| 国产精品99久久久| 国产精品88888| 国产一区二区伦理片| 国产美女av一区二区三区| 麻豆精品精品国产自在97香蕉| 国产精品久久影院| 国产欧美一区二区三区鸳鸯浴| 久久久久亚洲综合| 日本一区二区三区国色天香| 久久欧美一区二区| 国产精品美女一区二区三区| 中文字幕av不卡| 亚洲精品免费一二三区| 亚洲一级二级在线| 激情综合网av| 成人黄色网址在线观看| 在线精品观看国产| 欧美videos大乳护士334| 久久看人人爽人人| 亚洲天堂免费看| 香蕉加勒比综合久久| 久草在线在线精品观看| 日本高清不卡在线观看| 欧美午夜在线一二页| 欧美大白屁股肥臀xxxxxx| 久久久久久亚洲综合| 夜夜嗨av一区二区三区网页| 免费成人你懂的| 成人app在线| 在线观看网站黄不卡| 久久综合九色综合97_久久久| 欧美韩国日本不卡| 天天综合色天天综合| 国产一区二区不卡| 91视视频在线观看入口直接观看www | 日韩欧美电影一二三| 亚洲色图在线播放| 久久不见久久见免费视频1| 一本大道久久a久久综合婷婷| 欧美电影免费观看高清完整版在线观看| 国产精品少妇自拍| 蜜桃视频一区二区三区| 欧美在线免费观看视频| 国产精品福利电影一区二区三区四区| 日av在线不卡| 欧美日韩在线一区二区| 亚洲欧美日韩国产手机在线| 国产毛片一区二区| 日韩欧美精品三级| 亚洲成人自拍一区| 日本丰满少妇一区二区三区| 欧美激情在线一区二区三区| 精品一二三四在线| 日韩一级大片在线观看| 天天爽夜夜爽夜夜爽精品视频| 不卡一二三区首页| 久久久久久久久免费| 狠狠v欧美v日韩v亚洲ⅴ| 日韩一卡二卡三卡国产欧美| 五月婷婷色综合| 欧美精品日韩综合在线| 亚洲人成网站色在线观看| 国产成a人无v码亚洲福利| 2021久久国产精品不只是精品 | 欧美精品一区二区三区蜜臀| 五月天欧美精品| 欧美军同video69gay| 亚洲一区二区三区在线| 欧美中文字幕久久| 亚洲乱码中文字幕| 色婷婷亚洲综合| 一区二区在线观看视频在线观看| 97久久超碰国产精品| 1024成人网| 一本色道久久综合亚洲aⅴ蜜桃| 国产精品福利电影一区二区三区四区| 福利一区二区在线| 日本一区二区三区高清不卡| 99精品久久免费看蜜臀剧情介绍| 中文字幕中文在线不卡住| gogogo免费视频观看亚洲一| 国产精品嫩草久久久久| 99精品视频一区二区三区| 亚洲精品精品亚洲| 欧美精品自拍偷拍动漫精品| 日韩一区精品视频| 精品久久久久久最新网址| 久久99国产精品免费| 久久视频一区二区| 不卡视频一二三四| 亚洲一区二区视频在线| 91精品国产高清一区二区三区| 男人的天堂亚洲一区| 久久人人爽人人爽| 99精品视频在线免费观看| 午夜电影一区二区| 久久日韩精品一区二区五区| 成人97人人超碰人人99| 亚洲一区二区黄色| 精品日韩一区二区三区| 不卡av在线免费观看| 丝袜诱惑亚洲看片| 国产欧美久久久精品影院| 日本高清无吗v一区| 激情综合色播五月| 亚洲欧美日韩国产综合在线 | 不卡的电影网站| 亚洲国产精品久久一线不卡| 欧美大尺度电影在线| 91色视频在线| 国产一区在线不卡| 亚洲激情在线激情| 久久精品一区二区三区不卡牛牛| 色哟哟国产精品| 国产精品自产自拍| 天堂一区二区在线| 亚洲免费在线看| 久久精品人人做人人爽人人| 在线视频国内自拍亚洲视频| 国产成人综合在线| 午夜精品视频一区| 亚洲卡通欧美制服中文| 国产午夜精品在线观看| 欧美日韩国产综合一区二区三区| 高清国产一区二区三区| 蜜臀av性久久久久蜜臀av麻豆| 亚洲欧美一区二区三区久本道91| 亚洲精品一区二区三区四区高清| 欧美亚洲图片小说| 99久久精品国产导航| 国产成人啪午夜精品网站男同| 免费亚洲电影在线| 亚洲地区一二三色| 亚洲自拍偷拍麻豆| 亚洲黄色小视频| 国产精品夫妻自拍| 国产欧美一区二区精品忘忧草| 日韩精品在线看片z| 91精品在线免费| 欧美日韩精品一区二区在线播放| 99riav一区二区三区| 不卡一区二区在线| 成人app下载| 93久久精品日日躁夜夜躁欧美| 国产99久久久国产精品免费看| 国产麻豆9l精品三级站|