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