Home | History | Annotate | Line # | Download | only in lib
conio.S revision 1.6
      1  1.6       ad /*	$NetBSD: conio.S,v 1.6 2008/05/21 01:51:34 ad Exp $	*/
      2  1.1    perry 
      3  1.1    perry /* PC console handling
      4  1.1    perry   originally from: FreeBSD:sys/i386/boot/netboot/start2.S
      5  1.1    perry  */
      6  1.1    perry 
      7  1.1    perry #include <machine/asm.h>
      8  1.1    perry 
      9  1.1    perry 	.text
     10  1.1    perry 
     11  1.1    perry /**************************************************************************
     12  1.6       ad CLR - Clear screen
     13  1.6       ad **************************************************************************/
     14  1.6       ad ENTRY(conclr)
     15  1.6       ad 	push	%ebp
     16  1.6       ad 	mov	%esp,%ebp
     17  1.6       ad 	push	%ecx
     18  1.6       ad 	push	%ebx
     19  1.6       ad 	push	%esi
     20  1.6       ad 	push	%edi
     21  1.6       ad 
     22  1.6       ad 	movb	8(%ebp),%cl
     23  1.6       ad 
     24  1.6       ad 	call	_C_LABEL(prot_to_real)	# enter real mode
     25  1.6       ad 	.code16
     26  1.6       ad 
     27  1.6       ad 	/* Clear screen. */
     28  1.6       ad 	movw	$0x0600, %ax
     29  1.6       ad 	movw	$0x0700, %bx
     30  1.6       ad 	xorw	%cx, %cx
     31  1.6       ad 	movw	$0x184f, %dx	/* 80x25 */
     32  1.6       ad 	int	$0x10
     33  1.6       ad 
     34  1.6       ad 	/* Home cursor. */
     35  1.6       ad 	movb	$0x02, %ah
     36  1.6       ad 	xorw	%bx, %bx
     37  1.6       ad 	xorw	%dx, %dx
     38  1.6       ad 	int	$0x10
     39  1.6       ad 
     40  1.6       ad 	calll	_C_LABEL(real_to_prot) # back to protected mode
     41  1.6       ad 	.code32
     42  1.6       ad 
     43  1.6       ad 	pop	%edi
     44  1.6       ad 	pop	%esi
     45  1.6       ad 	pop	%ebx
     46  1.6       ad 	pop	%ecx
     47  1.6       ad 	pop	%ebp
     48  1.6       ad 	ret
     49  1.6       ad 
     50  1.6       ad /**************************************************************************
     51  1.1    perry PUTC - Print a character
     52  1.1    perry **************************************************************************/
     53  1.1    perry ENTRY(conputc)
     54  1.1    perry 	push	%ebp
     55  1.1    perry 	mov	%esp,%ebp
     56  1.1    perry 	push	%ecx
     57  1.1    perry 	push	%ebx
     58  1.1    perry 	push	%esi
     59  1.1    perry 	push	%edi
     60  1.1    perry 
     61  1.1    perry 	movb	8(%ebp),%cl
     62  1.1    perry 
     63  1.1    perry 	call	_C_LABEL(prot_to_real)	# enter real mode
     64  1.2      dsl 	.code16
     65  1.1    perry 
     66  1.1    perry 	movb	%cl,%al
     67  1.2      dsl 	movw	$1,%bx
     68  1.1    perry 	movb	$0x0e,%ah
     69  1.1    perry 	int	$0x10
     70  1.1    perry 
     71  1.2      dsl 	calll	_C_LABEL(real_to_prot) # back to protected mode
     72  1.2      dsl 	.code32
     73  1.1    perry 
     74  1.1    perry 	pop	%edi
     75  1.1    perry 	pop	%esi
     76  1.1    perry 	pop	%ebx
     77  1.1    perry 	pop	%ecx
     78  1.1    perry 	pop	%ebp
     79  1.1    perry 	ret
     80  1.1    perry 
     81  1.1    perry /**************************************************************************
     82  1.1    perry GETC - Get a character
     83  1.1    perry **************************************************************************/
     84  1.1    perry ENTRY(congetc)
     85  1.1    perry 	push	%ebp
     86  1.1    perry 	mov	%esp,%ebp
     87  1.1    perry 	push	%ebx
     88  1.1    perry 	push	%esi
     89  1.1    perry 	push	%edi
     90  1.1    perry 
     91  1.1    perry 	call	_C_LABEL(prot_to_real)	# enter real mode
     92  1.2      dsl 	.code16
     93  1.1    perry 
     94  1.1    perry 	movb	$0x0,%ah
     95  1.1    perry 	int	$0x16
     96  1.1    perry 	movb	%al,%bl
     97  1.1    perry 
     98  1.2      dsl 	calll	_C_LABEL(real_to_prot) # back to protected mode
     99  1.2      dsl 	.code32
    100  1.1    perry 
    101  1.1    perry 	xor	%eax,%eax
    102  1.1    perry 	movb	%bl,%al
    103  1.1    perry 
    104  1.1    perry 	pop	%edi
    105  1.1    perry 	pop	%esi
    106  1.1    perry 	pop	%ebx
    107  1.1    perry 	pop	%ebp
    108  1.1    perry 	ret
    109  1.1    perry 
    110  1.1    perry /**************************************************************************
    111  1.3  mycroft ISSHIFT - Check for keyboard interrupt; via shift key
    112  1.3  mycroft **************************************************************************/
    113  1.3  mycroft ENTRY(conisshift)
    114  1.3  mycroft 	push	%ebp
    115  1.3  mycroft 	mov	%esp,%ebp
    116  1.3  mycroft 	push	%ebx
    117  1.3  mycroft 	push	%esi
    118  1.3  mycroft 	push	%edi
    119  1.3  mycroft 
    120  1.3  mycroft 	call	_C_LABEL(prot_to_real)	# enter real mode
    121  1.3  mycroft 	.code16
    122  1.3  mycroft 
    123  1.3  mycroft 	xor	%bx,%bx
    124  1.3  mycroft 	movb	$0x2,%ah
    125  1.3  mycroft 	int	$0x16
    126  1.3  mycroft 	testb	$3,%al
    127  1.3  mycroft 	setnz	%bl
    128  1.3  mycroft 
    129  1.3  mycroft 	calll	_C_LABEL(real_to_prot) # back to protected mode
    130  1.3  mycroft 	.code32
    131  1.3  mycroft 
    132  1.3  mycroft 	xor	%eax,%eax
    133  1.3  mycroft 	movb	%bl,%al
    134  1.3  mycroft 
    135  1.3  mycroft 	pop	%edi
    136  1.3  mycroft 	pop	%esi
    137  1.3  mycroft 	pop	%ebx
    138  1.3  mycroft 	pop	%ebp
    139  1.3  mycroft 	ret
    140  1.3  mycroft 
    141  1.3  mycroft /**************************************************************************
    142  1.3  mycroft ISKEY - Check for keyboard input
    143  1.1    perry **************************************************************************/
    144  1.1    perry ENTRY(coniskey)
    145  1.1    perry 	push	%ebp
    146  1.1    perry 	mov	%esp,%ebp
    147  1.1    perry 	push	%ebx
    148  1.1    perry 	push	%esi
    149  1.1    perry 	push	%edi
    150  1.1    perry 
    151  1.1    perry 	call	_C_LABEL(prot_to_real)	# enter real mode
    152  1.2      dsl 	.code16
    153  1.1    perry 
    154  1.2      dsl 	xor	%bx,%bx
    155  1.1    perry 	movb	$0x1,%ah
    156  1.1    perry 	int	$0x16
    157  1.3  mycroft 	setnz	%bl
    158  1.1    perry 
    159  1.2      dsl 	calll	_C_LABEL(real_to_prot) # back to protected mode
    160  1.2      dsl 	.code32
    161  1.1    perry 
    162  1.1    perry 	xor	%eax,%eax
    163  1.1    perry 	movb	%bl,%al
    164  1.1    perry 
    165  1.1    perry 	pop	%edi
    166  1.1    perry 	pop	%esi
    167  1.1    perry 	pop	%ebx
    168  1.1    perry 	pop	%ebp
    169  1.1    perry 	ret
    170