📄 video.s
字号:
movw $VIDEO_80x25,(%di) # The 80x25 mode (ALL) movw $0x50,2(%di) movw $0x19,4(%di) movw $0x00,6(%di) addw $8,%di leaw bootsym(vga_modes), %si # All modes for std VGA movw $vga_modes_end-vga_modes, %cx rep movsb call vesa_modes # Detect VESA VGA modes movw $ASK_VGA, (%di) # End marker movw %di, bootsym(mt_end)mtab1: leaw modelist, %si # SI=mode list, DI=list endret0: ret# Modes usable on all standard VGAsvga_modes: .word VIDEO_80x50, 0x50,0x32,0 # 80x50 .word VIDEO_80x43, 0x50,0x2b,0 # 80x43 .word VIDEO_80x28, 0x50,0x1c,0 # 80x28 .word VIDEO_80x30, 0x50,0x1e,0 # 80x30 .word VIDEO_80x34, 0x50,0x22,0 # 80x34 .word VIDEO_80x60, 0x50,0x3c,0 # 80x60vga_modes_end:# Detect VESA modes.vesa_modes: movw %di, %bp # BP=original mode table end leaw vesa_glob_info, %di movw $0x4f00, %ax # VESA Get card info call int $0x10 movw %di, %si movw %bp, %di cmpw $0x004f, %ax # Successful? jnz ret0 cmpw $0x4556, (%si) # 'VE' jnz ret0 cmpw $0x4153, 2(%si) # 'SA' jnz ret0 movw $bootsym(vesa_name), bootsym(card_name) # Set name to "VESA VGA" pushw %gs lgsw 0xe(%si), %si # GS:SI=mode list movw $128, %cx # Iteration limitvesa1: gs; lodsw cmpw $0xffff, %ax # End of the table? jz vesar cmpw $0x0080, %ax # Check validity of mode ID jc vesa2 orb %ah, %ah # Valid IDs 0x0000-0x007f/0x0100-0x07ff jz vesan # Certain BIOSes report 0x80-0xff! cmpw $0x0800, %ax jnc vesaevesa2: pushw %cx movw %ax, %cx # Get mode information structure movw $0x4f01, %ax int $0x10 movw %cx, %bx # BX=mode number addb $VIDEO_FIRST_VESA>>8, %bh popw %cx cmpw $0x004f, %ax jnz vesan # Don't report errors (buggy BIOSES) movb (%di), %al # Check capabilities. andb $0x9b, %al # LFB gfx mode in color? cmpb $0x9b, %al jnz vesan movw %bx, (%di) # Store mode number movw 0x12(%di), %bx # Width movw %bx, 2(%di) movw 0x14(%di), %bx # Height movw %bx, 4(%di) xorw %bx, %bx movb 0x19(%di), %bl # Depth movw %bx, 6(%di) addw $8, %di # The mode is valid. Store it.vesan: loop vesa1 # Next mode. Limit exceeded => errorvesae: leaw bootsym(vesaer), %si call prtstr movw %bp, %di # Discard already found modes.vesar: popw %gs ret# Read a key and return the ASCII code in al, scan code in ahgetkey: xorb %ah, %ah int $0x16 ret# Read a key with a timeout of 30 seconds.# The hardware clock is used to get the time.getkt: call gettime addb $30, %al # Wait 30 seconds cmpb $60, %al jl lminute subb $60, %allminute: movb %al, %clagain: movb $0x01, %ah int $0x16 jnz getkey # key pressed, so get it call gettime cmpb %cl, %al jne again movb $0x20, %al # timeout, return `space' ret# Flush the keyboard bufferflush: movb $0x01, %ah int $0x16 jz empty xorb %ah, %ah int $0x16 jmp flushempty: ret# Print hexadecimal number.prthw: pushw %ax movb %ah, %al call prthb popw %axprthb: pushw %ax shrb $4, %al call prthn popw %ax andb $0x0f, %alprthn: cmpb $0x0a, %al jc prth1 addb $0x07, %alprth1: addb $0x30, %al jmp prtchr# Print decimal number in axprtdec: pushw %ax pushw %cx pushw %dx xorw %dx, %dx movw $0x0a, %cx divw %cx testw %ax, %ax jz skip10 cmpw $0x09, %ax jbe lt100 call prtdec jmp skip10lt100: addb $0x30, %al call prtchrskip10: movb %dl, %al addb $0x30, %al call prtchr popw %dx popw %cx popw %ax ret# Routine to print asciiz string at ds:siprtstr: lodsb andb %al, %al jz fin call prtchr jmp prtstrfin: ret# Space printingprtsp2: call prtspc # Print double spaceprtspc: movb $0x20, %al # Print single space (note: fall-thru)# Part of above routine, this one just prints ascii alprtchr: pushw %ax pushw %cx movw $7,%bx movw $0x01, %cx movb $0x0e, %ah int $0x10 popw %cx popw %ax retbeep: movb $0x07, %al jmp prtchr# Read the cmos clock. Return the seconds in algettime: pushw %cx movb $0x02, %ah int $0x1a movb %dh, %al # %dh contains the seconds andb $0x0f, %al movb %dh, %ah movb $0x04, %cl shrb %cl, %ah aad popw %cx retstore_edid:#ifdef CONFIG_FIRMWARE_EDID pushw %ax pushw %bx pushw %cx pushw %dx pushw %di cmpb $1, bootsym(opt_edid) # EDID disabled on cmdline (edid=no)? je .Lno_edid leaw vesa_glob_info, %di movw $0x4f00, %ax int $0x10 cmpw $0x004f, %ax jne .Lno_edid cmpw $0x0200, 4(%di) # only do EDID on >= VBE2.0 jb .Lno_edid xorw %di, %di # Report Capability pushw %di popw %es # ES:DI must be 0:0 movw $0x4f15, %ax xorw %bx, %bx xorw %cx, %cx int $0x10 pushw %ds popw %es cmpw $0x004f, %ax # Call failed? jne .Lno_edid movw %bx, bootsym(boot_edid_caps) cmpb $2, bootsym(opt_edid) # EDID forced on cmdline (edid=force)? je .Lforce_edid /* EDID not forced on cmdline, so perform further sanity checks. */ testb $3,%bl # No DDC capabilities? jz .Lno_edid cmpb $5,%bh # Longer than 5s to read EDID? ja .Lno_edid.Lforce_edid: movw $0x4f15, %ax # do VBE/DDC movw $0x01, %bx movw $0x00, %cx movw $0x00, %dx movw $bootsym(boot_edid_info), %di int $0x10.Lno_edid: popw %di # restore all registers popw %dx popw %cx popw %bx popw %ax#endif retopt_edid: .byte 0 # EDID parsing option (force/no/default)mt_end: .word 0 # End of video mode table if builtedit_buf: .space 6 # Line editor buffercard_name: .word 0 # Pointer to adapter namegraphic_mode: .byte 0 # Graphic mode with a linear frame bufferdac_size: .byte 6 # DAC bit depth# Status messageskeymsg: .ascii "Press <RETURN> to see video modes available," .byte 0x0d, 0x0a .ascii "<SPACE> to continue or wait 30 secs" .byte 0x0d, 0x0a, 0listhdr: .byte 0x0d, 0x0a .ascii "MODE-KEY MODE-ID WIDTHxHEIGHTxDEPTH"crlft: .byte 0x0d, 0x0a, 0prompt: .byte 0x0d, 0x0a .asciz "Enter mode number or 'menu': "unknt: .ascii "Unknown mode ID. Try again." .byte 0x0d, 0x0a, 0badmdt: .ascii "You passed an undefined mode number." .byte 0x0d, 0x0a, 0vesaer: .ascii "Error: Scanning of VESA modes failed. Please " .ascii "report to <mj@ucw.cz>." .byte 0x0d, 0x0a, 0textmode: .asciz " (text)"menu_more_msg: .asciz "<press SPACE for more>"menu_bail_msg: .ascii "<menu truncated>" .byte 0x0d, 0x0a, 0svga_name: .ascii " "vga_name: .asciz "VGA"vesa_name: .asciz "VESA"name_bann: .asciz "Video adapter: "force_size: .word 0 # Use this size instead of the one in BIOS varsvesa_size: .word 0,0,0 # width x depth x height .globl boot_vid_info, boot_edid_info, boot_edid_caps/* If we don't run at all, assume basic video mode 3 at 80x25. */boot_vid_mode: .word VIDEO_80x25boot_vid_info: .byte 0, 0 /* orig_x, orig_y */ .byte 3 /* text mode 3 */ .byte 80, 25 /* 80x25 */ .byte 1 /* isVGA */ .word 16 /* 8x16 font */ .fill 0x28,1,0boot_edid_info: .fill 128,1,0x13boot_edid_caps: .word 0x1313
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -