Home | History | Annotate | Line # | Download | only in lib
comio.S revision 1.3
      1  1.3       dsl /*	$NetBSD: comio.S,v 1.3 2003/02/01 14:48:18 dsl Exp $	*/
      2  1.1     perry 
      3  1.1     perry /* serial console handling
      4  1.1     perry   modelled after code in 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	addr32	.byte 0x67
     10  1.1     perry #define	data32	.byte 0x66
     11  1.1     perry 
     12  1.1     perry 	.text
     13  1.1     perry 
     14  1.1     perry /**************************************************************************
     15  1.1     perry INIT - Initialization (com number)
     16  1.1     perry **************************************************************************/
     17  1.1     perry ENTRY(cominit)
     18  1.1     perry 	push	%ebp
     19  1.1     perry 	mov	%esp,%ebp
     20  1.1     perry 	push	%ebx
     21  1.1     perry 	push	%edx
     22  1.1     perry 	push	%esi
     23  1.1     perry 	push	%edi
     24  1.1     perry 
     25  1.1     perry 	movl	8(%ebp), %edx
     26  1.1     perry 
     27  1.1     perry 	call	_C_LABEL(prot_to_real)	# enter real mode
     28  1.3       dsl 	.code16
     29  1.1     perry 
     30  1.1     perry 	# Initialize the serial port (dl) to 9600 baud, 8N1.
     31  1.1     perry 	movb	$0xe3, %al
     32  1.1     perry 	movb	$0, %ah
     33  1.1     perry 	int	$0x14
     34  1.1     perry 	mov	%ax,%bx
     35  1.1     perry 
     36  1.3       dsl 	calll	_C_LABEL(real_to_prot) # back to protected mode
     37  1.3       dsl 	.code32
     38  1.1     perry 
     39  1.1     perry 	xor	%eax,%eax
     40  1.1     perry 	mov	%bx,%ax
     41  1.1     perry 
     42  1.1     perry 	pop	%edi
     43  1.1     perry 	pop	%esi
     44  1.1     perry 	pop	%edx
     45  1.1     perry 	pop	%ebx
     46  1.1     perry 	pop	%ebp
     47  1.1     perry 	ret
     48  1.1     perry 
     49  1.1     perry /**************************************************************************
     50  1.1     perry PUTC - Print a character (char, com number)
     51  1.1     perry **************************************************************************/
     52  1.1     perry ENTRY(computc)
     53  1.1     perry 	push	%ebp
     54  1.1     perry 	mov	%esp,%ebp
     55  1.1     perry 	push	%ecx
     56  1.1     perry 	push	%ebx
     57  1.1     perry 	push	%edx
     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 	movl	12(%ebp),%edx
     63  1.1     perry 
     64  1.1     perry 	call	_C_LABEL(prot_to_real)	# enter real mode
     65  1.3       dsl 	.code16
     66  1.1     perry 
     67  1.1     perry 	movb	%cl,%al
     68  1.1     perry 	movb	$0x01, %ah
     69  1.1     perry 	int	$0x14
     70  1.1     perry 
     71  1.1     perry 	movb	%ah,%bl
     72  1.1     perry 
     73  1.3       dsl 	calll	_C_LABEL(real_to_prot) # back to protected mode
     74  1.3       dsl 	.code32
     75  1.1     perry 
     76  1.1     perry 	xor	%eax,%eax
     77  1.1     perry 	movb	%bl,%al
     78  1.1     perry 
     79  1.1     perry 	pop	%edi
     80  1.1     perry 	pop	%esi
     81  1.1     perry 	pop	%edx
     82  1.1     perry 	pop	%ebx
     83  1.1     perry 	pop	%ecx
     84  1.1     perry 	pop	%ebp
     85  1.1     perry 	ret
     86  1.1     perry 
     87  1.1     perry /**************************************************************************
     88  1.1     perry GETC - Get a character (com number)
     89  1.1     perry **************************************************************************/
     90  1.1     perry ENTRY(comgetc)
     91  1.1     perry 	push	%ebp
     92  1.1     perry 	mov	%esp,%ebp
     93  1.1     perry 	push	%ebx
     94  1.1     perry 	push	%edx
     95  1.1     perry 	push	%esi
     96  1.1     perry 	push	%edi
     97  1.1     perry 
     98  1.1     perry 	movl	8(%ebp),%edx
     99  1.1     perry 
    100  1.1     perry 	call	_C_LABEL(prot_to_real)	# enter real mode
    101  1.3       dsl 	.code16
    102  1.1     perry 
    103  1.1     perry 	movb	$0x02, %ah
    104  1.1     perry 	int	$0x14
    105  1.3       dsl 	mov	%ax, %bx
    106  1.1     perry 
    107  1.3       dsl 	calll	_C_LABEL(real_to_prot) # back to protected mode
    108  1.3       dsl 	.code32
    109  1.1     perry 
    110  1.1     perry 	xor	%eax,%eax
    111  1.2  drochner 	mov	%bx,%ax
    112  1.1     perry 
    113  1.1     perry 	pop	%edi
    114  1.1     perry 	pop	%esi
    115  1.1     perry 	pop	%edx
    116  1.1     perry 	pop	%ebx
    117  1.1     perry 	pop	%ebp
    118  1.1     perry 	ret
    119  1.1     perry 
    120  1.1     perry /**************************************************************************
    121  1.1     perry ISKEY - Check for keyboard interrupt (com number)
    122  1.1     perry **************************************************************************/
    123  1.1     perry ENTRY(comstatus)
    124  1.1     perry 	push	%ebp
    125  1.1     perry 	mov	%esp,%ebp
    126  1.1     perry 	push	%ebx
    127  1.1     perry 	push	%edx
    128  1.1     perry 	push	%esi
    129  1.1     perry 	push	%edi
    130  1.1     perry 
    131  1.1     perry 	movl	8(%ebp),%edx
    132  1.1     perry 
    133  1.1     perry 	call	_C_LABEL(prot_to_real)	# enter real mode
    134  1.3       dsl 	.code16
    135  1.1     perry 
    136  1.1     perry 	movb	$0x03, %ah
    137  1.1     perry 	int	$0x14
    138  1.1     perry 	mov	%ax,%bx
    139  1.1     perry 
    140  1.3       dsl 	calll	_C_LABEL(real_to_prot) # back to protected mode
    141  1.3       dsl 	.code32
    142  1.1     perry 
    143  1.1     perry 	xor	%eax,%eax
    144  1.1     perry 	mov	%bx,%ax
    145  1.1     perry 
    146  1.1     perry 	pop	%edi
    147  1.1     perry 	pop	%esi
    148  1.1     perry 	pop	%edx
    149  1.1     perry 	pop	%ebx
    150  1.1     perry 	pop	%ebp
    151  1.1     perry 	ret
    152