akbd: wskbd support.
ofb: OpenFirmware generic framebuffer.
This commit is contained in:
parent
dc95c94a01
commit
b6e7cc68c6
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: akbd.c,v 1.1 1998/10/13 11:21:21 tsubai Exp $ */
|
||||
/* $NetBSD: akbd.c,v 1.2 1998/10/14 12:15:10 tsubai Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1998 Colin Wood
|
||||
@ -39,24 +39,32 @@
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wskbdvar.h>
|
||||
#include <dev/wscons/wsksymdef.h>
|
||||
#include <dev/wscons/wsksymvar.h>
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#define KEYBOARD_ARRAY
|
||||
#include <machine/keyboard.h>
|
||||
|
||||
#include <macppc/dev/adbvar.h>
|
||||
#include <macppc/dev/aedvar.h>
|
||||
#include <macppc/dev/akbdmap.h>
|
||||
#include <macppc/dev/akbdvar.h>
|
||||
#include <macppc/dev/amsvar.h>
|
||||
|
||||
/*
|
||||
* Function declarations.
|
||||
*/
|
||||
static int kbdmatch __P((struct device *, struct cfdata *, void *));
|
||||
static void kbdattach __P((struct device *, struct device *, void *));
|
||||
static int akbdmatch __P((struct device *, struct cfdata *, void *));
|
||||
static void akbdattach __P((struct device *, struct device *, void *));
|
||||
void kbd_adbcomplete __P((caddr_t buffer, caddr_t data_area, int adb_command));
|
||||
static void kbd_processevent __P((adb_event_t *event, struct kbd_softc *));
|
||||
static void kbd_processevent __P((adb_event_t *event, struct akbd_softc *));
|
||||
#ifdef notyet
|
||||
static u_char getleds __P((int));
|
||||
static int setleds __P((struct kbd_softc *, u_char));
|
||||
static void blinkleds __P((struct kbd_softc *));
|
||||
static int setleds __P((struct akbd_softc *, u_char));
|
||||
static void blinkleds __P((struct akbd_softc *));
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -66,13 +74,38 @@ static volatile int kbd_done; /* Did ADBOp() complete? */
|
||||
|
||||
/* Driver definition. */
|
||||
struct cfattach akbd_ca = {
|
||||
sizeof(struct kbd_softc), kbdmatch, kbdattach
|
||||
sizeof(struct akbd_softc), akbdmatch, akbdattach
|
||||
};
|
||||
|
||||
extern struct cfdriver kbd_cd;
|
||||
extern struct cfdriver akbd_cd;
|
||||
|
||||
int akbd_enable __P((void *, int));
|
||||
void akbd_set_leds __P((void *, int));
|
||||
int akbd_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
|
||||
|
||||
struct wskbd_accessops akbd_accessops = {
|
||||
akbd_enable,
|
||||
akbd_set_leds,
|
||||
akbd_ioctl,
|
||||
};
|
||||
|
||||
void akbd_cngetc __P((void *, u_int *, int *));
|
||||
void akbd_cnpollc __P((void *, int));
|
||||
|
||||
struct wskbd_consops akbd_consops = {
|
||||
akbd_cngetc,
|
||||
akbd_cnpollc,
|
||||
};
|
||||
|
||||
struct wskbd_mapdata akbd_keymapdata = {
|
||||
akbd_keydesctab,
|
||||
KB_US,
|
||||
};
|
||||
|
||||
static int akbd_is_console __P((void));
|
||||
|
||||
static int
|
||||
kbdmatch(parent, cf, aux)
|
||||
akbdmatch(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
@ -86,16 +119,17 @@ kbdmatch(parent, cf, aux)
|
||||
}
|
||||
|
||||
static void
|
||||
kbdattach(parent, self, aux)
|
||||
akbdattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
ADBSetInfoBlock adbinfo;
|
||||
struct kbd_softc *sc = (struct kbd_softc *)self;
|
||||
struct akbd_softc *sc = (struct akbd_softc *)self;
|
||||
struct adb_attach_args *aa_args = (struct adb_attach_args *)aux;
|
||||
int count, error;
|
||||
short cmd;
|
||||
u_char buffer[9];
|
||||
struct wskbddev_attach_args a;
|
||||
|
||||
sc->origaddr = aa_args->origaddr;
|
||||
sc->adbaddr = aa_args->adbaddr;
|
||||
@ -197,7 +231,13 @@ kbdattach(parent, self, aux)
|
||||
if (adb_debug)
|
||||
printf("kbd: returned %d from SetADBInfo\n", error);
|
||||
#endif
|
||||
return;
|
||||
|
||||
a.console = akbd_is_console();
|
||||
a.keymap = &akbd_keymapdata;
|
||||
a.accessops = &akbd_accessops;
|
||||
a.accesscookie = sc;
|
||||
|
||||
sc->sc_wskbddev = config_found(self, &a, wskbddevprint);
|
||||
}
|
||||
|
||||
|
||||
@ -212,7 +252,7 @@ kbd_adbcomplete(buffer, data_area, adb_command)
|
||||
int adb_command;
|
||||
{
|
||||
adb_event_t event;
|
||||
struct kbd_softc *ksc;
|
||||
struct akbd_softc *ksc;
|
||||
int adbaddr;
|
||||
#ifdef ADB_DEBUG
|
||||
int i;
|
||||
@ -222,7 +262,7 @@ kbd_adbcomplete(buffer, data_area, adb_command)
|
||||
#endif
|
||||
|
||||
adbaddr = (adb_command & 0xf0) >> 4;
|
||||
ksc = (struct kbd_softc *)data_area;
|
||||
ksc = (struct akbd_softc *)data_area;
|
||||
|
||||
event.addr = adbaddr;
|
||||
event.hand_id = ksc->handler_id;
|
||||
@ -253,7 +293,7 @@ kbd_adbcomplete(buffer, data_area, adb_command)
|
||||
static void
|
||||
kbd_processevent(event, ksc)
|
||||
adb_event_t *event;
|
||||
struct kbd_softc *ksc;
|
||||
struct akbd_softc *ksc;
|
||||
{
|
||||
adb_event_t new_event;
|
||||
|
||||
@ -305,7 +345,7 @@ getleds(addr)
|
||||
*/
|
||||
static int
|
||||
setleds(ksc, leds)
|
||||
struct kbd_softc *ksc;
|
||||
struct akbd_softc *ksc;
|
||||
u_char leds;
|
||||
{
|
||||
int addr;
|
||||
@ -360,7 +400,7 @@ setleds(ksc, leds)
|
||||
*/
|
||||
static void
|
||||
blinkleds(ksc)
|
||||
struct kbd_softc *ksc;
|
||||
struct akbd_softc *ksc;
|
||||
{
|
||||
int addr, i;
|
||||
u_char blinkleds, origleds;
|
||||
@ -384,32 +424,135 @@ blinkleds(ksc)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
int
|
||||
kbdioctl(dev, cmd, data, flag, p)
|
||||
dev_t dev;
|
||||
int cmd;
|
||||
akbd_is_console()
|
||||
{
|
||||
int chosen, stdin, pkg;
|
||||
char name[16];
|
||||
int kbd;
|
||||
|
||||
chosen = OF_finddevice("/chosen");
|
||||
OF_getprop(chosen, "stdin", &stdin, 4);
|
||||
pkg = OF_instance_to_package(stdin);
|
||||
OF_getprop(pkg, "name", name, sizeof(name));
|
||||
|
||||
if (strcmp(name, "keyboard") == 0)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
akbd_enable(v, on)
|
||||
void *v;
|
||||
int on;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
akbd_set_leds(v, on)
|
||||
void *v;
|
||||
int on;
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
akbd_ioctl(v, cmd, data, flag, p)
|
||||
void *v;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
struct kbd_softc *ksc;
|
||||
int error = 0;
|
||||
|
||||
ksc = kbd_cd.cd_devs[minor(dev)];
|
||||
|
||||
switch (cmd) {
|
||||
case KIOCTYPE: /* Get keyboard type */
|
||||
*(u_int8_t *)data = ksc->handler_id;
|
||||
case KIOCSLED:
|
||||
error = setleds(ksc, *(u_char *)data);
|
||||
break;
|
||||
case KIOCGLED:
|
||||
*(u_int8_t *)data = ksc->sc_leds;
|
||||
break;
|
||||
default:
|
||||
error = (EINVAL);
|
||||
|
||||
case WSKBDIO_GTYPE:
|
||||
*(int *)data = 0; /* XXX */
|
||||
return 0;
|
||||
case WSKBDIO_SETLEDS:
|
||||
return 0;
|
||||
case WSKBDIO_GETLEDS:
|
||||
*(int *)data = 0;
|
||||
return 0;
|
||||
}
|
||||
return (error);
|
||||
/* kbdioctl(...); */
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int polledkey;
|
||||
extern int adb_polling;
|
||||
|
||||
int
|
||||
kbd_intr(event)
|
||||
adb_event_t *event;
|
||||
{
|
||||
int key, press, val;
|
||||
int type;
|
||||
|
||||
struct akbd_softc *sc = akbd_cd.cd_devs[0];
|
||||
|
||||
key = event->u.k.key;
|
||||
press = ADBK_PRESS(key);
|
||||
val = ADBK_KEYVAL(key);
|
||||
|
||||
type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;
|
||||
|
||||
if (key == 185) { /* Caps Lock released */
|
||||
type = WSCONS_EVENT_KEY_DOWN;
|
||||
wskbd_input(sc->sc_wskbddev, type, val);
|
||||
type = WSCONS_EVENT_KEY_UP;
|
||||
}
|
||||
|
||||
if (adb_polling)
|
||||
polledkey = key;
|
||||
else
|
||||
wskbd_input(sc->sc_wskbddev, type, val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
akbd_cnattach()
|
||||
{
|
||||
wskbd_cnattach(&akbd_consops, NULL, &akbd_keymapdata);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
akbd_cngetc(v, type, data)
|
||||
void *v;
|
||||
u_int *type;
|
||||
int *data;
|
||||
{
|
||||
int key, press, val;
|
||||
int s;
|
||||
|
||||
s = splhigh();
|
||||
|
||||
polledkey = -1;
|
||||
adb_polling = 1;
|
||||
|
||||
while (polledkey == -1) {
|
||||
adb_intr_cuda();
|
||||
DELAY(10000); /* XXX */
|
||||
}
|
||||
|
||||
adb_polling = 0;
|
||||
splx(s);
|
||||
|
||||
key = polledkey;
|
||||
press = ADBK_PRESS(key);
|
||||
val = ADBK_KEYVAL(key);
|
||||
|
||||
*data = val;
|
||||
*type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;
|
||||
}
|
||||
|
||||
void
|
||||
akbd_cnpollc(v, on)
|
||||
void *v;
|
||||
int on;
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
153
sys/arch/macppc/dev/akbdmap.h
Normal file
153
sys/arch/macppc/dev/akbdmap.h
Normal file
@ -0,0 +1,153 @@
|
||||
/* $NetBSD: akbdmap.h,v 1.1 1998/10/14 12:15:11 tsubai Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Juergen Hannken-Illjes.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* XXX This list is incomplete. */
|
||||
|
||||
#define KC(n) (0xe000 | (n)) /* see wsksymvar.h */
|
||||
|
||||
static const keysym_t akbd_keydesc_us[] = {
|
||||
/* pos command normal shifted */
|
||||
KC(0), KS_a,
|
||||
KC(1), KS_s,
|
||||
KC(2), KS_d,
|
||||
KC(3), KS_f,
|
||||
KC(4), KS_h,
|
||||
KC(5), KS_g,
|
||||
KC(6), KS_z,
|
||||
KC(7), KS_x,
|
||||
KC(8), KS_c,
|
||||
KC(9), KS_v,
|
||||
|
||||
KC(11), KS_b,
|
||||
KC(12), KS_q,
|
||||
KC(13), KS_w,
|
||||
KC(14), KS_e,
|
||||
KC(15), KS_r,
|
||||
KC(16), KS_y,
|
||||
KC(17), KS_t,
|
||||
KC(18), KS_1, KS_exclam,
|
||||
KC(19), KS_2, KS_at,
|
||||
KC(20), KS_3, KS_numbersign,
|
||||
KC(21), KS_4, KS_dollar,
|
||||
KC(22), KS_6, KS_asciicircum,
|
||||
KC(23), KS_5, KS_percent,
|
||||
KC(24), KS_equal, KS_plus,
|
||||
KC(25), KS_9, KS_parenleft,
|
||||
KC(26), KS_7, KS_ampersand,
|
||||
KC(27), KS_minus, KS_underscore,
|
||||
KC(28), KS_8, KS_asterisk,
|
||||
KC(29), KS_0, KS_parenright,
|
||||
KC(30), KS_bracketright, KS_braceright,
|
||||
KC(31), KS_o,
|
||||
KC(32), KS_u,
|
||||
KC(33), KS_bracketleft, KS_braceleft,
|
||||
KC(34), KS_i,
|
||||
KC(35), KS_p,
|
||||
KC(36), KS_Return,
|
||||
KC(37), KS_l,
|
||||
KC(38), KS_j,
|
||||
KC(39), KS_apostrophe, KS_quotedbl,
|
||||
KC(40), KS_k,
|
||||
KC(41), KS_semicolon, KS_colon,
|
||||
KC(42), KS_backslash, KS_bar,
|
||||
KC(43), KS_comma, KS_less,
|
||||
KC(44), KS_slash, KS_question,
|
||||
KC(45), KS_n,
|
||||
KC(46), KS_m,
|
||||
KC(47), KS_period, KS_greater,
|
||||
KC(48), KS_Tab,
|
||||
KC(49), KS_space,
|
||||
KC(50), KS_grave, KS_asciitilde,
|
||||
KC(51), KS_Delete,
|
||||
|
||||
KC(53), KS_Escape,
|
||||
KC(54), KS_Control_L,
|
||||
KC(55), KS_Cmd, /* Command */
|
||||
KC(56), KS_Shift_L,
|
||||
KC(57), KS_Caps_Lock,
|
||||
KC(58), KS_Cmd1, /* Option */
|
||||
KC(59), KS_Left,
|
||||
KC(60), KS_Right,
|
||||
KC(61), KS_Down,
|
||||
KC(62), KS_Up,
|
||||
|
||||
KC(65), KS_KP_Decimal,
|
||||
KC(67), KS_KP_Multiply,
|
||||
KC(69), KS_KP_Add,
|
||||
KC(71), KS_Clear,
|
||||
KC(75), KS_KP_Divide,
|
||||
KC(76), KS_KP_Enter,
|
||||
KC(78), KS_KP_Subtract,
|
||||
|
||||
KC(81), KS_KP_Equal,
|
||||
KC(82), KS_KP_0,
|
||||
KC(83), KS_KP_1,
|
||||
KC(84), KS_KP_2,
|
||||
KC(85), KS_KP_3,
|
||||
KC(86), KS_KP_4,
|
||||
KC(87), KS_KP_5,
|
||||
KC(88), KS_KP_6,
|
||||
KC(89), KS_KP_7,
|
||||
|
||||
KC(91), KS_KP_8,
|
||||
KC(92), KS_KP_9,
|
||||
|
||||
KC(95), KS_comma, /* XXX KS_KP_comma */
|
||||
|
||||
KC(106), KS_KP_Enter,
|
||||
|
||||
KC(127), KS_Cmd_Debugger,
|
||||
};
|
||||
|
||||
#if 0
|
||||
static const keysym_t akbd_keydesc_jp[] = {
|
||||
/* pos command normal shifted */
|
||||
KC(42), KS_grave, KS_asciitilde,
|
||||
KC(93), KS_backslash, KS_bar,
|
||||
};
|
||||
#endif
|
||||
|
||||
#define KBD_MAP(name, base, map) \
|
||||
{ name, base, sizeof(map)/sizeof(keysym_t), map }
|
||||
|
||||
static const struct wscons_keydesc akbd_keydesctab[] = {
|
||||
KBD_MAP(KB_US, 0, akbd_keydesc_us),
|
||||
};
|
||||
|
||||
#undef KBD_MAP
|
||||
#undef KC
|
431
sys/arch/macppc/dev/ofb.c
Normal file
431
sys/arch/macppc/dev/ofb.c
Normal file
@ -0,0 +1,431 @@
|
||||
/* $NetBSD: ofb.c,v 1.1 1998/10/14 12:15:11 tsubai Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
#include <dev/rcons/raster.h>
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wscons_raster.h>
|
||||
#include <dev/wscons/wsdisplayvar.h>
|
||||
|
||||
#include <machine/bat.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/grfioctl.h>
|
||||
|
||||
#include <macppc/dev/ofbvar.h>
|
||||
|
||||
int ofbmatch __P((struct device *, struct cfdata *, void *));
|
||||
void ofbattach __P((struct device *, struct device *, void *));
|
||||
int ofbprint __P((void *, const char *));
|
||||
|
||||
struct cfattach ofb_ca = {
|
||||
sizeof(struct ofb_softc), ofbmatch, ofbattach,
|
||||
};
|
||||
|
||||
struct ofb_devconfig ofb_console_dc;
|
||||
|
||||
struct wsdisplay_emulops ofb_emulops = {
|
||||
rcons_cursor, /* could use hardware cursor; punt */
|
||||
rcons_mapchar,
|
||||
rcons_putchar,
|
||||
rcons_copycols,
|
||||
rcons_erasecols,
|
||||
rcons_copyrows,
|
||||
rcons_eraserows,
|
||||
rcons_alloc_attr
|
||||
};
|
||||
|
||||
struct wsscreen_descr ofb_stdscreen = {
|
||||
"std",
|
||||
0, 0, /* will be filled in -- XXX shouldn't, it's global */
|
||||
&ofb_emulops,
|
||||
0, 0,
|
||||
WSSCREEN_REVERSE
|
||||
};
|
||||
|
||||
const struct wsscreen_descr *_ofb_scrlist[] = {
|
||||
&ofb_stdscreen,
|
||||
/* XXX other formats, graphics screen? */
|
||||
};
|
||||
|
||||
struct wsscreen_list ofb_screenlist = {
|
||||
sizeof(_ofb_scrlist) / sizeof(struct wsscreen_descr *), _ofb_scrlist
|
||||
};
|
||||
|
||||
static int ofb_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
|
||||
static int ofb_mmap __P((void *, off_t, int));
|
||||
static int ofb_alloc_screen __P((void *, const struct wsscreen_descr *,
|
||||
void **, int *, int *, long *));
|
||||
static void ofb_free_screen __P((void *, void *));
|
||||
static void ofb_show_screen __P((void *, void *));
|
||||
static int ofb_load_font __P((void *, void *, int, int, int, void *));
|
||||
|
||||
struct wsdisplay_accessops ofb_accessops = {
|
||||
ofb_ioctl,
|
||||
ofb_mmap,
|
||||
ofb_alloc_screen,
|
||||
ofb_free_screen,
|
||||
ofb_show_screen,
|
||||
ofb_load_font
|
||||
};
|
||||
|
||||
static void ofb_common_init __P((int, struct ofb_devconfig *));
|
||||
|
||||
int
|
||||
ofbmatch(parent, match, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *match;
|
||||
void *aux;
|
||||
{
|
||||
struct pci_attach_args *pa = aux;
|
||||
|
||||
if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
ofbattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct ofb_softc *sc = (struct ofb_softc *)self;
|
||||
struct pci_attach_args *pa = aux;
|
||||
struct wsemuldisplaydev_attach_args a;
|
||||
int console;
|
||||
struct ofb_devconfig *dc;
|
||||
|
||||
console = ofb_is_console();
|
||||
|
||||
if (console) {
|
||||
dc = &ofb_console_dc;
|
||||
sc->nscreens = 1;
|
||||
} else {
|
||||
int node;
|
||||
|
||||
dc = malloc(sizeof(struct ofb_devconfig), M_DEVBUF, M_WAITOK);
|
||||
bzero(dc, sizeof(struct ofb_devconfig));
|
||||
node = pcidev_to_ofdev(pa);
|
||||
|
||||
ofb_common_init(node, dc);
|
||||
}
|
||||
sc->sc_dc = dc;
|
||||
|
||||
if (dc->dc_paddr == 0) {
|
||||
printf(": cannot map framebuffer\n");
|
||||
return;
|
||||
}
|
||||
dc->dc_raster.pixels = mapiodev(dc->dc_paddr,
|
||||
dc->dc_linebytes * dc->dc_height);
|
||||
|
||||
printf(": %d x %d, %dbpp",
|
||||
dc->dc_raster.width, dc->dc_raster.height, dc->dc_raster.depth);
|
||||
|
||||
a.console = console;
|
||||
a.scrdata = &ofb_screenlist;
|
||||
a.accessops = &ofb_accessops;
|
||||
a.accesscookie = sc;
|
||||
|
||||
#ifdef DEBUG
|
||||
asm volatile ("mtdbatl 3,%0; mtdbatu 3,%1" :: "r"(0), "r"(0));
|
||||
#endif
|
||||
config_found(self, &a, wsemuldisplaydevprint);
|
||||
}
|
||||
|
||||
void
|
||||
ofb_common_init(node, dc)
|
||||
int node;
|
||||
struct ofb_devconfig *dc;
|
||||
{
|
||||
struct raster *rap;
|
||||
struct rcons *rcp;
|
||||
int i;
|
||||
int addr, width, height, linebytes, depth;
|
||||
u_int regs[5];
|
||||
|
||||
OF_getprop(node, "width", &width, sizeof(width));
|
||||
OF_getprop(node, "height", &height, sizeof(height));
|
||||
OF_getprop(node, "linebytes", &linebytes, sizeof(linebytes));
|
||||
OF_getprop(node, "depth", &depth, sizeof(depth));
|
||||
|
||||
OF_getprop(node, "assigned-addresses", regs, sizeof(regs));
|
||||
addr = regs[2] & 0xf0000000;
|
||||
|
||||
/* Map the framebuffer using BAT3. (va == pa) */
|
||||
asm volatile ("mtdbatl 3,%0; mtdbatu 3,%1; isync"
|
||||
:: "r"(BATL(addr, BAT_I)), "r"(BATU(addr)));
|
||||
|
||||
if (dc->dc_ih == 0) {
|
||||
char name[64];
|
||||
|
||||
bzero(name, 64);
|
||||
OF_package_to_path(node, name, sizeof(name));
|
||||
dc->dc_ih = OF_open(name);
|
||||
}
|
||||
|
||||
OF_interpret("frame-buffer-adr", 1, &addr);
|
||||
if (addr == 0)
|
||||
return;
|
||||
dc->dc_paddr = addr; /* PA of the frame buffer */
|
||||
|
||||
/* Set colormap to black on white. */
|
||||
OF_call_method_1("color!", dc->dc_ih, 4, 0, 0, 0, 0xff);
|
||||
OF_call_method_1("color!", dc->dc_ih, 4, 255, 255, 255, 0);
|
||||
for (i = 0; i < height * linebytes; i += sizeof(u_int32_t))
|
||||
*(u_int32_t *)(addr + i) = 0;
|
||||
|
||||
/* initialize the raster */
|
||||
rap = &dc->dc_raster;
|
||||
rap->width = width;
|
||||
rap->height = height;
|
||||
rap->depth = depth;
|
||||
rap->linelongs = linebytes / sizeof(u_int32_t);
|
||||
rap->pixels = (u_int32_t *)addr;
|
||||
|
||||
/* initialize the raster console blitter */
|
||||
rcp = &dc->dc_rcons;
|
||||
rcp->rc_sp = rap;
|
||||
rcp->rc_crow = rcp->rc_ccol = -1;
|
||||
rcp->rc_crowp = &rcp->rc_crow;
|
||||
rcp->rc_ccolp = &rcp->rc_ccol;
|
||||
rcons_init(rcp, 128, 128);
|
||||
|
||||
ofb_stdscreen.nrows = dc->dc_rcons.rc_maxrow;
|
||||
ofb_stdscreen.ncols = dc->dc_rcons.rc_maxcol;
|
||||
}
|
||||
|
||||
int
|
||||
ofb_is_console()
|
||||
{
|
||||
int chosen, stdout, node;
|
||||
char type[16];
|
||||
|
||||
chosen = OF_finddevice("/chosen");
|
||||
OF_getprop(chosen, "stdout", &stdout, 4);
|
||||
node = OF_instance_to_package(stdout);
|
||||
OF_getprop(node, "device_type", type, sizeof(type));
|
||||
if (strcmp(type, "display") == 0)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ofb_ioctl(v, cmd, data, flag, p)
|
||||
void *v;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
struct ofb_softc *sc = v;
|
||||
struct ofb_devconfig *dc = sc->sc_dc;
|
||||
struct wsdisplay_fbinfo *wdf;
|
||||
struct grfinfo *gm;
|
||||
|
||||
switch (cmd) {
|
||||
case WSDISPLAYIO_GTYPE:
|
||||
*(u_int *)data = WSDISPLAY_TYPE_PCIMISC; /* XXX ? */
|
||||
return 0;
|
||||
|
||||
case WSDISPLAYIO_GINFO:
|
||||
wdf = (void *)data;
|
||||
wdf->height = sc->sc_dc->dc_raster.height;
|
||||
wdf->width = sc->sc_dc->dc_raster.width;
|
||||
wdf->depth = sc->sc_dc->dc_raster.depth;
|
||||
wdf->cmsize = 256;
|
||||
return 0;
|
||||
|
||||
case WSDISPLAYIO_PUTCMAP:
|
||||
return putcmap(sc, data);
|
||||
|
||||
/* XXX There are no way to know framebuffer pa from a user program. */
|
||||
case GRFIOCGINFO:
|
||||
gm = (void *)data;
|
||||
bzero(gm, sizeof(struct grfinfo));
|
||||
gm->gd_fbaddr = (caddr_t)sc->sc_dc->dc_paddr;
|
||||
gm->gd_fbrowbytes = sc->sc_dc->dc_linebytes;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
ofb_mmap(v, offset, prot)
|
||||
void *v;
|
||||
off_t offset;
|
||||
int prot;
|
||||
{
|
||||
struct ofb_softc *sc = v;
|
||||
struct ofb_devconfig *dc = sc->sc_dc;
|
||||
|
||||
if (offset > (dc->dc_linebytes * dc->dc_height))
|
||||
return -1;
|
||||
|
||||
return dc->dc_paddr + offset;
|
||||
}
|
||||
|
||||
int
|
||||
ofb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
|
||||
void *v;
|
||||
const struct wsscreen_descr *type;
|
||||
void **cookiep;
|
||||
int *curxp, *curyp;
|
||||
long *attrp;
|
||||
{
|
||||
struct ofb_softc *sc = v;
|
||||
long defattr;
|
||||
|
||||
if (sc->nscreens > 0)
|
||||
return (ENOMEM);
|
||||
|
||||
*cookiep = &sc->sc_dc->dc_rcons; /* one and only for now */
|
||||
*curxp = 0;
|
||||
*curyp = 0;
|
||||
rcons_alloc_attr(&sc->sc_dc->dc_rcons, 0, 0, 0, &defattr);
|
||||
*attrp = defattr;
|
||||
sc->nscreens++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ofb_free_screen(v, cookie)
|
||||
void *v;
|
||||
void *cookie;
|
||||
{
|
||||
struct ofb_softc *sc = v;
|
||||
|
||||
if (sc->sc_dc == &ofb_console_dc)
|
||||
panic("ofb_free_screen: console");
|
||||
|
||||
sc->nscreens--;
|
||||
}
|
||||
|
||||
void
|
||||
ofb_show_screen(v, cookie)
|
||||
void *v;
|
||||
void *cookie;
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
ofb_load_font(v, cookie, first, num, stride, data)
|
||||
void *v;
|
||||
void *cookie;
|
||||
int first, num, stride;
|
||||
void *data;
|
||||
{
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
int
|
||||
ofb_cnattach()
|
||||
{
|
||||
struct ofb_devconfig *dc = &ofb_console_dc;
|
||||
long defattr;
|
||||
int crow;
|
||||
int chosen, stdout, node;
|
||||
char cmd[32];
|
||||
|
||||
chosen = OF_finddevice("/chosen");
|
||||
OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
|
||||
node = OF_instance_to_package(stdout);
|
||||
dc->dc_ih = stdout;
|
||||
|
||||
ofb_common_init(node, dc);
|
||||
#if 0
|
||||
/* get current cursor position */
|
||||
OF_interpret("line#", 1, &crow);
|
||||
|
||||
/* move (rom monitor) cursor to the lowest line */
|
||||
sprintf(cmd, "%x to line#", ofb_stdscreen.nrows - 1);
|
||||
OF_interpret(cmd, 0);
|
||||
#endif
|
||||
rcons_alloc_attr(&dc->dc_rcons, 0, 0, 0, &defattr);
|
||||
wsdisplay_cnattach(&ofb_stdscreen, &dc->dc_rcons, 0, 0, defattr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
putcmap(sc, cm)
|
||||
struct ofb_softc *sc;
|
||||
struct wsdisplay_cmap *cm;
|
||||
{
|
||||
struct ofb_devconfig *dc = sc->sc_dc;
|
||||
int index = cm->index;
|
||||
int count = cm->count;
|
||||
int i, s;
|
||||
u_char *r, *g, *b;
|
||||
|
||||
if (cm->index >= 256 || cm->count > 256 ||
|
||||
(cm->index + cm->count) > 256)
|
||||
return EINVAL;
|
||||
#if defined(UVM)
|
||||
if (!uvm_useracc(cm->red, cm->count, B_READ) ||
|
||||
!uvm_useracc(cm->green, cm->count, B_READ) ||
|
||||
!uvm_useracc(cm->blue, cm->count, B_READ))
|
||||
return EFAULT;
|
||||
#else
|
||||
if (!useracc(cm->red, cm->count, B_READ) ||
|
||||
!useracc(cm->green, cm->count, B_READ) ||
|
||||
!useracc(cm->blue, cm->count, B_READ))
|
||||
return EFAULT;
|
||||
#endif
|
||||
copyin(cm->red, &sc->sc_cmap_red[index], count);
|
||||
copyin(cm->green, &sc->sc_cmap_green[index], count);
|
||||
copyin(cm->blue, &sc->sc_cmap_blue[index], count);
|
||||
|
||||
r = &sc->sc_cmap_red[index];
|
||||
g = &sc->sc_cmap_green[index];
|
||||
b = &sc->sc_cmap_blue[index];
|
||||
|
||||
s = splhigh();
|
||||
asm volatile ("mtdbatl 3,%0; mtdbatu 3,%1"
|
||||
:: "r"(BATL(dc->dc_paddr, BAT_I)), "r"(BATU(dc->dc_paddr)));
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
OF_call_method_1("color!", dc->dc_ih, 4, *r, *g, *b, index);
|
||||
r++, g++, b++, index++;
|
||||
}
|
||||
splx(s);
|
||||
|
||||
return 0;
|
||||
}
|
53
sys/arch/macppc/dev/ofbvar.h
Normal file
53
sys/arch/macppc/dev/ofbvar.h
Normal file
@ -0,0 +1,53 @@
|
||||
/* $NetBSD: ofbvar.h,v 1.1 1998/10/14 12:15:13 tsubai Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
struct ofb_devconfig {
|
||||
paddr_t dc_paddr; /* physcal address */
|
||||
int dc_ih; /* ihandle of this node */
|
||||
|
||||
struct raster dc_raster; /* raster description */
|
||||
struct rcons dc_rcons; /* raster blitter control info */
|
||||
};
|
||||
|
||||
#define dc_width dc_raster.width
|
||||
#define dc_height dc_raster.height
|
||||
#define dc_depth dc_raster.depth
|
||||
#define dc_linebytes dc_raster.linelongs * sizeof(u_int32_t)
|
||||
|
||||
|
||||
struct ofb_softc {
|
||||
struct device sc_dev;
|
||||
|
||||
struct ofb_devconfig *sc_dc; /* device configuration */
|
||||
int nscreens;
|
||||
|
||||
u_char sc_cmap_red[256];
|
||||
u_char sc_cmap_green[256];
|
||||
u_char sc_cmap_blue[256];
|
||||
};
|
Loading…
Reference in New Issue
Block a user