xref: /netbsd/sys/arch/hpcsh/hpcsh/debug.c (revision bf9ec67e)
1 /*	$NetBSD: debug.c,v 1.7 2002/03/28 15:24:24 uch Exp $	*/
2 
3 /*-
4  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by UCHIYAMA Yasushi.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #include "debug_hpc.h"
40 
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 
44 #include <machine/debug.h>
45 #include <machine/bootinfo.h>
46 
47 #ifdef HPC_DEBUG_INTERRUPT_MONITOR
48 static struct intr_state_rgb16 {
49 	int cnt;
50 	int phase;
51 	/* R:G:B = [15:11][10:5][4:0] */
52 	u_int16_t color;
53 } __intr_state_rgb16[] = {
54 	{ 0, 0, RGB565_BLACK },
55 	{ 0, 0, RGB565_RED },
56 	{ 0, 0, RGB565_GREEN },
57 	{ 0, 0, RGB565_YELLOW },
58 	{ 0, 0, RGB565_BLUE },
59 	{ 0, 0, RGB565_MAGENTA },
60 	{ 0, 0, RGB565_CYAN },
61 	{ 0, 0, RGB565_WHITE },
62 };
63 
64 void
65 __dbg_heart_beat(enum heart_beat cause) /* 16bpp R:G:B = 5:6:5 only */
66 {
67 #define LINE_STEP	2
68 	struct intr_state_rgb16 *intr_state_rgb16 =
69 	    &__intr_state_rgb16[cause & 0x7];
70 	u_int16_t *fb = (u_int16_t *)bootinfo->fb_addr;
71 	int hline = bootinfo->fb_width;
72 	u_int16_t color = intr_state_rgb16->color;
73 	int i;
74 
75 	fb += (cause & 0x7) * bootinfo->fb_line_bytes * LINE_STEP;
76 	if (++intr_state_rgb16->cnt > hline)
77 		intr_state_rgb16->cnt = 0, intr_state_rgb16->phase ^= 1;
78 
79 	for (i = 0; i < 8; i++)
80 		*(fb + i) = color;
81 	*(fb + intr_state_rgb16->cnt) =
82 	    intr_state_rgb16->phase ? ~color : color;
83 #undef LINE_STEP
84 }
85 #endif /* HPC_DEBUG_INTERRUPT_MONITOR */
86