Home | History | Annotate | Line # | Download | only in lib
conio.S revision 1.1
      1  1.1  perry /*	$NetBSD: conio.S,v 1.1 1997/03/14 02:40:32 perry 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.1  perry 
     28  1.1  perry 	movb	%cl,%al
     29  1.1  perry 	data32
     30  1.1  perry 	mov	$1,%ebx
     31  1.1  perry 	movb	$0x0e,%ah
     32  1.1  perry 	int	$0x10
     33  1.1  perry 
     34  1.1  perry 	data32
     35  1.1  perry 	call	_C_LABEL(real_to_prot) # back to protected mode
     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.1  perry 
     56  1.1  perry 	movb	$0x0,%ah
     57  1.1  perry 	int	$0x16
     58  1.1  perry 	movb	%al,%bl
     59  1.1  perry 
     60  1.1  perry 	data32
     61  1.1  perry 	call	_C_LABEL(real_to_prot) # back to protected mode
     62  1.1  perry 
     63  1.1  perry 	xor	%eax,%eax
     64  1.1  perry 	movb	%bl,%al
     65  1.1  perry 
     66  1.1  perry 	pop	%edi
     67  1.1  perry 	pop	%esi
     68  1.1  perry 	pop	%ebx
     69  1.1  perry 	pop	%ebp
     70  1.1  perry 	ret
     71  1.1  perry 
     72  1.1  perry /**************************************************************************
     73  1.1  perry ISKEY - Check for keyboard interrupt
     74  1.1  perry **************************************************************************/
     75  1.1  perry ENTRY(coniskey)
     76  1.1  perry 	push	%ebp
     77  1.1  perry 	mov	%esp,%ebp
     78  1.1  perry 	push	%ebx
     79  1.1  perry 	push	%esi
     80  1.1  perry 	push	%edi
     81  1.1  perry 
     82  1.1  perry 	call	_C_LABEL(prot_to_real)	# enter real mode
     83  1.1  perry 
     84  1.1  perry 	xor	%ebx,%ebx
     85  1.1  perry 	movb	$0x1,%ah
     86  1.1  perry 	int	$0x16
     87  1.1  perry 	data32
     88  1.1  perry 	jz	1f
     89  1.1  perry 	movb	%al,%bl
     90  1.1  perry 1:
     91  1.1  perry 
     92  1.1  perry 	data32
     93  1.1  perry 	call	_C_LABEL(real_to_prot) # back to protected mode
     94  1.1  perry 
     95  1.1  perry 	xor	%eax,%eax
     96  1.1  perry 	movb	%bl,%al
     97  1.1  perry 
     98  1.1  perry 	pop	%edi
     99  1.1  perry 	pop	%esi
    100  1.1  perry 	pop	%ebx
    101  1.1  perry 	pop	%ebp
    102  1.1  perry 	ret
    103