Home | History | Annotate | Line # | Download | only in lib
biosvbe.S revision 1.1.14.1
      1 /* $NetBSD: biosvbe.S,v 1.1.14.1 2011/02/17 11:59:45 bouyer Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2009 Jared D. McNeill <jmcneill (at) invisible.ca>
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  * POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #include <machine/asm.h>
     30 
     31 	.text
     32 
     33 /*
     34  * VESA BIOS Extensions routines
     35  */
     36 
     37 /*
     38  * Function 00h - Return VBE Controller Information
     39  *
     40  * int biosvbe_info(struct vbeinfoblock *)
     41  * return: VBE call status
     42  */
     43 ENTRY(biosvbe_info)
     44 	pushl	%ebp
     45 	movl	%esp,%ebp
     46 	pushl	%ebx
     47 	pushl	%ecx
     48 	pushl	%edx
     49 	push	%esi
     50 	push	%edi
     51 
     52 	movl	8(%ebp), %edi	/* vbe info block address*/
     53 
     54 	call	_C_LABEL(prot_to_real)
     55 	.code16
     56 
     57 	push	%es
     58 
     59 	push	%di
     60 	shrl	$4, %edi
     61 	mov	%ds, %ax
     62 	add	%di, %ax
     63 	mov	%ax, %es
     64 	pop	%di
     65 	and	$0xf, %di	/* mode info block address now in es:di */
     66 
     67 	movw	$0x4f00, %ax	/* get vbe info block */
     68 	int	$0x10
     69 
     70 	pop	%es
     71 
     72 	calll	_C_LABEL(real_to_prot)
     73 	.code32
     74 
     75 	andl	$0xffff,%eax
     76 
     77 	pop	%edi
     78 	pop	%esi
     79 	popl	%edx
     80 	popl	%ecx
     81 	popl	%ebx
     82 	popl	%ebp
     83 	ret
     84 
     85 /*
     86  * Function 01h - Return VBE Mode Information
     87  *
     88  * int biosvbe_get_mode_info(int mode, struct modeinfoblock *mi)
     89  * return: VBE call status
     90  */
     91 ENTRY(biosvbe_get_mode_info)
     92 	pushl	%ebp
     93 	movl	%esp,%ebp
     94 	pushl	%ebx
     95 	pushl	%ecx
     96 	pushl	%edx
     97 	push	%esi
     98 	push	%edi
     99 
    100 	movl	8(%ebp), %ecx	/* mode number */
    101 	movl	12(%ebp), %edi	/* mode info block address */
    102 
    103 	call	_C_LABEL(prot_to_real)
    104 	.code16
    105 
    106 	push	%es
    107 
    108 	push	%di
    109 	shrl	$4, %edi
    110 	mov	%ds, %ax
    111 	add	%di, %ax
    112 	mov	%ax, %es
    113 	pop	%di
    114 	and	$0xf, %di	/* mode info block address now in es:di */
    115 
    116 	movw	$0x4f01, %ax	/* get mode info block */
    117 	int	$0x10
    118 
    119 	pop	%es
    120 
    121 	calll	_C_LABEL(real_to_prot)
    122 	.code32
    123 
    124 	andl	$0xffff,%eax
    125 
    126 	pop	%edi
    127 	pop	%esi
    128 	popl	%edx
    129 	popl	%ecx
    130 	popl	%ebx
    131 	popl	%ebp
    132 	ret
    133 
    134 /*
    135  * Function 02h - Set VBE Mode
    136  *
    137  * int biosvbe_set_mode(int mode)
    138  * return: VBE call status
    139  */
    140 ENTRY(biosvbe_set_mode)
    141 	pushl	%ebp
    142 	movl	%esp,%ebp
    143 	pushl	%ebx
    144 	pushl	%ecx
    145 	pushl	%edx
    146 	push	%esi
    147 	push	%edi
    148 
    149 	movl	8(%ebp), %ebx	/* mode number */
    150 	orl	$0x4000, %ebx
    151 
    152 	call	_C_LABEL(prot_to_real)
    153 	.code16
    154 
    155 	movw	$0x4f02, %ax	/* set mode */
    156 	int	$0x10
    157 
    158 	calll	_C_LABEL(real_to_prot)
    159 	.code32
    160 
    161 	andl	$0xffff,%eax
    162 
    163 	pop	%edi
    164 	pop	%esi
    165 	popl	%edx
    166 	popl	%ecx
    167 	popl	%ebx
    168 	popl	%ebp
    169 	ret
    170 
    171 /*
    172  * Function 08h - Set/Get DAC Palette Format
    173  *
    174  * int biosvbe_palette_format(int format)
    175  * return: VBE call status
    176  */
    177 ENTRY(biosvbe_palette_format)
    178 	pushl	%ebp
    179 	movl	%esp,%ebp
    180 	pushl	%ebx
    181 	pushl	%ecx
    182 	pushl	%edx
    183 	push	%esi
    184 	push	%edi
    185 
    186 	movl	8(%ebp), %ebx	/* mode number */
    187 
    188 	call	_C_LABEL(prot_to_real)
    189 	.code16
    190 
    191 	movw	$0x4f08, %ax	/* get/set palette format */
    192 	int	$0x10
    193 
    194 	calll	_C_LABEL(real_to_prot)
    195 	.code32
    196 
    197 	andl	$0xffff,%eax
    198 
    199 	pop	%edi
    200 	pop	%esi
    201 	popl	%edx
    202 	popl	%ecx
    203 	popl	%ebx
    204 	popl	%ebp
    205 	ret
    206 
    207 /*
    208  * Function 09h - Set/Get Palette Data
    209  *
    210  * int biosvbe_palette_data(int mode, int reg, struct paletteentry *)
    211  * return: VBE call status
    212  */
    213 ENTRY(biosvbe_palette_data)
    214 	pushl	%ebp
    215 	movl	%esp,%ebp
    216 	pushl	%ebx
    217 	pushl	%ecx
    218 	pushl	%edx
    219 	push	%esi
    220 	push	%edi
    221 
    222 	movl	8(%ebp), %ebx	/* mode number */
    223 	movl	12(%ebp), %edx	/* register */
    224 	movl	16(%ebp), %edi	/* palette entry address */
    225 	movl	$1, %ecx	/* # palette entries to update */
    226 
    227 	call	_C_LABEL(prot_to_real)
    228 	.code16
    229 
    230 	push	%es
    231 
    232 	push	%di
    233 	shrl	$4, %edi
    234 	mov	%ds, %ax
    235 	add	%di, %ax
    236 	mov	%ax, %es
    237 	pop	%di
    238 	and	$0xf, %di	/* palette entry address now in es:di */
    239 
    240 	movw	$0x4f09, %ax	/* get/set palette entry */
    241 	int	$0x10
    242 
    243 	pop	%es
    244 
    245 	calll	_C_LABEL(real_to_prot)
    246 	.code32
    247 
    248 	andl	$0xffff,%eax
    249 
    250 	pop	%edi
    251 	pop	%esi
    252 	popl	%edx
    253 	popl	%ecx
    254 	popl	%ebx
    255 	popl	%ebp
    256 	ret
    257 
    258 /*
    259  * Function 15h BL=00h - Report VBE/DDC Capabilities
    260  *
    261  * int biosvbe_ddc_caps(void)
    262  * return: VBE/DDC capabilities
    263  */
    264 ENTRY(biosvbe_ddc_caps)
    265 	pushl	%ebp
    266 	movl	%esp,%ebp
    267 	pushl	%ebx
    268 	pushl	%ecx
    269 	pushl	%edx
    270 	push	%esi
    271 	push	%edi
    272 
    273 	call	_C_LABEL(prot_to_real)
    274 	.code16
    275 
    276 	movw	$0x4f15, %ax	/* display identification extensions */
    277 	mov	$0x00, %bx	/* report DDC capabilities */
    278 
    279 	movl	$0x0000, %esi	/* ES:DI == 0:0 */
    280 	movl	$0x0000, %edi
    281 	mov	$0x00, %cx	/* controller unit number (00h = primary) */
    282 	int	$0x10
    283 
    284 	calll	_C_LABEL(real_to_prot)
    285 	.code32
    286 
    287 	movl	%eax,%ecx
    288 	movl	$0x0000,%eax
    289 	andl	$0xffff,%ecx
    290 	cmpl	$0x004f,%ecx
    291 	jne	1f
    292 	andl	$0xffff,%ebx
    293 	movl	%ebx,%eax
    294 1:
    295 
    296 	pop	%edi
    297 	pop	%esi
    298 	popl	%edx
    299 	popl	%ecx
    300 	popl	%ebx
    301 	popl	%ebp
    302 	ret
    303 
    304 /*
    305  * Function 15h BL=01h - Read EDID
    306  *
    307  * int biosvbe_ddc_read_edid(int blockno, void *buf)
    308  * return: VBE call status
    309  */
    310 ENTRY(biosvbe_ddc_read_edid)
    311 	pushl	%ebp
    312 	movl	%esp,%ebp
    313 	pushl	%ebx
    314 	pushl	%ecx
    315 	pushl	%edx
    316 	push	%esi
    317 	push	%edi
    318 
    319 	movl	8(%ebp), %edx	/* EDID block number */
    320 	movl	12(%ebp), %edi	/* EDID block address */
    321 
    322 	call	_C_LABEL(prot_to_real)
    323 	.code16
    324 
    325 	push	%es
    326 
    327 	push	%di
    328 	shrl	$4, %edi
    329 	mov	%ds, %ax
    330 	add	%di, %ax
    331 	mov	%ax, %es
    332 	pop	%di
    333 	and	$0xf, %di	/* EDID block address now in es:di */
    334 
    335 	movw	$0x4f15, %ax	/* display identification extensions */
    336 	mov	$0x01, %bx	/* read EDID */
    337 	mov	$0x00, %cx	/* controller unit number (00h = primary) */
    338 	int	$0x10
    339 
    340 	pop	%es
    341 
    342 	calll	_C_LABEL(real_to_prot)
    343 	.code32
    344 
    345 	andl	$0xffff,%eax
    346 
    347 	pop	%edi
    348 	pop	%esi
    349 	popl	%edx
    350 	popl	%ecx
    351 	popl	%ebx
    352 	popl	%ebp
    353 	ret
    354 
    355