shoelace源代码分析,bochs调试-67870

shoelace源代码分析,bochs调试-67870_第1张图片


在readkernel里面有调用0x67870处的一个call,而0x67870里面有一个jmp 9020:0000的跳转,

这正是我们要找的,并没有加载完运行startminix()函数,因为那是为启动minix要做的。


最后一个断点0x67870

b 0x6101f

c

s


最后在附上:readkernel的反汇编代码,里面为适应linux-0.11启动而改动的部分加红

<bochs:29> u /180
00060e7e: (                    ): push bp                   ; 55
00060e7f: (                    ): mov bp, sp                ; 89e5
00060e81: (                    ): push di                   ; 57
00060e82: (                    ): push si                   ; 56
00060e83: (                    ): add sp, 0xfffffffa        ; 83c4fa
00060e86: (                    ): mov al, byte ptr [ds:0x9f0c] ; a00c9f
00060e89: (                    ): test al, al               ; 84c0
00060e8b: (                    ): jnz 0xe95                 ; 7508
00060e8d: (                    ): xor ax, ax                ; 31c0
00060e8f: (                    ): mov word ptr ss:[bp+0xfff6], ax ; 8946f6
00060e92: (                    ): jmp 0xf42                 ; e9ad00
00060e95: (                    ): xor al, al                ; 30c0
00060e97: (                    ): mov byte ptr [ds:0x9f0c], al ; a20c9f
00060e9a: (                    ): mov ax, 0x1f8             ; b8f801
00060e9d: (                    ): mov word ptr ss:[bp+0xfffa], ax ; 8946fa
00060ea0: (                    ): mov ax, 0x2               ; b80200
00060ea3: (                    ): push ax                   ; 50
00060ea4: (                    ): mov bx, 0x8506            ; bb0685
00060ea7: (                    ): push bx                   ; 53
00060ea8: (                    ): mov bx, word ptr ss:[bp+0x4] ; 8b5e04
00060eab: (                    ): add bx, 0x1fe             ; 81c3fe01
00060eaf: (                    ): push bx                   ; 53
00060eb0: (                    ): call 0x78ac               ; e8f969
00060eb3: (                    ): add sp, 0x6               ; 83c406
00060eb6: (                    ): test ax, ax               ; 85c0
00060eb8: (                    ): jnz 0xec2                 ; 7508
00060eba: (                    ): mov ax, word ptr ss:[bp+0xfffa] ; 8b46fa
00060ebd: (                    ): dec ax                    ; 48
00060ebe: (                    ): dec ax                    ; 48
00060ebf: (                    ): mov word ptr ss:[bp+0xfffa], ax ; 8946fa
00060ec2: (                    ): mov ax, word ptr ss:[bp+0xfffa] ; 8b46fa
00060ec5: (                    ): add ax, word ptr ss:[bp+0x4] ; 034604
00060ec8: (                    ): mov bx, ax                ; 89c3
00060eca: (                    ): mov bx, word ptr ds:[bx]  ; 8b1f
00060ecc: (                    ): mov ax, bx                ; 89d8
00060ece: (                    ): inc ax                    ; 40
00060ecf: (                    ): xor bx, bx                ; 31db
00060ed1: (                    ): push bx                   ; 53
00060ed2: (                    ): push ax                   ; 50
00060ed3: (                    ): mov ax, 0x200             ; b80002
00060ed6: (                    ): xor bx, bx                ; 31db
00060ed8: (                    ): push bx                   ; 53
00060ed9: (                    ): push ax                   ; 50
00060eda: (                    ): mov ax, word ptr ss:[bp+0xfff2] ; 8b46f2
00060edd: (                    ): mov bx, word ptr ss:[bp+0xfff4] ; 8b5ef4
00060ee0: (                    ): lea di, word ptr ss:[bp+0xffee] ; 8d7eee
00060ee3: (                    ): call 0x82bc               ; e8d673
00060ee6: (                    ): add sp, 0x8               ; 83c408
00060ee9: (                    ): mov di, 0xaedc            ; bfdcae
00060eec: (                    ): call 0x8270               ; e88173
00060eef: (                    ): jz 0xf0a                  ; 7419
00060ef1: (                    ): mov ax, 0x1               ; b80100
00060ef4: (                    ): mov [ds:0x8504], ax       ; a30485
00060ef7: (                    ): xor ax, ax                ; 31c0
00060ef9: (                    ): mov bx, 0x9               ; bb0900
00060efc: (                    ): mov [ds:0x9f08], ax       ; a3089f
00060eff: (                    ): mov word ptr [ds:0x9f0a], bx ; 891e0a9f
00060f03: (                    ): xor ax, ax                ; 31c0
00060f05: (                    ): mov word ptr ss:[bp+0xfff6], ax ; 8946f6
00060f08: (                    ): jmp 0xf42                 ; eb38
00060f0a: (                    ): mov ax, word ptr ss:[bp+0xfffa] ; 8b46fa
00060f0d: (                    ): inc ax                    ; 40
00060f0e: (                    ): inc ax                    ; 40
00060f0f: (                    ): add ax, word ptr ss:[bp+0x4] ; 034604
00060f12: (                    ): mov bx, ax                ; 89c3
00060f14: (                    ): mov bx, word ptr ds:[bx]  ; 8b1f
00060f16: (                    ): mov word ptr [ds:0xae98], bx ; 891e98ae
00060f1a: (                    ): mov ax, word ptr ss:[bp+0xfffa] ; 8b46fa
00060f1d: (                    ): add ax, 0x4               ; 050400
00060f20: (                    ): add ax, word ptr ss:[bp+0x4] ; 034604
00060f23: (                    ): mov bx, ax                ; 89c3
00060f25: (                    ): mov bx, word ptr ds:[bx]  ; 8b1f
00060f27: (                    ): mov word ptr [ds:0xae94], bx ; 891e94ae
00060f2b: (                    ): mov ax, word ptr ss:[bp+0xfffa] ; 8b46fa
00060f2e: (                    ): add ax, 0x6               ; 050600
00060f31: (                    ): add ax, word ptr ss:[bp+0x4] ; 034604
00060f34: (                    ): mov bx, ax                ; 89c3
00060f36: (                    ): mov bx, word ptr ds:[bx]  ; 8b1f
00060f38: (                    ): mov word ptr [ds:0xae9c], bx ; 891e9cae
00060f3c: (                    ): mov ax, 0x200             ; b80002
00060f3f: (                    ): mov word ptr ss:[bp+0xfff6], ax ; 8946f6
00060f42: (                    ): mov ax, 0x400             ; b80004
00060f45: (                    ): sub ax, word ptr ss:[bp+0xfff6] ; 2b46f6
00060f48: (                    ): mov word ptr ss:[bp+0xfff8], ax ; 8946f8
00060f4b: (                    ): mov ax, word ptr ss:[bp+0xfff8] ; 8b46f8
00060f4e: (                    ): xor bx, bx                ; 31db
00060f50: (                    ): mov di, 0xaedc            ; bfdcae
00060f53: (                    ): call 0x8270               ; e81a73
00060f56: (                    ): jb 0xf5b                  ; 7203
00060f58: (                    ): jmp 0xff3                 ; e99800
00060f5b: (                    ): push word ptr ss:[bp+0xfff8] ; ff76f8
00060f5e: (                    ): push word ptr [ds:0x9f0a] ; ff360a9f
00060f62: (                    ): push word ptr [ds:0x9f08] ; ff36089f
00060f66: (                    ): mov ax, word ptr ss:[bp+0xfff6] ; 8b46f6
00060f69: (                    ): add ax, word ptr ss:[bp+0x4] ; 034604
00060f6c: (                    ): push ax                   ; 50
00060f6d: (                    ): call 0xea                 ; e87af1
00060f70: (                    ): add sp, 0x8               ; 83c408
00060f73: (                    ): mov ax, word ptr ss:[bp+0xfff8] ; 8b46f8
00060f76: (                    ): xor bx, bx                ; 31db
00060f78: (                    ): push bx                   ; 53
00060f79: (                    ): push ax                   ; 50
00060f7a: (                    ): mov ax, [ds:0xaedc]       ; a1dcae
00060f7d: (                    ): mov bx, word ptr [ds:0xaede] ; 8b1edeae
00060f81: (                    ): lea di, word ptr ss:[bp+0xfff2] ; 8d7ef2
00060f84: (                    ): call 0x8328               ; e8a173
00060f87: (                    ): mov [ds:0xaedc], ax       ; a3dcae
00060f8a: (                    ): mov word ptr [ds:0xaede], bx ; 891edeae
00060f8e: (                    ): add sp, 0x4               ; 83c404
00060f91: (                    ): mov ax, word ptr ss:[bp+0xfff8] ; 8b46f8
00060f94: (                    ): xor bx, bx                ; 31db
00060f96: (                    ): mov di, 0x9f08            ; bf089f
00060f99: (                    ): call 0x8260               ; e8c472
00060f9c: (                    ): mov [ds:0x9f08], ax       ; a3089f
00060f9f: (                    ): mov word ptr [ds:0x9f0a], bx ; 891e0a9f
00060fa3: (                    ): mov ax, [ds:0x8504]       ; a10485
00060fa6: (                    ): test ax, ax               ; 85c0
00060fa8: (                    ): jz 0xfea                  ; 7440
00060faa: (                    ): mov ax, 0xc00             ; b8000c
00060fad: (                    ): mov bx, 0x9               ; bb0900
00060fb0: (                    ): push bx                   ; 53
00060fb1: (                    ): push ax                   ; 50
00060fb2: (                    ): mov ax, [ds:0x9f08]       ; a1089f
00060fb5: (                    ): mov bx, word ptr [ds:0x9f0a] ; 8b1e0a9f
00060fb9: (                    ): lea di, word ptr ss:[bp+0xfff2] ; 8d7ef2
00060fbc: (                    ): call 0x8270               ; e8b172
00060fbf: (                    ): lea sp, word ptr ss:[bp+0xfff6] ; 8d66f6
00060fc2: (                    ): jnz 0xfea                 ; 7526
00060fc4: (                    ): mov ax, 0x200             ; b80002
00060fc7: (                    ): push ax                   ; 50
00060fc8: (                    ): xor ax, ax                ; 31c0
00060fca: (                    ): mov bx, 0x1               ; bb0100
00060fcd: (                    ): push bx                   ; 53
00060fce: (                    ): push ax                   ; 50
00060fcf: (                    ): mov bx, word ptr ss:[bp+0x4] ; 8b5e04
00060fd2: (                    ): add bx, 0x200             ; 81c30002
00060fd6: (                    ): push bx                   ; 53
00060fd7: (                    ): call 0xea                 ; e810f1

00060fda: (                    ): add sp, 0x8               ; 83c408
00060fdd: (                    ): mov ax, 0x200             ; b80002
00060fe0: (                    ): mov bx, 0x1               ; bb0100
00060fe3: (                    ): mov [ds:0x9f08], ax       ; a3089f
00060fe6: (                    ): mov word ptr [ds:0x9f0a], bx ; 891e0a9f
00060fea: (                    ): xor ax, ax                ; 31c0
00060fec: (                    ): add sp, 0x6               ; 83c406
00060fef: (                    ): pop si                    ; 5e
00060ff0: (                    ): pop di                    ; 5f
00060ff1: (                    ): pop bp                    ; 5d
00060ff2: (                    ): retn                      ; c3

00060ff3: (                    ): push word ptr [ds:0xaedc] ; ff36dcae
00060ff7: (                    ): push word ptr [ds:0x9f0a] ; ff360a9f
00060ffb: (                    ): push word ptr [ds:0x9f08] ; ff36089f
00060fff: (                    ): mov ax, word ptr ss:[bp+0xfff6] ; 8b46f6
00061002: (                    ): add ax, word ptr ss:[bp+0x4] ; 034604
00061005: (                    ): push ax                   ; 50
00061006: (                    ): call 0xea                 ; e8e1f0
00061009: (                    ): add sp, 0x8               ; 83c408
0006100c: (                    ): mov ax, 0x1               ; b80100
0006100f: (                    ): xor bx, bx                ; 31db
00061011: (                    ): mov [ds:0xaedc], ax       ; a3dcae
00061014: (                    ): mov word ptr [ds:0xaede], bx ; 891edeae
00061018: (                    ): mov ax, [ds:0x8504]       ; a10485
0006101b: (                    ): test ax, ax               ; 85c0
0006101d: (                    ): jz 0x1022                 ; 7403
0006101f: (                    ): call 0x7870               ; e84e68
00061022: (                    ): mov ax, 0x1               ; b80100
00061025: (                    ): add sp, 0x6               ; 83c406
00061028: (                    ): pop si                    ; 5e
00061029: (                    ): pop di                    ; 5f
0006102a: (                    ): pop bp                    ; 5d
0006102b: (                    ): retn                      ; c3



在没有源码的情况下,猜测是正确的,

今天看到了shoelace.cdif文件的关键的修正部分:


X+ #define SETUPSEG 0x9020
X+ extern void startlinux();
X+ unsigned getdev();
X+
X  static inode_nr
X  readkernel F1(buffer *, bp)
X  
X***************
X*** 627,641 ****
X  
X      if ( (long) (* (unsigned int *) (&((char *) bp)[build_base]) + 1)
X           * SECTOR_SIZE != filesize) {
X!       printf("%s conflicting size information\n", filename);
X!       longjmp(errjmp, 1);
X!     }
X!
X!     fsck_ds = * (unsigned int *) (&((char *) bp)[build_base+2]);
X!     fsck_pc = * (unsigned int *) (&((char *) bp)[build_base+4]);
X!     fsck_cs = * (unsigned int *) (&((char *) bp)[build_base+6]);
X!
X!     bpinx = SECTOR_SIZE;
X    }
X  
X    bpsize = sizeof(*bp) - bpinx;
X--- 634,667 ----
X  
X      if ( (long) (* (unsigned int *) (&((char *) bp)[build_base]) + 1)
X           * SECTOR_SIZE != filesize) {
X!   /*    printf("%s conflicting size information\n", filename);
X!       longjmp(errjmp, 1);*/
X!       unsigned *myptr = (unsigned int *) (&((char *) bp)[508]);
X!       /*char *myroot = getenvs(SaveConfigPtr,"rootdev");
X!       if (strcmp(myroot,"bootdev"))
X!         *myptr = atoi(myroot);
X!       else
X!         *myptr = 0;
X!       if (*myptr == 0)
X!       { if (diskcode)
X!           *myptr = DEV_HD0 + bootpart;
X!         else
X!           if (n_sectors = 15)
X!             *myptr = 0x208;
X!           else
X!             *myptr = 0x21c;
X!       }*/
X!       Linux = 1;
X!       LoadPoint = 0x90000;
X!       bpinx = 0;
X!     }
X!     else {
X!       fsck_ds = * (unsigned int *) (&((char *) bp)[build_base+2]);
X!       fsck_pc = * (unsigned int *) (&((char *) bp)[build_base+4]);
X!       fsck_cs = * (unsigned int *) (&((char *) bp)[build_base+6]);
X!       bpinx = SECTOR_SIZE;
X!     }
X!
X    }
X  
X    bpsize = sizeof(*bp) - bpinx;
X***************
X*** 644,654 ****
X--- 670,687 ----
X      copyto((char *) bp + bpinx, LoadPoint, bpsize);
X      filesize  -= bpsize;
X      LoadPoint += bpsize;
X+     if (Linux && (LoadPoint==0x90C00))
X+     {
X+       copyto((char *) bp + SECTOR_SIZE, (ADDRESS)0x10000, SECTOR_SIZE);
X+       LoadPoint = 0x10200;
X+     }
X      return 0;
X    }
X  
X    copyto((char *) bp + bpinx, LoadPoint, (unsigned int) filesize);
X    filesize = 1;
X+   if (Linux)
X+     startlinux();
X    return ROOT_INODE;
X  }



X.text
X.define _startlinux
X.text
X
XSETUPLEN = 4                | nr of setup-sectors
XBOOTSEG  = 0x07c0            | original address of boot-sector
XINITSEG  = 0x9000            | we move boot here - out of the way
XSETUPSEG = 0x9020            | setup starts here
XSYSSEG   = 0x1000            | system loaded at 0x10000 (65536).
X
X| ROOT_DEV:    0x000 - same type of floppy as boot.
X|        0x301 - first partition on first drive etc
XROOT_DEV = 0x302 | 0x306
X
X_startlinux:
X     mov    ax,#BOOTSEG
X     mov    ds,ax
X     mov    ax,#INITSEG
X     mov    es,ax
Xgo:    mov    ax,cs
X    mov    ds,ax
X    mov    es,ax
X| put stack at 0x9ff00.
X    mov    ss,ax
X    mov    sp,#0xFF00        | arbitrary value >>512
X
Xok_load_setup:
X
X| Get disk drive parameters, specifically nr of sectors/track
X
X    mov    ch,#0x00
X    seg cs
X|    mov    sectors,cx
X    mov    ax,#INITSEG
X    mov    es,ax
X
X
X
X    seg cs
X
X| after that (everyting loaded), we jump to
X| the setup-routine loaded directly after
X| the bootblock:
X
X    jmpi    0,SETUPSEG
X
X
X


你可能感兴趣的:(setup,bochs,bootsect,shoelace,67870)