xref: /minix3/sys/arch/i386/stand/lib/message32.S (revision 58a2b0008e28f606a7f7f5faaeaba4faac57a1ea)
1*58a2b000SEvgeniy Ivanov/*	$NetBSD: message32.S,v 1.1 2009/11/19 22:13:17 dsl Exp $	*/
2*58a2b000SEvgeniy Ivanov
3*58a2b000SEvgeniy Ivanov/*-
4*58a2b000SEvgeniy Ivanov * Copyright (c) 2003 The NetBSD Foundation, Inc.
5*58a2b000SEvgeniy Ivanov * All rights reserved.
6*58a2b000SEvgeniy Ivanov *
7*58a2b000SEvgeniy Ivanov * This code is derived from software contributed to The NetBSD Foundation
8*58a2b000SEvgeniy Ivanov * by David Laight.
9*58a2b000SEvgeniy Ivanov *
10*58a2b000SEvgeniy Ivanov * Redistribution and use in source and binary forms, with or without
11*58a2b000SEvgeniy Ivanov * modification, are permitted provided that the following conditions
12*58a2b000SEvgeniy Ivanov * are met:
13*58a2b000SEvgeniy Ivanov * 1. Redistributions of source code must retain the above copyright
14*58a2b000SEvgeniy Ivanov *    notice, this list of conditions and the following disclaimer.
15*58a2b000SEvgeniy Ivanov * 2. Redistributions in binary form must reproduce the above copyright
16*58a2b000SEvgeniy Ivanov *    notice, this list of conditions and the following disclaimer in the
17*58a2b000SEvgeniy Ivanov *    documentation and/or other materials provided with the distribution.
18*58a2b000SEvgeniy Ivanov *
19*58a2b000SEvgeniy Ivanov * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*58a2b000SEvgeniy Ivanov * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*58a2b000SEvgeniy Ivanov * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*58a2b000SEvgeniy Ivanov * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*58a2b000SEvgeniy Ivanov * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*58a2b000SEvgeniy Ivanov * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*58a2b000SEvgeniy Ivanov * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*58a2b000SEvgeniy Ivanov * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*58a2b000SEvgeniy Ivanov * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*58a2b000SEvgeniy Ivanov * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*58a2b000SEvgeniy Ivanov * POSSIBILITY OF SUCH DAMAGE.
30*58a2b000SEvgeniy Ivanov */
31*58a2b000SEvgeniy Ivanov
32*58a2b000SEvgeniy Ivanov#include <machine/asm.h>
33*58a2b000SEvgeniy Ivanov
34*58a2b000SEvgeniy Ivanov/*
35*58a2b000SEvgeniy Ivanov * Output messages directly to serial port from 32bit mode.
36*58a2b000SEvgeniy Ivanov * Useful for debugging when the real-prot is suspect.
37*58a2b000SEvgeniy Ivanov *
38*58a2b000SEvgeniy Ivanov * %ds:dump_eax_buff must be somewhere it is safe to write 12 bytes.
39*58a2b000SEvgeniy Ivanov */
40*58a2b000SEvgeniy Ivanov
41*58a2b000SEvgeniy Ivanov#ifndef COM_PORT_VAL
42*58a2b000SEvgeniy Ivanov#define COM_PORT_VAL $0x3f8	/* Standard address COM1 (dty0) */
43*58a2b000SEvgeniy Ivanov#endif
44*58a2b000SEvgeniy Ivanov
45*58a2b000SEvgeniy Ivanov	.globl	message32
46*58a2b000SEvgeniy Ivanov	.code32
47*58a2b000SEvgeniy Ivanovmessage32:
48*58a2b000SEvgeniy Ivanov	pusha
49*58a2b000SEvgeniy Ivanovmessage32_1:
50*58a2b000SEvgeniy Ivanov	lodsb
51*58a2b000SEvgeniy Ivanov2:
52*58a2b000SEvgeniy Ivanov	mov     COM_PORT_VAL, %dx
53*58a2b000SEvgeniy Ivanov	outb    %al, %dx
54*58a2b000SEvgeniy Ivanov	add     $5, %dl
55*58a2b000SEvgeniy Ivanov3:      inb     %dx
56*58a2b000SEvgeniy Ivanov	test    $0x40, %al
57*58a2b000SEvgeniy Ivanov	jz      3b
58*58a2b000SEvgeniy Ivanov
59*58a2b000SEvgeniy Ivanov	lodsb
60*58a2b000SEvgeniy Ivanov	test    %al, %al
61*58a2b000SEvgeniy Ivanov	jnz     2b
62*58a2b000SEvgeniy Ivanov	popa
63*58a2b000SEvgeniy Ivanov	ret
64*58a2b000SEvgeniy Ivanov
65*58a2b000SEvgeniy Ivanov	.globl	dump_eax32
66*58a2b000SEvgeniy Ivanovdump_eax32:
67*58a2b000SEvgeniy Ivanov	pusha
68*58a2b000SEvgeniy Ivanov	movl	$dump_eax_buff, %esi
69*58a2b000SEvgeniy Ivanov	mov	%esi, %edi
70*58a2b000SEvgeniy Ivanov	push	$8
71*58a2b000SEvgeniy Ivanov	pop	%ecx
72*58a2b000SEvgeniy Ivanov1:	roll	$4, %eax
73*58a2b000SEvgeniy Ivanov	push	%eax
74*58a2b000SEvgeniy Ivanov	andb	$0x0f, %al
75*58a2b000SEvgeniy Ivanov	addb	$0x30, %al			/* 30..3f - clear AF */
76*58a2b000SEvgeniy Ivanov#if 1 /* 5 bytes to generate real hex... */
77*58a2b000SEvgeniy Ivanov	daa					/* 30..39, 40..45 */
78*58a2b000SEvgeniy Ivanov	addb	$0xc0, %al			/* f0..f9, 00..05 */
79*58a2b000SEvgeniy Ivanov	adcb	$0x40, %al			/* 30..39, 41..46 */
80*58a2b000SEvgeniy Ivanov#endif
81*58a2b000SEvgeniy Ivanov	movb	%al,(%edi)
82*58a2b000SEvgeniy Ivanov	inc	%edi
83*58a2b000SEvgeniy Ivanov	pop	%eax
84*58a2b000SEvgeniy Ivanov	loop	1b
85*58a2b000SEvgeniy Ivanov	push	$0x20				/* space + 3 NULs */
86*58a2b000SEvgeniy Ivanov	pop	(%edi)
87*58a2b000SEvgeniy Ivanov	jmp	message32_1
88