Home | History | Annotate | Line # | Download | only in lib
conio.S revision 1.3
      1  1.3  mycroft /*	$NetBSD: conio.S,v 1.3 2005/01/27 18:20:45 mycroft 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 #define	data32	.byte 0x66
     10  1.1    perry 
     11  1.1    perry 	.text
     12  1.1    perry 
     13  1.1    perry /**************************************************************************
     14  1.1    perry PUTC - Print a character
     15  1.1    perry **************************************************************************/
     16  1.1    perry ENTRY(conputc)
     17  1.1    perry 	push	%ebp
     18  1.1    perry 	mov	%esp,%ebp
     19  1.1    perry 	push	%ecx
     20  1.1    perry 	push	%ebx
     21  1.1    perry 	push	%esi
     22  1.1    perry 	push	%edi
     23  1.1    perry 
     24  1.1    perry 	movb	8(%ebp),%cl
     25  1.1    perry 
     26  1.1    perry 	call	_C_LABEL(prot_to_real)	# enter real mode
     27  1.2      dsl 	.code16
     28  1.1    perry 
     29  1.1    perry 	movb	%cl,%al
     30  1.2      dsl 	movw	$1,%bx
     31  1.1    perry 	movb	$0x0e,%ah
     32  1.1    perry 	int	$0x10
     33  1.1    perry 
     34  1.2      dsl 	calll	_C_LABEL(real_to_prot) # back to protected mode
     35  1.2      dsl 	.code32
     36  1.1    perry 
     37  1.1    perry 	pop	%edi
     38  1.1    perry 	pop	%esi
     39  1.1    perry 	pop	%ebx
     40  1.1    perry 	pop	%ecx
     41  1.1    perry 	pop	%ebp
     42  1.1    perry 	ret
     43  1.1    perry 
     44  1.1    perry /**************************************************************************
     45  1.1    perry GETC - Get a character
     46  1.1    perry **************************************************************************/
     47  1.1    perry ENTRY(congetc)
     48  1.1    perry 	push	%ebp
     49  1.1    perry 	mov	%esp,%ebp
     50  1.1    perry 	push	%ebx
     51  1.1    perry 	push	%esi
     52  1.1    perry 	push	%edi
     53  1.1    perry 
     54  1.1    perry 	call	_C_LABEL(prot_to_real)	# enter real mode
     55  1.2      dsl 	.code16
     56  1.1    perry 
     57  1.1    perry 	movb	$0x0,%ah
     58  1.1    perry 	int	$0x16
     59  1.1    perry 	movb	%al,%bl
     60  1.1    perry 
     61  1.2      dsl 	calll	_C_LABEL(real_to_prot) # back to protected mode
     62  1.2      dsl 	.code32
     63  1.1    perry 
     64  1.1    perry 	xor	%eax,%eax
     65  1.1    perry 	movb	%bl,%al
     66  1.1    perry 
     67  1.1    perry 	pop	%edi
     68  1.1    perry 	pop	%esi
     69  1.1    perry 	pop	%ebx
     70  1.1    perry 	pop	%ebp
     71  1.1    perry 	ret
     72  1.1    perry 
     73  1.1    perry /**************************************************************************
     74  1.3  mycroft ISSHIFT - Check for keyboard interrupt; via shift key
     75  1.3  mycroft **************************************************************************/
     76  1.3  mycroft ENTRY(conisshift)
     77  1.3  mycroft 	push	%ebp
     78  1.3  mycroft 	mov	%esp,%ebp
     79  1.3  mycroft 	push	%ebx
     80  1.3  mycroft 	push	%esi
     81  1.3  mycroft 	push	%edi
     82  1.3  mycroft 
     83  1.3  mycroft 	call	_C_LABEL(prot_to_real)	# enter real mode
     84  1.3  mycroft 	.code16
     85  1.3  mycroft 
     86  1.3  mycroft 	xor	%bx,%bx
     87  1.3  mycroft 	movb	$0x2,%ah
     88  1.3  mycroft 	int	$0x16
     89  1.3  mycroft 	testb	$3,%al
     90  1.3  mycroft 	setnz	%bl
     91  1.3  mycroft 
     92  1.3  mycroft 	calll	_C_LABEL(real_to_prot) # back to protected mode
     93  1.3  mycroft 	.code32
     94  1.3  mycroft 
     95  1.3  mycroft 	xor	%eax,%eax
     96  1.3  mycroft 	movb	%bl,%al
     97  1.3  mycroft 
     98  1.3  mycroft 	pop	%edi
     99  1.3  mycroft 	pop	%esi
    100  1.3  mycroft 	pop	%ebx
    101  1.3  mycroft 	pop	%ebp
    102  1.3  mycroft 	ret
    103  1.3  mycroft 
    104  1.3  mycroft /**************************************************************************
    105  1.3  mycroft ISKEY - Check for keyboard input
    106  1.1    perry **************************************************************************/
    107  1.1    perry ENTRY(coniskey)
    108  1.1    perry 	push	%ebp
    109  1.1    perry 	mov	%esp,%ebp
    110  1.1    perry 	push	%ebx
    111  1.1    perry 	push	%esi
    112  1.1    perry 	push	%edi
    113  1.1    perry 
    114  1.1    perry 	call	_C_LABEL(prot_to_real)	# enter real mode
    115  1.2      dsl 	.code16
    116  1.1    perry 
    117  1.2      dsl 	xor	%bx,%bx
    118  1.1    perry 	movb	$0x1,%ah
    119  1.1    perry 	int	$0x16
    120  1.3  mycroft 	setnz	%bl
    121  1.1    perry 
    122  1.2      dsl 	calll	_C_LABEL(real_to_prot) # back to protected mode
    123  1.2      dsl 	.code32
    124  1.1    perry 
    125  1.1    perry 	xor	%eax,%eax
    126  1.1    perry 	movb	%bl,%al
    127  1.1    perry 
    128  1.1    perry 	pop	%edi
    129  1.1    perry 	pop	%esi
    130  1.1    perry 	pop	%ebx
    131  1.1    perry 	pop	%ebp
    132  1.1    perry 	ret
    133