patch-1.3.75 linux/arch/i386/boot/setup.S
Next file: linux/arch/i386/boot/video.S
Previous file: linux/arch/i386/boot/Makefile
Back to the patch index
Back to the overall index
- Lines: 791
- Date:
Sat Mar 16 13:52:10 1996
- Orig file:
v1.3.74/linux/arch/i386/boot/setup.S
- Orig date:
Wed Mar 13 10:09:11 1996
diff -u --recursive --new-file v1.3.74/linux/arch/i386/boot/setup.S linux/arch/i386/boot/setup.S
@@ -23,6 +23,9 @@
! High load stuff, initrd support and position independency
! by Hans Lermen & Werner Almesberger, February 1996
! <lermen@elserv.ffm.fgan.de>, <almesber@lrc.epfl.ch>
+!
+! Video handling moved to video.S by Martin Mares, March 1996
+! <mj@k332.feld.cvut.cz>
! NOTE! These had better be the same as in bootsect.s!
#define __ASSEMBLY__
@@ -31,10 +34,6 @@
#include <linux/version.h>
#include <linux/compile.h>
-#ifndef SVGA_MODE
-#define SVGA_MODE ASK_VGA
-#endif
-
! Signature words to ensure LILO loaded us right
#define SIG1 0xAA55
#define SIG2 0x5A5A
@@ -122,13 +121,18 @@
prtstr: lodsb
and al,al
jz fin
- call prnt1
+ call prtchr
jmp prtstr
fin: ret
+! Space printing
+
+prtsp2: call prtspc ! Print double space
+prtspc: mov al,#0x20 ! Print single space (fall-thru!)
+
! Part of above routine, this one just prints ascii al
-prnt1: push ax
+prtchr: push ax
push cx
xor bh,bh
mov cx,#0x01
@@ -139,7 +143,7 @@
ret
beep: mov al,#0x07
- jmp prnt1
+ jmp prtchr
no_sig_mess: .ascii "No setup signature found ..."
db 0x00
@@ -216,49 +220,16 @@
int 0x15
mov [2],ax
-! set the keyboard repeat rate to the max
+! Set the keyboard repeat rate to the max
mov ax,#0x0305
xor bx,bx ! clear bx
int 0x16
-! check for EGA/VGA and some config parameters
+! Check for video adapter and its parameters and allow the
+! user to browse video modes.
- mov ah,#0x12
- mov bl,#0x10
- int 0x10
- mov [8],ax
- mov [10],bx
- mov [12],cx
- mov ax,#0x5019
- cmp bl,#0x10
- je novga
- mov ax,#0x1a00 ! Added check for EGA/VGA discrimination
- int 0x10
- mov bx,ax
- mov ax,#0x5019
- movb [15],#0 ! by default, no VGA
- cmp bl,#0x1a ! 1a means VGA, anything else EGA or lower
- jne novga
- movb [15],#1 ! we've detected a VGA
- call chsvga
-novga: mov [14],al
- mov ah,#0x03 ! read cursor pos
- xor bh,bh ! clear bh
- int 0x10 ! save it in known place, con_init fetches
- mov [0],dx ! it from 0x90000.
-
-! Get video-card data:
-
- mov ah,#0x0f
- int 0x10
- mov [4],bx ! bh = display page
- mov [6],ax ! al = video mode, ah = window width
- xor ax,ax
- mov es,ax ! Access low memory
- seg es
- mov ax,[0x485] ! POINTS - Height of character matrix
- mov [16],ax
+ call video
! Get hd0 data
@@ -307,7 +278,7 @@
stosb
is_disk1:
-! check for PS/2 pointing device
+! Check for PS/2 pointing device
mov ax,cs ! aka #SETUPSEG
sub ax,#DELTA_INITSEG ! aka #INITSEG
@@ -361,7 +332,7 @@
done_apm_bios:
#endif
-! now we want to move to protected mode ...
+! Now we want to move to protected mode ...
seg cs
cmp realmode_swtch,#0
@@ -516,7 +487,7 @@
mov al,#0xFB ! mask all irq's but irq2 which
out #0x21,al ! is cascaded
-! well, that certainly wasn't fun :-(. Hopefully it works, and we don't
+! 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.
@@ -530,12 +501,11 @@
! Note that the short jump isn't strictly needed, although there are
! reasons why it might be a good idea. It won't hurt in any case.
!
- xor ax,ax
- inc ax ! protected mode (PE) bit
+ mov ax,#1 ! protected mode (PE) bit
lmsw ax ! This is it!
jmp flush_instr
flush_instr:
- mov bx,#0 ! Flag to indicate a boot
+ xor bx,bx ! Flag to indicate a boot
! NOTE: For high loaded big kernels we need a
! jmpi 0x100000,KERNEL_CS
@@ -664,45 +634,6 @@
test al,#2 ! is input buffer full?
jnz empty_8042 ! yes - loop
ret
-!
-! Read a key and return the (US-)ascii code in al, scan code in ah
-!
-getkey:
- xor ah,ah
- int 0x16
- ret
-
-!
-! Read a key with a timeout of 30 seconds. The cmos clock is used to get
-! the time.
-!
-getkt:
- call gettime
- add al,#30 ! wait 30 seconds
- cmp al,#60
- jl lminute
- sub al,#60
-lminute:
- mov cl,al
-again: mov ah,#0x01
- int 0x16
- jnz getkey ! key pressed, so get it
- call gettime
- cmp al,cl
- jne again
- mov al,#0x20 ! timeout, return default char `space'
- ret
-
-!
-! Flush the keyboard buffer
-!
-flush: mov ah,#0x01
- int 0x16
- jz empty
- xor ah,ah
- int 0x16
- jmp flush
-empty: ret
!
! Read the cmos clock. Return the seconds in al
@@ -721,510 +652,16 @@
ret
!
-! Delay is needed after doing i/o
+! Delay is needed after doing I/O
!
delay:
.word 0x00eb ! jmp $+2
ret
-! Routine trying to recognize type of SVGA-board present (if any)
-! and if it recognize one gives the choices of resolution it offers.
-! If one is found the resolution chosen is given by al,ah (rows,cols).
-
-chsvga: cld
- push ds
- push cs
- mov ax,[0x01fa]
- pop ds
- mov modesave,ax
- mov ax,#0xc000
- mov es,ax
- mov ax,modesave
- cmp ax,#NORMAL_VGA
- je defvga
- cmp ax,#EXTENDED_VGA
- je vga50
- cmp ax,#ASK_VGA
- jne svga
- lea si,msg1
- call prtstr
- call flush
-nokey: call getkt
- cmp al,#0x0d ! enter ?
- je svga ! yes - svga selection
- cmp al,#0x20 ! space ?
- je defvga ! no - repeat
- call beep
- jmp nokey
-defvga: mov ax,#0x5019
- pop ds
- ret
-/* extended vga mode: 80x50 */
-vga50:
- mov ax,#0x1112
- xor bl,bl
- int 0x10 ! use 8x8 font set (50 lines on VGA)
- mov ax,#0x1200
- mov bl,#0x20
- int 0x10 ! use alternate print screen
- mov ax,#0x1201
- mov bl,#0x34
- int 0x10 ! turn off cursor emulation
- mov ah,#0x01
- mov cx,#0x0607
- int 0x10 ! turn on cursor (scan lines 6 to 7)
- pop ds
- mov ax,#0x5032 ! return 80x50
- ret
-/* extended vga mode: 80x28 */
-vga28:
- pop ax ! clean the stack
- mov ax,#0x1111
- xor bl,bl
- int 0x10 ! use 9x14 fontset (28 lines on VGA)
- mov ah, #0x01
- mov cx,#0x0b0c
- int 0x10 ! turn on cursor (scan lines 11 to 12)
- pop ds
- mov ax,#0x501c ! return 80x28
- ret
-/* svga modes */
-!
-! test for presence of an S3 VGA chip. The algorithm was taken
-! from the SuperProbe package of XFree86 1.2.1
-! report bugs to Christoph.Niemann@linux.org
-!
-svga: cld
- mov cx,#0x0f35 ! we store some constants in cl/ch
- mov dx,#0x03d4
- movb al,#0x38
- call inidx
- mov bh,al ! store current value of CRT-register 0x38
- mov ax,#0x0038
- call outidx ! disable writing to special regs
- movb al,cl ! check whether we can write special reg 0x35
- call inidx
- movb bl,al ! save the current value of CRT reg 0x35
- andb al,#0xf0 ! clear bits 0-3
- movb ah,al
- movb al,cl ! and write it to CRT reg 0x35
- call outidx
- call inidx ! now read it back
- andb al,ch ! clear the upper 4 bits
- jz s3_2 ! the first test failed. But we have a
- movb ah,bl ! second chance
- mov al,cl
- call outidx
- jmp s3_1 ! do the other tests
-s3_2: mov ax,cx ! load ah with 0xf and al with 0x35
- orb ah,bl ! set the upper 4 bits of ah with the orig value
- call outidx ! write ...
- call inidx ! ... and reread
- andb al,cl ! turn off the upper 4 bits
- push ax
- movb ah,bl ! restore old value in register 0x35
- movb al,cl
- call outidx
- pop ax
- cmp al,ch ! setting lower 4 bits was successful => bad
- je no_s3 ! writing is allowed => this is not an S3
-s3_1: mov ax,#0x4838 ! allow writing to special regs by putting
- call outidx ! magic number into CRT-register 0x38
- movb al,cl ! check whether we can write special reg 0x35
- call inidx
- movb bl,al
- andb al,#0xf0
- movb ah,al
- movb al,cl
- call outidx
- call inidx
- andb al,ch
- jnz no_s3 ! no, we can't write => no S3
- mov ax,cx
- orb ah,bl
- call outidx
- call inidx
- andb al,ch
- push ax
- movb ah,bl ! restore old value in register 0x35
- movb al,cl
- call outidx
- pop ax
- cmp al,ch
- jne no_s31 ! writing not possible => no S3
- movb al,#0x30
- call inidx ! now get the S3 id ...
- lea di,idS3
- mov cx,#0x10
- repne
- scasb
- je no_s31
- lea si,dsc_S3 ! table of descriptions of video modes for BIOS
- lea di,mo_S3 ! table of sizes of video modes for my BIOS
- movb ah,bh
- movb al,#0x38
- call outidx ! restore old value of CRT register 0x38
- br selmod ! go ask for video mode
-no_s3: movb al,#0x35 ! restore CRT register 0x35
- movb ah,bl
- call outidx
-no_s31: movb ah,bh
- movb al,#0x38
- call outidx ! restore old value of CRT register 0x38
-
- lea si,idati ! Check ATI 'clues'
- mov di,#0x31
- mov cx,#0x09
- repe
- cmpsb
- jne noati
- lea si,dscati
- lea di,moati
- br selmod
-noati: mov ax,#0x200f ! Check Ahead 'clues'
- mov dx,#0x3ce
- out dx,ax
- inc dx
- in al,dx
- cmp al,#0x20
- je isahed
- cmp al,#0x21
- jne noahed
-isahed: lea si,dscahead
- lea di,moahead
- br selmod
-noahed: mov dx,#0x3c3 ! Check Chips & Tech. 'clues'
- in al,dx
- or al,#0x10
- out dx,al
- mov dx,#0x104
- in al,dx
- mov bl,al
- mov dx,#0x3c3
- in al,dx
- and al,#0xef
- out dx,al
- cmp bl,[idcandt]
- jne nocant
- lea si,dsccandt
- lea di,mocandt
- br selmod
-nocant: mov dx,#0x3d4 ! Check Cirrus 'clues'
- mov al,#0x0c
- out dx,al
- inc dx
- in al,dx
- mov bl,al
- xor al,al
- out dx,al
- dec dx
- mov al,#0x1f
- out dx,al
- inc dx
- in al,dx
- mov bh,al
- xor ah,ah
- shl al,#4
- mov cx,ax
- mov al,bh
- shr al,#4
- add cx,ax
- shl cx,#8
- add cx,#6
- mov ax,cx
- mov dx,#0x3c4
- out dx,ax
- inc dx
- in al,dx
- and al,al
- jnz nocirr
- mov al,bh
- out dx,al
- in al,dx
- cmp al,#0x01
- jne nocirr
- call rst3d4
- lea si,dsccirrus
- lea di,mocirrus
- br selmod
-rst3d4: mov dx,#0x3d4
- mov al,bl
- xor ah,ah
- shl ax,#8
- add ax,#0x0c
- out dx,ax
- ret
-nocirr: call rst3d4 ! Check Everex 'clues'
- mov ax,#0x7000
- xor bx,bx
- int 0x10
- cmp al,#0x70
- jne noevrx
- shr dx,#4
- cmp dx,#0x678
- je istrid
- cmp dx,#0x236
- je istrid
- lea si,dsceverex
- lea di,moeverex
- br selmod
-istrid: lea cx,ev2tri
- jmp cx
-noevrx: lea si,idgenoa ! Check Genoa 'clues'
- xor ax,ax
- seg es
- mov al,[0x37]
- mov di,ax
- mov cx,#0x04
- dec si
- dec di
-l1: inc si
- inc di
- mov al,(si)
- test al,al
- jz l2
- seg es
- cmp al,(di)
-l2: loope l1
- cmp cx,#0x00
- jne nogen
- lea si,dscgenoa
- lea di,mogenoa
- br selmod
-nogen: cld
- lea si,idoakvga
- mov di,#0x08
- mov cx,#0x08
- repe
- cmpsb
- jne nooak
- lea si,dscoakvga
- lea di,mooakvga
- br selmod
-nooak: cld
- lea si,idparadise ! Check Paradise 'clues'
- mov di,#0x7d
- mov cx,#0x04
- repe
- cmpsb
- jne nopara
- lea si,dscparadise
- lea di,moparadise
- br selmod
-nopara: mov dx,#0x3c4 ! Check Trident 'clues'
- mov al,#0x0e
- out dx,al
- inc dx
- in al,dx
- xchg ah,al
- xor al,al
- out dx,al
- in al,dx
- xchg al,ah
- mov bl,al ! Strange thing ... in the book this wasn't
- and bl,#0x02 ! necessary but it worked on my card which
- jz setb2 ! is a trident. Without it the screen goes
- and al,#0xfd ! blurred ...
- jmp clrb2 !
-setb2: or al,#0x02 !
-clrb2: out dx,al
- and ah,#0x0f
- cmp ah,#0x02
- jne notrid
-ev2tri: lea si,dsctrident
- lea di,motrident
- jmp selmod
-notrid: mov dx,#0x3cd ! Check Tseng 'clues'
- in al,dx ! Could things be this simple ! :-)
- mov bl,al
- mov al,#0x55
- out dx,al
- in al,dx
- mov ah,al
- mov al,bl
- out dx,al
- cmp ah,#0x55
- jne notsen
- lea si,dsctseng
- lea di,motseng
- jmp selmod
-notsen: mov dx,#0x3cc ! Check Video7 'clues'
- in al,dx
- mov dx,#0x3b4
- and al,#0x01
- jz even7
- mov dx,#0x3d4
-even7: mov al,#0x0c
- out dx,al
- inc dx
- in al,dx
- mov bl,al
- mov al,#0x55
- out dx,al
- in al,dx
- dec dx
- mov al,#0x1f
- out dx,al
- inc dx
- in al,dx
- mov bh,al
- dec dx
- mov al,#0x0c
- out dx,al
- inc dx
- mov al,bl
- out dx,al
- mov al,#0x55
- xor al,#0xea
- cmp al,bh
- jne novid7
- lea si,dscvideo7
- lea di,movideo7
- jmp selmod
-novid7: lea si,dsunknown
- lea di,mounknown
-selmod: xor cx,cx
- mov cl,(di)
- mov ax,modesave
- cmp ax,#ASK_VGA
- je askmod
- cmp ax,#NORMAL_VGA
- je askmod
- cmp al,cl
- jl gotmode
- push si
- lea si,msg4
- call prtstr
- pop si
-askmod: push si
- lea si,msg2
- call prtstr
- pop si
- push si
- push cx
-tbl: pop bx
- push bx
- mov al,bl
- sub al,cl
- call modepr
- lodsw
- xchg al,ah
- call dprnt
- xchg ah,al
- push ax
- mov al,#0x78
- call prnt1
- pop ax
- call dprnt
- push si
- lea si,crlf ! print CR+LF
- call prtstr
- pop si
- loop tbl
- pop cx
- lea si,msg3
- call prtstr
- pop si
- add cl,#0x30
- jmp nonum
-nonumb: call beep
-nonum: call getkey
- cmp al,#0x30 ! ascii `0'
- jb nonumb
- cmp al,#0x3a ! ascii `9'
- jbe number
- cmp al,#0x61 ! ascii `a'
- jb nonumb
- cmp al,#0x7a ! ascii `z'
- ja nonumb
- sub al,#0x27
- cmp al,cl
- jae nonumb
- sub al,#0x30
- jmp gotmode
-number: cmp al,cl
- jae nonumb
- sub al,#0x30
-gotmode: xor ah,ah
- or al,al
- beq vga50
- push ax
- dec ax
- beq vga28
- add di,ax
- mov al,(di)
- int 0x10
- pop ax
- shl ax,#1
- add si,ax
- lodsw
- pop ds
- ret
-
-! Routine to write al into a VGA-register that is
-! accessed via an index register
-!
-! dx contains the address of the index register
-! al contains the index
-! ah contains the value to write to the data register (dx + 1)
-!
-! no registers are changed
-
-outidx: out dx,al
- push ax
- mov al,ah
- inc dx
- out dx,al
- dec dx
- pop ax
- ret
-inidx: out dx,al
- inc dx
- in al,dx
- dec dx
- ret
-
-! Routine to print a decimal value on screen, the value to be
-! printed is put in al (i.e 0-255).
-
-dprnt: push ax
- push cx
- xor ah,ah ! Clear ah
- mov cl,#0x0a
- idiv cl
- cmp al,#0x09
- jbe lt100
- call dprnt
- jmp skip10
-lt100: add al,#0x30
- call prnt1
-skip10: mov al,ah
- add al,#0x30
- call prnt1
- pop cx
- pop ax
- ret
-
!
-! Routine to print the mode number key on screen. Mode numbers
-! 0-9 print the ascii values `0' to '9', 10-35 are represented by
-! the letters `a' to `z'. This routine prints some spaces around the
-! mode no.
+! Descriptor tables
!
-modepr: push ax
- cmp al,#0x0a
- jb digit ! Here is no check for number > 35
- add al,#0x27
-digit: add al,#0x30
- mov modenr, al
- push si
- lea si, modestring
- call prtstr
- pop si
- pop ax
- ret
-
gdt:
.word 0,0,0,0 ! dummy
@@ -1248,68 +685,25 @@
.word 0x800 ! gdt limit=2048, 256 GDT entries
.word 512+gdt,0x9 ! gdt base = 0X9xxxx
-msg1: .ascii "Press <RETURN> to see SVGA-modes available, <SPACE> to continue or wait 30 secs."
- db 0x0d, 0x0a, 0x0a, 0x00
-msg2: .ascii "Mode: COLSxROWS:"
- db 0x0d, 0x0a, 0x0a, 0x00
-msg3: db 0x0d, 0x0a
- .ascii "Choose mode by pressing the corresponding number or letter."
-crlf: db 0x0d, 0x0a, 0x00
-msg4: .ascii "You passed an undefined mode number to setup. Please choose a new mode."
- db 0x0d, 0x0a, 0x0a, 0x07, 0x00
-modestring: .ascii " "
-modenr: db 0x00 ! mode number
- .ascii ": "
- db 0x00
-
-idati: .ascii "761295520"
-idcandt: .byte 0xa5
-idgenoa: .byte 0x77, 0x00, 0x99, 0x66
-idparadise: .ascii "VGA="
-idoakvga: .ascii "OAK VGA "
-idS3: .byte 0x81, 0x82, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95
- .byte 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa8, 0xb0
-
-! Manufacturer: Numofmodes+2: Mode:
-! Number of modes is the number of chip-specific svga modes plus the extended
-! modes available on any vga (currently 2)
-
-moati: .byte 0x06, 0x23, 0x33, 0x22, 0x21
-moahead: .byte 0x07, 0x22, 0x23, 0x24, 0x2f, 0x34
-mocandt: .byte 0x04, 0x60, 0x61
-mocirrus: .byte 0x06, 0x1f, 0x20, 0x22, 0x31
-moeverex: .byte 0x0c, 0x03, 0x04, 0x07, 0x08, 0x0a, 0x0b, 0x16, 0x18, 0x21, 0x40
-mogenoa: .byte 0x0c, 0x58, 0x5a, 0x60, 0x61, 0x62, 0x63, 0x64, 0x72, 0x74, 0x78
-moparadise: .byte 0x04, 0x55, 0x54
-motrident: .byte 0x09, 0x50, 0x51, 0x52, 0x57, 0x58, 0x59, 0x5a
-motseng: .byte 0x07, 0x26, 0x2a, 0x23, 0x24, 0x22
-movideo7: .byte 0x08, 0x40, 0x43, 0x44, 0x41, 0x42, 0x45
-mooakvga: .byte 0x08, 0x00, 0x07, 0x4e, 0x4f, 0x50, 0x51
-mo_S3: .byte 0x04, 0x54, 0x55
-mounknown: .byte 0x02
-
-! msb = Cols lsb = Rows:
-! The first two modes are standard vga modes available on any vga.
-! mode 0 is 80x50 and mode 1 is 80x28
-
-dscati: .word 0x5032, 0x501c, 0x8419, 0x842c, 0x641e, 0x6419
-dscahead: .word 0x5032, 0x501c, 0x842c, 0x8419, 0x841c, 0xa032, 0x5042
-dsccandt: .word 0x5032, 0x501c, 0x8419, 0x8432
-dsccirrus: .word 0x5032, 0x501c, 0x8419, 0x842c, 0x841e, 0x6425
-dsceverex: .word 0x5032, 0x501c, 0x5022, 0x503c, 0x642b, 0x644b, 0x8419, 0x842c, 0x501e, 0x641b, 0xa040, 0x841e
-dscgenoa: .word 0x5032, 0x501c, 0x5020, 0x642a, 0x8419, 0x841d, 0x8420, 0x842c, 0x843c, 0x503c, 0x5042, 0x644b
-dscparadise: .word 0x5032, 0x501c, 0x8419, 0x842c
-dsctrident: .word 0x5032, 0x501c, 0x501e, 0x502b, 0x503c, 0x8419, 0x841e, 0x842b, 0x843c
-dsctseng: .word 0x5032, 0x501c, 0x503c, 0x6428, 0x8419, 0x841c, 0x842c
-dscvideo7: .word 0x5032, 0x501c, 0x502b, 0x503c, 0x643c, 0x8419, 0x842c, 0x841c
-dscoakvga: .word 0x5032, 0x501c, 0x2819, 0x5019, 0x503c, 0x843c, 0x8419, 0x842b
-dsc_S3: .word 0x5032, 0x501c, 0x842b, 0x8419
-dsunknown: .word 0x5032, 0x501c
-modesave: .word SVGA_MODE
+!
+! Include video setup & detection code
+!
+
+#include "video.S"
+
+!
+! Setup signature -- must be last
+!
-! This must be last
setup_sig1: .word SIG1
setup_sig2: .word SIG2
+
+!
+! After this point, there is some free space which is used by the video mode
+! handling code to store the temporary mode table (not used by the kernel).
+!
+
+modelist:
.text
endtext:
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this