1 /* $NetBSD: debug.c,v 1.11 2008/04/28 20:23:22 martin 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 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: debug.c,v 1.11 2008/04/28 20:23:22 martin Exp $");
34
35 #include "debug_hpc.h"
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39
40 #include <machine/debug.h>
41 #include <machine/bootinfo.h>
42
43 #ifdef HPC_DEBUG_INTERRUPT_MONITOR
44 static struct intr_state_rgb16 {
45 int cnt;
46 int phase;
47 /* R:G:B = [15:11][10:5][4:0] */
48 uint16_t color;
49 } __intr_state_rgb16[] = {
50 { 0, 0, RGB565_BLACK },
51 { 0, 0, RGB565_RED },
52 { 0, 0, RGB565_GREEN },
53 { 0, 0, RGB565_YELLOW },
54 { 0, 0, RGB565_BLUE },
55 { 0, 0, RGB565_MAGENTA },
56 { 0, 0, RGB565_CYAN },
57 { 0, 0, RGB565_WHITE },
58 };
59
60 void
__dbg_heart_beat(enum heart_beat cause)61 __dbg_heart_beat(enum heart_beat cause) /* 16bpp R:G:B = 5:6:5 only */
62 {
63 #define LINE_STEP 2
64 struct intr_state_rgb16 *intr_state_rgb16 =
65 &__intr_state_rgb16[cause & 0x7];
66 uint16_t *fb = (uint16_t *)bootinfo->fb_addr;
67 int hline = bootinfo->fb_width;
68 uint16_t color = intr_state_rgb16->color;
69 int i;
70
71 fb += (cause & 0x7) * bootinfo->fb_line_bytes * LINE_STEP;
72 if (++intr_state_rgb16->cnt > hline)
73 intr_state_rgb16->cnt = 0, intr_state_rgb16->phase ^= 1;
74
75 for (i = 0; i < 8; i++)
76 *(fb + i) = color;
77 *(fb + intr_state_rgb16->cnt) =
78 intr_state_rgb16->phase ? ~color : color;
79 #undef LINE_STEP
80 }
81 #endif /* HPC_DEBUG_INTERRUPT_MONITOR */
82