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