📄 disk.s
字号:
#if 0; disk.S -- inquire of BIOS and display disk parameters;Copyright 1999-2002 John Coffman.All rights reserved.Licensed under the terms contained in the file 'COPYING' in the source directory.#endif#define DEBUG 0#define DELL_DIRTY_HACKSYSSEG = 0x1000 ; DEF_SYSSEGSETUPSEG = 0x9020 ; DEF_SETUPSEG .text#if 1.globl _main_main:#endif .globl zerozero:; we want this to look like a bootable kernel image; so we include the following header; jmp begin .ascii "HdrS" ; Signature for Setup header .word 0x0201 ; header format version number .word 0,0 ; realmode switch, SETUPSEG .word SYSSEG ; SYSSEG -- load at 1000:0000 .word id_string .byte 0 ; type of loader .byte 0 ; flags 0=load low .word 0x200 ; move size dd 0x1000 ; load us here dd 0 ; ramdisk image .word bs_helper,SETUPSEG ; kludge??? .word modelist+1024 ; heap end pointer;----------end of header------------ begin: mov ax,cs cli ;make purists happy mov ss,ax mov sp,#0x7FFE sti ; *** call start ;do not separate from the instruction belowstart: pop bx ;this MUST immediately follow the 'call' sub bx,#start-zero lea dx,zero sub bx,dx ;BX=100h under DOS, BX=0h under BIOS mov cl,#4 sar bx,cl add ax,bx mov ds,ax cld#ifdef DELL_DIRTY_HACK mov ah,#15 ; get video mode int 0x10 cbw int 0x10 ; set video mode#endif call say .ascii "\n>>>> Disk Detection and Parameter Display <<<<\n" .ascii "Version 1.5.4, Copyright (C) 1999-2002 John Coffman.\n" .ascii "Re-use and redistribution rights set forth" .ascii " in the file \"COPYING\".\n\n" .byte 0 cmp magic,#0xAA55 je sane ;check that we got the DS set right call say .ascii "\n\nCS/DS sanity check failed.\n" .byte 0hlti: hlt jmp hlti;;; nop ;spacermagic: .word 0xAA55sane:#if 0 xor ax,ax mov dl,al int 0x13 mov ah,#8 int 0x13#endif smsw ax test al,#1 jnz v86mode br realmodev86mode: call say .ascii "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" .ascii "!!! *** Warning: DOS is not running in REAL mode *** !!!\n" .ascii "!!! *** Reported results may not be accurate *** !!!\n" .ascii "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" .byte 0 call pauserealmode: call say .ascii "There " .byte 0 int 0x11 ; get equipment configuration test al,#1 mov ah,#-1 jz noflop shl ax,1 shl ax,1 and ah,#3 jz flop1noflop: call say .ascii "are " .byte 0 jmp flop2flop1: call say .ascii "is " .byte 0flop2: inc ah mov nflop,ah mov al,ah add al,#0x30 call putc call say .ascii " floppy drive" .byte 0 mov al,#'s dec ah jz flop3 call putcflop3: inc ah call say .ascii " with BIOS support.\n" .byte 0; now probe for floppy drives mov dl,#-1fprobe: mov ah,#8 inc dl push dx xor cx,cx int 0x13 pop dx jc fstop or cx,cx jnz fprobefstop: mov ah,nflop cmp ah,dl je fdisplay call say .ascii "But probing has found " .byte 0 mov al,dl add al,#'0 call putc call say .ascii "!!!\n" .byte 0 cmp ah,dl jae fdisplay xchg ah,dlfdisplay: mov dl,#0 ;start with drive 0x00 xor cx,cx mov cl,ah jcxz floppy1floppy: call drive inc dl loop floppyfloppy1: mov al,#10 call putc call say .ascii "There is " .byte 0 int 0x12 ;get amount of low memory;;; mov ax,#640 ;debug xor dx,dx call print call say .ascii "K of low memory" .byte 0 mov bx,#640 sub bx,ax jnz ebda1 call say .ascii " with no EBDA." .byte 0 br ebda2ebda1: push ax mov ax,bx xor bx,bx call say .ascii ". EBDA size = " .byte 0 call dec3 call say .ascii "K EBDA starts at 0x" .byte 0 pop ax mov cl,#6 shl ax,cl call wout call say .ascii "0" .byte 0ebda2: call say .ascii "\n" .byte 0; post-floppy pause call pause mov ah,#0 mov dl,#0x80 int 0x13 mov ah,#8 int 0x13 mov ah,#0 jc nohard mov ah,dlnohard: mov nhard,ah call say .ascii "There " .byte 0 dec ah jz hard1 call say .ascii "are " .byte 0 jmp hard2hard1: call say .ascii "is " .byte 0hard2: inc ah mov al,ah add al,#'0 call putc call say .ascii " hard drive" .byte 0 mov al,#'s dec ah jz hard3 call putchard3: inc ah call say .ascii " with BIOS support.\n" .byte 0; probe for hard drives mov dl,#0x80-1hprobe: mov ah,#8 inc dl push dx xor cx,cx int 0x13 pop dx jc hstop or cx,cx jnz hprobehstop: and dl,#0x7f mov ah,nhard cmp ah,dl je hdisplay call say .ascii "But probing has found " .byte 0 mov al,dl add al,#'0 call putc call say .ascii "!!!\n" .byte 0 cmp ah,dl jae hdisplay xchg ah,dlhdisplay: mov dl,#0x80 ;start with drive 0x80 xor cx,cx mov cl,ah jcxz hdd1hard: call drive inc dl loop hardhdd1: test byte ptr bigflag,#0xFF jz hdd2 br bighdd2: test byte ptr bigcyl,#0xFF jz hdd3 br big2hdd3: call say .ascii "\nEither your BIOS does not support EDD" .ascii " packet calls, or you have no large\n" .ascii "disks. You do not need to use LILO with" .ascii " the 'lba32' global option (or '-L'\n" .ascii "switch).\n" .byte 0 br exitbig: call say .ascii "\nYou have " .byte 0 cmp byte bigflag,#1 je noS call say .ascii "disks" .byte 0 jmp goOnnoS: call say .ascii "a disk" .byte 0goOn: call say .ascii " bigger than 8.4Gb" .byte 0big1c: call say .ascii " with Enhanced BIOS support.\n" .ascii "Using LILO with the 'lba32' global option" .ascii " (or '-L' switch) is recommended.\n" .byte 0 br exitbig2: call say .ascii "\nYou have " .byte 0 cmp byte bigcyl,#1 je big2a call say .ascii "disks" .byte 0 jmp big2bbig2a: call say .ascii "a disk" .byte 0big2b: call say .ascii " with more than 1023 cylinders" .byte 0 br big1cnflop: .byte 0nhard: .byte 0bigflag: .byte 0bigcyl: db 0nlimit: dd 1024*255*63, 0; inquire whether EDD drive BIOS calls are valid; Carry clear says NO, Carry set says YES, CX=device bits &; SI = pointer to dparam tableinqedd: push ax push bx push dx push si mov ah,#0x41 mov bx,#0x55aa int 0x13 jc edd7 cmp bx,#0xaa55 jne edd7 test cl,#7 stc jz edd8 lea si,dparam mov word (si),#dlth;;; nop ;spacer;;; nop ;spacer mov dh,ah ;save version number mov ah,#0x48 ;get drive parameters int 0x13 jc edd7 stc pop ax ;discard saved SI mov (si+1),dh ;save version info jmp edd9 ;return SI, too edd7: xor cx,cx ;carry is clearedd8: pop siedd9: pop dx pop bx pop ax ret; pause for the user to look at the screenpause: call say .ascii "Hit any key to continue..." .byte 0 mov ah,#0 int 0x16 call say .ascii "\r \n" .byte 0 ret; print out the IBM BIOS drive parameters for the drive in DLdrive: push bp push ax push bx push cx push es push di push si push dx call say .ascii "Drive 0x" .byte 0 mov al,dl call bout call say .ascii " Cyl:Head:Sec = " .byte 0 mov ah,#8 int 0x13#if DEBUG mov cx,#0xFAFF mov dh,#0xFF ; 0xFE is the max.#endif push cx push dx rol cl,1 mov di,#1000 rol cl,1 xor bh,bh and cl,#3 xchg ch,cl inc cx mov ax,cx xor dx,dx div di mov bp,cx or ax,ax jz cyl2 call say .ascii "1" .byte 0 mov bh,#0x80cyl2: xchg ax,dx call dec3 call punct pop dx xor ax,ax mov al,dh xor bh,bh inc ax call dec3 mov dx,ax call punct;;; pop cx;;; and cl,#0x3F;;; mov al,cl pop ax and ax,#0x3F call dec3 call say .ascii " (" .byte 0;;; mul dl mul dx mul bp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -