diff options
author | Dale S. Rahn <rahnds@cvs.openbsd.org> | 2000-09-06 02:45:13 +0000 |
---|---|---|
committer | Dale S. Rahn <rahnds@cvs.openbsd.org> | 2000-09-06 02:45:13 +0000 |
commit | 15d7b4a2e698a8a2e0b59f9358b1cd04731ec748 (patch) | |
tree | d70dca0384008704af104c58e58308e5091db770 /sys | |
parent | 7d234c9ba71d44455f983c77491b8f4ac666a699 (diff) |
First cut at vga console support for PowerMac (USB keyboard)
uses adb to reboot or power-off system.
add support for various USB devices into device table, as well
as some other missing devices.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/powerpc/powerpc/conf.c | 67 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/machdep.c | 53 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/ofw_machdep.c | 179 |
3 files changed, 219 insertions, 80 deletions
diff --git a/sys/arch/powerpc/powerpc/conf.c b/sys/arch/powerpc/powerpc/conf.c index 6d283d4de4e..ddb3a00f22d 100644 --- a/sys/arch/powerpc/powerpc/conf.c +++ b/sys/arch/powerpc/powerpc/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.15 2000/06/15 03:12:46 rahnds Exp $ */ +/* $OpenBSD: conf.c,v 1.16 2000/09/06 02:45:11 rahnds Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom @@ -110,19 +110,13 @@ cdev_decl(ofrtc); cdev_decl(kbd); cdev_decl(ms); -#if 0 #include "wsdisplay.h" -#include "wskdb.h" +#include "wskbd.h" #include "wsmouse.h" -#else -#define NWSKBD 0 -#define NWSDISPLAY 0 -#define NWSMOUSE 0 cdev_decl(wsdisplay); -cdev_decl(wskdb); +cdev_decl(wskbd); cdev_decl(wsmouse); -#endif #include <sd.h> #include <st.h> @@ -168,6 +162,23 @@ cdev_decl(lkm); #endif #include "ksyms.h" cdev_decl(ksyms); +#include "usb.h" +cdev_decl(usb); +#include "uhid.h" +cdev_decl(uhid); +#include "ugen.h" +cdev_decl(ugen); +#include "ulpt.h" +cdev_decl(ulpt); +#include "urio.h" +cdev_decl(urio); +#include "ucom.h" +cdev_decl(ucom); + +#include "raid.h" +cdev_decl(raid); +#include "wsmux.h" +cdev_decl(wsmux); struct cdevsw cdevsw[] = { @@ -196,21 +207,12 @@ struct cdevsw cdevsw[] = { cdev_bpftun_init(NBPFILTER,bpf),/* 22: berkeley packet filter */ cdev_bpftun_init(NTUN,tun), /* 23: network tunnel */ cdev_lkm_init(NLKM,lkm), /* 24: loadable module driver */ - #if 0 - cdev_wsdisplay_init(NWSDISPLAY,wscons), /* 25: workstation console */ - #else cdev_notdef(), /* 25 */ - #endif cdev_notdef(), /* 26 */ cdev_notdef(), /* 27 */ cdev_notdef(), /* 28 */ - #if 0 - cdev_mouse_init(NWSKDB,wskbd), /* 29 /dev/kbd XX */ - cdev_mouse_init(NWSMOUSE,msmouse), /* 30 /dev/mouse XXX */ - #else cdev_notdef(), /* 29 */ cdev_notdef(), /* 30 */ - #endif cdev_notdef(), /* 31 */ cdev_notdef(), /* 32 */ cdev_lkm_dummy(), /* 33 */ @@ -236,7 +238,29 @@ struct cdevsw cdevsw[] = { #else cdev_notdef(), /* 51 */ #endif - /* If adding devs, don't forget to expand 'chrtoblktbl' below! */ + cdev_notdef(), /* 52 */ + cdev_notdef(), /* 53 */ + cdev_disk_init(NRAID,raid), /* 54: RAIDframe disk driver */ + cdev_notdef(), /* 55 */ + /* The following slots are reserved for isdn4bsd. */ + cdev_notdef(), /* 56: i4b main device */ + cdev_notdef(), /* 57: i4b control device */ + cdev_notdef(), /* 58: i4b raw b-channel access */ + cdev_notdef(), /* 59: i4b trace device */ + cdev_notdef(), /* 60: i4b phone device */ + /* End of reserved slots for isdn4bsd. */ + cdev_usb_init(NUSB,usb), /* 61: USB controller */ + cdev_usbdev_init(NUHID,uhid), /* 62: USB generic HID */ + cdev_ugen_init(NUGEN,ugen), /* 63: USB generic driver */ + cdev_ulpt_init(NULPT,ulpt), /* 64: USB printers */ + cdev_usbdev_init(NURIO,urio), /* 65: USB Diamond Rio 500 */ + cdev_tty_init(NUCOM,ucom), /* 66: USB tty */ + cdev_wsdisplay_init(NWSDISPLAY, /* 67: frame buffers, etc. */ + wsdisplay), + cdev_mouse_init(NWSKBD, wskbd), /* 68: keyboards */ + cdev_mouse_init(NWSMOUSE, /* 69: mice */ + wsmouse), + cdev_mouse_init(NWSMUX, wsmux), /* 70: ws multiplexor */ }; int nchrdev = sizeof cdevsw / sizeof cdevsw[0]; @@ -327,18 +351,15 @@ blktochr(dev) } #include <dev/cons.h> +#include <vgafb_pci.h> cons_decl(com); cons_decl(ofc); -/* cons_decl(wscons); */ struct consdev constab[] = { #if NOFCONS > 0 cons_init(ofc), #endif -#if NWSCONS1 > 0 - cons_init(wscons), -#endif #if NCOM > 0 cons_init(com), #endif diff --git a/sys/arch/powerpc/powerpc/machdep.c b/sys/arch/powerpc/powerpc/machdep.c index fc35c0f535b..a4cdcb0e639 100644 --- a/sys/arch/powerpc/powerpc/machdep.c +++ b/sys/arch/powerpc/powerpc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.44 2000/07/14 03:45:27 rahnds Exp $ */ +/* $OpenBSD: machdep.c,v 1.45 2000/09/06 02:45:11 rahnds Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -72,6 +72,7 @@ #include <machine/autoconf.h> #include <machine/bus.h> #include <machine/pio.h> +#include "adb.h" /* * Global variables used here and there @@ -329,9 +330,15 @@ where = 3; case 'd': boothowto |= RB_KDB; break; + case 'c': + boothowto |= RB_CONFIG; + break; } } } +#if 0 + ddb_init((int)(esym - (&_end)), &_end, esym); +#endif /* * Set up extents for pci mappings @@ -355,16 +362,20 @@ where = 3; (caddr_t)devio_ex_storage, sizeof(devio_ex_storage), EX_NOCOALESCE|EX_NOWAIT); - ofwconprobe(); - /* * Now we can set up the console as mapping is enabled. */ consinit(); + printf("inited\n"); + /* while using openfirmware, run userconfig */ + if (boothowto & RB_CONFIG) { + user_config(); + } + /* + * Replace with real console. + */ + ofwconprobe(); -#if 0 - dump_avail(); -#endif #if NIPKDB > 0 /* * Now trap to IPKDB @@ -881,6 +892,14 @@ boot(howto) splhigh(); if (howto & RB_HALT) { doshutdownhooks(); + if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { +#if NADB > 0 + delay(1000000); + adb_poweroff(); + printf("WARNING: powerdown failed!\n"); +#endif + } + printf("halted\n\n"); (fw->exit)(); } @@ -888,25 +907,11 @@ boot(howto) dumpsys(); doshutdownhooks(); printf("rebooting\n\n"); -#if 0 - if (what && *what) { - if (strlen(what) > sizeof str - 5) - printf("boot string too large, ignored\n"); - else { - strcpy(str, what); - ap1 = ap = str + strlen(str); - *ap++ = ' '; - } - } - *ap++ = '-'; - if (howto & RB_SINGLE) - *ap++ = 's'; - if (howto & RB_KDB) - *ap++ = 'd'; - *ap++ = 0; - if (ap[-2] == '-') - *ap1 = 0; + +#if NADB > 0 + adb_restart(); /* not return */ #endif + OF_exit(); (fw->boot)(str); printf("boot failed, spinning\n"); diff --git a/sys/arch/powerpc/powerpc/ofw_machdep.c b/sys/arch/powerpc/powerpc/ofw_machdep.c index 572ec2497fb..5b29c5e2e76 100644 --- a/sys/arch/powerpc/powerpc/ofw_machdep.c +++ b/sys/arch/powerpc/powerpc/ofw_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_machdep.c,v 1.14 2000/03/23 04:04:21 rahnds Exp $ */ +/* $OpenBSD: ofw_machdep.c,v 1.15 2000/09/06 02:45:12 rahnds Exp $ */ /* $NetBSD: ofw_machdep.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */ /* @@ -49,6 +49,8 @@ #include <machine/powerpc.h> #include <machine/autoconf.h> +#include <ukbd.h> + void OF_exit __P((void)) __attribute__((__noreturn__)); void OF_boot __P((char *bootspec)) __attribute__((__noreturn__)); void ofw_mem_regions __P((struct mem_region **memp, struct mem_region **availp)); @@ -122,15 +124,21 @@ static struct { } ofw_mapping[256]; int OF_stdout; +int OF_stdin; int save_ofw_mapping() { int mmui, mmu; int chosen; - int stdout; + int stdout, stdin; if ((chosen = OF_finddevice("/chosen")) == -1) { return 0; } + if (OF_getprop(chosen, "stdin", &stdin, sizeof stdin) != sizeof stdin) + { + return 0; + } + OF_stdin = stdin; if (OF_getprop(chosen, "stdout", &stdout, sizeof stdout) != sizeof stdout) { return 0; @@ -312,8 +320,12 @@ ofwtrysercon(char *name, int qhandle) ppc_console_serfreq=freq; } } + +#include <dev/pci/pcivar.h> +#include <arch/powerpc/pci/vgafb_pcivar.h> + static -u_int32_t +pcitag_t ofw_make_tag(cpv, bus, dev, fnc) void *cpv; int bus, dev, fnc; @@ -329,42 +341,143 @@ ofwenablepcimemio(char *name, int qhandle) * on MCG, VI machines. */ } -#include <machine/bat.h> -/* HACK */ -#include <dev/pci/pcireg.h> -#include <dev/pci/pcivar.h> -#include <dev/pci/pcidevs.h> -#include <powerpc/pci/pcibrvar.h> -#include <powerpc/pci/mpc106reg.h> +#define OFW_PCI_PHYS_HI_BUSMASK 0x00ff0000 +#define OFW_PCI_PHYS_HI_BUSSHIFT 16 +#define OFW_PCI_PHYS_HI_DEVICEMASK 0x0000f800 +#define OFW_PCI_PHYS_HI_DEVICESHIFT 11 +#define OFW_PCI_PHYS_HI_FUNCTIONMASK 0x00000700 +#define OFW_PCI_PHYS_HI_FUNCTIONSHIFT 8 + +#define pcibus(x) \ + (((x) & OFW_PCI_PHYS_HI_BUSMASK) >> OFW_PCI_PHYS_HI_BUSSHIFT) +#define pcidev(x) \ + (((x) & OFW_PCI_PHYS_HI_DEVICEMASK) >> OFW_PCI_PHYS_HI_DEVICESHIFT) +#define pcifunc(x) \ + (((x) & OFW_PCI_PHYS_HI_FUNCTIONMASK) >> OFW_PCI_PHYS_HI_FUNCTIONSHIFT) + + +struct ppc_bus_space ppc_membus; +int cons_displaytype=0; +bus_space_tag_t cons_membus = &ppc_membus; +bus_space_handle_t cons_display_mem_h; +bus_space_handle_t cons_display_ctl_h; +int cons_height, cons_width, cons_linebytes, cons_depth; + +#include "vgafb_pci.h" + void ofwconprobe() { - int qhandle, phandle; +#if NVGAFB_PCI > 0 char name[32]; - for (qhandle = OF_peer(0); qhandle; qhandle = phandle) { - if (OF_getprop(qhandle, "device_type", name, sizeof name) >= 0) - { - if (strcmp (name, "serial") == 0) { - ofwtrysercon (name, qhandle); - } - } + char iname[32]; + int len; + int stdout_node, stdin_node; + int parent; + int err; + u_int32_t memtag, iotag; + struct ppc_pci_chipset pa; + struct { + u_int32_t phys_hi, phys_mid, phys_lo; + u_int32_t size_hi, size_lo; + } addr [8]; + + pa.pc_make_tag = &ofw_make_tag; + + stdout_node = OF_instance_to_package(OF_stdout); + len = OF_getprop(stdout_node, "name", name, 20); + name[len] = 0; + /* + printf("console out [%s]", name); + */ + cons_displaytype=1; + err = OF_getprop(stdout_node, "width", &cons_width, 4); + if ( err != 4) { + cons_width = 0; + } + err = OF_getprop(stdout_node, "linebytes", &cons_linebytes, 4); + if ( err != 4) { + cons_linebytes = cons_width; + } + err = OF_getprop(stdout_node, "height", &cons_height, 4); + if ( err != 4) { + cons_height = 0; + } + err = OF_getprop(stdout_node, "depth", &cons_depth, 4); + if ( err != 4) { + cons_depth = 0; + } - if (phandle = OF_child(qhandle)) - continue; - while (qhandle) { - if (phandle = OF_peer(qhandle)) - break; - qhandle = OF_parent(qhandle); - } + stdin_node = OF_instance_to_package(OF_stdin); + len = OF_getprop(stdin_node, "name", iname, 20); + iname[len] = 0; + printf("console in [%s]", iname); + /* what to do about serial console? */ + if (strcmp ("keyboard", iname) == 0) { + int node; + char type[20]; + /* ok we have a keyboard, is it usb or adb? */ + /* TODO */ + /* configure usb if UKBD exists */ +#if NUKBD > 0 + printf("USB"); + ukbd_cnattach(); +#endif } - /* setup pci/isa as necessary to found map io area */ + + len = OF_getprop(stdout_node, "assigned-addresses", addr, sizeof(addr)); + if (len < sizeof(addr[0])) { + printf(": no address\n"); + return; + } + memtag = ofw_make_tag(NULL, pcibus(addr[0].phys_hi), + pcidev(addr[0].phys_hi), + pcifunc(addr[0].phys_hi)); + iotag = ofw_make_tag(NULL, pcibus(addr[1].phys_hi), + pcidev(addr[1].phys_hi), + pcifunc(addr[1].phys_hi)); + + printf(": memaddr %x size %x, ", addr[0].phys_lo, addr[0].size_lo); + printf(": ioaddr %x, size %x", addr[1].phys_lo, addr[1].size_lo); + printf(": memtag %x, iotag %x", memtag, iotag); + printf(": cons_width %d cons_linebytes %d cons_height %d\n", + cons_width, cons_linebytes, cons_height); + + if (addr[0].size_lo > 0x100000) { + addr[0].size_lo = 0x100000; + } + + + { + int i,j; + + cons_membus->bus_base = 0x80000000; + cons_membus->bus_reverse = 1; #if 0 - printf("found desired console address %x qhandle %x serfreq %x\n", - ppc_console_addr, ppc_console_qhandle, - ppc_console_serfreq); + err = bus_space_map( cons_membus, addr[0].phys_lo, addr[0].size_lo, + 0, &cons_display_mem_h); + printf("mem map err %x",err); + bus_space_map( cons_membus, addr[1].phys_lo, addr[1].size_lo, + 0, &cons_display_ctl_h); +#endif + + vgafb_pci_console(cons_membus, + addr[1].phys_lo, addr[1].size_lo, + cons_membus, + addr[0].phys_lo, addr[0].size_lo, + &pa, pcibus(addr[1].phys_hi), pcidev(addr[1].phys_hi), + pcifunc(addr[1].phys_hi)); + + +#if 0 + for (j = 2; j < 4; j++) { + for (i = 0; i < cons_width * cons_height; i++) { + bus_space_write_1(cons_membus, + cons_display_mem_h, i, j); + + } + } +#endif + } #endif - - /* do this from probed values, not from constants */ - addbatmap(MPC106_V_ISA_IO_SPACE, MPC106_P_ISA_IO_SPACE, BAT_I); - addbatmap(0xB0000000, 0xB0000000, BAT_I); /* map interrupt vector */ } |