clean up debug print and configuration.

This commit is contained in:
uch 2002-01-27 05:15:35 +00:00
parent 4a61fd0786
commit 415a0562eb
11 changed files with 514 additions and 561 deletions

View File

@ -1,7 +1,7 @@
/* $NetBSD: hd64461.c,v 1.2 2001/07/13 16:21:39 uch Exp $ */ /* $NetBSD: hd64461.c,v 1.3 2002/01/27 05:15:36 uch Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -46,9 +46,7 @@
#include <machine/intr.h> #include <machine/intr.h>
#include <sh3/shbvar.h> #include <sh3/shbvar.h>
#ifdef DEBUG
#include <hpcsh/hpcsh/debug.h> #include <hpcsh/hpcsh/debug.h>
#endif
#include <hpcsh/dev/hd64461/hd64461var.h> #include <hpcsh/dev/hd64461/hd64461var.h>
#include <hpcsh/dev/hd64461/hd64461reg.h> #include <hpcsh/dev/hd64461/hd64461reg.h>
@ -56,7 +54,7 @@
#include <hpcsh/dev/hd64461/hd64461intcvar.h> #include <hpcsh/dev/hd64461/hd64461intcvar.h>
/* HD64461 modules. INTC, TIMER, POWER modules are included in hd64461if */ /* HD64461 modules. INTC, TIMER, POWER modules are included in hd64461if */
static struct hd64461_module { STATIC struct hd64461_module {
const char *name; const char *name;
} hd64461_modules[] = { } hd64461_modules[] = {
[HD64461_MODULE_VIDEO] = { "hd64461video" }, [HD64461_MODULE_VIDEO] = { "hd64461video" },
@ -91,21 +89,21 @@ struct hd64461_softc {
struct device sc_dev; struct device sc_dev;
}; };
static int hd64461_match(struct device *, struct cfdata *, void *); STATIC int hd64461_match(struct device *, struct cfdata *, void *);
static void hd64461_attach(struct device *, struct device *, void *); STATIC void hd64461_attach(struct device *, struct device *, void *);
static int hd64461_print(void *, const char *); STATIC int hd64461_print(void *, const char *);
struct cfattach hd64461if_ca = { struct cfattach hd64461if_ca = {
sizeof(struct hd64461_softc), hd64461_match, hd64461_attach sizeof(struct hd64461_softc), hd64461_match, hd64461_attach
}; };
static void hd64461_module_attach(struct hd64461_softc *); STATIC void hd64461_module_attach(struct hd64461_softc *);
static int hd64461_intr(void *); STATIC int hd64461_intr(void *);
#ifdef DEBUG #ifdef DEBUG
static void hd64461_info(struct hd64461_softc *); STATIC void hd64461_info(struct hd64461_softc *);
#endif #endif
static int int
hd64461_match(struct device *parent, struct cfdata *cf, void *aux) hd64461_match(struct device *parent, struct cfdata *cf, void *aux)
{ {
static int match; static int match;
@ -125,7 +123,7 @@ hd64461_match(struct device *parent, struct cfdata *cf, void *aux)
return (1); return (1);
} }
static void void
hd64461_attach(struct device *parent, struct device *self, void *aux) hd64461_attach(struct device *parent, struct device *self, void *aux)
{ {
struct shb_attach_args *ia = aux; struct shb_attach_args *ia = aux;
@ -144,7 +142,7 @@ hd64461_attach(struct device *parent, struct device *self, void *aux)
hd64461_module_attach(sc); hd64461_module_attach(sc);
} }
static void void
hd64461_module_attach(struct hd64461_softc *sc) hd64461_module_attach(struct hd64461_softc *sc)
{ {
struct hd64461_attach_args ha; struct hd64461_attach_args ha;
@ -161,7 +159,7 @@ hd64461_module_attach(struct hd64461_softc *sc)
} }
} }
static int int
hd64461_print(void *aux, const char *pnp) hd64461_print(void *aux, const char *pnp)
{ {
struct hd64461_attach_args *ha = aux; struct hd64461_attach_args *ha = aux;
@ -246,68 +244,67 @@ hd64461_intr(void *arg)
} }
#ifdef DEBUG #ifdef DEBUG
static void void
hd64461_info(struct hd64461_softc *sc) hd64461_info(struct hd64461_softc *sc)
{ {
const char name[] = __FUNCTION__;
u_int16_t r16; u_int16_t r16;
dbg_banner_start(name, sizeof name); dbg_banner_function();
/* /*
* System * System
*/ */
printf("STBCR (System Control Register)\n"); printf("STBCR (System Control Register)\n");
r16 = hd64461_reg_read_2(HD64461_SYSSTBCR_REG16); r16 = hd64461_reg_read_2(HD64461_SYSSTBCR_REG16);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_SYSSTBCR_##m, #m) #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_SYSSTBCR_##m, #m)
DBG_BIT_PRINT(r16, CKIO_STBY); DBG_BITMASK_PRINT(r16, CKIO_STBY);
DBG_BIT_PRINT(r16, SAFECKE_IST); DBG_BITMASK_PRINT(r16, SAFECKE_IST);
DBG_BIT_PRINT(r16, SLCKE_IST); DBG_BITMASK_PRINT(r16, SLCKE_IST);
DBG_BIT_PRINT(r16, SAFECKE_OST); DBG_BITMASK_PRINT(r16, SAFECKE_OST);
DBG_BIT_PRINT(r16, SLCKE_OST); DBG_BITMASK_PRINT(r16, SLCKE_OST);
DBG_BIT_PRINT(r16, SMIAST); DBG_BITMASK_PRINT(r16, SMIAST);
DBG_BIT_PRINT(r16, SLCDST); DBG_BITMASK_PRINT(r16, SLCDST);
DBG_BIT_PRINT(r16, SPC0ST); DBG_BITMASK_PRINT(r16, SPC0ST);
DBG_BIT_PRINT(r16, SPC1ST); DBG_BITMASK_PRINT(r16, SPC1ST);
DBG_BIT_PRINT(r16, SAFEST); DBG_BITMASK_PRINT(r16, SAFEST);
DBG_BIT_PRINT(r16, STM0ST); DBG_BITMASK_PRINT(r16, STM0ST);
DBG_BIT_PRINT(r16, STM1ST); DBG_BITMASK_PRINT(r16, STM1ST);
DBG_BIT_PRINT(r16, SIRST); DBG_BITMASK_PRINT(r16, SIRST);
DBG_BIT_PRINT(r16, SURTSD); DBG_BITMASK_PRINT(r16, SURTSD);
#undef DBG_BIT_PRINT #undef DBG_BITMASK_PRINT
printf("\n"); printf("\n");
printf("SYSCR (System Configuration Register)\n"); printf("SYSCR (System Configuration Register)\n");
r16 = hd64461_reg_read_2(HD64461_SYSSYSCR_REG16); r16 = hd64461_reg_read_2(HD64461_SYSSYSCR_REG16);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_SYSSYSCR_##m, #m) #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_SYSSYSCR_##m, #m)
DBG_BIT_PRINT(r16, SCPU_BUS_IGAT); DBG_BITMASK_PRINT(r16, SCPU_BUS_IGAT);
DBG_BIT_PRINT(r16, SPTA_IR); DBG_BITMASK_PRINT(r16, SPTA_IR);
DBG_BIT_PRINT(r16, SPTA_TM); DBG_BITMASK_PRINT(r16, SPTA_TM);
DBG_BIT_PRINT(r16, SPTB_UR); DBG_BITMASK_PRINT(r16, SPTB_UR);
DBG_BIT_PRINT(r16, WAIT_CTL_SEL); DBG_BITMASK_PRINT(r16, WAIT_CTL_SEL);
DBG_BIT_PRINT(r16, SMODE1); DBG_BITMASK_PRINT(r16, SMODE1);
DBG_BIT_PRINT(r16, SMODE0); DBG_BITMASK_PRINT(r16, SMODE0);
#undef DBG_BIT_PRINT #undef DBG_BITMASK_PRINT
printf("\n"); printf("\n");
printf("SCPUCR (CPU Data Bus Control Register)\n"); printf("SCPUCR (CPU Data Bus Control Register)\n");
r16 = hd64461_reg_read_2(HD64461_SYSSCPUCR_REG16); r16 = hd64461_reg_read_2(HD64461_SYSSCPUCR_REG16);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_SYSSCPUCR_##m, #m) #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_SYSSCPUCR_##m, #m)
DBG_BIT_PRINT(r16, SPDSTOF); DBG_BITMASK_PRINT(r16, SPDSTOF);
DBG_BIT_PRINT(r16, SPDSTIG); DBG_BITMASK_PRINT(r16, SPDSTIG);
DBG_BIT_PRINT(r16, SPCSTOF); DBG_BITMASK_PRINT(r16, SPCSTOF);
DBG_BIT_PRINT(r16, SPCSTIG); DBG_BITMASK_PRINT(r16, SPCSTIG);
DBG_BIT_PRINT(r16, SPBSTOF); DBG_BITMASK_PRINT(r16, SPBSTOF);
DBG_BIT_PRINT(r16, SPBSTIG); DBG_BITMASK_PRINT(r16, SPBSTIG);
DBG_BIT_PRINT(r16, SPASTOF); DBG_BITMASK_PRINT(r16, SPASTOF);
DBG_BIT_PRINT(r16, SPASTIG); DBG_BITMASK_PRINT(r16, SPASTIG);
DBG_BIT_PRINT(r16, SLCDSTIG); DBG_BITMASK_PRINT(r16, SLCDSTIG);
DBG_BIT_PRINT(r16, SCPU_CS56_EP); DBG_BITMASK_PRINT(r16, SCPU_CS56_EP);
DBG_BIT_PRINT(r16, SCPU_CMD_EP); DBG_BITMASK_PRINT(r16, SCPU_CMD_EP);
DBG_BIT_PRINT(r16, SCPU_ADDR_EP); DBG_BITMASK_PRINT(r16, SCPU_ADDR_EP);
DBG_BIT_PRINT(r16, SCPDPU); DBG_BITMASK_PRINT(r16, SCPDPU);
DBG_BIT_PRINT(r16, SCPU_A2319_EP); DBG_BITMASK_PRINT(r16, SCPU_A2319_EP);
#undef DBG_BIT_PRINT #undef DBG_BITMASK_PRINT
printf("\n"); printf("\n");
printf("\n"); printf("\n");
@ -316,32 +313,32 @@ hd64461_info(struct hd64461_softc *sc)
*/ */
printf("NIRR (Interrupt Request Register)\n"); printf("NIRR (Interrupt Request Register)\n");
r16 = hd64461_reg_read_2(HD64461_INTCNIRR_REG16); r16 = hd64461_reg_read_2(HD64461_INTCNIRR_REG16);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_INTCNIRR_##m, #m) #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_INTCNIRR_##m, #m)
DBG_BIT_PRINT(r16, PCC0R); DBG_BITMASK_PRINT(r16, PCC0R);
DBG_BIT_PRINT(r16, PCC1R); DBG_BITMASK_PRINT(r16, PCC1R);
DBG_BIT_PRINT(r16, AFER); DBG_BITMASK_PRINT(r16, AFER);
DBG_BIT_PRINT(r16, GPIOR); DBG_BITMASK_PRINT(r16, GPIOR);
DBG_BIT_PRINT(r16, TMU0R); DBG_BITMASK_PRINT(r16, TMU0R);
DBG_BIT_PRINT(r16, TMU1R); DBG_BITMASK_PRINT(r16, TMU1R);
DBG_BIT_PRINT(r16, IRDAR); DBG_BITMASK_PRINT(r16, IRDAR);
DBG_BIT_PRINT(r16, UARTR); DBG_BITMASK_PRINT(r16, UARTR);
#undef DBG_BIT_PRINT #undef DBG_BITMASK_PRINT
printf("\n"); printf("\n");
printf("NIMR (Interrupt Mask Register)\n"); printf("NIMR (Interrupt Mask Register)\n");
r16 = hd64461_reg_read_2(HD64461_INTCNIMR_REG16); r16 = hd64461_reg_read_2(HD64461_INTCNIMR_REG16);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_INTCNIMR_##m, #m) #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_INTCNIMR_##m, #m)
DBG_BIT_PRINT(r16, PCC0M); DBG_BITMASK_PRINT(r16, PCC0M);
DBG_BIT_PRINT(r16, PCC1M); DBG_BITMASK_PRINT(r16, PCC1M);
DBG_BIT_PRINT(r16, AFEM); DBG_BITMASK_PRINT(r16, AFEM);
DBG_BIT_PRINT(r16, GPIOM); DBG_BITMASK_PRINT(r16, GPIOM);
DBG_BIT_PRINT(r16, TMU0M); DBG_BITMASK_PRINT(r16, TMU0M);
DBG_BIT_PRINT(r16, TMU1M); DBG_BITMASK_PRINT(r16, TMU1M);
DBG_BIT_PRINT(r16, IRDAM); DBG_BITMASK_PRINT(r16, IRDAM);
DBG_BIT_PRINT(r16, UARTM); DBG_BITMASK_PRINT(r16, UARTM);
#undef DBG_BIT_PRINT #undef DBG_BITMASK_PRINT
printf("\n"); printf("\n");
dbg_banner_end(); dbg_banner_line();
} }
#endif /* DEBUG */ #endif /* DEBUG */

View File

@ -1,7 +1,7 @@
/* $NetBSD: hd64461pcmcia.c,v 1.8 2001/12/15 13:23:21 soren Exp $ */ /* $NetBSD: hd64461pcmcia.c,v 1.9 2002/01/27 05:15:36 uch Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -35,7 +35,8 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#define HD64461PCMCIA_DEBUG
#include "debug_hpcsh.h"
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -47,10 +48,6 @@
#include <machine/bus.h> #include <machine/bus.h>
#include <machine/intr.h> #include <machine/intr.h>
#ifdef DEBUG
#include <hpcsh/hpcsh/debug.h>
#endif
#include <dev/pcmcia/pcmciareg.h> #include <dev/pcmcia/pcmciareg.h>
#include <dev/pcmcia/pcmciavar.h> #include <dev/pcmcia/pcmciavar.h>
#include <dev/pcmcia/pcmciachip.h> #include <dev/pcmcia/pcmciachip.h>
@ -65,18 +62,11 @@
#include "locators.h" #include "locators.h"
#ifdef HD64461PCMCIA_DEBUG #ifdef HD64461PCMCIA_DEBUG
int hd64461pcmcia_debug = 1; #define DPRINTF_ENABLE
#define DPRINTF(fmt, args...) \ #define DPRINTF_DEBUG hd64461pcmcia_debug
if (hd64461pcmcia_debug) \
printf("%s: " fmt, __FUNCTION__ , ##args)
#define DPRINTFN(n, arg) \
if (hd64461pcmcia_debug > (n)) \
printf("%s: " fmt, __FUNCTION__ , ##args)
#else
#define DPRINTF(arg...) ((void)0)
#define DPRINTFN(n, arg...) ((void)0)
#endif #endif
#include <hpcsh/hpcsh/debug.h>
enum controller_channel { enum controller_channel {
CHANNEL_0 = 0, CHANNEL_0 = 0,
@ -164,75 +154,80 @@ struct hd64461pcmcia_softc {
struct hd64461pcmcia_channel sc_ch[CHANNEL_MAX]; struct hd64461pcmcia_channel sc_ch[CHANNEL_MAX];
}; };
static int _chip_mem_alloc(pcmcia_chipset_handle_t, bus_size_t, STATIC int hd64461pcmcia_chip_mem_alloc(pcmcia_chipset_handle_t, bus_size_t,
struct pcmcia_mem_handle *); struct pcmcia_mem_handle *);
static void _chip_mem_free(pcmcia_chipset_handle_t, STATIC void hd64461pcmcia_chip_mem_free(pcmcia_chipset_handle_t,
struct pcmcia_mem_handle *); struct pcmcia_mem_handle *);
static int _chip_mem_map(pcmcia_chipset_handle_t, int, bus_addr_t, STATIC int hd64461pcmcia_chip_mem_map(pcmcia_chipset_handle_t, int, bus_addr_t,
bus_size_t, struct pcmcia_mem_handle *, bus_size_t *, int *); bus_size_t, struct pcmcia_mem_handle *, bus_size_t *, int *);
static void _chip_mem_unmap(pcmcia_chipset_handle_t, int); STATIC void hd64461pcmcia_chip_mem_unmap(pcmcia_chipset_handle_t, int);
static int _chip_io_alloc(pcmcia_chipset_handle_t, bus_addr_t, STATIC int hd64461pcmcia_chip_io_alloc(pcmcia_chipset_handle_t, bus_addr_t,
bus_size_t, bus_size_t, struct pcmcia_io_handle *); bus_size_t, bus_size_t, struct pcmcia_io_handle *);
static void _chip_io_free(pcmcia_chipset_handle_t, struct pcmcia_io_handle *); STATIC void hd64461pcmcia_chip_io_free(pcmcia_chipset_handle_t,
static int _chip_io_map(pcmcia_chipset_handle_t, int, bus_addr_t, struct pcmcia_io_handle *);
STATIC int hd64461pcmcia_chip_io_map(pcmcia_chipset_handle_t, int, bus_addr_t,
bus_size_t, struct pcmcia_io_handle *, int *); bus_size_t, struct pcmcia_io_handle *, int *);
static void _chip_io_unmap(pcmcia_chipset_handle_t, int); STATIC void hd64461pcmcia_chip_io_unmap(pcmcia_chipset_handle_t, int);
static void _chip_socket_enable(pcmcia_chipset_handle_t); STATIC void hd64461pcmcia_chip_socket_enable(pcmcia_chipset_handle_t);
static void _chip_socket_disable(pcmcia_chipset_handle_t); STATIC void hd64461pcmcia_chip_socket_disable(pcmcia_chipset_handle_t);
static void *_chip_intr_establish(pcmcia_chipset_handle_t, STATIC void *hd64461pcmcia_chip_intr_establish(pcmcia_chipset_handle_t,
struct pcmcia_function *, int, int (*)(void *), void *); struct pcmcia_function *, int, int (*)(void *), void *);
static void _chip_intr_disestablish(pcmcia_chipset_handle_t, void *); STATIC void hd64461pcmcia_chip_intr_disestablish(pcmcia_chipset_handle_t,
void *);
static struct pcmcia_chip_functions hd64461pcmcia_functions = { STATIC struct pcmcia_chip_functions hd64461pcmcia_functions = {
_chip_mem_alloc, hd64461pcmcia_chip_mem_alloc,
_chip_mem_free, hd64461pcmcia_chip_mem_free,
_chip_mem_map, hd64461pcmcia_chip_mem_map,
_chip_mem_unmap, hd64461pcmcia_chip_mem_unmap,
_chip_io_alloc, hd64461pcmcia_chip_io_alloc,
_chip_io_free, hd64461pcmcia_chip_io_free,
_chip_io_map, hd64461pcmcia_chip_io_map,
_chip_io_unmap, hd64461pcmcia_chip_io_unmap,
_chip_intr_establish, hd64461pcmcia_chip_intr_establish,
_chip_intr_disestablish, hd64461pcmcia_chip_intr_disestablish,
_chip_socket_enable, hd64461pcmcia_chip_socket_enable,
_chip_socket_disable, hd64461pcmcia_chip_socket_disable,
}; };
static int hd64461pcmcia_match(struct device *, struct cfdata *, void *); STATIC int hd64461pcmcia_match(struct device *, struct cfdata *, void *);
static void hd64461pcmcia_attach(struct device *, struct device *, void *); STATIC void hd64461pcmcia_attach(struct device *, struct device *, void *);
static int hd64461pcmcia_print(void *, const char *); STATIC int hd64461pcmcia_print(void *, const char *);
static int hd64461pcmcia_submatch(struct device *, struct cfdata *, void *); STATIC int hd64461pcmcia_submatch(struct device *, struct cfdata *, void *);
struct cfattach hd64461pcmcia_ca = { struct cfattach hd64461pcmcia_ca = {
sizeof(struct hd64461pcmcia_softc), hd64461pcmcia_match, sizeof(struct hd64461pcmcia_softc), hd64461pcmcia_match,
hd64461pcmcia_attach hd64461pcmcia_attach
}; };
static void hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *, STATIC void hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *,
enum controller_channel); enum controller_channel);
/* hot plug */ /* hot plug */
static void hd64461pcmcia_create_event_thread(void *); STATIC void hd64461pcmcia_create_event_thread(void *);
static void hd64461pcmcia_event_thread(void *); STATIC void hd64461pcmcia_event_thread(void *);
static void queue_event(struct hd64461pcmcia_channel *, STATIC void queue_event(struct hd64461pcmcia_channel *,
enum hd64461pcmcia_event_type); enum hd64461pcmcia_event_type);
/* interrupt handler */ /* interrupt handler */
static int hd64461pcmcia_channel0_intr(void *); STATIC int hd64461pcmcia_channel0_intr(void *);
static int hd64461pcmcia_channel1_intr(void *); STATIC int hd64461pcmcia_channel1_intr(void *);
/* card status */ /* card status */
static enum hd64461pcmcia_event_type detect_card(enum controller_channel); STATIC enum hd64461pcmcia_event_type detect_card(enum controller_channel);
static void power_off(enum controller_channel) __attribute__((__unused__)); STATIC void hd64461pcmcia_power_off(enum controller_channel)
static void power_on(enum controller_channel) __attribute__((__unused__)); __attribute__((__unused__));
STATIC void hd64461pcmcia_power_on(enum controller_channel)
__attribute__((__unused__));
/* memory window access ops */ /* memory window access ops */
static void memory_window_mode(enum controller_channel, STATIC void hd64461pcmcia_memory_window_mode(enum controller_channel,
enum memory_window_mode)__attribute__((__unused__)); enum memory_window_mode)__attribute__((__unused__));
static void memory_window_16(enum controller_channel, enum memory_window_16); STATIC void hd64461pcmcia_memory_window_16(enum controller_channel,
enum memory_window_16);
/* bus width */ /* bus width */
static void set_bus_width(enum controller_channel, int); STATIC void hd64461_set_bus_width(enum controller_channel, int);
#ifdef DEBUG #ifdef HD64461PCMCIA_DEBUG
static void hd64461pcmcia_info(struct hd64461pcmcia_softc *); STATIC void hd64461pcmcia_info(struct hd64461pcmcia_softc *);
#endif #endif
/* fix SH3 Area[56] bug */ /* fix SH3 Area[56] bug */
static void fixup_sh3_pcmcia_area(bus_space_tag_t); STATIC void fixup_sh3_pcmcia_area(bus_space_tag_t);
#define _BUS_SPACE_ACCESS_HOOK() \ #define _BUS_SPACE_ACCESS_HOOK() \
{ \ { \
u_int8_t dummy __attribute__((__unused__)) = \ u_int8_t dummy __attribute__((__unused__)) = \
@ -246,7 +241,7 @@ _BUS_SPACE_SET_MULTI(_sh3_pcmcia_bug, 1, 8)
#define DELAY_MS(x) delay((x) * 1000) #define DELAY_MS(x) delay((x) * 1000)
static int int
hd64461pcmcia_match(struct device *parent, struct cfdata *cf, void *aux) hd64461pcmcia_match(struct device *parent, struct cfdata *cf, void *aux)
{ {
struct hd64461_attach_args *ha = aux; struct hd64461_attach_args *ha = aux;
@ -254,7 +249,7 @@ hd64461pcmcia_match(struct device *parent, struct cfdata *cf, void *aux)
return (ha->ha_module_id == HD64461_MODULE_PCMCIA); return (ha->ha_module_id == HD64461_MODULE_PCMCIA);
} }
static void void
hd64461pcmcia_attach(struct device *parent, struct device *self, void *aux) hd64461pcmcia_attach(struct device *parent, struct device *self, void *aux)
{ {
struct hd64461_attach_args *ha = aux; struct hd64461_attach_args *ha = aux;
@ -264,9 +259,8 @@ hd64461pcmcia_attach(struct device *parent, struct device *self, void *aux)
printf("\n"); printf("\n");
#ifdef DEBUG #ifdef HD64461PCMCIA_DEBUG
if (bootverbose) hd64461pcmcia_info(sc);
hd64461pcmcia_info(sc);
#endif #endif
/* Channel 0/1 common CSC event queue */ /* Channel 0/1 common CSC event queue */
SIMPLEQ_INIT (&sc->sc_event_head); SIMPLEQ_INIT (&sc->sc_event_head);
@ -276,7 +270,7 @@ hd64461pcmcia_attach(struct device *parent, struct device *self, void *aux)
hd64461pcmcia_attach_channel(sc, CHANNEL_1); hd64461pcmcia_attach_channel(sc, CHANNEL_1);
} }
static void void
hd64461pcmcia_create_event_thread(void *arg) hd64461pcmcia_create_event_thread(void *arg)
{ {
struct hd64461pcmcia_softc *sc = arg; struct hd64461pcmcia_softc *sc = arg;
@ -288,7 +282,7 @@ hd64461pcmcia_create_event_thread(void *arg)
KASSERT(error == 0); KASSERT(error == 0);
} }
static void void
hd64461pcmcia_event_thread(void *arg) hd64461pcmcia_event_thread(void *arg)
{ {
struct hd64461pcmcia_softc *sc = arg; struct hd64461pcmcia_softc *sc = arg;
@ -323,7 +317,7 @@ hd64461pcmcia_event_thread(void *arg)
/* NOTREACHED */ /* NOTREACHED */
} }
static int int
hd64461pcmcia_print(void *arg, const char *pnp) hd64461pcmcia_print(void *arg, const char *pnp)
{ {
@ -333,7 +327,7 @@ hd64461pcmcia_print(void *arg, const char *pnp)
return (UNCONF); return (UNCONF);
} }
static int int
hd64461pcmcia_submatch(struct device *parent, struct cfdata *cf, void *aux) hd64461pcmcia_submatch(struct device *parent, struct cfdata *cf, void *aux)
{ {
struct pcmciabus_attach_args *paa = aux; struct pcmciabus_attach_args *paa = aux;
@ -356,7 +350,7 @@ hd64461pcmcia_submatch(struct device *parent, struct cfdata *cf, void *aux)
return ((*cf->cf_attach->ca_match)(parent, cf, aux)); return ((*cf->cf_attach->ca_match)(parent, cf, aux));
} }
static void void
hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *sc, hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *sc,
enum controller_channel channel) enum controller_channel channel)
{ {
@ -393,7 +387,7 @@ hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *sc,
} }
/* I/O port extent and interrupt staff */ /* I/O port extent and interrupt staff */
_chip_socket_disable(ch); /* enable CSC interrupt only */ hd64461pcmcia_chip_socket_disable(ch); /* enable CSC interrupt only */
if (channel == CHANNEL_0) { if (channel == CHANNEL_0) {
ch->ch_iobase = 0; ch->ch_iobase = 0;
@ -406,7 +400,7 @@ hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *sc,
hd64461_intr_establish(HD64461_IRQ_PCC0, IST_LEVEL, IPL_TTY, hd64461_intr_establish(HD64461_IRQ_PCC0, IST_LEVEL, IPL_TTY,
hd64461pcmcia_channel0_intr, ch); hd64461pcmcia_channel0_intr, ch);
} else { } else {
set_bus_width(CHANNEL_1, PCMCIA_WIDTH_IO16); hd64461_set_bus_width(CHANNEL_1, PCMCIA_WIDTH_IO16);
hd64461_intr_establish(HD64461_IRQ_PCC1, IST_EDGE, IPL_TTY, hd64461_intr_establish(HD64461_IRQ_PCC1, IST_EDGE, IPL_TTY,
hd64461pcmcia_channel1_intr, ch); hd64461pcmcia_channel1_intr, ch);
} }
@ -425,7 +419,7 @@ hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *sc,
} }
} }
static int int
hd64461pcmcia_channel0_intr(void *arg) hd64461pcmcia_channel0_intr(void *arg)
{ {
struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)arg; struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)arg;
@ -449,7 +443,7 @@ hd64461pcmcia_channel0_intr(void *arg)
return ret; return ret;
} }
static int int
hd64461pcmcia_channel1_intr(void *arg) hd64461pcmcia_channel1_intr(void *arg)
{ {
struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)arg; struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)arg;
@ -473,7 +467,7 @@ hd64461pcmcia_channel1_intr(void *arg)
return ret; return ret;
} }
static void void
queue_event(struct hd64461pcmcia_channel *ch, queue_event(struct hd64461pcmcia_channel *ch,
enum hd64461pcmcia_event_type type) enum hd64461pcmcia_event_type type)
{ {
@ -519,8 +513,9 @@ queue_event(struct hd64461pcmcia_channel *ch,
/* /*
* interface for pcmcia driver. * interface for pcmcia driver.
*/ */
static void * void *
_chip_intr_establish(pcmcia_chipset_handle_t pch, struct pcmcia_function *pf, hd64461pcmcia_chip_intr_establish(pcmcia_chipset_handle_t pch,
struct pcmcia_function *pf,
int ipl, int (*ih_func)(void *), void *ih_arg) int ipl, int (*ih_func)(void *), void *ih_arg)
{ {
struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch; struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
@ -549,8 +544,8 @@ _chip_intr_establish(pcmcia_chipset_handle_t pch, struct pcmcia_function *pf,
return (void *)ih_func; return (void *)ih_func;
} }
static void void
_chip_intr_disestablish(pcmcia_chipset_handle_t pch, void *ih) hd64461pcmcia_chip_intr_disestablish(pcmcia_chipset_handle_t pch, void *ih)
{ {
struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch; struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
int channel = ch->ch_channel; int channel = ch->ch_channel;
@ -573,8 +568,8 @@ _chip_intr_disestablish(pcmcia_chipset_handle_t pch, void *ih)
splx(s); splx(s);
} }
static int int
_chip_mem_alloc(pcmcia_chipset_handle_t pch, bus_size_t size, hd64461pcmcia_chip_mem_alloc(pcmcia_chipset_handle_t pch, bus_size_t size,
struct pcmcia_mem_handle *pcmhp) struct pcmcia_mem_handle *pcmhp)
{ {
struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch; struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
@ -590,14 +585,16 @@ _chip_mem_alloc(pcmcia_chipset_handle_t pch, bus_size_t size,
return (0); return (0);
} }
static void void
_chip_mem_free(pcmcia_chipset_handle_t pch, struct pcmcia_mem_handle *pcmhp) hd64461pcmcia_chip_mem_free(pcmcia_chipset_handle_t pch,
struct pcmcia_mem_handle *pcmhp)
{ {
/* nothing to do */ /* nothing to do */
} }
static int int
_chip_mem_map(pcmcia_chipset_handle_t pch, int kind, bus_addr_t card_addr, hd64461pcmcia_chip_mem_map(pcmcia_chipset_handle_t pch, int kind,
bus_addr_t card_addr,
bus_size_t size, struct pcmcia_mem_handle *pcmhp, bus_size_t size, struct pcmcia_mem_handle *pcmhp,
bus_size_t *offsetp, int *windowp) bus_size_t *offsetp, int *windowp)
{ {
@ -630,7 +627,7 @@ _chip_mem_map(pcmcia_chipset_handle_t pch, int kind, bus_addr_t card_addr,
goto bad; goto bad;
/* XXX bogus. check window per common memory access. */ /* XXX bogus. check window per common memory access. */
memory_window_16(ch->ch_channel, window); hd64461pcmcia_memory_window_16(ch->ch_channel, window);
*offsetp = ofs + 0x01000000; /* skip attribute area */ *offsetp = ofs + 0x01000000; /* skip attribute area */
cookie->wc_window = window; cookie->wc_window = window;
} }
@ -649,8 +646,8 @@ _chip_mem_map(pcmcia_chipset_handle_t pch, int kind, bus_addr_t card_addr,
return (1); return (1);
} }
static void void
_chip_mem_unmap(pcmcia_chipset_handle_t pch, int window) hd64461pcmcia_chip_mem_unmap(pcmcia_chipset_handle_t pch, int window)
{ {
struct hd64461pcmcia_window_cookie *cookie = (void *)window; struct hd64461pcmcia_window_cookie *cookie = (void *)window;
@ -661,9 +658,9 @@ _chip_mem_unmap(pcmcia_chipset_handle_t pch, int window)
free(cookie, M_DEVBUF); free(cookie, M_DEVBUF);
} }
static int int
_chip_io_alloc(pcmcia_chipset_handle_t pch, bus_addr_t start, bus_size_t size, hd64461pcmcia_chip_io_alloc(pcmcia_chipset_handle_t pch, bus_addr_t start,
bus_size_t align, struct pcmcia_io_handle *pcihp) bus_size_t size, bus_size_t align, struct pcmcia_io_handle *pcihp)
{ {
struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch; struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
@ -694,8 +691,9 @@ _chip_io_alloc(pcmcia_chipset_handle_t pch, bus_addr_t start, bus_size_t size,
return (0); return (0);
} }
static int int
_chip_io_map(pcmcia_chipset_handle_t pch, int width, bus_addr_t offset, hd64461pcmcia_chip_io_map(pcmcia_chipset_handle_t pch, int width,
bus_addr_t offset,
bus_size_t size, struct pcmcia_io_handle *pcihp, int *windowp) bus_size_t size, struct pcmcia_io_handle *pcihp, int *windowp)
{ {
struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch; struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
@ -705,7 +703,7 @@ _chip_io_map(pcmcia_chipset_handle_t pch, int width, bus_addr_t offset,
if (ch->ch_channel == CHANNEL_1) if (ch->ch_channel == CHANNEL_1)
return (1); return (1);
set_bus_width(CHANNEL_0, width); hd64461_set_bus_width(CHANNEL_0, width);
DPRINTF("%#lx:%#lx+%#lx %s\n", pcihp->ioh, offset, size, DPRINTF("%#lx:%#lx+%#lx %s\n", pcihp->ioh, offset, size,
width_names[width]); width_names[width]);
@ -713,8 +711,9 @@ _chip_io_map(pcmcia_chipset_handle_t pch, int width, bus_addr_t offset,
return (0); return (0);
} }
static void void
_chip_io_free(pcmcia_chipset_handle_t pch, struct pcmcia_io_handle *pcihp) hd64461pcmcia_chip_io_free(pcmcia_chipset_handle_t pch,
struct pcmcia_io_handle *pcihp)
{ {
struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch; struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
@ -729,14 +728,14 @@ _chip_io_free(pcmcia_chipset_handle_t pch, struct pcmcia_io_handle *pcihp)
DPRINTF("%#lx+%#lx\n", pcihp->ioh, pcihp->size); DPRINTF("%#lx+%#lx\n", pcihp->ioh, pcihp->size);
} }
static void void
_chip_io_unmap(pcmcia_chipset_handle_t pch, int window) hd64461pcmcia_chip_io_unmap(pcmcia_chipset_handle_t pch, int window)
{ {
/* nothing to do */ /* nothing to do */
} }
static void void
_chip_socket_enable(pcmcia_chipset_handle_t pch) hd64461pcmcia_chip_socket_enable(pcmcia_chipset_handle_t pch)
{ {
struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch; struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
int channel = ch->ch_channel; int channel = ch->ch_channel;
@ -748,8 +747,8 @@ _chip_socket_enable(pcmcia_chipset_handle_t pch)
isr = HD64461_PCCISR(channel); isr = HD64461_PCCISR(channel);
gcr = HD64461_PCCGCR(channel); gcr = HD64461_PCCGCR(channel);
power_off(channel); hd64461pcmcia_power_off(channel);
power_on(channel); hd64461pcmcia_power_on(channel);
#if notyet #if notyet
{ {
int i; int i;
@ -778,19 +777,19 @@ _chip_socket_enable(pcmcia_chipset_handle_t pch)
printf("."); printf(".");
} }
printf("reset failed.\n"); printf("reset failed.\n");
power_off(channel); hd64461pcmcia_power_off(channel);
return; return;
reset_ok: reset_ok:
} }
#endif /* notyet */ #endif /* notyet */
/* set Continuous 16-MB Area Mode */ /* set Continuous 16-MB Area Mode */
ch->ch_memory_window_mode = MEMWIN_16M_MODE; ch->ch_memory_window_mode = MEMWIN_16M_MODE;
memory_window_mode(channel, ch->ch_memory_window_mode); hd64461pcmcia_memory_window_mode(channel, ch->ch_memory_window_mode);
/* /*
* set Common memory area. * set Common memory area.
*/ */
memory_window_16(channel, MEMWIN_16M_COMMON_0); hd64461pcmcia_memory_window_16(channel, MEMWIN_16M_COMMON_0);
/* set the card type */ /* set the card type */
r = hd64461_reg_read_1(gcr); r = hd64461_reg_read_1(gcr);
@ -809,8 +808,8 @@ _chip_socket_enable(pcmcia_chipset_handle_t pch)
DPRINTF("OK.\n"); DPRINTF("OK.\n");
} }
static void void
_chip_socket_disable(pcmcia_chipset_handle_t pch) hd64461pcmcia_chip_socket_disable(pcmcia_chipset_handle_t pch)
{ {
struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch; struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
int channel = ch->ch_channel; int channel = ch->ch_channel;
@ -820,14 +819,14 @@ _chip_socket_disable(pcmcia_chipset_handle_t pch)
hd64461_reg_write_1(HD64461_PCCCSCR(channel), 0); hd64461_reg_write_1(HD64461_PCCCSCR(channel), 0);
/* power down the socket */ /* power down the socket */
power_off(channel); hd64461pcmcia_power_off(channel);
} }
/* /*
* Card detect * Card detect
*/ */
static void void
power_off(enum controller_channel channel) hd64461pcmcia_power_off(enum controller_channel channel)
{ {
#if notyet #if notyet
u_int8_t r; u_int8_t r;
@ -871,8 +870,8 @@ power_off(enum controller_channel channel)
#endif /* notyet */ #endif /* notyet */
} }
static void void
power_on(enum controller_channel channel) hd64461pcmcia_power_on(enum controller_channel channel)
{ {
u_int8_t r; u_int8_t r;
u_int16_t r16; u_int16_t r16;
@ -962,7 +961,7 @@ power_on(enum controller_channel channel)
HD64461_PCC1CSCR_REG8, 0); HD64461_PCC1CSCR_REG8, 0);
} }
static enum hd64461pcmcia_event_type enum hd64461pcmcia_event_type
detect_card(enum controller_channel channel) detect_card(enum controller_channel channel)
{ {
u_int8_t r; u_int8_t r;
@ -986,8 +985,8 @@ detect_card(enum controller_channel channel)
/* /*
* Memory window access ops. * Memory window access ops.
*/ */
static void void
memory_window_mode(enum controller_channel channel, hd64461pcmcia_memory_window_mode(enum controller_channel channel,
enum memory_window_mode mode) enum memory_window_mode mode)
{ {
bus_addr_t a = HD64461_PCCGCR(channel); bus_addr_t a = HD64461_PCCGCR(channel);
@ -999,8 +998,9 @@ memory_window_mode(enum controller_channel channel,
hd64461_reg_write_1(a, r); hd64461_reg_write_1(a, r);
} }
static void void
memory_window_16(enum controller_channel channel, enum memory_window_16 window) hd64461pcmcia_memory_window_16(enum controller_channel channel,
enum memory_window_16 window)
{ {
bus_addr_t a = HD64461_PCCGCR(channel); bus_addr_t a = HD64461_PCCGCR(channel);
u_int8_t r; u_int8_t r;
@ -1026,7 +1026,7 @@ memory_window_16(enum controller_channel channel, enum memory_window_16 window)
} }
#if unused #if unused
static void void
memory_window_32(enum controller_channel channel, enum memory_window_32 window) memory_window_32(enum controller_channel channel, enum memory_window_32 window)
{ {
bus_addr_t a = HD64461_PCCGCR(channel); bus_addr_t a = HD64461_PCCGCR(channel);
@ -1050,8 +1050,8 @@ memory_window_32(enum controller_channel channel, enum memory_window_32 window)
} }
#endif #endif
static void void
set_bus_width(enum controller_channel channel, int width) hd64461_set_bus_width(enum controller_channel channel, int width)
{ {
u_int16_t r16; u_int16_t r16;
@ -1066,7 +1066,7 @@ set_bus_width(enum controller_channel channel, int width)
SHREG_BCR2 = r16; SHREG_BCR2 = r16;
} }
static void void
fixup_sh3_pcmcia_area(bus_space_tag_t t) fixup_sh3_pcmcia_area(bus_space_tag_t t)
{ {
struct hpcsh_bus_space *hbs = (void *)t; struct hpcsh_bus_space *hbs = (void *)t;
@ -1077,69 +1077,46 @@ fixup_sh3_pcmcia_area(bus_space_tag_t t)
hbs->hbs_sm_1 = _sh3_pcmcia_bug_set_multi_1; hbs->hbs_sm_1 = _sh3_pcmcia_bug_set_multi_1;
} }
#ifdef DEBUG #ifdef HD64461PCMCIA_DEBUG
static void void
hd64461pcmcia_info(struct hd64461pcmcia_softc *sc) hd64461pcmcia_info(struct hd64461pcmcia_softc *sc)
{ {
const char name[] = __FUNCTION__;
u_int8_t r8; u_int8_t r8;
dbg_banner_start(name, sizeof name); dbg_banner_function();
/* /*
* PCC0 * PCC0
*/ */
printf("[PCC0 memory and I/O card (SH3 Area 6)]\n"); printf("[PCC0 memory and I/O card (SH3 Area 6)]\n");
printf("PCC0 Interface Status Register\n"); printf("PCC0 Interface Status Register\n");
r8 = hd64461_reg_read_1(HD64461_PCC0ISR_REG8); r8 = hd64461_reg_read_1(HD64461_PCC0ISR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCC0ISR_##m, #m)
DBG_BIT_PRINT(r8, P0READY); #define _(m) dbg_bitmask_print(r8, HD64461_PCC0ISR_##m, #m)
DBG_BIT_PRINT(r8, P0MWP); _(P0READY);_(P0MWP);_(P0VS2);_(P0VS1);_(P0CD2);_(P0CD1);
DBG_BIT_PRINT(r8, P0VS2); _(P0BVD2);_(P0BVD1);
DBG_BIT_PRINT(r8, P0VS1); #undef _
DBG_BIT_PRINT(r8, P0CD2);
DBG_BIT_PRINT(r8, P0CD1);
DBG_BIT_PRINT(r8, P0BVD2);
DBG_BIT_PRINT(r8, P0BVD1);
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
printf("PCC0 General Control Register\n"); printf("PCC0 General Control Register\n");
r8 = hd64461_reg_read_1(HD64461_PCC0GCR_REG8); r8 = hd64461_reg_read_1(HD64461_PCC0GCR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCC0GCR_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCC0GCR_##m, #m)
DBG_BIT_PRINT(r8, P0DRVE); _(P0DRVE);_(P0PCCR);_(P0PCCT);_(P0VCC0);_(P0MMOD);
DBG_BIT_PRINT(r8, P0PCCR); _(P0PA25);_(P0PA24);_(P0REG);
DBG_BIT_PRINT(r8, P0PCCT); #undef _
DBG_BIT_PRINT(r8, P0VCC0);
DBG_BIT_PRINT(r8, P0MMOD);
DBG_BIT_PRINT(r8, P0PA25);
DBG_BIT_PRINT(r8, P0PA24);
DBG_BIT_PRINT(r8, P0REG);
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
printf("PCC0 Card Status Change Register\n"); printf("PCC0 Card Status Change Register\n");
r8 = hd64461_reg_read_1(HD64461_PCC0CSCR_REG8); r8 = hd64461_reg_read_1(HD64461_PCC0CSCR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCC0CSCR_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCC0CSCR_##m, #m)
DBG_BIT_PRINT(r8, P0SCDI); _(P0SCDI);_(P0IREQ);_(P0SC);_(P0CDC);_(P0RC);_(P0BW);_(P0BD);
DBG_BIT_PRINT(r8, P0IREQ); #undef _
DBG_BIT_PRINT(r8, P0SC);
DBG_BIT_PRINT(r8, P0CDC);
DBG_BIT_PRINT(r8, P0RC);
DBG_BIT_PRINT(r8, P0BW);
DBG_BIT_PRINT(r8, P0BD);
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
printf("PCC0 Card Status Change Interrupt Enable Register\n"); printf("PCC0 Card Status Change Interrupt Enable Register\n");
r8 = hd64461_reg_read_1(HD64461_PCC0CSCIER_REG8); r8 = hd64461_reg_read_1(HD64461_PCC0CSCIER_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCC0CSCIER_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCC0CSCIER_##m, #m)
DBG_BIT_PRINT(r8, P0CRE); _(P0CRE);_(P0SCE);_(P0CDE);_(P0RE);_(P0BWE);_(P0BDE);
DBG_BIT_PRINT(r8, P0SCE); #undef _
DBG_BIT_PRINT(r8, P0CDE);
DBG_BIT_PRINT(r8, P0RE);
DBG_BIT_PRINT(r8, P0BWE);
DBG_BIT_PRINT(r8, P0BDE);
#undef DBG_BIT_PRINT
printf("\ninterrupt type: "); printf("\ninterrupt type: ");
switch (r8 & HD64461_PCC0CSCIER_P0IREQE_MASK) { switch (r8 & HD64461_PCC0CSCIER_P0IREQE_MASK) {
case HD64461_PCC0CSCIER_P0IREQE_NONE: case HD64461_PCC0CSCIER_P0IREQE_NONE:
@ -1158,10 +1135,9 @@ hd64461pcmcia_info(struct hd64461pcmcia_softc *sc)
printf("PCC0 Software Control Register\n"); printf("PCC0 Software Control Register\n");
r8 = hd64461_reg_read_1(HD64461_PCC0SCR_REG8); r8 = hd64461_reg_read_1(HD64461_PCC0SCR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCC0SCR_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCC0SCR_##m, #m)
DBG_BIT_PRINT(r8, P0VCC1); _(P0VCC1);_(P0SWP);
DBG_BIT_PRINT(r8, P0SWP); #undef _
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
/* /*
@ -1170,59 +1146,38 @@ hd64461pcmcia_info(struct hd64461pcmcia_softc *sc)
printf("[PCC1 memory card only (SH3 Area 5)]\n"); printf("[PCC1 memory card only (SH3 Area 5)]\n");
printf("PCC1 Interface Status Register\n"); printf("PCC1 Interface Status Register\n");
r8 = hd64461_reg_read_1(HD64461_PCC1ISR_REG8); r8 = hd64461_reg_read_1(HD64461_PCC1ISR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCC1ISR_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCC1ISR_##m, #m)
DBG_BIT_PRINT(r8, P1READY); _(P1READY);_(P1MWP);_(P1VS2);_(P1VS1);_(P1CD2);_(P1CD1);
DBG_BIT_PRINT(r8, P1MWP); _(P1BVD2);_(P1BVD1);
DBG_BIT_PRINT(r8, P1VS2); #undef _
DBG_BIT_PRINT(r8, P1VS1);
DBG_BIT_PRINT(r8, P1CD2);
DBG_BIT_PRINT(r8, P1CD1);
DBG_BIT_PRINT(r8, P1BVD2);
DBG_BIT_PRINT(r8, P1BVD1);
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
printf("PCC1 General Contorol Register\n"); printf("PCC1 General Contorol Register\n");
r8 = hd64461_reg_read_1(HD64461_PCC1GCR_REG8); r8 = hd64461_reg_read_1(HD64461_PCC1GCR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCC1GCR_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCC1GCR_##m, #m)
DBG_BIT_PRINT(r8, P1DRVE); _(P1DRVE);_(P1PCCR);_(P1VCC0);_(P1MMOD);_(P1PA25);_(P1PA24);_(P1REG);
DBG_BIT_PRINT(r8, P1PCCR); #undef _
DBG_BIT_PRINT(r8, P1VCC0);
DBG_BIT_PRINT(r8, P1MMOD);
DBG_BIT_PRINT(r8, P1PA25);
DBG_BIT_PRINT(r8, P1PA24);
DBG_BIT_PRINT(r8, P1REG);
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
printf("PCC1 Card Status Change Register\n"); printf("PCC1 Card Status Change Register\n");
r8 = hd64461_reg_read_1(HD64461_PCC1CSCR_REG8); r8 = hd64461_reg_read_1(HD64461_PCC1CSCR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCC1CSCR_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCC1CSCR_##m, #m)
DBG_BIT_PRINT(r8, P1SCDI); _(P1SCDI);_(P1CDC);_(P1RC);_(P1BW);_(P1BD);
DBG_BIT_PRINT(r8, P1CDC); #undef _
DBG_BIT_PRINT(r8, P1RC);
DBG_BIT_PRINT(r8, P1BW);
DBG_BIT_PRINT(r8, P1BD);
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
printf("PCC1 Card Status Change Interrupt Enable Register\n"); printf("PCC1 Card Status Change Interrupt Enable Register\n");
r8 = hd64461_reg_read_1(HD64461_PCC1CSCIER_REG8); r8 = hd64461_reg_read_1(HD64461_PCC1CSCIER_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCC1CSCIER_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCC1CSCIER_##m, #m)
DBG_BIT_PRINT(r8, P1CRE); _(P1CRE);_(P1CDE);_(P1RE);_(P1BWE);_(P1BDE);
DBG_BIT_PRINT(r8, P1CDE); #undef _
DBG_BIT_PRINT(r8, P1RE);
DBG_BIT_PRINT(r8, P1BWE);
DBG_BIT_PRINT(r8, P1BDE);
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
printf("PCC1 Software Control Register\n"); printf("PCC1 Software Control Register\n");
r8 = hd64461_reg_read_1(HD64461_PCC1SCR_REG8); r8 = hd64461_reg_read_1(HD64461_PCC1SCR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCC1SCR_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCC1SCR_##m, #m)
DBG_BIT_PRINT(r8, P1VCC1); _(P1VCC1);_(P1SWP);
DBG_BIT_PRINT(r8, P1SWP); #undef _
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
/* /*
@ -1231,30 +1186,25 @@ hd64461pcmcia_info(struct hd64461pcmcia_softc *sc)
printf("[General Control]\n"); printf("[General Control]\n");
printf("PCC0 Output pins Control Register\n"); printf("PCC0 Output pins Control Register\n");
r8 = hd64461_reg_read_1(HD64461_PCCP0OCR_REG8); r8 = hd64461_reg_read_1(HD64461_PCCP0OCR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCCP0OCR_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCCP0OCR_##m, #m)
DBG_BIT_PRINT(r8, P0DEPLUP); _(P0DEPLUP);_(P0AEPLUP);
DBG_BIT_PRINT(r8, P0AEPLUP); #undef _
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
printf("PCC1 Output pins Control Register\n"); printf("PCC1 Output pins Control Register\n");
r8 = hd64461_reg_read_1(HD64461_PCCP1OCR_REG8); r8 = hd64461_reg_read_1(HD64461_PCCP1OCR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCCP1OCR_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCCP1OCR_##m, #m)
DBG_BIT_PRINT(r8, P1RST8MA); _(P1RST8MA);_(P1RST4MA);_(P1RAS8MA);_(P1RAS4MA);
DBG_BIT_PRINT(r8, P1RST4MA); #undef _
DBG_BIT_PRINT(r8, P1RAS8MA);
DBG_BIT_PRINT(r8, P1RAS4MA);
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
printf("PC Card General Control Register\n"); printf("PC Card General Control Register\n");
r8 = hd64461_reg_read_1(HD64461_PCCPGCR_REG8); r8 = hd64461_reg_read_1(HD64461_PCCPGCR_REG8);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_PCCPGCR_##m, #m) #define _(m) dbg_bitmask_print(r8, HD64461_PCCPGCR_##m, #m)
DBG_BIT_PRINT(r8, PSSDIR); _(PSSDIR);_(PSSRDWR);
DBG_BIT_PRINT(r8, PSSRDWR); #undef _
#undef DBG_BIT_PRINT
printf("\n"); printf("\n");
dbg_banner_end(); dbg_banner_line();
} }
#endif /* DEBUG */ #endif /* DEBUG */

View File

@ -1,7 +1,7 @@
/* $NetBSD: hd64461uart.c,v 1.4 2001/09/14 17:12:43 uch Exp $ */ /* $NetBSD: hd64461uart.c,v 1.5 2002/01/27 05:15:36 uch Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -49,15 +49,13 @@
#include <dev/ic/comvar.h> #include <dev/ic/comvar.h>
#include <dev/ic/comreg.h> #include <dev/ic/comreg.h>
#ifdef DEBUG
#include <hpcsh/hpcsh/debug.h> #include <hpcsh/hpcsh/debug.h>
#endif
#include <hpcsh/dev/hd64461/hd64461var.h> #include <hpcsh/dev/hd64461/hd64461var.h>
#include <hpcsh/dev/hd64461/hd64461reg.h> #include <hpcsh/dev/hd64461/hd64461reg.h>
#include <hpcsh/dev/hd64461/hd64461intcvar.h> #include <hpcsh/dev/hd64461/hd64461intcvar.h>
static struct hd64461uart_chip { STATIC struct hd64461uart_chip {
struct hpcsh_bus_space __tag_body; struct hpcsh_bus_space __tag_body;
bus_space_tag_t io_tag; bus_space_tag_t io_tag;
int console; int console;
@ -75,23 +73,19 @@ cdev_decl(com);
void comcnprobe(struct consdev *); void comcnprobe(struct consdev *);
void comcninit(struct consdev *); void comcninit(struct consdev *);
static int hd64461uart_match(struct device *, struct cfdata *, void *); STATIC int hd64461uart_match(struct device *, struct cfdata *, void *);
static void hd64461uart_attach(struct device *, struct device *, void *); STATIC void hd64461uart_attach(struct device *, struct device *, void *);
struct cfattach hd64461uart_ca = { struct cfattach hd64461uart_ca = {
sizeof(struct hd64461uart_softc), hd64461uart_match, sizeof(struct hd64461uart_softc), hd64461uart_match,
hd64461uart_attach hd64461uart_attach
}; };
static void hd64461uart_init(void); STATIC void hd64461uart_init(void);
static u_int8_t hd64461uart_read_1(void *, bus_space_handle_t, bus_size_t); STATIC u_int8_t hd64461uart_read_1(void *, bus_space_handle_t, bus_size_t);
static void hd64461uart_write_1(void *, bus_space_handle_t, bus_size_t, STATIC void hd64461uart_write_1(void *, bus_space_handle_t, bus_size_t,
u_int8_t); u_int8_t);
#ifdef DEBUG
static void hd64461uart_info(struct hd64461uart_softc *);
#endif
#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
#ifndef COMCN_SPEED #ifndef COMCN_SPEED
#define COMCN_SPEED 19200 #define COMCN_SPEED 19200
@ -124,7 +118,7 @@ comcninit(struct consdev *cp)
hd64461uart_chip.console = 1; hd64461uart_chip.console = 1;
} }
static int int
hd64461uart_match(struct device *parent, struct cfdata *cf, void *aux) hd64461uart_match(struct device *parent, struct cfdata *cf, void *aux)
{ {
struct hd64461_attach_args *ha = aux; struct hd64461_attach_args *ha = aux;
@ -132,7 +126,7 @@ hd64461uart_match(struct device *parent, struct cfdata *cf, void *aux)
return (ha->ha_module_id == HD64461_MODULE_UART); return (ha->ha_module_id == HD64461_MODULE_UART);
} }
static void void
hd64461uart_attach(struct device *parent, struct device *self, void *aux) hd64461uart_attach(struct device *parent, struct device *self, void *aux)
{ {
struct hd64461_attach_args *ha = aux; struct hd64461_attach_args *ha = aux;
@ -158,10 +152,6 @@ hd64461uart_attach(struct device *parent, struct device *self, void *aux)
r16 &= ~HD64461_SYSSTBCR_SURTSD; r16 &= ~HD64461_SYSSTBCR_SURTSD;
hd64461_reg_write_2(HD64461_SYSSTBCR_REG16, r16); hd64461_reg_write_2(HD64461_SYSSTBCR_REG16, r16);
#ifdef DEBUG
if (bootverbose)
hd64461uart_info(sc);
#endif
/* sanity check */ /* sanity check */
if (!comprobe1(csc->sc_iot, csc->sc_ioh)) { if (!comprobe1(csc->sc_iot, csc->sc_ioh)) {
printf(": device problem. don't attach.\n"); printf(": device problem. don't attach.\n");
@ -178,7 +168,7 @@ hd64461uart_attach(struct device *parent, struct device *self, void *aux)
comintr, self); comintr, self);
} }
static void void
hd64461uart_init() hd64461uart_init()
{ {
@ -194,29 +184,17 @@ hd64461uart_init()
hd64461uart_chip.io_tag->hbs_w_1 = hd64461uart_write_1; hd64461uart_chip.io_tag->hbs_w_1 = hd64461uart_write_1;
} }
static u_int8_t u_int8_t
hd64461uart_read_1(void *t, bus_space_handle_t h, bus_size_t ofs) hd64461uart_read_1(void *t, bus_space_handle_t h, bus_size_t ofs)
{ {
return *(volatile u_int8_t *)(h + (ofs << 1)); return *(volatile u_int8_t *)(h + (ofs << 1));
} }
static void void
hd64461uart_write_1(void *t, bus_space_handle_t h, bus_size_t ofs, hd64461uart_write_1(void *t, bus_space_handle_t h, bus_size_t ofs,
u_int8_t val) u_int8_t val)
{ {
*(volatile u_int8_t *)(h + (ofs << 1)) = val; *(volatile u_int8_t *)(h + (ofs << 1)) = val;
} }
#ifdef DEBUG
static void
hd64461uart_info(struct hd64461uart_softc *sc)
{
const char name[] = __FUNCTION__;
printf("\n");
dbg_banner_start(name, sizeof name);
dbg_banner_end();
}
#endif /* DEBUG */

View File

@ -1,7 +1,7 @@
/* $NetBSD: hd64461video.c,v 1.5 2001/12/05 22:16:30 atatat Exp $ */ /* $NetBSD: hd64461video.c,v 1.6 2002/01/27 05:15:36 uch Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -35,7 +35,8 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
// #define HD64461VIDEO_DEBUG
#include "debug_hpcsh.h"
// #define HD64461VIDEO_HWACCEL // #define HD64461VIDEO_HWACCEL
#include <sys/param.h> #include <sys/param.h>
@ -68,22 +69,11 @@
#include <machine/bootinfo.h> #include <machine/bootinfo.h>
#ifdef HD64461VIDEO_DEBUG #ifdef HD64461VIDEO_DEBUG
#define DPRINTF_ENABLE
#define DPRINTF_DEBUG hd64461video_debug
#endif
#include <hpcsh/hpcsh/debug.h> #include <hpcsh/hpcsh/debug.h>
#endif
#ifdef HD64461VIDEO_DEBUG
int hd64461video_debug = 1;
#define DPRINTF(fmt, args...) \
if (hd64461video_debug) \
printf("%s: " fmt, __FUNCTION__ , ##args)
#define DPRINTFN(n, arg) \
if (hd64461video_debug > (n)) \
printf("%s: " fmt, __FUNCTION__ , ##args)
#else
#define DPRINTF(arg...) ((void)0)
#define DPRINTFN(n, arg...) ((void)0)
#endif
struct hd64461video_chip; struct hd64461video_chip;
struct hd64461video_font { struct hd64461video_font {
@ -100,7 +90,7 @@ struct hd64461video_softc {
struct hd64461video_font sc_font; struct hd64461video_font sc_font;
}; };
static struct hd64461video_chip { STATIC struct hd64461video_chip {
struct video_chip vc; struct video_chip vc;
enum hd64461video_display_mode { enum hd64461video_display_mode {
LCD256_C, LCD256_C,
@ -121,27 +111,30 @@ static struct hd64461video_chip {
int console; int console;
} hd64461video_chip; } hd64461video_chip;
static int hd64461video_match(struct device *, struct cfdata *, void *);
static void hd64461video_attach(struct device *, struct device *, void *);
void hd64461video_cnprobe(struct consdev *); void hd64461video_cnprobe(struct consdev *);
void hd64461video_cninit(struct consdev *); void hd64461video_cninit(struct consdev *);
static void setup_hpcfbif(struct hd64461video_chip *); STATIC int hd64461video_match(struct device *, struct cfdata *, void *);
static void update_videochip_status(struct hd64461video_chip *); STATIC void hd64461video_attach(struct device *, struct device *, void *);
static size_t frame_buffer_size(struct hd64461video_chip *);
static void hwaccel_init(struct hd64461video_chip *);
static void set_clut(struct hd64461video_chip *, int, int, u_int8_t *, STATIC void hd64461video_setup_hpcfbif(struct hd64461video_chip *);
u_int8_t *, u_int8_t *); STATIC void hd64461video_update_videochip_status(struct hd64461video_chip *);
static void get_clut(struct hd64461video_chip *, int, int, u_int8_t *, STATIC size_t hd64461video_frame_buffer_size(struct hd64461video_chip *);
u_int8_t *, u_int8_t *); STATIC void hd64461video_hwaccel_init(struct hd64461video_chip *);
static void set_display_mode(struct hd64461video_chip *) __attribute__((__unused__));
static void set_display_mode_lcdc(struct hd64461video_chip *); STATIC void hd64461video_set_clut(struct hd64461video_chip *, int, int,
static void set_display_mode_crtc(struct hd64461video_chip *); u_int8_t *, u_int8_t *, u_int8_t *);
STATIC void hd64461video_get_clut(struct hd64461video_chip *, int, int,
u_int8_t *, u_int8_t *, u_int8_t *);
#if notyet
STATIC void hd64461video_set_display_mode(struct hd64461video_chip *);
STATIC void hd64461video_set_display_mode_lcdc(struct hd64461video_chip *);
STATIC void hd64461video_set_display_mode_crtc(struct hd64461video_chip *);
#endif
#ifdef HD64461VIDEO_DEBUG #ifdef HD64461VIDEO_DEBUG
static void _info(struct hd64461video_softc *) __attribute__((__unused__)); STATIC void hd64461video_info(struct hd64461video_softc *);
static void _dump(void) __attribute__((__unused__)); STATIC void hd64461video_dump(void) __attribute__((__unused__));
#endif #endif
struct cfattach hd64461video_ca = { struct cfattach hd64461video_ca = {
@ -175,13 +168,14 @@ struct hpcfb_accessops hd64461video_ha = {
}; };
/* font */ /* font */
static void font_load_16bpp(u_int16_t *, u_int8_t *, int, int, int); STATIC void hd64461video_font_load_16bpp(u_int16_t *, u_int8_t *, int, int, int);
static void font_load_8bpp(u_int8_t *, u_int8_t *, int, int, int); STATIC void hd64461video_font_load_8bpp(u_int8_t *, u_int8_t *, int, int, int);
static void font_set_attr(struct hd64461video_softc *, struct wsdisplay_font *); STATIC void hd64461video_font_set_attr(struct hd64461video_softc *,
static void font_load(struct hd64461video_softc *); struct wsdisplay_font *);
static vaddr_t font_start_addr(struct hd64461video_softc *, int); STATIC void hd64461video_font_load(struct hd64461video_softc *);
STATIC vaddr_t hd64461video_font_start_addr(struct hd64461video_softc *, int);
static int int
hd64461video_match(struct device *parent, struct cfdata *cf, void *aux) hd64461video_match(struct device *parent, struct cfdata *cf, void *aux)
{ {
struct hd64461_attach_args *ha = aux; struct hd64461_attach_args *ha = aux;
@ -189,7 +183,7 @@ hd64461video_match(struct device *parent, struct cfdata *cf, void *aux)
return (ha->ha_module_id == HD64461_MODULE_VIDEO); return (ha->ha_module_id == HD64461_MODULE_VIDEO);
} }
static void void
hd64461video_attach(struct device *parent, struct device *self, void *aux) hd64461video_attach(struct device *parent, struct device *self, void *aux)
{ {
struct hd64461_attach_args *ha = aux; struct hd64461_attach_args *ha = aux;
@ -204,26 +198,26 @@ hd64461video_attach(struct device *parent, struct device *self, void *aux)
printf(": "); printf(": ");
/* detect frame buffer size */ /* detect frame buffer size */
fbsize = frame_buffer_size(&hd64461video_chip); fbsize = hd64461video_frame_buffer_size(&hd64461video_chip);
format_bytes(pbuf, sizeof(pbuf), fbsize); format_bytes(pbuf, sizeof(pbuf), fbsize);
printf("frame buffer = %s ", pbuf); printf("frame buffer = %s ", pbuf);
/* update chip status */ /* update chip status */
update_videochip_status(&hd64461video_chip); hd64461video_update_videochip_status(&hd64461video_chip);
// set_display_mode(&hd64461video_chip); // hd64461video_set_display_mode(&hd64461video_chip);
if (hd64461video_chip.console) if (hd64461video_chip.console)
printf(", console"); printf(", console");
printf("\n"); printf("\n");
#ifdef HD64461VIDEO_DEBUG #ifdef HD64461VIDEO_DEBUG
_info(sc); hd64461video_info(sc);
_dump(); hd64461video_dump();
#endif #endif
/* setup hpcfb interface */ /* setup hpcfb interface */
setup_hpcfbif(&hd64461video_chip); hd64461video_setup_hpcfbif(&hd64461video_chip);
/* setup off-screen buffer */ /* setup off-screen buffer */
on_screen_size = (vc->vc_fbwidth * vc->vc_fbheight * vc->vc_fbdepth) / on_screen_size = (vc->vc_fbwidth * vc->vc_fbheight * vc->vc_fbdepth) /
@ -240,7 +234,7 @@ hd64461video_attach(struct device *parent, struct device *self, void *aux)
} }
/* initialize hardware acceralation */ /* initialize hardware acceralation */
hwaccel_init(&hd64461video_chip); hd64461video_hwaccel_init(&hd64461video_chip);
/* register interface to hpcfb */ /* register interface to hpcfb */
hfa.ha_console = hd64461video_chip.console; hfa.ha_console = hd64461video_chip.console;
@ -263,8 +257,8 @@ hd64461video_cninit(struct consdev *cndev)
hd64461video_chip.console = 1; hd64461video_chip.console = 1;
hd64461video_chip.vc.vc_reverse = video_reverse_color(); hd64461video_chip.vc.vc_reverse = video_reverse_color();
update_videochip_status(&hd64461video_chip); hd64461video_update_videochip_status(&hd64461video_chip);
setup_hpcfbif(&hd64461video_chip); hd64461video_setup_hpcfbif(&hd64461video_chip);
hpcfb_cnattach(&hd64461video_chip.hf); hpcfb_cnattach(&hd64461video_chip.hf);
cn_tab->cn_pri = CN_INTERNAL; cn_tab->cn_pri = CN_INTERNAL;
@ -294,8 +288,8 @@ hd64461video_cnprobe(struct consdev *cndev)
} }
/* hpcfb support */ /* hpcfb support */
static void void
setup_hpcfbif(struct hd64461video_chip *hvc) hd64461video_setup_hpcfbif(struct hd64461video_chip *hvc)
{ {
struct video_chip *vc = &hvc->vc; struct video_chip *vc = &hvc->vc;
struct hpcfb_fbconf *fb = &hvc->hf; struct hpcfb_fbconf *fb = &hvc->hf;
@ -327,7 +321,6 @@ setup_hpcfbif(struct hd64461video_chip *hvc)
fb->hf_access_flags |= HPCFB_ACCESS_BYTE; fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
fb->hf_access_flags |= HPCFB_ACCESS_WORD; fb->hf_access_flags |= HPCFB_ACCESS_WORD;
fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
if (vc->vc_reverse) if (vc->vc_reverse)
fb->hf_access_flags |= HPCFB_ACCESS_REVERSE; fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
@ -369,8 +362,8 @@ setup_hpcfbif(struct hd64461video_chip *hvc)
} }
} }
static void void
hwaccel_init(struct hd64461video_chip *hvc) hd64461video_hwaccel_init(struct hd64461video_chip *hvc)
{ {
u_int16_t r; u_int16_t r;
@ -438,7 +431,7 @@ hd64461video_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
return (ENOMEM); return (ENOMEM);
} }
get_clut(sc->sc_vc, idx, cnt, r, g, b); hd64461video_get_clut(sc->sc_vc, idx, cnt, r, g, b);
copyout(r, cmap->red, cnt); copyout(r, cmap->red, cnt);
copyout(g, cmap->green,cnt); copyout(g, cmap->green,cnt);
copyout(b, cmap->blue, cnt); copyout(b, cmap->blue, cnt);
@ -473,7 +466,7 @@ hd64461video_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
copyin(cmap->red, r, cnt); copyin(cmap->red, r, cnt);
copyin(cmap->green,g, cnt); copyin(cmap->green,g, cnt);
copyin(cmap->blue, b, cnt); copyin(cmap->blue, b, cnt);
set_clut(sc->sc_vc, idx, cnt, r, g, b); hd64461video_set_clut(sc->sc_vc, idx, cnt, r, g, b);
cmap_work_free(r, g, b, 0); cmap_work_free(r, g, b, 0);
return (0); return (0);
@ -733,8 +726,8 @@ hd64461video_font(void *ctx, struct wsdisplay_font *font)
{ {
struct hd64461video_softc *sc = (struct hd64461video_softc *)ctx; struct hd64461video_softc *sc = (struct hd64461video_softc *)ctx;
font_set_attr(sc, font); hd64461video_font_set_attr(sc, font);
font_load(sc); hd64461video_font_load(sc);
} }
void void
@ -746,8 +739,8 @@ hd64461video_iodone(void *ctx)
} }
/* internal */ /* internal */
static void void
font_load_16bpp(u_int16_t *d, u_int8_t *s, int w, int h, int step) hd64461video_font_load_16bpp(u_int16_t *d, u_int8_t *s, int w, int h, int step)
{ {
int i, j, n; int i, j, n;
n = step / sizeof(u_int16_t); n = step / sizeof(u_int16_t);
@ -760,8 +753,8 @@ font_load_16bpp(u_int16_t *d, u_int8_t *s, int w, int h, int step)
} }
} }
static void void
font_load_8bpp(u_int8_t *d, u_int8_t *s, int w, int h, int step) hd64461video_font_load_8bpp(u_int8_t *d, u_int8_t *s, int w, int h, int step)
{ {
int i, j, n; int i, j, n;
n = step / sizeof(u_int8_t); n = step / sizeof(u_int8_t);
@ -774,8 +767,9 @@ font_load_8bpp(u_int8_t *d, u_int8_t *s, int w, int h, int step)
} }
} }
static void void
font_set_attr(struct hd64461video_softc *sc, struct wsdisplay_font *f) hd64461video_font_set_attr(struct hd64461video_softc *sc,
struct wsdisplay_font *f)
{ {
struct hd64461video_chip *hvc = sc->sc_vc; struct hd64461video_chip *hvc = sc->sc_vc;
struct wsdisplay_font *font = (struct wsdisplay_font *)&sc->sc_font; struct wsdisplay_font *font = (struct wsdisplay_font *)&sc->sc_font;
@ -796,8 +790,8 @@ font_set_attr(struct hd64461video_softc *sc, struct wsdisplay_font *f)
} }
/* return frame buffer virtual address of charcter #n */ /* return frame buffer virtual address of charcter #n */
static vaddr_t vaddr_t
font_start_addr(struct hd64461video_softc *sc, int n) hd64461video_font_start_addr(struct hd64461video_softc *sc, int n)
{ {
struct hd64461video_chip *hvc = sc->sc_vc; struct hd64461video_chip *hvc = sc->sc_vc;
struct hd64461video_font *font = &sc->sc_font; struct hd64461video_font *font = &sc->sc_font;
@ -809,8 +803,8 @@ font_start_addr(struct hd64461video_softc *sc, int n)
return base; return base;
} }
static void void
font_load(struct hd64461video_softc *sc) hd64461video_font_load(struct hd64461video_softc *sc)
{ {
struct hd64461video_chip *hvc = sc->sc_vc; struct hd64461video_chip *hvc = sc->sc_vc;
struct wsdisplay_font *font = (struct wsdisplay_font *)&sc->sc_font; struct wsdisplay_font *font = (struct wsdisplay_font *)&sc->sc_font;
@ -835,15 +829,17 @@ font_load(struct hd64461video_softc *sc)
switch (hvc->vc.vc_fbdepth) { switch (hvc->vc.vc_fbdepth) {
case 8: case 8:
for (i = font->firstchar; i < font->numchars; i++) { for (i = font->firstchar; i < font->numchars; i++) {
font_load_8bpp((u_int8_t *)font_start_addr(sc, i), hd64461video_font_load_8bpp
q, w, h, step); ((u_int8_t *)hd64461video_font_start_addr(sc, i),
q, w, h, step);
q += n; q += n;
} }
break; break;
case 16: case 16:
for (i = font->firstchar; i < font->numchars; i++) { for (i = font->firstchar; i < font->numchars; i++) {
font_load_16bpp((u_int16_t *)font_start_addr(sc, i), hd64461video_font_load_16bpp
q, w, h, step); ((u_int16_t *)hd64461video_font_start_addr(sc, i),
q, w, h, step);
q += n; q += n;
} }
break; break;
@ -852,8 +848,8 @@ font_load(struct hd64461video_softc *sc)
sc->sc_font.loaded = TRUE; sc->sc_font.loaded = TRUE;
} }
static void void
update_videochip_status(struct hd64461video_chip *hvc) hd64461video_update_videochip_status(struct hd64461video_chip *hvc)
{ {
struct video_chip *vc = &hvc->vc; struct video_chip *vc = &hvc->vc;
u_int16_t r; u_int16_t r;
@ -917,20 +913,21 @@ update_videochip_status(struct hd64461video_chip *hvc)
vc->vc_fbheight = height; vc->vc_fbheight = height;
} }
static void #if notyet
set_display_mode(struct hd64461video_chip *hvc) void
hd64461video_set_display_mode(struct hd64461video_chip *hvc)
{ {
if (hvc->mode == LCDCRT || hvc->mode == CRT256_C) if (hvc->mode == LCDCRT || hvc->mode == CRT256_C)
set_display_mode_crtc(hvc); hd64461video_set_display_mode_crtc(hvc);
set_display_mode_lcdc(hvc); hd64461video_set_display_mode_lcdc(hvc);
} }
static void void
set_display_mode_lcdc(struct hd64461video_chip *hvc) hd64461video_set_display_mode_lcdc(struct hd64461video_chip *hvc)
{ {
static struct { struct {
u_int16_t clor; /* display size 640 x 240 */ u_int16_t clor; /* display size 640 x 240 */
u_int16_t ldr3; u_int16_t ldr3;
const char *name; const char *name;
@ -963,14 +960,15 @@ set_display_mode_lcdc(struct hd64461video_chip *hvc)
printf("%s ", conf->name); printf("%s ", conf->name);
} }
static void void
set_display_mode_crtc(struct hd64461video_chip *hvc) hd64461video_set_display_mode_crtc(struct hd64461video_chip *hvc)
{ {
/* not yet */ /* not yet */
} }
#endif /* notyet */
static size_t size_t
frame_buffer_size(struct hd64461video_chip *hvc) hd64461video_frame_buffer_size(struct hd64461video_chip *hvc)
{ {
vaddr_t page, startaddr, endaddr; vaddr_t page, startaddr, endaddr;
int x; int x;
@ -1007,8 +1005,8 @@ frame_buffer_size(struct hd64461video_chip *hvc)
return (page - startaddr); return (page - startaddr);
} }
static void void
set_clut(struct hd64461video_chip *vc, int idx, int cnt, hd64461video_set_clut(struct hd64461video_chip *vc, int idx, int cnt,
u_int8_t *r, u_int8_t *g, u_int8_t *b) u_int8_t *r, u_int8_t *g, u_int8_t *b)
{ {
KASSERT(r && g && b); KASSERT(r && g && b);
@ -1019,20 +1017,20 @@ set_clut(struct hd64461video_chip *vc, int idx, int cnt,
/* set data */ /* set data */
while (cnt && LEGAL_CLUT_INDEX(idx)) { while (cnt && LEGAL_CLUT_INDEX(idx)) {
u_int16_t v; u_int16_t v;
#define SET_CLUT(x) \ #define HD64461VIDEO_SET_CLUT(x) \
v = (x >> 2) & 0x3f; \ v = (x >> 2) & 0x3f; \
hd64461_reg_write_2(HD64461_LCDCPTWDR_REG16, v) hd64461_reg_write_2(HD64461_LCDCPTWDR_REG16, v)
SET_CLUT(*r); HD64461VIDEO_SET_CLUT(*r);
SET_CLUT(*g); HD64461VIDEO_SET_CLUT(*g);
SET_CLUT(*b); HD64461VIDEO_SET_CLUT(*b);
#undef SET_CLUT #undef HD64461VIDEO_SET_CLUT
r++, g++, b++; r++, g++, b++;
idx++, cnt--; idx++, cnt--;
} }
} }
static void void
get_clut(struct hd64461video_chip *vc, int idx, int cnt, hd64461video_get_clut(struct hd64461video_chip *vc, int idx, int cnt,
u_int8_t *r, u_int8_t *g, u_int8_t *b) u_int8_t *r, u_int8_t *g, u_int8_t *b)
{ {
KASSERT(r && g && b); KASSERT(r && g && b);
@ -1044,29 +1042,28 @@ get_clut(struct hd64461video_chip *vc, int idx, int cnt,
/* get data */ /* get data */
while (cnt && LEGAL_CLUT_INDEX(idx)) { while (cnt && LEGAL_CLUT_INDEX(idx)) {
u_int16_t v; u_int16_t v;
#define GET_CLUT(x) \ #define HD64461VIDEO_GET_CLUT(x) \
v = hd64461_reg_read_2(HD64461_LCDCPTWDR_REG16); \ v = hd64461_reg_read_2(HD64461_LCDCPTWDR_REG16); \
x = HD64461_LCDCPTRDR(v); \ x = HD64461_LCDCPTRDR(v); \
x <<= 2 x <<= 2
GET_CLUT(*r); HD64461VIDEO_GET_CLUT(*r);
GET_CLUT(*g); HD64461VIDEO_GET_CLUT(*g);
GET_CLUT(*b); HD64461VIDEO_GET_CLUT(*b);
#undef GET_CLUT #undef HD64461VIDEO_GET_CLUT
r++, g++, b++; r++, g++, b++;
idx++, cnt--; idx++, cnt--;
} }
} }
#ifdef HD64461VIDEO_DEBUG #ifdef HD64461VIDEO_DEBUG
static void void
_info(struct hd64461video_softc *sc) hd64461video_info(struct hd64461video_softc *sc)
{ {
const char name[] = __FUNCTION__;
u_int16_t r; u_int16_t r;
int color; int color;
int i; int i;
dbg_banner_start(name, sizeof name); dbg_banner_function();
printf("---[LCD]---\n"); printf("---[LCD]---\n");
/* Base Address Register */ /* Base Address Register */
r = hd64461_reg_read_2(HD64461_LCDCBAR_REG16); r = hd64461_reg_read_2(HD64461_LCDCBAR_REG16);
@ -1080,16 +1077,16 @@ _info(struct hd64461video_softc *sc)
/* LCDC Control Register */ /* LCDC Control Register */
r = hd64461_reg_read_2(HD64461_LCDCCR_REG16); r = hd64461_reg_read_2(HD64461_LCDCCR_REG16);
i = HD64461_LCDCCR_DSPSEL(r); i = HD64461_LCDCCR_DSPSEL(r);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_LCDCCR_##m, #m) #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_LCDCCR_##m, #m)
printf("LCDCCR (LCD Control Register)\n"); printf("LCDCCR (LCD Control Register)\n");
DBG_BIT_PRINT(r, STBAK); DBG_BITMASK_PRINT(r, STBAK);
DBG_BIT_PRINT(r, STREQ); DBG_BITMASK_PRINT(r, STREQ);
DBG_BIT_PRINT(r, MOFF); DBG_BITMASK_PRINT(r, MOFF);
DBG_BIT_PRINT(r, REFSEL); DBG_BITMASK_PRINT(r, REFSEL);
DBG_BIT_PRINT(r, EPON); DBG_BITMASK_PRINT(r, EPON);
DBG_BIT_PRINT(r, SPON); DBG_BITMASK_PRINT(r, SPON);
printf("\n"); printf("\n");
#undef DBG_BIT_PRINT #undef DBG_BITMASK_PRINT
printf("LCDCCR Display selct LCD[%c] CRT[%c]\n", printf("LCDCCR Display selct LCD[%c] CRT[%c]\n",
i == HD64461_LCDCCR_DSPSEL_LCD_CRT || i == HD64461_LCDCCR_DSPSEL_LCD_CRT ||
i == HD64461_LCDCCR_DSPSEL_LCD ? 'x' : '_', i == HD64461_LCDCCR_DSPSEL_LCD ? 'x' : '_',
@ -1100,20 +1097,20 @@ _info(struct hd64461video_softc *sc)
/* 1 */ /* 1 */
r = hd64461_reg_read_2(HD64461_LCDLDR1_REG16); r = hd64461_reg_read_2(HD64461_LCDLDR1_REG16);
printf("(LCD Display Register)\n"); printf("(LCD Display Register)\n");
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_LCDLDR1_##m, #m) #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_LCDLDR1_##m, #m)
printf("LCDLDR1: "); printf("LCDLDR1: ");
DBG_BIT_PRINT(r, DINV); DBG_BITMASK_PRINT(r, DINV);
DBG_BIT_PRINT(r, DON); DBG_BITMASK_PRINT(r, DON);
printf("\n"); printf("\n");
#undef DBG_BIT_PRINT #undef DBG_BITMASK_PRINT
/* 2 */ /* 2 */
r = hd64461_reg_read_2(HD64461_LCDLDR2_REG16); r = hd64461_reg_read_2(HD64461_LCDLDR2_REG16);
i = HD64461_LCDLDR2_LM(r); i = HD64461_LCDLDR2_LM(r);
#define DBG_BIT_PRINT(r, m) dbg_bit_print(r, HD64461_LCDLDR2_##m, #m) #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_LCDLDR2_##m, #m)
printf("LCDLDR2: "); printf("LCDLDR2: ");
DBG_BIT_PRINT(r, CC1); DBG_BITMASK_PRINT(r, CC1);
DBG_BIT_PRINT(r, CC2); DBG_BITMASK_PRINT(r, CC2);
#undef DBG_BIT_PRINT #undef DBG_BITMASK_PRINT
color = 0; color = 0;
switch (i) { switch (i) {
default: default:
@ -1218,18 +1215,16 @@ _info(struct hd64461video_softc *sc)
printf("CRTVRER: %d (CRTC vertical retrace end line)\n", printf("CRTVRER: %d (CRTC vertical retrace end line)\n",
HD64461_LCDCRTVRER(r)); HD64461_LCDCRTVRER(r));
dbg_banner_end();
} }
static void void
_dump() hd64461video_dump()
{ {
u_int16_t r; u_int16_t r;
printf("---Display Mode Setting---\n"); printf("---[Display Mode Setting]---\n");
#define DUMPREG(x) \ #define DUMPREG(x) \
r = hd64461_reg_read_2(HD64461_LCD ## x ## _REG16); \ r = hd64461_reg_read_2(HD64461_LCD ## x ## _REG16); \
printf("%-10s 0x%04x ", #x, r); \ __dbg_bit_print(r, sizeof(u_int16_t), 0, 0, #x, 1)
bitdisp(r)
DUMPREG(CBAR); DUMPREG(CBAR);
DUMPREG(CLOR); DUMPREG(CLOR);
DUMPREG(CCR); DUMPREG(CCR);
@ -1245,6 +1240,7 @@ _dump()
DUMPREG(CRTVRSR); DUMPREG(CRTVRSR);
DUMPREG(CRTVRER); DUMPREG(CRTVRER);
#undef DUMPREG #undef DUMPREG
dbg_banner_line();
} }
#endif /* HD64461VIDEO_DEBUG */ #endif /* HD64461VIDEO_DEBUG */

View File

@ -1,7 +1,7 @@
/* $NetBSD: pfckbd.c,v 1.3 2001/09/14 17:11:52 uch Exp $ */ /* $NetBSD: pfckbd.c,v 1.4 2002/01/27 05:15:35 uch Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -35,7 +35,8 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#define PFCKBD_DEBUG
#include "debug_hpcsh.h"
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -52,20 +53,11 @@
#include <hpcsh/dev/pfckbdvar.h> #include <hpcsh/dev/pfckbdvar.h>
#ifdef PFCKBD_DEBUG #ifdef PFCKBD_DEBUG
int pfckbd_debug = 0; #define DPRINTF_ENABLE
#define DPRINTF(fmt, args...) \ #define DPRINTF_DEBUG pfckbd_debug
if (pfckbd_debug) \
printf("%s: " fmt, __FUNCTION__ , ##args)
#define DPRINTFN(n, arg) \
if (pfckbd_debug > (n)) \
printf("%s: " fmt, __FUNCTION__ , ##args)
#define STATIC
#else
#define DPRINTF(arg...) ((void)0)
#define DPRINTFN(n, arg...) ((void)0)
#define STATIC static
#endif #endif
#include <hpcsh/hpcsh/debug.h>
STATIC int pfckbd_match(struct device *, struct cfdata *, void *); STATIC int pfckbd_match(struct device *, struct cfdata *, void *);
STATIC void pfckbd_attach(struct device *, struct device *, void *); STATIC void pfckbd_attach(struct device *, struct device *, void *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.5 2001/07/09 18:18:25 uch Exp $ */ /* $NetBSD: autoconf.c,v 1.6 2002/01/27 05:15:36 uch Exp $ */
/* /*
* Copyright (c) 1988 University of Utah. * Copyright (c) 1988 University of Utah.
@ -43,6 +43,7 @@
*/ */
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h> #include <sys/conf.h>
#include <sys/disklabel.h> #include <sys/disklabel.h>
#include <sys/device.h> #include <sys/device.h>

View File

@ -1,7 +1,7 @@
/* $NetBSD: bus_space.c,v 1.4 2001/07/09 18:18:25 uch Exp $ */ /* $NetBSD: bus_space.c,v 1.5 2002/01/27 05:15:36 uch Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -33,24 +33,21 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "debug_hpcsh.h"
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/extent.h> #include <sys/extent.h>
#include <machine/bus.h> #include <machine/bus.h>
#ifdef BUS_SPACE_DEBUG /* bus.h turn on BUS_SPACE_DEBUG if the global DEBUG option is enabled. */
int bus_space_debug = 0; #ifdef BUS_SPACE_DEBUG
#define DPRINTF(fmt, args...) \ #define DPRINTF_ENABLE
if (bus_space_debug) \ #define DPRINTF_DEBUG bus_space_debug
printf("%s: " fmt, __FUNCTION__ , ##args)
#define DPRINTFN(n, arg) \
if (bus_space_debug > (n)) \
printf("%s: " fmt, __FUNCTION__ , ##args)
#else
#define DPRINTF(arg...) ((void)0)
#define DPRINTFN(n, arg...) ((void)0)
#endif #endif
#include <hpcsh/hpcsh/debug.h>
#define _BUS_SPACE_ACCESS_HOOK() ((void)0) #define _BUS_SPACE_ACCESS_HOOK() ((void)0)
_BUS_SPACE_READ(_bus_space, 1, 8) _BUS_SPACE_READ(_bus_space, 1, 8)
@ -206,8 +203,6 @@ _bus_space_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
*bshp = (bus_space_handle_t)bpa; *bshp = (bus_space_handle_t)bpa;
DPRINTF("success.\n");
return (0); return (0);
} }
@ -253,8 +248,6 @@ _bus_space_alloc(void *t, bus_addr_t rstart, bus_addr_t rend,
if (bpap) if (bpap)
*bpap = bpa; *bpap = bpa;
DPRINTF("success.\n");
return (0); return (0);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.2 2001/07/09 18:18:25 uch Exp $ */ /* $NetBSD: clock.c,v 1.3 2002/01/27 05:15:37 uch Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -34,6 +34,7 @@
*/ */
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/device.h> #include <sys/device.h>

View File

@ -1,7 +1,7 @@
/* $NetBSD: console.c,v 1.5 2001/07/08 10:42:38 uch Exp $ */ /* $NetBSD: console.c,v 1.6 2002/01/27 05:15:37 uch Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -54,9 +54,6 @@
#if NBICONSDEV > 0 #if NBICONSDEV > 0
#include <dev/hpc/biconsvar.h> #include <dev/hpc/biconsvar.h>
#include <dev/hpc/bicons.h> #include <dev/hpc/bicons.h>
#define DPRINTF(arg) printf arg
#else
#define DPRINTF(arg)
#endif #endif
#if NHPCFB > 0 #if NHPCFB > 0

View File

@ -1,7 +1,7 @@
/* $NetBSD: debug.c,v 1.2 2001/06/28 18:59:06 uch Exp $ */ /* $NetBSD: debug.c,v 1.3 2002/01/27 05:15:37 uch Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -36,7 +36,6 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef DEBUG
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -46,35 +45,77 @@
#define BANNER_LENGTH 80 #define BANNER_LENGTH 80
static const char onoff[2] = "_x"; static const char onoff[2] = "_x";
static void __dbg_draw_line(int);
void void
dbg_bit_print(u_int32_t reg, u_int32_t mask, const char *name) __dbg_bit_print(u_int32_t a, int len, int start, int end, char *title,
int count)
{ {
u_int32_t j, j1;
int i, n;
char buf[64];
n = len * NBBY - 1;
j1 = 1 << n;
end = end ? end : n;
printf(" ");
if (title) {
printf("[%-16s] ", title);
}
for (j = j1, i = n; j > 0; j >>=1, i--) {
if (i > end || i < start) {
printf("%c", a & j ? '+' : '-'); /* out of range */
} else {
printf("%c", a & j ? '|' : '.');
}
}
snprintf(buf, sizeof buf, " [0x%%0%dx %%12d]", len << 1);
printf(buf, a, a);
if (count) {
for (j = j1, i = n; j > 0; j >>=1, i--) {
if (!(i > end || i < start) && (a & j)) {
printf(" %d", i);
}
}
}
printf("\n");
}
void
dbg_bitmask_print(u_int32_t reg, u_int32_t mask, const char *name)
{
printf("%s[%c] ", name, onoff[reg & mask ? 1 : 0]); printf("%s[%c] ", name, onoff[reg & mask ? 1 : 0]);
} }
void void
dbg_banner_start(const char *name, size_t len) dbg_banner_title(const char *name, size_t len)
{ {
int n = (BANNER_LENGTH - (len + 2)) >> 1; int n = (BANNER_LENGTH - (len + 2)) >> 1;
__dbg_draw_line(n);
dbg_draw_line(n);
printf("[%s]", name); printf("[%s]", name);
__dbg_draw_line(n); dbg_draw_line(n);
printf("\n"); printf("\n");
} }
void void
dbg_banner_end() dbg_banner_line()
{ {
__dbg_draw_line(BANNER_LENGTH);
dbg_draw_line(BANNER_LENGTH);
printf("\n"); printf("\n");
} }
void void
__dbg_draw_line(int n) dbg_draw_line(int n)
{ {
int i; int i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
printf("-"); printf("-");
} }
@ -115,5 +156,3 @@ __dbg_heart_beat(enum heart_beat cause) /* 16bpp R:G:B = 5:6:5 only */
#undef LINE_STEP #undef LINE_STEP
} }
#endif /* INTERRUPT_MONITOR */ #endif /* INTERRUPT_MONITOR */
#endif /* DEBUG */

View File

@ -1,7 +1,7 @@
/* $NetBSD: debug.h,v 1.2 2001/06/28 18:59:06 uch Exp $ */ /* $NetBSD: debug.h,v 1.3 2002/01/27 05:15:37 uch Exp $ */
/*- /*-
* Copyright (c) 1999-2001 The NetBSD Foundation, Inc. * Copyright (c) 1999-2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -36,44 +36,63 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opt_interrupt_monitor.h"
/*
* debug version exports all symbols.
*/
#ifdef DEBUG #ifdef DEBUG
//#define INTERRUPT_MONITOR #define STATIC
#else
#define STATIC static
#endif
#define __bitdisp(a, s, e, m, c) \ /*
({ \ * printf control
u_int32_t __j, __j1; \ * sample:
int __i, __s, __e, __n; \ * #ifdef FOO_DEBUG
__n = sizeof(typeof(a)) * NBBY - 1; \ * #define DPRINTF_ENABLE
__j1 = 1 << __n; \ * #define DPRINTF_DEBUG foo_debug
__e = e ? e : __n; \ * #define DPRINTF_LEVEL 2
__s = s; \ * #endif
for (__j = __j1, __i = __n; __j > 0; __j >>=1, __i--) { \ */
if (__i > __e || __i < __s) { \ #define PRINTF(fmt, args...) printf("%s: " fmt, __FUNCTION__ , ##args)
printf("%c", a & __j ? '+' : '-'); \ #ifdef DPRINTF_ENABLE
} else { \ #ifndef DPRINTF_DEBUG
printf("%c", a & __j ? '|' : '.'); \ #error "specify unique debug symbol"
} \ #endif
} \ #ifndef DPRINTF_LEVEL
if (m) { \ #define DPRINTF_LEVEL 1
printf("[%s]", (char*)m); \ #endif
} \ int DPRINTF_DEBUG = DPRINTF_LEVEL;
if (c) { \ #define DPRINTF(fmt, args...) if (DPRINTF_DEBUG) PRINTF(fmt, ##args)
for (__j = __j1, __i = __n; __j > 0; __j >>=1, __i--) { \ #define _DPRINTF(fmt, args...) if (DPRINTF_DEBUG) printf(fmt, ##args)
if (!(__i > __e || __i < __s) && (a & __j)) { \ #define DPRINTFN(n, fmt, args...) \
printf(" %d", __i); \ if (DPRINTF_DEBUG > (n)) PRINTF(fmt, ##args)
} \ #else /* DPRINTF_ENABLE */
} \ #define DPRINTF(args...) ((void)0)
} \ #define _DPRINTF(args...) ((void)0)
printf(" [0x%08x] %d", a, a); \ #define DPRINTFN(n, args...) ((void)0)
printf("\n"); \ #endif /* DPRINTF_ENABLE */
})
#define bitdisp(a) __bitdisp((a), 0, 0, 0, 1)
__BEGIN_DECLS /*
void dbg_bit_print(u_int32_t, u_int32_t, const char *); * debug print utility
void dbg_banner_start(const char *, size_t); */
void dbg_banner_end(void); #define dbg_bit_print(a) __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, 0, 1)
void __dbg_bit_print(u_int32_t, int, int, int, char *, int);
void dbg_bitmask_print(u_int32_t, u_int32_t, const char *);
void dbg_draw_line(int);
void dbg_banner_title(const char *, size_t);
void dbg_banner_line(void);
#define dbg_banner_function() \
{ \
const char funcname[] = __FUNCTION__; \
dbg_banner_title(funcname, sizeof funcname); \
}
/*
* interrupt monitor
*/
#ifdef INTERRUPT_MONITOR #ifdef INTERRUPT_MONITOR
enum heart_beat { enum heart_beat {
HEART_BEAT_CYAN = 0, HEART_BEAT_CYAN = 0,
@ -85,17 +104,7 @@ enum heart_beat {
HEART_BEAT_WHITE, HEART_BEAT_WHITE,
HEART_BEAT_BLACK HEART_BEAT_BLACK
}; };
void __dbg_heart_beat(enum heart_beat); void __dbg_heart_beat(enum heart_beat);
#else #else
#define __dbg_heart_beat(x) ((void)0) #define __dbg_heart_beat(x) ((void)0)
#endif /* INTERRUPT_MONITOR */ #endif /* INTERRUPT_MONITOR */
__END_DECLS
#else /* DEBUG */
#define bitdisp(...) ((void)0)
#define dbg_bit_print(...) ((void)0)
#define dbg_banner_start(...) ((void)0)
#define dbg_banner_end(...) ((void)0)
#define __dbg_heart_beat(...) ((void)0)
#endif /* DEBUG */