From 34fbf6de293841e562d7522f435979d714dd53b3 Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 14 Dec 1995 03:52:27 +0000 Subject: [PATCH] update to netbsd --- sys/arch/alpha/README | 200 ++--- sys/arch/alpha/STATUS | 125 ++-- sys/arch/alpha/TODO.users | 11 +- sys/arch/alpha/alpha/clock.c | 100 ++- sys/arch/alpha/alpha/clock_mc.c | 81 +- sys/arch/alpha/alpha/cpu.c | 47 +- sys/arch/alpha/alpha/dec_2100_a50.c | 30 +- sys/arch/alpha/alpha/dec_axppci_33.c | 126 ++++ .../makexxboot.c => alpha/dec_axppci_33.h} | 35 +- sys/arch/alpha/alpha/dec_kn20aa.c | 126 ++++ sys/arch/alpha/alpha/dec_kn20aa.h | 32 + sys/arch/alpha/alpha/genassym.c | 27 +- sys/arch/alpha/alpha/interrupt.c | 31 +- sys/arch/alpha/alpha/locore.s | 323 ++++++-- sys/arch/alpha/alpha/machdep.c | 62 +- sys/arch/alpha/alpha/mainbus.c | 10 +- sys/arch/alpha/alpha/mem.c | 9 +- sys/arch/alpha/alpha/pal.s | 7 +- sys/arch/alpha/alpha/pmap.c | 286 +++++--- sys/arch/alpha/alpha/process_machdep.c | 48 +- sys/arch/alpha/alpha/support.c | 22 +- sys/arch/alpha/alpha/sys_machdep.c | 6 +- sys/arch/alpha/alpha/trap.c | 51 +- sys/arch/alpha/alpha/vm_machdep.c | 45 +- sys/arch/alpha/compile/.cvsignore | 11 + sys/arch/alpha/compile/build_all | 15 + sys/arch/alpha/compile/rebuild_all | 23 + sys/arch/alpha/conf/ALPHA | 54 +- sys/arch/alpha/conf/BUNNY | 18 +- sys/arch/alpha/conf/DILLY | 96 +++ sys/arch/alpha/conf/GENERIC | 37 +- sys/arch/alpha/conf/GENERIC_NFS | 37 +- sys/arch/alpha/conf/JURA | 53 +- sys/arch/alpha/conf/MACALLAN | 17 +- sys/arch/alpha/conf/Makefile.alpha | 20 +- sys/arch/alpha/conf/NONAME | 89 +++ sys/arch/alpha/conf/TOMMY | 26 +- sys/arch/alpha/conf/files.alpha | 120 +-- sys/arch/alpha/conf/std.alpha | 9 + sys/arch/alpha/include/ansi.h | 8 +- sys/arch/alpha/include/asm.h | 64 +- sys/arch/alpha/include/autoconf.h | 8 +- sys/arch/alpha/include/db_machdep.h | 56 ++ sys/arch/alpha/include/ecoff.h | 44 +- sys/arch/alpha/include/eisa_machdep.h | 0 sys/arch/alpha/include/intrcnt.h | 68 ++ sys/arch/alpha/include/isa_machdep.h | 31 + sys/arch/alpha/include/param.h | 4 +- sys/arch/alpha/include/pci_machdep.h | 36 + sys/arch/alpha/include/pio.h | 88 --- sys/arch/alpha/include/pmap.h | 12 +- sys/arch/alpha/include/profile.h | 190 ++++- sys/arch/alpha/include/psl.h | 16 +- sys/arch/alpha/include/pte.h | 12 +- sys/arch/alpha/include/rpb.h | 4 +- sys/arch/alpha/include/vmparam.h | 3 +- sys/arch/alpha/isa/isa_machdep.c | 169 ----- sys/arch/alpha/isa/pckbd.c | 99 ++- sys/arch/alpha/pci/apecs.c | 248 +++---- sys/arch/alpha/pci/apecs_isa.c | 421 +++++------ sys/arch/alpha/pci/apecs_pci.c | 398 ++++------ sys/arch/alpha/pci/apecsreg.h | 8 +- sys/arch/alpha/pci/apecsvar.h | 72 ++ sys/arch/alpha/pci/cia.c | 176 +++++ sys/arch/alpha/pci/cia_isa.c | 346 +++++++++ sys/arch/alpha/pci/cia_pci.c | 222 ++++++ .../alpha/{isa/isa_intr.h => pci/ciareg.h} | 37 +- sys/arch/alpha/pci/ciavar.h | 69 ++ sys/arch/alpha/pci/lca.c | 210 ++++++ sys/arch/alpha/pci/lca_isa.c | 346 +++++++++ sys/arch/alpha/pci/lca_pci.c | 226 ++++++ sys/arch/alpha/pci/lcareg.h | 55 ++ sys/arch/alpha/pci/lcavar.h | 68 ++ sys/arch/alpha/pci/pci_2100_a50.c | 134 ++-- sys/arch/alpha/pci/pci_2100_a50.h | 32 + sys/arch/alpha/pci/pci_axppci_33.c | 204 ++++++ sys/arch/alpha/pci/pci_axppci_33.h | 32 + sys/arch/alpha/pci/pci_chipset.h | 74 -- sys/arch/alpha/pci/pci_kn20aa.c | 294 ++++++++ sys/arch/alpha/pci/pci_kn20aa.h | 36 + sys/arch/alpha/pci/pci_machdep.c | 258 ++----- sys/arch/alpha/pci/pci_machdep.h | 53 -- sys/arch/alpha/pci/pcivga.c | 110 +-- sys/arch/alpha/pci/pcivgavar.h | 29 +- sys/arch/alpha/pci/sio.c | 116 ++- sys/arch/alpha/pci/sio_pic.c | 117 +-- sys/arch/alpha/pci/siovar.h | 36 + sys/arch/alpha/pci/tga.c | 226 +++--- sys/arch/alpha/pci/tgareg.h | 7 +- sys/arch/alpha/pci/tgavar.h | 30 +- sys/arch/alpha/pci/wscons.c | 9 +- .../alpha/{isa/isa_dma.h => pci/wsconsvar.h} | 29 +- sys/arch/alpha/stand/Makefile | 6 +- sys/arch/alpha/stand/Makefile.inc | 9 + sys/arch/alpha/stand/OSFpal.c | 26 + sys/arch/alpha/stand/bbinfo.h | 14 + sys/arch/alpha/stand/boot/Makefile | 102 ++- sys/arch/alpha/stand/boot/TODO | 7 - sys/arch/alpha/stand/boot/boot.c | 7 +- sys/arch/alpha/stand/boot/conf.c | 10 +- .../alpha/stand/boot/{libsa => }/devopen.c | 4 +- sys/arch/alpha/stand/boot/disk.c | 20 +- sys/arch/alpha/stand/boot/disk.h | 7 + .../alpha/stand/boot/{libsa => }/filesystem.c | 2 +- sys/arch/alpha/stand/boot/libsa/Makefile | 14 - sys/arch/alpha/stand/boot/newvers.sh | 4 +- sys/arch/alpha/stand/boot/prom.c | 135 ---- sys/arch/alpha/stand/boot/prom_disp.S | 116 --- sys/arch/alpha/stand/boot/version | 4 +- sys/arch/alpha/stand/bootxx.c | 122 ++++ sys/arch/alpha/stand/bootxx/Makefile | 85 +-- sys/arch/alpha/stand/bootxx/TODO | 7 - sys/arch/alpha/stand/bootxx/boot.c | 186 ----- sys/arch/alpha/stand/bootxx/disk.c | 152 ---- sys/arch/alpha/stand/bootxx/libsa/Makefile | 19 - sys/arch/alpha/stand/bootxx/libsa/alloc.c | 110 --- sys/arch/alpha/stand/bootxx/libsa/bcopy.c | 72 -- sys/arch/alpha/stand/bootxx/libsa/devopen.c | 165 ----- sys/arch/alpha/stand/bootxx/libsa/disklabel.c | 53 -- sys/arch/alpha/stand/bootxx/libsa/lseek.c | 89 --- sys/arch/alpha/stand/bootxx/libsa/open.c | 125 ---- sys/arch/alpha/stand/bootxx/libsa/read.c | 93 --- sys/arch/alpha/stand/bootxx/libsa/strcmp.c | 62 -- sys/arch/alpha/stand/bootxx/libsa/strlen.c | 58 -- sys/arch/alpha/stand/bootxx/libsa/ufs.c | 690 ------------------ sys/arch/alpha/stand/bootxx/stand.h | 98 --- sys/arch/alpha/stand/bootxx/start.S | 69 -- .../alpha/stand/{bootxx => }/headersize.c | 4 +- sys/arch/alpha/stand/installboot.c | 389 ++++++++++ sys/arch/alpha/stand/{bootxx => }/prom.c | 33 +- sys/arch/alpha/stand/{bootxx => }/prom_disp.S | 10 +- sys/arch/alpha/stand/puts.c | 9 + sys/arch/alpha/stand/{boot => }/start.S | 23 +- sys/arch/alpha/stand/xxboot/Makefile | 13 - sys/arch/alpha/tc/if_le.c | 170 +---- sys/arch/alpha/tc/scc.c | 6 +- 136 files changed, 6368 insertions(+), 5136 deletions(-) create mode 100644 sys/arch/alpha/alpha/dec_axppci_33.c rename sys/arch/alpha/{stand/xxboot/makexxboot.c => alpha/dec_axppci_33.h} (57%) create mode 100644 sys/arch/alpha/alpha/dec_kn20aa.c create mode 100644 sys/arch/alpha/alpha/dec_kn20aa.h create mode 100644 sys/arch/alpha/compile/build_all create mode 100644 sys/arch/alpha/compile/rebuild_all create mode 100644 sys/arch/alpha/conf/DILLY create mode 100644 sys/arch/alpha/conf/NONAME create mode 100644 sys/arch/alpha/conf/std.alpha create mode 100644 sys/arch/alpha/include/db_machdep.h create mode 100644 sys/arch/alpha/include/eisa_machdep.h create mode 100644 sys/arch/alpha/include/intrcnt.h create mode 100644 sys/arch/alpha/include/isa_machdep.h create mode 100644 sys/arch/alpha/include/pci_machdep.h delete mode 100644 sys/arch/alpha/include/pio.h delete mode 100644 sys/arch/alpha/isa/isa_machdep.c create mode 100644 sys/arch/alpha/pci/apecsvar.h create mode 100644 sys/arch/alpha/pci/cia.c create mode 100644 sys/arch/alpha/pci/cia_isa.c create mode 100644 sys/arch/alpha/pci/cia_pci.c rename sys/arch/alpha/{isa/isa_intr.h => pci/ciareg.h} (61%) create mode 100644 sys/arch/alpha/pci/ciavar.h create mode 100644 sys/arch/alpha/pci/lca.c create mode 100644 sys/arch/alpha/pci/lca_isa.c create mode 100644 sys/arch/alpha/pci/lca_pci.c create mode 100644 sys/arch/alpha/pci/lcareg.h create mode 100644 sys/arch/alpha/pci/lcavar.h create mode 100644 sys/arch/alpha/pci/pci_2100_a50.h create mode 100644 sys/arch/alpha/pci/pci_axppci_33.c create mode 100644 sys/arch/alpha/pci/pci_axppci_33.h delete mode 100644 sys/arch/alpha/pci/pci_chipset.h create mode 100644 sys/arch/alpha/pci/pci_kn20aa.c create mode 100644 sys/arch/alpha/pci/pci_kn20aa.h delete mode 100644 sys/arch/alpha/pci/pci_machdep.h create mode 100644 sys/arch/alpha/pci/siovar.h rename sys/arch/alpha/{isa/isa_dma.h => pci/wsconsvar.h} (60%) create mode 100644 sys/arch/alpha/stand/Makefile.inc create mode 100644 sys/arch/alpha/stand/OSFpal.c create mode 100644 sys/arch/alpha/stand/bbinfo.h delete mode 100644 sys/arch/alpha/stand/boot/TODO rename sys/arch/alpha/stand/boot/{libsa => }/devopen.c (98%) create mode 100644 sys/arch/alpha/stand/boot/disk.h rename sys/arch/alpha/stand/boot/{libsa => }/filesystem.c (96%) delete mode 100644 sys/arch/alpha/stand/boot/libsa/Makefile delete mode 100644 sys/arch/alpha/stand/boot/prom.c delete mode 100644 sys/arch/alpha/stand/boot/prom_disp.S create mode 100644 sys/arch/alpha/stand/bootxx.c delete mode 100644 sys/arch/alpha/stand/bootxx/TODO delete mode 100644 sys/arch/alpha/stand/bootxx/boot.c delete mode 100644 sys/arch/alpha/stand/bootxx/disk.c delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/Makefile delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/alloc.c delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/bcopy.c delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/devopen.c delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/disklabel.c delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/lseek.c delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/open.c delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/read.c delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/strcmp.c delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/strlen.c delete mode 100644 sys/arch/alpha/stand/bootxx/libsa/ufs.c delete mode 100644 sys/arch/alpha/stand/bootxx/stand.h delete mode 100644 sys/arch/alpha/stand/bootxx/start.S rename sys/arch/alpha/stand/{bootxx => }/headersize.c (93%) create mode 100644 sys/arch/alpha/stand/installboot.c rename sys/arch/alpha/stand/{bootxx => }/prom.c (90%) rename sys/arch/alpha/stand/{bootxx => }/prom_disp.S (94%) create mode 100644 sys/arch/alpha/stand/puts.c rename sys/arch/alpha/stand/{boot => }/start.S (89%) delete mode 100644 sys/arch/alpha/stand/xxboot/Makefile diff --git a/sys/arch/alpha/README b/sys/arch/alpha/README index 55e2aa1a6b4..0ee83f2b924 100644 --- a/sys/arch/alpha/README +++ b/sys/arch/alpha/README @@ -1,104 +1,46 @@ -I'm pleased to (finally) announce the release of NetBSD/Alpha. - -As some of you may know, NetBSD is a freely-available and freely- -redistributable BSD-derived system that runs on a variety of hardware -platforms, including i386's, Amigas, SPARCs, and DECstations. The Alpha -port is unique, because it's the first port of NetBSD to a 64-bit -architecture. - -The Alpha port of NetBSD is a true 64-bit port: pointers and longs are 64 -bits. This involved a _LOT_ of changes to "machine-independent" kernel, -and to many of the user-land programs. - -So, some details on the status of the port, and a list of supported hardware: - - The port is self-hosting; it is stable enough to build all of its - constituent binaries (including GCC and the rest of the tool chain) - many times over. I've seen uptimes of more than a week, with - multiple compiles going 24 hours a day. It is in "production use" - for its own development, and will soon be in use by computer science - researchers. It's _not_ simply a kernel hacker's toy at this point. - - Lots of things still don't work properly. In particular, a lot of - (poorly-written) user-land programs don't work. As far as I'm - aware, however, there are no found-but-yet-unfixed bugs in the - libraries, which makes getting programs working a bit easier. - Unfortunately, at this time, GDB isn't capable of actually debugging - programs (though it is good for disassembling them, if you know - where they crashed). It's worth noting that the internet protocol - suite works well (and, indeed, I do most of my work remotedly - logged in), and the SunRPC library also works. (Both required serious - modifications to make them work with 64 bit pointers and longs.) - Because formatting the manual pages would have required making g++ - and groff work, there are no formatted man pages included and - there's no easy way to format them. If you need the manual pages, - I'd suggest that you look on another NetBSD system. If you - absolutely can't do that, OSF/1 manual pages should be OK for - most tasks. - - There's rudimentary support for running OSF/1 binaries, which I - originally used when bootstrapping the system. However, it is only - capable of running statically linked binaries, so it's not very - useful except for bootstrapping. It's hoped that eventually we'll - be able to run dynamically-linked OSF/1 binaries. (If you wish to - work on this, please get in touch with me!) NetBSD/Alpha can safely - read and write OSF/1 (v2.0; I would guess v1.x and v3.x as well) - file systems (assuming you don't have OSF/1's security features - enabled). Additionally, the NetBSD/Alpha disklabel format is - compatible with OSF/1's. - - Supported hardware: - DEC 3000/[456789]00 (I've only tested it on the 400 and - 600, but the rest should "just work) using the following - peripherals: - - Serial ports -- barely; the serial driver needs a - lot of help and is not useful for many - complex tasks. - LANCE ethernet -- only the on-board model; I've - not tried any TurboChannel boards, and - didn't write complete support for them into - the driver. - SCSI system -- it recognizes and can use both - on-board SCSI controller chips. However, - it has trouble working with both at the - same time. - - At this time neither the Smart Frame Buffer nor the - ISDN/Audio interface is supported. - - DEC 3000/300 (with the same hardware supported as above; - I've not tested these very much at all, on any of the - 3000/300 models.) - - Unfortunately, at this time none of the following systems are - supported: - AlphaPCs -- the EISA-bus Alpha systems - AlphaStations -- the PCI-bus Alpha systems - The Futurebus-based Alpha server systems - The multiprocessor Alpha systems +$NetBSD: README,v 1.7 1995/11/23 02:33:17 cgd Exp $ Obtaining NetBSD/Alpha sources and binaries: - This release is being made in two parts, source and binary. The - source distribution is a gzipped tar file containing all of the - sources used to build the system, including the compiler and - user-land sources. (Most of the kernel and user-land changes - have made it back into the NetBSD source tree. Many have not, - however, and the compiler shipped with NetBSD doesn't work on - the Alpha; if you're using NetBSD on the Alpha, you _need_ my - source distribution.) The binary distribution is a gzipped disk - image from an rz25 disk; it's approximately 406M ungzipped - (63M gzipped), and you install it by dd'ing it on to a raw disk; - more on this later. - - If you wish to obtain the source or binaries for the NetBSD/Alpha - distribution, send me (cgd@cs.cmu.edu) mail, and I'll arrange to - get them to you. They're sufficiently large that I've not yet - found an FTP site for them, and also, given the preliminary nature - of this distribution, I want to keep in close contact with - the people who are using them. - + NetBSD/Alpha sources and binaries are available from: + ftp://ftp.netbsd.org/pub/NetBSD/arch/alpha + See the README.files file there to figure out which of + the following items corresponds to what file(s) in the FTP + archive. + + There are two sets of system binaries available: + (1) an rz25 disk image, for first-time installation + (see below), and + (2) two tar files of the binaries, for updates. + (one of the tar files is the contents of /etc, + one is everything else, except a kernel. + There are no instructions on how to use these. + Good luck! 8-) + + There are also two precompiled kernels available: one generic + kernel which will prompt for a root device, and one which tries + to boot diskless. The generic kernel is included in the rz25 + disk image. + + X11 client binaries are packaged seperately. (There is no + server at this time.) + + There are several sets of sources available: + (1) kernel source snapshot (complete kernel sources), + (2) compiler toolchain source snapshot (complete + toolchain sources), + (3) diffs to the NetBSD-current sources as of the date + of the release to make them match what's used on + the alpha port. (You should be able to get the + NetBSD-current sources, replace the kernel sources + with the ones i'm distributing, add in these + diffs and the toolchain sources, and compile up a + complete system.) + (4) diffs to the XFree86 3.1.2 sources to make them + work with NetBSD/Alpha. (If you add these to + the XFree86 3.1.2 sources, you should be able to + compile up the X clients.) + If you are interested in the NetBSD/Alpha port, I suggest that you subscribe to the NetBSD "port-alpha" mailing list by sending an email message to majordomo@netbsd.org with no subject and with a @@ -143,12 +85,14 @@ Installing the NetBSD/Alpha distribution: /etc/myname (the hostname of the machine) /etc/mygate (the LAN's gateway's IP address, if your network setup requires that it be named explicitly) - /etc/hostname.le0 (to describe the enet addr, etc., for the - Alpha's ethernet. The format can be discerned by - looking in /etc/netstart. As an example, for - my development machine, it's: + /etc/hostname.le0 (on TurboChannel machines, to describe + the enet addr, etc., for the Alpha's ethernet. The + format can be discerned by looking in /etc/netstart. + As an example, for my development machine, it's: inet macallan.dssc.cs.cmu.edu 0xffff0000 128.2.255.255 ^^^^^^^^^^^^^^^hostname ^^^netmask ^^^broadcast) + /etc/hostname.de0 (on PCI machines; same format as + hostname.le0 would have.) /etc/fstab (a prototype is in /etc/fstab.sd) (You can also create the files mentioned above by mounting the disk's file systems under OSF/1 and filling in the appropriate @@ -169,30 +113,14 @@ Using NetBSD/Alpha: that's what I do, and it works just fine. If you'd like tips on good ways to keep the NetBSD sources under source control, just ask. - A fair number of binaries don't work properly. For example: - GDB won't properly run programs or debug core files; someone - needs to write support for NetBSD/Alpha. - diff dumps core if there are differences in the files being - compared (but it _doesn't_ dump core if they're the - same!) - ps and w don't work properly, for several reasons: - (a) they don't know how to read an ECOFF binary's - namelist, so can't find the addresses of - things in core - (b) I've thus far been lazy, and didn't bother - creating some of the necessary entries in - the device switches (e.g. /dev/drum), - because I knew nothing could use them - because of (a) anyway... - - As noted above, the SCSI code is reliable only when being used with - one SCSI bus at a time; this is obviously a bug. Additionally, the - SCSI driver seems unhappy about dealing with certain types of disk - drives (e.g. the IBM Lightning). I don't know why these problems - exist yet, but it's worth noting that somebody's in the process of - rewriting the 53c94 chip support from the ground up because the - current support is "somewhat lacking." (This should solve at least - the latter problem.) + A fair number of binaries don't work properly. For example, GDB + won't properly run programs or debug core files; someone needs + to write support for NetBSD/Alpha. + + As noted above, the SCSI code on TurboChannel machines is reliable + only when being used with one SCSI bus at a time; this is obviously + a bug. Additionally, the SCSI driver seems unhappy about dealing + with certain types of disk drives (e.g. the IBM Lightning). Because I've been working on getting the system up and running, then out the door, I've not had much time to do performance analysis on @@ -201,26 +129,6 @@ Using NetBSD/Alpha: I'm seeing performance comparable to that of OSF/1 on the same hardware, so I've not gone too far wrong anywhere. - I've run 'paranoia' on NetBSD/Alpha, and it reports one defect (the - same result as for OSF/1). - -Thanks to: - Carnegie Mellon University, for funding for this project. - Digital Equipment Corporation, for the hardware and documentation. - Keith Bostic, for writing and/or working on a large chunk of the - code, and for general moral corruption and good humor. - Kirk McKusick, for being the Final Arbiter of Taste and Style. - Jeff Mogul, for providing moral support, documentation, and - pointers thereto. - Various people working on NetBSD, for suggestions, sanity checking, - drivers, etc. - Whoever I'm forgetting, for things that I don't remember right now. - - -That's it for now; get in touch if you'd like to get copies of the software -and/or would like to contribute to the development effort. I'll be sending -out status reports to various places (probably including the place(s) you -saw this announcement) as things progress. Chris Demetriou diff --git a/sys/arch/alpha/STATUS b/sys/arch/alpha/STATUS index 39a0d75fc8f..6f9d08c679b 100644 --- a/sys/arch/alpha/STATUS +++ b/sys/arch/alpha/STATUS @@ -1,4 +1,4 @@ -$NetBSD: STATUS,v 1.1 1995/04/25 18:59:14 cgd Exp $ +$NetBSD: STATUS,v 1.2 1995/11/23 02:33:26 cgd Exp $ NetBSD/Alpha's Status @@ -9,7 +9,7 @@ Supported hardware: 600, but the rest should "just work) using the following peripherals: - Serial ports + Built-in serial ports LANCE ethernet -- only the on-board interface. (see below.) SCSI system -- it recognizes and can use both on-board SCSI controller chips. However, it has trouble working with @@ -23,88 +23,71 @@ Supported hardware: DEC 3000/300 family, with same hardware above. -NetBSD/Alpha has actually been run on the following types of machines: - DEC 3000/400 - DEC 3000/600 - [ XXX THERE ARE MORE; if you're running it on a machine not - listed, mail me about it.] + *** NOTE THAT I HAVE NOT TESTED NEW KERNELS THOROUGHLY ON + DEC 3000/[3-900] SYSTEMS! + AlphaStation {200,250,400} systems using the following + peripherals: + + On-board NRC 53c810 SCSI. + On-board ns16550-based serial ports. + DC21040-based ethernet (on-board or in an option + slot). + DC21050-based PCI-PCI bridges (though other + types of PCI-PCI bridges should work). + PCI VGA video boards. + DEC ZLXp-E1 (DC21030-based, "TGA") video boards. + Keyboard. + + Things that ARE NOT supported at this time: + DEC ZLXp-E2 and ZLXp-E3 video boards. + Mouse. + Sound hardware (Windows Sound System). + + AlphaStation 600 systems, with the same supported hardware + list as the AlphaStation {200,250,400} systems. (NOTE THAT + THAT MEANS THE AlphaStation 600's BUILT-IN SCSI CONTROLLERS + DO NOT WORK. You'll need to get a 53c810 board, or + something.) + + AXPpci systems, with the same supported hardware list as + the AlphaStation {200,250,400} systems. (AXPpci support + was written by Jeffrey Hsu. Thanks, Jeff!) At this time none of the following systems are supported: - DECpc AXP systems -- the Alpha systems with EISA busses - AlphaStations -- the Alpha systems with PCI busses (i.e. - PCI/ISA or PCI/EISA) - The Futurebus-based Alpha server systems - The multiprocessor Alpha systems - -I am in the process of porting NetBSD/Alpha to the PCI-based systems, -in particular, to the AlphaStation 400 4/233. I was hoping to get a -DECpc AXP port working "for free" based on the PCI work, but the -DECpc AXP is a very different (and, in my opinion, very alien) piece -of hardware. If somebody wants to make NetBSD/Alpha run on the -DECpc AXP system, get in touch and I'll do what I can to help you -get started. (Right now, it can detect devices on the EISA bus, etc., -but the I/O layout is distinctly _not_ what I'd expected and/or hoped -for. It's significantly more difficult to deal with than I'd expected.) - -It's unclear how much support for other PCI-based systems (i.e. the -AlphaStation 200 and AlphaStation 250 machines) will be won by getting -the AlphaStation 400 supported. It should at least make porting to -those machines easier. - - -Because no frame buffers are supported, NetBSD/Alpha _must_ be used with -a serial console. To do that on: + DECpc AXP systems (EISA-bus PC-like systems) + Alpha "server" systems + Multiprocessor Alpha systems + +I was hoping to get a DECpc AXP port working "for free" based on +the PCI work, but the DECpc AXP is a very different (and, in my +opinion, very alien) piece of hardware. If somebody wants to make +NetBSD/Alpha run on the DECpc AXP system, get in touch and I'll do +what I can to help you get started. + + +Console frame buffers & keyboard are supported only on the AlphaStation +and AXPpci families of machines. On the TurboChannel-baesd machines, +NetBSD/Alpha _must_ be used with a serial console. To configure various +Alpha systems to use a serial console, do the following depending on +the model: DEC 3000/[4-9]00's: Flip the appropriate switch on the back of the machine. + (See your owner's manual for more details.) DEC 3000/300 family machines: Boot the machine with the keyboard/mouse connector unplugged. - DECpc AXP's and AlphaStations: - Boot the machine with the keyboard unplugged. (Note: - I've never actually booted one of these machines with - a serial console, so I can't verify that this is - correct. Also, people who've booted test kernels for - me have reported trouble using these boxes with a - serial console, but I'm not sure why; the kernel for - these systems is not advanced enough to have its own - serial driver yet, and so is using the PROM routines.) - -There actually is hope of getting somebody to come up with working -graphics board drivers and even an X server. More on that as things -develop. - - -Getting people running with my latest sources still isn't as easy as -it should be; not all of my sources are integrated into the NetBSD -master source tree yet. Most of the diffs are in, however, and I -suggest the following tactic for people who are trying to get running -with an "up to date" system: - - Get the latest NetBSD sources from: - ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/tar_files - - Replace that 'sys' tree with the latest snapshot I've put up - for ftp under the directory: - ftp://ftp.netbsd.org/pub/NetBSD/arch/alpha - - If you'd like to compile the compiler and tool chain, add to - that the GNU tools tree (src/devo) from my original source - distribution tar file, which can also be found under: - ftp://ftp.netbsd.org/pub/NetBSD/arch/alpha - (Unfortunately, there's not a way to get just that part of the - source distribution; I'll fix that in a day or two.) - -That won't be perfect, but it'll get you most of the way there. + DECpc AXPs, AXPpcis, and AlphaStations: + Get to the console prompt. Set the variable + "console" to be "serial", and "init" or power cycle + the system. -I'm planning to put up a new 'sys' snapshot, as well as new kernel -image, in a couple of days. Hopefully by that time, all of the -user-land changes will have been merged into the master NetBSD source -tree. +See the file src/sys/arch/alpha/README to find out how to get the +latest sources and/or binaries. Please see the file src/sys/arch/alpha/TODO.users for a list of things that users can do to help NetBSD/Alpha improve. If you're interested diff --git a/sys/arch/alpha/TODO.users b/sys/arch/alpha/TODO.users index 314be1c83cc..410c973a7f1 100644 --- a/sys/arch/alpha/TODO.users +++ b/sys/arch/alpha/TODO.users @@ -1,4 +1,4 @@ -$NetBSD: TODO.users,v 1.1 1995/04/25 18:16:15 cgd Exp $ +$NetBSD: TODO.users,v 1.2 1995/11/23 02:33:29 cgd Exp $ The NetBSD/Alpha "User" To-Do List @@ -18,10 +18,8 @@ Once you've done something on this list, send me context diffs. Chris Demetriou cgd@netbsd.org -- - Make GDB work. - (1) for debugging live processes; shouldn't require kernel work. - (2) for debugging core dumps; may require kernel work. + (1) function arguments and local variables don't seem to work. Test programs; find and fix bugs. In particular: (1) make sure accounting works @@ -29,8 +27,6 @@ Test programs; find and fix bugs. In particular: (3) last i checked, 'file' core dumped (4) /usr/games -Compile some of the more useful X clients. (e.g. xterm and resize.) - Make TurboChannel option slots work reasonably. This will require different sets of code to be written on the 3000/[4-9]00 and on the 3000/300 families. It shouldn't be too hard, but you will need some @@ -50,4 +46,5 @@ Make DDB work. (For completeness, may require a.out kernel binaries and/or some ecoff symbol handling code to be written; the former is strongly preferred.) -Make CVS work. I've no reason to think that it shouldn't, but... +Track down bugs caused by compiling the kernel with -O. (At least + some of these are likely to be code generation bugs.) diff --git a/sys/arch/alpha/alpha/clock.c b/sys/arch/alpha/alpha/clock.c index 4eddc3a232c..bf41c872648 100644 --- a/sys/arch/alpha/alpha/clock.c +++ b/sys/arch/alpha/alpha/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.4 1995/08/03 00:53:34 cgd Exp $ */ +/* $NetBSD: clock.c,v 1.5 1995/11/23 02:33:41 cgd Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -47,12 +47,20 @@ #include #include -#include #include +#include #include + +#include "asic.h" +#if NASIC #include /* XXX */ +#endif + +#include "isa.h" +#if NISA #include /* XXX */ +#endif /* Definition of the driver for autoconfig. */ static int clockmatch __P((struct device *, void *, void *)); @@ -62,7 +70,8 @@ struct cfdriver clockcd = sizeof(struct clock_softc) }; #if defined(DEC_3000_500) || defined(DEC_3000_300) || \ - defined(DEC_2000_300) || defined(DEC_2100_A50) + defined(DEC_2000_300) || defined(DEC_2100_A50) || \ + defined(DEC_KN20AA) void mcclock_attach __P((struct device *parent, struct device *self, void *aux)); #endif @@ -82,29 +91,21 @@ clockmatch(parent, cfdata, aux) { struct cfdata *cf = cfdata; struct confargs *ca = aux; +#if NASIC + extern struct cfdriver asiccd; - /* See how many clocks this system has */ - switch (hwrpb->rpb_type) { -#if defined(DEC_3000_500) || defined(DEC_3000_300) - -#if defined(DEC_3000_500) - case ST_DEC_3000_500: -#endif -#if defined(DEC_3000_300) - case ST_DEC_3000_300: -#endif + if (parent->dv_cfdata->cf_driver == &asiccd) { /* make sure that we're looking for this type of device. */ if (!BUS_MATCHNAME(ca, "dallas_rtc")) return (0); if (cf->cf_unit >= 1) return (0); - - break; + } else #endif +#if NISA + if ((parent->dv_cfdata->cf_driver == &isacd)) { -#if defined(DEC_2100_A50) - case ST_DEC_2100_A50: /* Just say yes. XXX */ if (cf->cf_unit >= 1) @@ -112,28 +113,19 @@ clockmatch(parent, cfdata, aux) /* XXX XXX XXX */ { - struct isa_attach_args *ia = aux; + struct isadev_attach_args *ida = aux; - if (ia->ia_iobase != 0x70 && /* XXX */ - ia->ia_iobase != -1) /* XXX */ + if (ida->ida_port[0] != 0x70 && /* XXX */ + ida->ida_port[0] != -1) /* XXX */ return (0); - ia->ia_iobase = 0x70; /* XXX */ - ia->ia_iosize = 2; /* XXX */ - ia->ia_msize = 0; + ida->ida_port[0] = 0x70; /* XXX */ + ida->ida_nports[0] = 2; /* XXX */ + ida->ida_iosiz[0] = 0; } - - break; -#endif - -#if defined(DEC_2000_300) - case ST_DEC_2000_300: - panic("clockmatch on jensen"); + } else #endif - - default: - panic("unknown CPU"); - } + return (0); return (1); } @@ -145,34 +137,20 @@ clockattach(parent, self, aux) void *aux; { - switch (hwrpb->rpb_type) { -#if defined(DEC_3000_500) || defined(DEC_3000_300) || \ - defined(DEC_2000_300) || defined(DEC_2100_A50) -#if defined(DEC_3000_500) - case ST_DEC_3000_500: -#endif -#if defined(DEC_2000_300) - case ST_DEC_2000_300: -#endif -#if defined(DEC_3000_300) - case ST_DEC_3000_300: -#endif -#if defined(DEC_2100_A50) - case ST_DEC_2100_A50: -#endif - mcclock_attach(parent, self, aux); - break; -#endif /* defined(at least one of lots of system types) */ - - default: - panic("clockattach: it didn't get here. really."); - } - + /* + * XXX deal with other clock type, if the system + * XXX supports the other clock. get systype + * from RPB. + */ + mcclock_attach(parent, self, aux); /* * establish the clock interrupt; it's a special case */ - set_clockintr(hardclock); + set_clockintr(); +#ifdef EVCNT_COUNTERS + evcnt_attach(self, "intr", &clock_intr_evcnt); +#endif printf("\n"); } @@ -197,9 +175,13 @@ clockattach(parent, self, aux) cpu_initclocks() { extern int tickadj; - struct clock_softc *csc = (struct clock_softc *)clockcd.cd_devs[0]; + struct clock_softc *csc; int fractick; + if (clockcd.cd_devs == NULL || + (csc = (struct clock_softc *)clockcd.cd_devs[0]) == NULL) + panic("cpu_initclocks: no clock attached"); + hz = 1024; /* 1024 Hz clock */ tick = 1000000 / hz; /* number of microseconds between interrupts */ tickfix = 1000000 - (hz * tick); diff --git a/sys/arch/alpha/alpha/clock_mc.c b/sys/arch/alpha/alpha/clock_mc.c index d30bc78703a..28529ce8fdd 100644 --- a/sys/arch/alpha/alpha/clock_mc.c +++ b/sys/arch/alpha/alpha/clock_mc.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock_mc.c,v 1.2 1995/06/28 04:30:30 cgd Exp $ */ +/* $NetBSD: clock_mc.c,v 1.3 1995/11/23 02:33:45 cgd Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -48,12 +48,22 @@ #include #include -#include #include /* XXX */ #include #include +#include "tc.h" +#if NTC + /* XXX */ +#endif + +#include "isa.h" +#if NISA +#include +#include +#endif + void mcclock_attach __P((struct device *parent, struct device *self, void *aux)); static void mcclock_init __P((struct clock_softc *csc)); @@ -66,6 +76,8 @@ struct mcclockdata { void (*mc_write) __P((struct clock_softc *csc, u_int reg, u_int datum)); u_int (*mc_read) __P((struct clock_softc *csc, u_int reg)); + __const void *mc_accessfns; + void *mc_accessarg; void *mc_addr; }; @@ -74,14 +86,14 @@ struct mcclockdata { #define mc146818_read(sc, reg) \ (*((struct mcclockdata *)sc->sc_data)->mc_read)(sc, reg) -#if defined(DEC_3000_500) || defined(DEC_3000_300) +#if NTC static void mc_write_tc __P((struct clock_softc *csc, u_int reg, u_int datum)); static u_int mc_read_tc __P((struct clock_softc *csc, u_int reg)); static struct mcclockdata mcclockdata_tc = { mc_write_tc, mc_read_tc }; #endif -#if defined(DEC_2000_300) || defined(DEC_2100_A50) +#if NISA static void mc_write_isa __P((struct clock_softc *csc, u_int reg, u_int datum)); static u_int mc_read_isa __P((struct clock_softc *csc, u_int reg)); @@ -95,9 +107,12 @@ mcclock_attach(parent, self, aux) void *aux; { struct clock_softc *csc = (struct clock_softc *)self; - + struct isadev_attach_args *ida = aux; register volatile struct chiptime *c; struct confargs *ca = aux; +#if NTC + extern struct cfdriver asiccd; /* XXX */ +#endif printf(": mc146818 or compatible"); @@ -105,41 +120,30 @@ mcclock_attach(parent, self, aux) csc->sc_get = mcclock_get; csc->sc_set = mcclock_set; - switch (hwrpb->rpb_type) { -#if defined(DEC_3000_500) || defined(DEC_3000_300) -#if defined(DEC_3000_500) - case ST_DEC_3000_500: -#endif -#if defined(DEC_3000_300) - case ST_DEC_3000_300: -#endif +#if NTC + if (parent->dv_cfdata->cf_driver == &asiccd) { /* * XXX should really allocate a new one and copy, or * something. unlikely we'll have more than one... */ csc->sc_data = &mcclockdata_tc; mcclockdata_tc.mc_addr = BUS_CVTADDR(ca); - break; -#endif - -#if defined(DEC_2000_300) || defined(DEC_2100_A50) -#if defined(DEC_2000_300) - case ST_DEC_2000_300: -#endif -#if defined(DEC_2100_A50) - case ST_DEC_2100_A50: + } else #endif +#if NISA + if (parent->dv_cfdata->cf_driver == &isacd) { /* * XXX should really allocate a new one and copy, or * something. unlikely we'll have more than one... */ csc->sc_data = &mcclockdata_isa; - break; + mcclockdata_isa.mc_accessfns = ida->ida_piofns; + mcclockdata_isa.mc_accessarg = ida->ida_pioarg; + } else #endif - - default: + { printf("\n"); - panic("don't know how to set up for other system types."); + panic("clockattach: can't tell what bus we're on"); } /* Turn interrupts off, just in case. */ @@ -210,7 +214,7 @@ mcclock_set(csc, ct) } -#if defined(DEC_3000_500) || defined(DEC_3000_300) +#if NTC struct tc_clockdatum { u_char datum; char pad[3]; @@ -243,21 +247,21 @@ mc_read_tc(csc, reg) return (dp[reg].datum); } -#endif /* DEC_3000_500 || DEC_3000_300 */ - +#endif /* NTC */ -#if defined(DEC_2000_300) || defined(DEC_2100_A50) -#include -#include +#if NISA static void mc_write_isa(csc, reg, datum) struct clock_softc *csc; u_int reg, datum; { + struct mcclockdata *cdp = csc->sc_data; + __const struct isa_pio_fns *ipf = cdp->mc_accessfns; + void *ipfa = cdp->mc_accessarg; - outb(IO_RTC, reg); - outb(IO_RTC + 1, datum); + OUTB(ipf, ipfa, IO_RTC, reg); + OUTB(ipf, ipfa, IO_RTC + 1, datum); } static u_int @@ -265,8 +269,11 @@ mc_read_isa(csc, reg) struct clock_softc *csc; u_int reg; { + struct mcclockdata *cdp = csc->sc_data; + __const struct isa_pio_fns *ipf = cdp->mc_accessfns; + void *ipfa = cdp->mc_accessarg; - outb(IO_RTC, reg); - return inb(IO_RTC + 1); + OUTB(ipf, ipfa, IO_RTC, reg); + return INB(ipf, ipfa, IO_RTC + 1); } -#endif /* DEC_3000_500 || DEC_3000_300 */ +#endif /* NISA */ diff --git a/sys/arch/alpha/alpha/cpu.c b/sys/arch/alpha/alpha/cpu.c index b1d98ade6d1..dad5807610e 100644 --- a/sys/arch/alpha/alpha/cpu.c +++ b/sys/arch/alpha/alpha/cpu.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.3 1995/06/28 02:45:01 cgd Exp $ */ +/* $NetBSD: cpu.c,v 1.4 1995/11/23 02:33:48 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -73,12 +73,13 @@ cpuattach(parent, dev, aux) "EV5 (21164)", /* PCS_PROC_EV5 */ "EV45 (21064A)", /* PCS_PROC_EV45 */ }; - char *cpu_minor[] = { + int ncpu_major = sizeof(cpu_major) / sizeof(cpu_major[0]); + char *dc21064_cpu_minor[] = { "Pass 2 or 2.1", "Pass 3", }; - int ncpu_major = sizeof(cpu_major) / sizeof(cpu_major[0]); - int ncpu_minor = sizeof(cpu_minor) / sizeof(cpu_minor[0]); + int ndc21064_cpu_minor = + sizeof(dc21064_cpu_minor) / sizeof(dc21064_cpu_minor[0]); u_int32_t major, minor; int needcomma, needrev, i; @@ -96,10 +97,22 @@ cpuattach(parent, dev, aux) printf(", "); - if (minor < ncpu_minor) - printf("%s", cpu_minor[minor]); - else + switch (major) { + case PCS_PROC_EV4: + if (minor < ndc21064_cpu_minor) + printf("%s", dc21064_cpu_minor[minor]); + else + printf("UNKNOWN MINOR TYPE (%d)", minor); + break; + + case PCS_PROC_EV45: + case PCS_PROC_EV5: + printf("Pass %d", minor + 1); + break; + + default: printf("UNKNOWN MINOR TYPE (%d)", minor); + } if (p->pcs_proc_revision[0] != 0) { /* XXX bad test? */ printf(", "); @@ -133,20 +146,12 @@ cpuattach(parent, dev, aux) printf("\n"); } - if (major == PCS_PROC_LCA4) { - struct confargs nca; - - /* - * If the processor is an LCA, then it's got the PCI - * bus interface built in. Attach it here. (!!!) - */ - nca.ca_name = "lca"; - nca.ca_slot = 0; - nca.ca_offset = 0; - nca.ca_bus = NULL; - if (!config_found(dev, &nca, cpuprint)) - panic("cpuattach: couldn't attach LCA bus interface"); - } + /* + * Though we could (should?) attach the LCA's PCI + * bus here there is no good reason to do so, and + * the bus attachment code is easier to understand + * and more compact if done the 'normal' way. + */ } static int diff --git a/sys/arch/alpha/alpha/dec_2100_a50.c b/sys/arch/alpha/alpha/dec_2100_a50.c index 64a4cfc3d55..3e7e4b67b2b 100644 --- a/sys/arch/alpha/alpha/dec_2100_a50.c +++ b/sys/arch/alpha/alpha/dec_2100_a50.c @@ -1,4 +1,4 @@ -/* $NetBSD: dec_2100_a50.c,v 1.2 1995/08/03 01:12:15 cgd Exp $ */ +/* $NetBSD: dec_2100_a50.c,v 1.3 1995/11/23 02:33:52 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -32,12 +32,15 @@ #include #include -#include #include #include #include -#include + +#include +#include + +#include char * dec_2100_a50_modelname() @@ -57,6 +60,10 @@ dec_2100_a50_modelname() return "AlphaStation 200 4/233 (\"Mustang II\")"; break; + case 0x2000: + return "AlphaStation 250 4/266"; + break; + case SV_ST_MUSTANG2_4_100: return "AlphaStation 200 4/100 (\"Mustang II\")"; break; @@ -73,8 +80,11 @@ dec_2100_a50_consinit(constype) char *constype; { struct ctb *ctb; + struct apecs_config *acp; + extern struct apecs_config apecs_configuration; - apecs_init(); + acp = &apecs_configuration; + apecs_init(acp); ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off); @@ -92,14 +102,18 @@ dec_2100_a50_consinit(constype) extern int comcngetc __P((dev_t)); extern void comcnputc __P((dev_t, int)); extern void comcnpollc __P((dev_t, int)); + extern __const struct isa_pio_fns *comconsipf; + extern __const void *comconsipfa; static struct consdev comcons = { NULL, NULL, comcngetc, comcnputc, comcnpollc, NODEV, 1 }; - - cominit(0, comdefaultrate); + cominit(acp->ac_piofns, acp->ac_pioarg, 0, + comdefaultrate); comconsole = 0; /* XXX */ comconsaddr = 0x3f8; /* XXX */ comconsinit = 0; + comconsipf = acp->ac_piofns; + comconsipfa = acp->ac_pioarg; cn_tab = &comcons; comcons.cn_dev = makedev(26, 0); /* XXX */ @@ -109,7 +123,9 @@ dec_2100_a50_consinit(constype) case 3: /* display console ... */ /* XXX */ - pci_display_console(0, ctb->ctb_turboslot & 0xffff, 0); + pci_display_console(acp->ac_conffns, acp->ac_confarg, + acp->ac_memfns, acp->ac_memarg, acp->ac_piofns, + acp->ac_pioarg, 0, ctb->ctb_turboslot & 0xffff, 0); break; default: diff --git a/sys/arch/alpha/alpha/dec_axppci_33.c b/sys/arch/alpha/alpha/dec_axppci_33.c new file mode 100644 index 00000000000..e688836b8f8 --- /dev/null +++ b/sys/arch/alpha/alpha/dec_axppci_33.c @@ -0,0 +1,126 @@ +/* $NetBSD: dec_axppci_33.c,v 1.1 1995/11/23 02:33:55 cgd Exp $ */ + +/* + * Copyright (c) 1995 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 +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +char * +dec_axppci_33_modelname() +{ + + switch (hwrpb->rpb_variation & SV_ST_MASK) { + case 0: /* XXX */ + return "Alpha PC AXPpci33 (\"NoName\")"; + + default: + printf("unknown system variation %lx\n", + hwrpb->rpb_variation & SV_ST_MASK); + return NULL; + } +} + +void +dec_axppci_33_consinit(constype) + char *constype; +{ + struct ctb *ctb; + struct lca_config *lcp; + extern struct lca_config lca_configuration; + + lcp = &lca_configuration; + lca_init(lcp); + + ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off); + + printf("constype = %s\n", constype); + printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type); + printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot); + + switch (ctb->ctb_term_type) { + case 2: + /* serial console ... */ + /* XXX */ + { + extern int comdefaultrate, comconsole; + extern int comconsaddr, comconsinit; + extern int comcngetc __P((dev_t)); + extern void comcnputc __P((dev_t, int)); + extern void comcnpollc __P((dev_t, int)); + extern __const struct isa_pio_fns *comconsipf; + extern __const void *comconsipfa; + static struct consdev comcons = { NULL, NULL, + comcngetc, comcnputc, comcnpollc, NODEV, 1 }; + + + cominit(lcp->lc_piofns, lcp->lc_pioarg, 0, + comdefaultrate); + comconsole = 0; /* XXX */ + comconsaddr = 0x3f8; /* XXX */ + comconsinit = 0; + comconsipf = lcp->lc_piofns; + comconsipfa = lcp->lc_pioarg; + + cn_tab = &comcons; + comcons.cn_dev = makedev(26, 0); /* XXX */ + break; + } + + case 3: + /* display console ... */ + /* XXX */ + pci_display_console(lcp->lc_conffns, lcp->lc_confarg, + lcp->lc_memfns, lcp->lc_memarg, lcp->lc_piofns, + lcp->lc_pioarg, 0, ctb->ctb_turboslot & 0xffff, 0); + break; + + default: + panic("consinit: unknown console type %d\n", + ctb->ctb_term_type); + } +} + +dev_t +dec_axppci_33_bootdev(booted_dev) + char *booted_dev; +{ + + panic("gack."); +} diff --git a/sys/arch/alpha/stand/xxboot/makexxboot.c b/sys/arch/alpha/alpha/dec_axppci_33.h similarity index 57% rename from sys/arch/alpha/stand/xxboot/makexxboot.c rename to sys/arch/alpha/alpha/dec_axppci_33.h index 07d52fffc72..1eb82dbbd56 100644 --- a/sys/arch/alpha/stand/xxboot/makexxboot.c +++ b/sys/arch/alpha/alpha/dec_axppci_33.h @@ -1,7 +1,7 @@ -/* $NetBSD: makexxboot.c,v 1.1 1995/02/13 23:08:47 cgd Exp $ */ +/* $NetBSD: dec_axppci_33.h,v 1.1 1995/11/23 02:33:57 cgd Exp $ */ /* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. * * Author: Chris G. Demetriou @@ -27,31 +27,6 @@ * rights to redistribute these changes. */ -#define BBPAD 0x1e0 -struct bb { - char bb_pad[BBPAD]; /* disklabel lives in here, actually */ - long bb_secsize; /* size of secondary boot block */ - long bb_secstart; /* start of secondary boot block */ - long bb_flags; /* unknown; always zero */ - long bb_cksum; /* checksum of the the boot block, as longs. */ -}; - -main() -{ - struct bb bb; - long *lp, *ep; - - bzero(&bb, sizeof bb); - bb.bb_secsize = 16; - bb.bb_secstart = 1; - bb.bb_flags = 0; - bb.bb_cksum = 0; - - for (lp = (long *)&bb, ep = &bb.bb_cksum; lp < ep; lp++) - bb.bb_cksum += *lp; - - if (write(1, &bb, sizeof bb) != sizeof bb) - exit(1); - - exit(0); -} +char *dec_axppci_33_modelname __P((void)); +void dec_axppci_33_consinit __P((char *)); +dev_t dec_axppci_33_bootdev __P((char *)); diff --git a/sys/arch/alpha/alpha/dec_kn20aa.c b/sys/arch/alpha/alpha/dec_kn20aa.c new file mode 100644 index 00000000000..789fa2f20b1 --- /dev/null +++ b/sys/arch/alpha/alpha/dec_kn20aa.c @@ -0,0 +1,126 @@ +/* $NetBSD: dec_kn20aa.c,v 1.1 1995/11/23 02:34:00 cgd Exp $ */ + +/* + * Copyright (c) 1995 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 +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +char * +dec_kn20aa_modelname() +{ + + switch (hwrpb->rpb_variation & SV_ST_MASK) { + case 0: + return "AlphaStation 600 5/266 (KN20AA)"; + + default: + printf("unknown system variation %lx\n", + hwrpb->rpb_variation & SV_ST_MASK); + return NULL; + } +} + +void +dec_kn20aa_consinit(constype) + char *constype; +{ + struct ctb *ctb; + struct cia_config *ccp; + extern struct cia_config cia_configuration; + + ccp = &cia_configuration; + cia_init(ccp); + + ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off); + + printf("constype = %s\n", constype); + printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type); + printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot); + + switch (ctb->ctb_term_type) { + case 2: + /* serial console ... */ + /* XXX */ + { + extern int comdefaultrate, comconsole; + extern int comconsaddr, comconsinit; + extern int comcngetc __P((dev_t)); + extern void comcnputc __P((dev_t, int)); + extern void comcnpollc __P((dev_t, int)); + extern __const struct isa_pio_fns *comconsipf; + extern __const void *comconsipfa; + static struct consdev comcons = { NULL, NULL, + comcngetc, comcnputc, comcnpollc, NODEV, 1 }; + + + cominit(ccp->cc_piofns, ccp->cc_pioarg, 0, + comdefaultrate); + comconsole = 0; /* XXX */ + comconsaddr = 0x3f8; /* XXX */ + comconsinit = 0; + comconsipf = ccp->cc_piofns; + comconsipfa = ccp->cc_pioarg; + + cn_tab = &comcons; + comcons.cn_dev = makedev(26, 0); /* XXX */ + break; + } + + case 3: + /* display console ... */ + /* XXX */ + pci_display_console(ccp->cc_conffns, ccp->cc_confarg, + ccp->cc_memfns, ccp->cc_memarg, ccp->cc_piofns, + ccp->cc_pioarg, 0, ctb->ctb_turboslot & 0xffff, 0); + break; + + default: + panic("consinit: unknown console type %d\n", + ctb->ctb_term_type); + } +} + +dev_t +dec_kn20aa_bootdev(booted_dev) + char *booted_dev; +{ + + panic("gack."); +} diff --git a/sys/arch/alpha/alpha/dec_kn20aa.h b/sys/arch/alpha/alpha/dec_kn20aa.h new file mode 100644 index 00000000000..d078cca8c03 --- /dev/null +++ b/sys/arch/alpha/alpha/dec_kn20aa.h @@ -0,0 +1,32 @@ +/* $NetBSD: dec_kn20aa.h,v 1.1 1995/11/23 02:34:03 cgd Exp $ */ + +/* + * Copyright (c) 1995 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. + */ + +char *dec_kn20aa_modelname __P((void)); +void dec_kn20aa_consinit __P((char *)); +dev_t dec_kn20aa_bootdev __P((char *)); diff --git a/sys/arch/alpha/alpha/genassym.c b/sys/arch/alpha/alpha/genassym.c index 8d6267dbe1e..3eb7fcad1bb 100644 --- a/sys/arch/alpha/alpha/genassym.c +++ b/sys/arch/alpha/alpha/genassym.c @@ -1,4 +1,4 @@ -/* $NetBSD: genassym.c,v 1.2 1995/03/24 15:07:10 cgd Exp $ */ +/* $NetBSD: genassym.c,v 1.3 1995/11/23 02:34:06 cgd Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -51,17 +51,13 @@ #include #include -#ifdef notdef /* XXX */ -#include -#include #include -#include -#include -#else /* XXX */ -#define offsetof(type, member) ((size_t)(&((type *)0)->member)) -#endif /* XXX */ +#include +#include + +void def __P((char *, long)); -extern int errno; +#define off(what, s, m) def(what, (int)offsetof(s, m)) void def(what, val) @@ -69,17 +65,10 @@ def(what, val) long val; { - if (printf("#define\t%s\t%ld\n", what, val) < 0) { -#ifdef notdef /* XXX */ - (void)fprintf(stderr, "genassym: printf: %s\n", - strerror(errno)); -#endif /* XXX */ - exit(1); - } + if (printf("#define\t%s\t%ld\n", what, val) < 0) + err(1, "printf"); } -#define off(what, s, m) def(what, (int)offsetof(s, m)) - main() { diff --git a/sys/arch/alpha/alpha/interrupt.c b/sys/arch/alpha/alpha/interrupt.c index 667976b34c9..3b1b1eaadae 100644 --- a/sys/arch/alpha/alpha/interrupt.c +++ b/sys/arch/alpha/alpha/interrupt.c @@ -1,4 +1,4 @@ -/* $NetBSD: interrupt.c,v 1.3 1995/08/03 00:54:28 cgd Exp $ */ +/* $NetBSD: interrupt.c,v 1.4 1995/11/23 02:34:08 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -35,6 +35,12 @@ #include #include +#ifdef EVCNT_COUNTERS +#include +#else +#include +#endif + struct logout { #define LOGOUT_RETRY 0x1000000000000000 /* Retry bit. */ #define LOGOUT_LENGTH 0xffff /* Length mask. */ @@ -50,6 +56,10 @@ static void (*iointr) __P((void *, int)) = nullintr; static void (*clockintr) __P((void *, int)) = nullintr; static int mc_expected, mc_received; +#ifdef EVCNT_COUNTERS +struct evcnt clock_intr_evcnt; /* event counter for clock intrs. */ +#endif + void interrupt(framep, type, vec, logoutp) struct trapframe *framep; @@ -75,15 +85,28 @@ nullintr(framep, vec) { } +static void +real_clockintr(framep, vec) + void *framep; + int vec; +{ + +#ifdef EVCNT_COUNTERS + clock_intr_evcnt.ev_count++; +#else + intrcnt[INTRCNT_CLOCK]++; +#endif + hardclock(framep); +} + void -set_clockintr(nclockintr) - void (*nclockintr) __P((struct clockframe *)); +set_clockintr() { if (clockintr != nullintr) panic("set clockintr twice"); - clockintr = (void (*) __P((void *, int)))nclockintr; + clockintr = real_clockintr; } void diff --git a/sys/arch/alpha/alpha/locore.s b/sys/arch/alpha/alpha/locore.s index c1ec9f87983..50439438fde 100644 --- a/sys/arch/alpha/alpha/locore.s +++ b/sys/arch/alpha/alpha/locore.s @@ -1,21 +1,21 @@ -/* $NetBSD: locore.s,v 1.6 1995/08/03 01:00:11 cgd Exp $ */ +/* $NetBSD: locore.s,v 1.7 1995/11/23 02:34:11 cgd Exp $ */ /* * Copyright (c) 1994, 1995 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 + * + * 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 @@ -30,6 +30,9 @@ #define LOCORE #include +#ifndef EVCNT_COUNTERS +#include +#endif #include "assym.s" /* don't reorder instructions; paranoia. */ @@ -55,7 +58,7 @@ bootstack: * All arguments are passed to alpha_init(). */ .text -NESTED(__start,1,0,ra,0,0) +NESTED_NOPROFILE(__start,1,0,ra,0,0) br pv,1f 1: SETGP(pv) @@ -117,7 +120,7 @@ NESTED(__start,1,0,ra,0,0) /**************************************************************************/ /* - * Pull in the PROM interface routines; these are needed for + * Pull in the PROM interface routines; these are needed for * prom printf (while bootstrapping), and for determining the * boot device, etc. */ @@ -899,12 +902,12 @@ LEAF(switch_exit, 1) /* save the exiting proc pointer */ mov a0, s0 - + /* Switch to proc0. */ lda t4, proc0 /* t4 = &proc0 */ ldq t5, P_MD_PCBPADDR(t4) /* t5 = p->p_md.md_pcbpaddr */ stq t5, curpcb /* and store it in curpcb */ - + /* * Do the context swap, and invalidate old TLB entries (XXX). * XXX should do the ASN thing, and therefore not have to invalidate. @@ -935,10 +938,6 @@ LEAF(switch_exit, 1) /**************************************************************************/ -#define COPY_FRAME_SIZE 32 -#define COPY_FRAME_RA 0 -#define COPY_FRAME_S6 8 - /* * Copy a null-terminated string within the kernel's address space. * If lenp is not NULL, store the number of chars copied in *lenp @@ -948,11 +947,6 @@ LEAF(switch_exit, 1) LEAF(copystr, 4) SETGP(pv) - /* set up stack frame */ - lda sp, -COPY_FRAME_SIZE(sp) - stq ra, COPY_FRAME_RA(sp) - stq s6, COPY_FRAME_S6(sp) - mov a2, t0 /* t0 = i = len */ beq a2, 2f /* if (len == 0), bail out */ @@ -976,11 +970,6 @@ LEAF(copystr, 4) subl t0, a2, t0 /* *lenp = (i - len) */ stq t0, 0(a3) 3: - /* tear down stack frame */ - ldq ra, COPY_FRAME_RA(sp) - ldq s6, COPY_FRAME_S6(sp) - addq sp, COPY_FRAME_SIZE, sp - beq t1, 4f /* *from == '\0'; leave quietly */ CONST(ENAMETOOLONG, v0) /* *from != '\0'; error. */ @@ -997,7 +986,7 @@ NESTED(copyinstr, 4, 16, ra, 0, 0) stq ra, (16-8)(sp) /* save ra */ CONST(VM_MAX_ADDRESS, t0) /* make sure that src addr */ cmpult a0, t0, t1 /* is in user space. */ - beq t1, copyerr_noframe /* if it's not, error out. */ + beq t1, copyerr /* if it's not, error out. */ lda v0, copyerr /* set up fault handler. */ .set noat ldq at_reg, curproc @@ -1021,7 +1010,7 @@ NESTED(copyoutstr, 4, 16, ra, 0, 0) stq ra, (16-8)(sp) /* save ra */ CONST(VM_MAX_ADDRESS, t0) /* make sure that dest addr */ cmpult a1, t0, t1 /* is in user space. */ - beq t1, copyerr_noframe /* if it's not, error out. */ + beq t1, copyerr /* if it's not, error out. */ lda v0, copyerr /* set up fault handler. */ .set noat ldq at_reg, curproc @@ -1042,40 +1031,235 @@ NESTED(copyoutstr, 4, 16, ra, 0, 0) /* * Copy a bytes within the kernel's address space. * - * int bcopy(char *from, char *to, u_int len); + * In the kernel, bcopy() doesn't have to handle the overlapping + * case; that's that ovbcopy() is for. However, it doesn't hurt + * to do both in bcopy, and it does provide a measure of safety. + * + * void bcopy(char *from, char *to, size_t len); + * void ovbcopy(char *from, char *to, size_t len); */ -LEAF(bcopy, 3) - SETGP(pv) - - /* set up stack frame */ - lda sp, -COPY_FRAME_SIZE(sp) - stq ra, COPY_FRAME_RA(sp) - stq s6, COPY_FRAME_S6(sp) +LEAF(bcopy,3) +XLEAF(ovbcopy,3) + + /* Check for negative length */ + ble a2,bcopy_done + + /* Check for overlap */ + subq a1,a0,t5 + cmpult t5,a2,t5 + bne t5,bcopy_overlap + + /* a3 = end address */ + addq a0,a2,a3 + + /* Get the first word */ + ldq_u t2,0(a0) + + /* Do they have the same alignment? */ + xor a0,a1,t0 + and t0,7,t0 + and a1,7,t1 + bne t0,bcopy_different_alignment + + /* src & dst have same alignment */ + beq t1,bcopy_all_aligned + + ldq_u t3,0(a1) + addq a2,t1,a2 + mskqh t2,a0,t2 + mskql t3,a0,t3 + or t2,t3,t2 + + /* Dst is 8-byte aligned */ + +bcopy_all_aligned: + /* If less than 8 bytes,skip loop */ + subq a2,1,t0 + and a2,7,a2 + bic t0,7,t0 + beq t0,bcopy_samealign_lp_end + +bcopy_samealign_lp: + stq_u t2,0(a1) + addq a1,8,a1 + ldq_u t2,8(a0) + subq t0,8,t0 + addq a0,8,a0 + bne t0,bcopy_samealign_lp + +bcopy_samealign_lp_end: + /* If we're done, exit */ + bne a2,bcopy_small_left + stq_u t2,0(a1) + RET - mov a2, t0 /* t0 = i = len */ - beq a2, 2f /* if (len == 0), bail out */ +bcopy_small_left: + mskql t2,a2,t4 + ldq_u t3,0(a1) + mskqh t3,a2,t3 + or t4,t3,t4 + stq_u t4,0(a1) + RET -1: - ldq_u t1, 0(a0) /* t1 = *from */ - extbl t1, a0, t1 - ldq_u t3, 0(a1) /* set up t2 with quad around *to */ - insbl t1, a1, t2 - mskbl t3, a1, t3 - or t3, t2, t3 /* add *from to quad around *to */ - stq_u t3, 0(a1) /* write out that quad */ +bcopy_different_alignment: + /* + * this is the fun part + */ + addq a0,a2,a3 + cmpule a2,8,t0 + bne t0,bcopy_da_finish + + beq t1,bcopy_da_noentry + + /* Do the initial partial word */ + subq zero,a1,t0 + and t0,7,t0 + ldq_u t3,7(a0) + extql t2,a0,t2 + extqh t3,a0,t3 + or t2,t3,t5 + insql t5,a1,t5 + ldq_u t6,0(a1) + mskql t6,a1,t6 + or t5,t6,t5 + stq_u t5,0(a1) + addq a0,t0,a0 + addq a1,t0,a1 + subq a2,t0,a2 + ldq_u t2,0(a0) + +bcopy_da_noentry: + subq a2,1,t0 + bic t0,7,t0 + and a2,7,a2 + beq t0,bcopy_da_finish2 + +bcopy_da_lp: + ldq_u t3,7(a0) + addq a0,8,a0 + extql t2,a0,t4 + extqh t3,a0,t5 + subq t0,8,t0 + or t4,t5,t5 + stq t5,0(a1) + addq a1,8,a1 + beq t0,bcopy_da_finish1 + ldq_u t2,7(a0) + addq a0,8,a0 + extql t3,a0,t4 + extqh t2,a0,t5 + subq t0,8,t0 + or t4,t5,t5 + stq t5,0(a1) + addq a1,8,a1 + bne t0,bcopy_da_lp + +bcopy_da_finish2: + /* Do the last new word */ + mov t2,t3 + +bcopy_da_finish1: + /* Do the last partial word */ + ldq_u t2,-1(a3) + extql t3,a0,t3 + extqh t2,a0,t2 + or t2,t3,t2 + br zero,bcopy_samealign_lp_end + +bcopy_da_finish: + /* Do the last word in the next source word */ + ldq_u t3,-1(a3) + extql t2,a0,t2 + extqh t3,a0,t3 + or t2,t3,t2 + insqh t2,a1,t3 + insql t2,a1,t2 + lda t4,-1(zero) + mskql t4,a2,t5 + cmovne t5,t5,t4 + insqh t4,a1,t5 + insql t4,a1,t4 + addq a1,a2,a4 + ldq_u t6,0(a1) + ldq_u t7,-1(a4) + bic t6,t4,t6 + bic t7,t5,t7 + and t2,t4,t2 + and t3,t5,t3 + or t2,t6,t2 + or t3,t7,t3 + stq_u t3,-1(a4) + stq_u t2,0(a1) + RET - subl a2, 1, a2 /* len-- */ - addq a1, 1, a1 /* to++ */ - addq a0, 1, a0 /* from++ */ - bne a2, 1b /* if (len != 0) copy more */ +bcopy_overlap: + /* + * Basically equivalent to previous case, only backwards. + * Not quite as highly optimized + */ + addq a0,a2,a3 + addq a1,a2,a4 + + /* less than 8 bytes - don't worry about overlap */ + cmpule a2,8,t0 + bne t0,bcopy_ov_short + + /* Possibly do a partial first word */ + and a4,7,t4 + beq t4,bcopy_ov_nostart2 + subq a3,t4,a3 + subq a4,t4,a4 + ldq_u t1,0(a3) + subq a2,t4,a2 + ldq_u t2,7(a3) + ldq t3,0(a4) + extql t1,a3,t1 + extqh t2,a3,t2 + or t1,t2,t1 + mskqh t3,t4,t3 + mskql t1,t4,t1 + or t1,t3,t1 + stq t1,0(a4) + +bcopy_ov_nostart2: + bic a2,7,t4 + and a2,7,a2 + beq t4,bcopy_ov_lp_end + +bcopy_ov_lp: + /* This could be more pipelined, but it doesn't seem worth it */ + ldq_u t0,-8(a3) + subq a4,8,a4 + ldq_u t1,-1(a3) + subq a3,8,a3 + extql t0,a3,t0 + extqh t1,a3,t1 + subq t4,8,t4 + or t0,t1,t0 + stq t0,0(a4) + bne t4,bcopy_ov_lp + +bcopy_ov_lp_end: + beq a2,bcopy_done + + ldq_u t0,0(a0) + ldq_u t1,7(a0) + ldq_u t2,0(a1) + extql t0,a0,t0 + extqh t1,a0,t1 + or t0,t1,t0 + insql t0,a1,t0 + mskql t2,a1,t2 + or t2,t0,t2 + stq_u t2,0(a1) + +bcopy_done: + RET -2: - /* tear down stack frame */ - ldq ra, COPY_FRAME_RA(sp) - ldq s6, COPY_FRAME_S6(sp) - addq sp, COPY_FRAME_SIZE, sp +bcopy_ov_short: + ldq_u t2,0(a0) + br zero,bcopy_da_finish - RET END(bcopy) NESTED(copyin, 3, 16, ra, 0, 0) @@ -1084,7 +1268,7 @@ NESTED(copyin, 3, 16, ra, 0, 0) stq ra, (16-8)(sp) /* save ra */ CONST(VM_MAX_ADDRESS, t0) /* make sure that src addr */ cmpult a0, t0, t1 /* is in user space. */ - beq t1, copyerr_noframe /* if it's not, error out. */ + beq t1, copyerr /* if it's not, error out. */ lda v0, copyerr /* set up fault handler. */ .set noat ldq at_reg, curproc @@ -1109,7 +1293,7 @@ NESTED(copyout, 3, 16, ra, 0, 0) stq ra, (16-8)(sp) /* save ra */ CONST(VM_MAX_ADDRESS, t0) /* make sure that dest addr */ cmpult a1, t0, t1 /* is in user space. */ - beq t1, copyerr_noframe /* if it's not, error out. */ + beq t1, copyerr /* if it's not, error out. */ lda v0, copyerr /* set up fault handler. */ .set noat ldq at_reg, curproc @@ -1130,13 +1314,6 @@ NESTED(copyout, 3, 16, ra, 0, 0) LEAF(copyerr, 0) SETGP(pv) - - /* tear down copy functions' stack frame */ - ldq ra, COPY_FRAME_RA(sp) - ldq s6, COPY_FRAME_S6(sp) - addq sp, COPY_FRAME_SIZE, sp - -XLEAF(copyerr_noframe, 0) ldq ra, (16-8)(sp) /* restore ra. */ lda sp, 16(sp) /* kill stack frame. */ CONST(EFAULT, v0) /* return EFAULT. */ @@ -1424,3 +1601,23 @@ XLEAF(suswintr, 2) /* XXX what is a 'word'? */ END(fswberr) /**************************************************************************/ + +/* + * Some bogus data, to keep vmstat happy, for now. + */ + + .data +EXPORT(intrnames) +#ifndef EVCNT_COUNTERS + INTRNAMES_DEFINITION +#endif +EXPORT(eintrnames) + .align 3 +EXPORT(intrcnt) +#ifndef EVCNT_COUNTERS + INTRCNT_DEFINITION +#endif +EXPORT(eintrcnt) + .text + +/**************************************************************************/ diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c index 5fac09b3deb..ea042e92696 100644 --- a/sys/arch/alpha/alpha/machdep.c +++ b/sys/arch/alpha/alpha/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.11 1995/10/07 06:25:19 mycroft Exp $ */ +/* $NetBSD: machdep.c,v 1.12 1995/11/23 02:34:15 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -81,6 +81,15 @@ #ifdef DEC_2100_A50 #include #endif +#ifdef DEC_KN20AA +#include +#endif +#ifdef DEC_AXPPCI_33 +#include +#endif +#ifdef DEC_21000 +#include +#endif #include #include "ether.h" @@ -141,9 +150,11 @@ char *model_names[] = { "DEC 2100/A500 (\"Sable\")", "AXPvme 64", "AXPpci 33 (\"NoName\")", - "UNKNOWN (12)", + "DEC 21000 (\"TurboLaser\")", "DEC 2100/A50 (\"Avanti\") family", "Mustang", + "DEC KN20AA", + "UNKNOWN (16)", "DEC 1000 (\"Mikasa\")", }; int nmodel_names = sizeof model_names/sizeof model_names[0]; @@ -333,6 +344,8 @@ alpha_init(pfn, ptb, argc, argv, envp) * find out this CPU's page size */ PAGE_SIZE = hwrpb->rpb_page_size; + if (PAGE_SIZE != 8192) + panic("page size %d != 8192?!", PAGE_SIZE); v = (caddr_t)alpha_round_page(_end); /* @@ -374,6 +387,24 @@ alpha_init(pfn, ptb, argc, argv, envp) break; #endif +#ifdef DEC_KN20AA + case ST_DEC_KN20AA: + cpu_modelname = dec_kn20aa_modelname; + cpu_consinit = dec_kn20aa_consinit; + cpu_bootdev = dec_kn20aa_bootdev; + cpu_iobus = "cia"; + break; +#endif + +#ifdef DEC_AXPPCI_33 + case ST_DEC_AXPPCI_33: + cpu_modelname = dec_axppci_33_modelname; + cpu_consinit = dec_axppci_33_consinit; + cpu_bootdev = dec_axppci_33_bootdev; + cpu_iobus = "lca"; + break; +#endif + #ifdef DEC_2000_300 case ST_DEC_2000_300: cpu_modelname = dec_2000_300_modelname; @@ -381,13 +412,16 @@ alpha_init(pfn, ptb, argc, argv, envp) cpu_bootdev = dec_2000_300_bootdev; cpu_iobus = "ibus"; XXX DEC 2000/300 NOT SUPPORTED + break; #endif -#if defined(ADU) || defined(DEC_4000) || defined(DEC_7000) || \ - defined(DEC_2100_A500) || defined(DEC_AXPVME_64) || \ - defined(DEC_AXPPCI_33) || defined(DEC_MUSTANG) || \ - defined(DEC_1000) - THIS SYSTEM NOT SUPPORTED +#ifdef DEC_21000 + case ST_DEC_21000: + cpu_modelname = dec_21000_modelname; + cpu_consinit = dec_21000_consinit; + cpu_bootdev = dec_21000_bootdev; + cpu_iobus = "tlsb"; + break; #endif default: @@ -445,9 +479,9 @@ alpha_init(pfn, ptb, argc, argv, envp) * to map these into virtual address space. */ #define valloc(name, type, num) \ - (name) = (type *)v; v = (caddr_t)((name)+(num)) + (name) = (type *)v; v = (caddr_t)ALIGN((name)+(num)) #define valloclim(name, type, num, lim) \ - (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num))) + (name) = (type *)v; v = (caddr_t)ALIGN((lim) = ((name)+(num))) #ifdef REAL_CLISTS valloc(cfree, struct cblock, nclist); #endif @@ -605,7 +639,7 @@ alpha_init(pfn, ptb, argc, argv, envp) consinit() { - cpu_consinit(boot_console); + (*cpu_consinit)(boot_console); pmap_unmap_prom(); } @@ -769,11 +803,11 @@ boot(howto) dumpsys(); } +haltsys: + /* run any shutdown hooks */ doshutdownhooks(); -haltsys: - #ifdef BOOTKEY printf("hit any key to %s...\n", howto & RB_HALT ? "halt" : "reboot"); cngetc(); @@ -1462,10 +1496,8 @@ cpu_exec_ecoff_hook(p, epp, eap) epp->ep_emul = &emul_netbsd; break; -#ifdef DIAGNOSTIC default: - panic("cpu_exec_ecoff_hook: can't get here from there."); -#endif + return ENOEXEC; } return 0; } diff --git a/sys/arch/alpha/alpha/mainbus.c b/sys/arch/alpha/alpha/mainbus.c index 5a2d1a1a4a4..22ed3e6c2d7 100644 --- a/sys/arch/alpha/alpha/mainbus.c +++ b/sys/arch/alpha/alpha/mainbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.4 1995/08/03 01:01:26 cgd Exp $ */ +/* $NetBSD: mainbus.c,v 1.5 1995/11/23 02:34:18 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -125,12 +125,6 @@ mbattach(parent, self, aux) nca.ca_bus = &sc->sc_bus; config_found(self, &nca, mbprint); } - - /* - * XXX: note that the following should be at various places in - * machdep.c. - */ - /* WEIRD: Note that the "LCA" CPU attches the PCI bus directly... */ } static int @@ -139,8 +133,6 @@ mbprint(aux, pnp) char *pnp; { - if (pnp) - return (QUIET); return (UNCONF); } diff --git a/sys/arch/alpha/alpha/mem.c b/sys/arch/alpha/alpha/mem.c index b6e9d74077c..5f310eed697 100644 --- a/sys/arch/alpha/alpha/mem.c +++ b/sys/arch/alpha/alpha/mem.c @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.4 1995/06/28 02:45:13 cgd Exp $ */ +/* $NetBSD: mem.c,v 1.5 1995/11/23 02:34:21 cgd Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -103,6 +103,7 @@ mmrw(dev, uio, flags) /* minor device 0 is physical memory */ case 0: v = uio->uio_offset; +kmemphys: #ifndef DEBUG /* allow reads only in RAM (except for DEBUG) */ if (v < ctob(firstusablepage) || @@ -117,6 +118,12 @@ mmrw(dev, uio, flags) /* minor device 1 is kernel memory */ case 1: v = uio->uio_offset; + + if (v >= K0SEG_BEGIN && v < K0SEG_END) { + v = k0segtophys(v); + goto kmemphys; + } + c = min(iov->iov_len, MAXPHYS); if (!kernacc((caddr_t)v, c, uio->uio_rw == UIO_READ ? B_READ : B_WRITE)) diff --git a/sys/arch/alpha/alpha/pal.s b/sys/arch/alpha/alpha/pal.s index 1bebc1e6bc7..bc03e0004ca 100644 --- a/sys/arch/alpha/alpha/pal.s +++ b/sys/arch/alpha/alpha/pal.s @@ -1,4 +1,4 @@ -/* $NetBSD: pal.s,v 1.1 1995/02/13 23:07:06 cgd Exp $ */ +/* $NetBSD: pal.s,v 1.2 1995/11/23 02:34:23 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -209,6 +209,11 @@ LEAF(pal_swpipl,1) RET END(pal_swpipl) +LEAF_NOPROFILE(profile_swpipl,1) + call_pal PAL_OSF1_swpipl + RET + END(profile_swpipl) + /* * pal_tbi: Translation buffer invalidate. [PRIVILEGED] * diff --git a/sys/arch/alpha/alpha/pmap.c b/sys/arch/alpha/alpha/pmap.c index f674b1f66b2..59804c9d9be 100644 --- a/sys/arch/alpha/alpha/pmap.c +++ b/sys/arch/alpha/alpha/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.6 1995/08/03 00:52:24 cgd Exp $ */ +/* $NetBSD: pmap.c,v 1.7 1995/11/23 02:34:26 cgd Exp $ */ /* * Copyright (c) 1991, 1993 @@ -196,8 +196,6 @@ extern vm_offset_t pager_sva, pager_eva; #define pmap_pte_pa(pte) (PG_PFNUM(*(pte)) << PGSHIFT) #define pmap_pte_prot(pte) (*(pte) & PG_PROT) #define pmap_pte_w(pte) (*(pte) & PG_WIRED) -#define pmap_pte_m(pte) (*(pte) & PG_MOD) -#define pmap_pte_u(pte) (*(pte) & PG_USED) #define pmap_pte_v(pte) (*(pte) & PG_V) #define pmap_pte_set_w(pte, v) \ @@ -255,13 +253,13 @@ vm_offset_t virtual_end; /* VA of last avail page (end of kernel AS) */ vm_offset_t vm_first_phys; /* PA of first managed page */ vm_offset_t vm_last_phys; /* PA just past last managed page */ boolean_t pmap_initialized = FALSE; /* Has pmap_init completed? */ -char *pmap_attributes; /* reference and modify bits */ +char *pmap_attributes; /* reference and modify bits */ /* * Internal routines */ +void alpha_protection_init __P((void)); void pmap_remove_mapping __P((pmap_t, vm_offset_t, pt_entry_t *, int)); -boolean_t pmap_testbit __P((vm_offset_t, u_long)); void pmap_changebit __P((vm_offset_t, u_long, boolean_t)); void pmap_enter_ptpage __P((pmap_t, vm_offset_t)); #ifdef DEBUG @@ -306,18 +304,16 @@ pmap_bootstrap(firstaddr, ptaddr) */ valloc(Segtabzero, pt_entry_t, NPTEPG); Segtabzeropte = (k0segtophys(Segtabzero) >> PGSHIFT) << PG_SHIFT; - Segtabzeropte |= PG_V|PG_KRE|PG_KWE|PG_WIRED; + Segtabzeropte |= PG_V | PG_KRE | PG_KWE | PG_WIRED; /* * Figure out how many PTE's are necessary to map the kernel. * The '512' comes from PAGER_MAP_SIZE in vm_pager_init(). * This should be kept in sync. * We also reserve space for kmem_alloc_pageable() for vm_fork(). - * Note that UPAGES is added, to allow for the double-mapping - * of user structs that occurs at the start of the mapped kvm area */ Sysmapsize = (VM_KMEM_SIZE + VM_MBUF_SIZE + VM_PHYS_SIZE + - nbuf * MAXBSIZE + 16 * NCARGS) / NBPG + 512 + 256 + UPAGES; + nbuf * MAXBSIZE + 16 * NCARGS) / NBPG + 512 + 256; Sysmapsize += maxproc * (btoc(ALPHA_STSIZE) + btoc(ALPHA_MAX_PTSIZE)); #ifdef SYSVSHM @@ -382,14 +378,14 @@ pmap_bootstrap(firstaddr, ptaddr) for (i = 0; i < howmany(Sysptmapsize, NPTEPG); i++) { pte = (k0segtophys(Sysptmap + (i*PAGE_SIZE)) >> PGSHIFT) << PG_SHIFT; - pte |= PG_V|PG_ASM|PG_KRE|PG_KWE|PG_WIRED; + pte |= PG_V | PG_ASM | PG_KRE | PG_KWE | PG_WIRED; Lev1map[kvtol1pte(VM_MIN_KERNEL_ADDRESS + (i*PAGE_SIZE*NPTEPG*NPTEPG))] = pte; } /* Finally, map the virtual page table */ pte = (k0segtophys(Lev1map) >> PGSHIFT) << PG_SHIFT; - pte |= PG_V|PG_KRE|PG_KWE; /* NOTE NO ASM */ + pte |= PG_V | PG_KRE | PG_KWE; /* NOTE NO ASM */ Lev1map[kvtol1pte(VPTBASE)] = pte; /* @@ -399,7 +395,7 @@ pmap_bootstrap(firstaddr, ptaddr) for (i = 0; i < howmany(Sysmapsize, NPTEPG); i++) { pte = (k0segtophys(((caddr_t)Sysmap)+(i*PAGE_SIZE)) >> PGSHIFT) << PG_SHIFT; - pte |= PG_V|PG_ASM|PG_KRE|PG_KWE|PG_WIRED; + pte |= PG_V | PG_ASM | PG_KRE | PG_KWE | PG_WIRED; Sysptmap[vatoste(VM_MIN_KERNEL_ADDRESS+ (i*PAGE_SIZE*NPTEPG))] = pte; } @@ -485,7 +481,7 @@ pmap_bootstrap_alloc(size) size = round_page(size); avail_start += size; - blkclr((caddr_t)val, size); + bzero((caddr_t)val, size); return ((void *)val); } @@ -498,7 +494,6 @@ void pmap_init(phys_start, phys_end) vm_offset_t phys_start, phys_end; { - int prot, *kp, *up; vm_offset_t addr, addr2; vm_size_t s; @@ -507,33 +502,8 @@ pmap_init(phys_start, phys_end) printf("pmap_init(%x, %x)\n", phys_start, phys_end); #endif - kp = protection_codes[0]; - up = protection_codes[1]; - - for (prot = 0; prot < 8; prot++) { - switch (prot) { - case VM_PROT_NONE | VM_PROT_NONE | VM_PROT_NONE: - *kp++ = PG_ASM; - *up++ = 0; - break; - case VM_PROT_READ | VM_PROT_NONE | VM_PROT_NONE: - case VM_PROT_READ | VM_PROT_NONE | VM_PROT_EXECUTE: - case VM_PROT_NONE | VM_PROT_NONE | VM_PROT_EXECUTE: - *kp++ = PG_ASM|PG_KRE; - *up++ = PG_URE|PG_KRE; - break; - case VM_PROT_NONE | VM_PROT_WRITE | VM_PROT_NONE: - *kp++ = PG_ASM|PG_KWE; - *up++ = PG_UWE|PG_KWE; - break; - case VM_PROT_NONE | VM_PROT_WRITE | VM_PROT_EXECUTE: - case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_NONE: - case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE: - *kp++ = PG_ASM|PG_KWE|PG_KRE; - *up++ = PG_UWE|PG_URE|PG_KWE|PG_KRE; - break; - } - } + /* initialize protection array */ + alpha_protection_init(); /* * Allocate the segment table map @@ -809,7 +779,7 @@ pmap_page_protect(pa, prot) /* copy_on_write */ case VM_PROT_READ: case VM_PROT_READ|VM_PROT_EXECUTE: -/* XXX */ pmap_changebit(pa, PG_KWE|PG_UWE, FALSE); +/* XXX */ pmap_changebit(pa, PG_KWE | PG_UWE, FALSE); return; /* remove_all */ default: @@ -1121,8 +1091,11 @@ validate: /* * Build the new PTE. */ - npte = ((pa >> PGSHIFT) << PG_SHIFT) | pte_prot(pmap, prot) | - (*pte & (PG_MOD|PG_USED)) | PG_V; + npte = ((pa >> PGSHIFT) << PG_SHIFT) | pte_prot(pmap, prot) | PG_V; + if ((pmap_attributes[pa_index(pa)] & PMAP_ATTR_REF) == 0) + npte |= PG_FOR | PG_FOW | PG_FOE; + else if ((pmap_attributes[pa_index(pa)] & PMAP_ATTR_MOD) == 0) + npte |= PG_FOW; if (wired) npte |= PG_WIRED; #ifdef DEBUG @@ -1513,7 +1486,7 @@ pmap_pageable(pmap, sva, eva, pageable) /* * Mark it unmodified to avoid pageout */ - pmap_changebit(pa, PG_MOD, FALSE); + pmap_clear_modify(pa); #ifdef DEBUG if ((PHYS_TO_VM_PAGE(pa)->flags & PG_CLEAN) == 0) { printf("pa %lx: flags=%lx: not clean\n", @@ -1541,7 +1514,10 @@ pmap_clear_modify(pa) if (pmapdebug & PDB_FOLLOW) printf("pmap_clear_modify(%lx)\n", pa); #endif - pmap_changebit(pa, PG_MOD, FALSE); + if ((pmap_attributes[pa_index(pa)] & PMAP_ATTR_MOD) != 0) { + pmap_changebit(pa, PG_FOW, TRUE); + pmap_attributes[pa_index(pa)] &= ~PMAP_ATTR_MOD; + } } /* @@ -1557,7 +1533,10 @@ void pmap_clear_reference(pa) if (pmapdebug & PDB_FOLLOW) printf("pmap_clear_reference(%lx)\n", pa); #endif - pmap_changebit(pa, PG_USED, FALSE); + if ((pmap_attributes[pa_index(pa)] & PMAP_ATTR_REF) != 0) { + pmap_changebit(pa, PG_FOR | PG_FOW | PG_FOE, TRUE); + pmap_attributes[pa_index(pa)] &= ~PMAP_ATTR_REF; + } } /* @@ -1571,14 +1550,15 @@ boolean_t pmap_is_referenced(pa) vm_offset_t pa; { + boolean_t rv; + + rv = (pmap_attributes[pa_index(pa)] & PMAP_ATTR_REF) != 0; #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) { - boolean_t rv = pmap_testbit(pa, PG_USED); printf("pmap_is_referenced(%lx) -> %c\n", pa, "FT"[rv]); - return(rv); } #endif - return(pmap_testbit(pa, PG_USED)); + return rv; } /* @@ -1592,14 +1572,15 @@ boolean_t pmap_is_modified(pa) vm_offset_t pa; { + boolean_t rv; + + rv = (pmap_attributes[pa_index(pa)] & PMAP_ATTR_MOD) != 0; #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) { - boolean_t rv = pmap_testbit(pa, PG_MOD); printf("pmap_is_modified(%lx) -> %c\n", pa, "FT"[rv]); - return(rv); } #endif - return(pmap_testbit(pa, PG_MOD)); + return rv; } vm_offset_t @@ -1613,6 +1594,44 @@ pmap_phys_address(ppn) * Miscellaneous support routines follow */ +/* + * Initialize Alpha protection code array. + */ +/* static */ +void +alpha_protection_init() +{ + int prot, *kp, *up; + + kp = protection_codes[0]; + up = protection_codes[1]; + + for (prot = 0; prot < 8; prot++) { + switch (prot) { + case VM_PROT_NONE | VM_PROT_NONE | VM_PROT_NONE: + *kp++ = PG_ASM; + *up++ = 0; + break; + case VM_PROT_READ | VM_PROT_NONE | VM_PROT_NONE: + case VM_PROT_READ | VM_PROT_NONE | VM_PROT_EXECUTE: + case VM_PROT_NONE | VM_PROT_NONE | VM_PROT_EXECUTE: + *kp++ = PG_ASM | PG_KRE; + *up++ = PG_URE | PG_KRE; + break; + case VM_PROT_NONE | VM_PROT_WRITE | VM_PROT_NONE: + *kp++ = PG_ASM | PG_KWE; + *up++ = PG_UWE | PG_KWE; + break; + case VM_PROT_NONE | VM_PROT_WRITE | VM_PROT_EXECUTE: + case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_NONE: + case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE: + *kp++ = PG_ASM | PG_KWE | PG_KRE; + *up++ = PG_UWE | PG_URE | PG_KWE | PG_KRE; + break; + } + } +} + /* * Invalidate a single page denoted by pmap/va. * If (pte != NULL), it is the already computed PTE for the page. @@ -1632,7 +1651,6 @@ pmap_remove_mapping(pmap, va, pte, flags) pmap_t ptpmap; pt_entry_t *ste; int s; - long bits; #ifdef DEBUG pt_entry_t opte; @@ -1670,7 +1688,6 @@ pmap_remove_mapping(pmap, va, pte, flags) if (pmapdebug & PDB_REMOVE) printf("remove: invalidating pte at %lx\n", pte); #endif - bits = *pte & (PG_USED|PG_MOD); *pte = PG_NV; if ((flags & PRM_TFLUSH) && active_pmap(pmap)) TBIS((caddr_t)va); @@ -1807,50 +1824,7 @@ pmap_remove_mapping(pmap, va, pte, flags) pv->pv_flags &= ~PV_PTPAGE; ptpmap->pm_ptpages--; } - /* - * Update saved attributes for managed page - */ - pmap_attributes[pa_index(pa)] |= bits; - splx(s); -} - -/* static */ -boolean_t -pmap_testbit(pa, bit) - register vm_offset_t pa; - u_long bit; -{ - register pv_entry_t pv; - register pt_entry_t *pte; - int s; - - if (pa < vm_first_phys || pa >= vm_last_phys) - return(FALSE); - - pv = pa_to_pvh(pa); - s = splimp(); - /* - * Check saved info first - */ - if (pmap_attributes[pa_index(pa)] & bit) { - splx(s); - return(TRUE); - } - /* - * Not found, check current mappings returning - * immediately if found. - */ - if (pv->pv_pmap != NULL) { - for (; pv; pv = pv->pv_next) { - pte = pmap_pte(pv->pv_pmap, pv->pv_va); - if (*pte & bit) { - splx(s); - return(TRUE); - } - } - } splx(s); - return(FALSE); } /* static */ @@ -1886,11 +1860,6 @@ pmap_changebit(pa, bit, setem) #endif pv = pa_to_pvh(pa); s = splimp(); - /* - * Clear saved attributes (modify, reference) - */ - if (!setem) - pmap_attributes[pa_index(pa)] &= ~bit; /* * Loop over all current mappings setting/clearing as appropos * If setting RO do we need to clear the VAC? @@ -1908,7 +1877,7 @@ pmap_changebit(pa, bit, setem) /* * XXX don't write protect pager mappings */ -/* XXX */ if (bit == (PG_UWE|PG_KWE)) { +/* XXX */ if (bit == (PG_UWE | PG_KWE)) { extern vm_offset_t pager_sva, pager_eva; if (va >= pager_sva && va < pager_eva) @@ -2037,6 +2006,11 @@ pmap_enter_ptpage(pmap, va) * letting the VM system allocate a zero-filled page. */ else { + /* + * Count the segment table reference now so that we won't + * lose the segment table when low on memory. + */ + pmap->pm_sref++; #ifdef DEBUG if (pmapdebug & (PDB_ENTER|PDB_PTPAGE)) printf("enter: about to fault UPT pg at %lx\n", va); @@ -2084,8 +2058,8 @@ pmap_enter_ptpage(pmap, va) /* * Map the new PT page into the segment table. - * Also increment the reference count on the segment table if this - * was a user page table page. Note that we don't use vm_map_pageable + * Reference count on the user segment tables incremented above + * to prevent race conditions. Note that we don't use vm_map_pageable * to keep the count like we do for PT pages, this is mostly because * it would be difficult to identify ST pages in pmap_pageable to * release them. We also avoid the overhead of vm_map_pageable. @@ -2093,7 +2067,6 @@ pmap_enter_ptpage(pmap, va) *ste = ((ptpa >> PGSHIFT) << PG_SHIFT) | PG_KRE | PG_KWE | PG_V | (pmap == pmap_kernel() ? PG_ASM : 0); if (pmap != pmap_kernel()) { - pmap->pm_sref++; #ifdef DEBUG if (pmapdebug & (PDB_ENTER|PDB_PTPAGE|PDB_SEGTAB)) printf("enter: stab %lx refcnt %d\n", @@ -2113,6 +2086,105 @@ pmap_enter_ptpage(pmap, va) splx(s); } +/* + * Emulate reference and/or modified bit hits. + */ +void +pmap_emulate_reference(p, v, user, write) + struct proc *p; + vm_offset_t v; + int user; + int write; +{ + pt_entry_t faultoff, *pte; + vm_offset_t pa; + char attr; + +#ifdef DEBUG + if (pmapdebug & PDB_FOLLOW) + printf("pmap_emulate_reference: 0x%lx, 0x%lx, %d, %d\n", + p, v, user, write); +#endif + + /* + * Convert process and virtual address to physical address. + */ + if (v >= VM_MIN_KERNEL_ADDRESS) { + if (user) + panic("pmap_emulate_reference: user ref to kernel"); + pte = kvtopte(v); + } else { +#ifdef DIAGNOSTIC + if (p == NULL) + panic("pmap_emulate_reference: bad proc"); + if (p->p_vmspace == NULL) + panic("pmap_emulate_reference: bad p_vmspace"); +#endif + pte = pmap_pte(&p->p_vmspace->vm_pmap, v); + } +#ifdef DEBUG + if (pmapdebug & PDB_FOLLOW) { + printf("\tpte = 0x%lx, ", pte); + printf("*pte = 0x%lx\n", *pte); + } +#endif +#ifdef DEBUG /* These checks are more expensive */ + if (!pmap_pte_v(pte)) + panic("pmap_emulate_reference: invalid pte"); +#if 0 + /* + * Can't do these, because cpu_fork and cpu_swapin call + * pmap_emulate_reference(), and the bits aren't guaranteed, + * for them... + */ + if (write) { + if (!(*pte & (user ? PG_UWE : PG_UWE | PG_KWE))) + panic("pmap_emulate_reference: write but unwritable"); + if (!(*pte & PG_FOW)) + panic("pmap_emulate_reference: write but not FOW"); + } else { + if (!(*pte & (user ? PG_URE : PG_URE | PG_KRE))) + panic("pmap_emulate_reference: !write but unreadable"); + if (!(*pte & (PG_FOR | PG_FOE))) + panic("pmap_emulate_reference: !write but not FOR|FOE"); + } +#endif + /* Other diagnostics? */ +#endif + pa = pmap_pte_pa(pte); +#ifdef DEBUG + if (pmapdebug & PDB_FOLLOW) + printf("\tpa = 0x%lx\n", pa); +#endif + + /* + * Twiddle the appropriate bits to reflect the reference + * and/or modification.. + * + * The rules: + * (1) always mark page as used, and + * (2) if it was a write fault, mark page as modified. + */ + attr = PMAP_ATTR_REF; + faultoff = PG_FOR | PG_FOE; + if (write) { + attr |= PMAP_ATTR_MOD; + faultoff |= PG_FOW; + } + pmap_attributes[pa_index(pa)] |= attr; + pmap_changebit(pa, faultoff, FALSE); + if ((*pte & faultoff) != 0) { +#if 0 + /* + * This is apparently normal. Why? -- cgd + */ + printf("warning: pmap_changebit didn't."); +#endif + *pte &= ~faultoff; + TBIS((caddr_t)v); + } +} + #ifdef DEBUG /* static */ void diff --git a/sys/arch/alpha/alpha/process_machdep.c b/sys/arch/alpha/alpha/process_machdep.c index 5e51f21450a..8a07130043c 100644 --- a/sys/arch/alpha/alpha/process_machdep.c +++ b/sys/arch/alpha/alpha/process_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: process_machdep.c,v 1.2 1995/03/24 15:07:17 cgd Exp $ */ +/* $NetBSD: process_machdep.c,v 1.3 1995/11/23 02:34:29 cgd Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou @@ -59,24 +59,20 @@ #include #include #include -#include #include #include +#define process_frame(p) ((p)->p_md.md_tf) +#define process_fpframe(p) (&(p)->p_addr->u_pcb.pcb_fp) + int process_read_regs(p, regs) struct proc *p; struct reg *regs; { - struct trapframe *frame; - - if ((p->p_flag & P_INMEM) == 0) - return (EIO); - - frame = p->p_md.md_tf; - - frametoreg(frame, regs); + frametoreg(process_frame(p), regs); + regs->r_regs[R_ZERO] = process_frame(p)->tf_pc; return (0); } @@ -85,15 +81,9 @@ process_write_regs(p, regs) struct proc *p; struct reg *regs; { - struct trapframe *frame; - - if ((p->p_flag & P_INMEM) == 0) - return (EIO); - - frame = p->p_md.md_tf; - - regtoframe(regs, frame); + process_frame(p)->tf_pc = regs->r_regs[R_ZERO]; + regtoframe(regs, process_frame(p)); return (0); } @@ -114,15 +104,9 @@ process_set_pc(p, addr) struct proc *p; caddr_t addr; { - struct trapframe *frame; - - if ((p->p_flag & P_INMEM) == 0) - return (EIO); - - frame = p->p_md.md_tf; + struct trapframe *frame = process_frame(p); frame->tf_pc = (u_int64_t)addr; - return (0); } @@ -133,17 +117,13 @@ process_read_fpregs(p, regs) { extern struct proc *fpcurproc; - if ((p->p_flag & P_INMEM) == 0) - return (EIO); - if (p == fpcurproc) { pal_wrfen(1); - savefpstate(&p->p_addr->u_pcb.pcb_fp); + savefpstate(process_fpframe(p)); pal_wrfen(0); } - bcopy(&p->p_addr->u_pcb.pcb_fp, regs, sizeof(struct fpreg)); - + bcopy(process_fpframe(p), regs, sizeof(struct fpreg)); return (0); } @@ -154,13 +134,9 @@ process_write_fpregs(p, regs) { extern struct proc *fpcurproc; - if ((p->p_flag & P_INMEM) == 0) - return (EIO); - if (p == fpcurproc) fpcurproc = NULL; - bcopy(regs, &p->p_addr->u_pcb.pcb_fp, sizeof(struct fpreg)); - + bcopy(regs, process_fpframe(p), sizeof(struct fpreg)); return (0); } diff --git a/sys/arch/alpha/alpha/support.c b/sys/arch/alpha/alpha/support.c index 7e043b7723f..db0f291dc0b 100644 --- a/sys/arch/alpha/alpha/support.c +++ b/sys/arch/alpha/alpha/support.c @@ -1,4 +1,4 @@ -/* $NetBSD: support.c,v 1.1 1995/02/13 23:07:13 cgd Exp $ */ +/* $NetBSD: support.c,v 1.2 1995/11/23 02:34:32 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -33,26 +33,6 @@ #include #include -void -blkclr(void *b, size_t len) -{ - bzero(b, len); -} - -void -ovbcopy(void *a, void *b, size_t len) -{ - if (b < a) { - while (len--) - *((char *)b)++ = *((char *)a)++; - } else { - ((char *)a) += len; - ((char *)b) += len; - while (len--) - *--((char *)b) = *--((char *)a); - } -} - struct qelem { struct qelem *q_forw; struct qelem *q_back; diff --git a/sys/arch/alpha/alpha/sys_machdep.c b/sys/arch/alpha/alpha/sys_machdep.c index ae9b527ec85..fdca27625f8 100644 --- a/sys/arch/alpha/alpha/sys_machdep.c +++ b/sys/arch/alpha/alpha/sys_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_machdep.c,v 1.2 1995/09/19 23:00:53 thorpej Exp $ */ +/* $NetBSD: sys_machdep.c,v 1.3 1995/11/23 02:34:35 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -34,12 +34,12 @@ #include int -sysarch(p, v, retval) +sys_sysarch(p, v, retval) struct proc *p; void *v; register_t *retval; { - struct sysarch_args /* { + struct sys_sysarch_args /* { syscallarg(int) op; syscallarg(char *) parms; } */ *uap = v; diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c index 8291e5034ab..fcea4840ca4 100644 --- a/sys/arch/alpha/alpha/trap.c +++ b/sys/arch/alpha/alpha/trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.4 1995/06/28 02:45:21 cgd Exp $ */ +/* $NetBSD: trap.c,v 1.5 1995/11/23 02:34:37 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -119,7 +119,7 @@ trap(type, code, v, framep) p->p_md.md_tf = framep; } #ifdef DDB - if (type == T_TRACE || type == T_BREAKPOINT) { + if (type == T_BPT) { if (kdb_trap(type, framep)) return; } @@ -202,23 +202,19 @@ sigfpe: i = SIGFPE; goto sigfpe; case T_BPT|T_USER: case T_BUGCHK|T_USER: + ucode = code; + i = SIGTRAP; + break; + case T_OPDEC|T_USER: ucode = code; - i = SIGILL; + i = SIGILL; break; case T_INVALTRANS: case T_INVALTRANS|T_USER: case T_ACCESS: case T_ACCESS|T_USER: -#ifdef notdef /* None of these should happen. */ - case T_FOR: - case T_FOR|T_USER: - case T_FOE: - case T_FOE|T_USER: - case T_FOW: - case T_FOW|T_USER: -#endif { register vm_offset_t va; register struct vmspace *vm; @@ -302,6 +298,18 @@ sigfpe: i = SIGFPE; i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; break; } + + case T_FOR: + case T_FOR|T_USER: + case T_FOE: + case T_FOE|T_USER: + pmap_emulate_reference(p, v, (type & T_USER) != 0, 0); + goto out; + + case T_FOW: + case T_FOW|T_USER: + pmap_emulate_reference(p, v, (type & T_USER) != 0, 1); + goto out; } trapsignal(p, i, ucode); @@ -449,9 +457,28 @@ syscall(code, framep) scdebug_ret(p, code, error, rval); #endif - userret(p, framep, sticks, (u_int)0, 0); + userret(p, framep->tf_pc, sticks); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p->p_tracep, code, error, rval[0]); #endif } + +/* + * Process the tail end of a fork() for the child. + */ +void +child_return(p) + struct proc *p; +{ + + /* + * Return values in the frame set by cpu_fork(). + */ + + userret(p, p->p_md.md_tf->tf_pc, 0); +#ifdef KTRACE + if (KTRPOINT(p, KTR_SYSRET)) + ktrsysret(p->p_tracep, SYS_fork, 0, 0); +#endif +} diff --git a/sys/arch/alpha/alpha/vm_machdep.c b/sys/arch/alpha/alpha/vm_machdep.c index 6742c88ed07..5b31b6d23c2 100644 --- a/sys/arch/alpha/alpha/vm_machdep.c +++ b/sys/arch/alpha/alpha/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.4 1995/06/28 02:45:23 cgd Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.6 1995/12/09 04:37:23 mycroft Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -130,6 +130,7 @@ cpu_exit(p) * address in each process; in the future we will probably relocate * the frame pointers on the stack after copying. */ +void cpu_fork(p1, p2) register struct proc *p1, *p2; { @@ -137,6 +138,7 @@ cpu_fork(p1, p2) pt_entry_t *ptep; int i; extern struct proc *fpcurproc; + extern void proc_trampoline(), rei(), child_return(); p2->p_md.md_tf = p1->p_md.md_tf; p2->p_md.md_flags = p1->p_md.md_flags & MDP_FPUSED; @@ -149,6 +151,16 @@ cpu_fork(p1, p2) p2->p_md.md_pcbpaddr = &((struct user *)(PG_PFNUM(*ptep) << PGSHIFT))->u_pcb; + /* + * Simulate a write to the process's U-area pages, + * so that the system doesn't lose badly. + * (If this isn't done, the kernel can't read or + * write the kernel stack. "Ouch!") + */ + for (i = 0; i < UPAGES; i++) + pmap_emulate_reference(p2, (vm_offset_t)up + i * PAGE_SIZE, + 0, 1); + /* * Copy floating point state from the FP chip to the PCB * if this process has state stored there. @@ -203,15 +215,20 @@ cpu_fork(p1, p2) p2tf->tf_regs[FRAME_A4] = 1; /* is child */ /* - * Arrange for continuation at rei(). Note that the - * child process doesn't stay in the kernel for long! + * Arrange for continuation at child_return(), which + * will return to rei(). Note that the child process + * doesn't stay in the kernel for long! + * + * This is an inlined version of cpu_set_kpc. */ - up->u_pcb.pcb_ksp = (u_int64_t)p2tf; - up->u_pcb.pcb_context[7] = (u_int64_t)rei; - up->u_pcb.pcb_context[8] = 0; + up->u_pcb.pcb_ksp = (u_int64_t)p2tf; + up->u_pcb.pcb_context[0] = + (u_int64_t)child_return; /* s0: pc */ + up->u_pcb.pcb_context[1] = + (u_int64_t)rei; /* s1: ra */ + up->u_pcb.pcb_context[7] = + (u_int64_t)proc_trampoline; /* ra: assembly magic */ } - - return (0); } /* @@ -223,6 +240,8 @@ cpu_fork(p1, p2) * * Note that it's assumed that when the named process returns, rei() * should be invoked, to return to user mode. + * + * (Note that cpu_fork(), above, uses an open-coded version of this.) */ void cpu_set_kpc(p, pc) @@ -260,6 +279,16 @@ cpu_swapin(p) ptep = kvtopte(up); p->p_md.md_pcbpaddr = &((struct user *)(PG_PFNUM(*ptep) << PGSHIFT))->u_pcb; + + /* + * Simulate a write to the process's U-area pages, + * so that the system doesn't lose badly. + * (If this isn't done, the kernel can't read or + * write the kernel stack. "Ouch!") + */ + for (i = 0; i < UPAGES; i++) + pmap_emulate_reference(p, (vm_offset_t)up + i * PAGE_SIZE, + 0, 1); } /* diff --git a/sys/arch/alpha/compile/.cvsignore b/sys/arch/alpha/compile/.cvsignore index 3bc6a4003a3..a978fa858c0 100644 --- a/sys/arch/alpha/compile/.cvsignore +++ b/sys/arch/alpha/compile/.cvsignore @@ -1,7 +1,18 @@ ALPHA +ALPHA.PROF BUNNY +BUNNY.PROF +DILLY +DILLY.PROF GENERIC +GENERIC.PROF GENERIC_NFS +GENERIC_NFS.PROF JURA +JURA.PROF MACALLAN +MACALLAN.PROF +NONAME +NONAME.PROF TOMMY +TOMMY.PROF diff --git a/sys/arch/alpha/compile/build_all b/sys/arch/alpha/compile/build_all new file mode 100644 index 00000000000..a0a470cd77d --- /dev/null +++ b/sys/arch/alpha/compile/build_all @@ -0,0 +1,15 @@ +#!/bin/sh - + +dirlist=`find . -type d ! \( -name . -o -name CVS \) -prune | \ + sed -e s,./,, | sort` + +for dir in $dirlist; do + echo === $dir + echo "" + echo "***" + echo "" + (cd $dir ; time make -k) + echo "" + echo "***" + echo "" +done diff --git a/sys/arch/alpha/compile/rebuild_all b/sys/arch/alpha/compile/rebuild_all new file mode 100644 index 00000000000..fd619a5bcd5 --- /dev/null +++ b/sys/arch/alpha/compile/rebuild_all @@ -0,0 +1,23 @@ +#!/bin/sh - + +dirlist=`find . -type d ! \( -name . -o -name CVS \) -prune | \ + sed -e s,./,, | sort` + +for dir in $dirlist; do + echo === $dir + echo "" + echo "***" + echo "" + (cd $dir ; time make -k clean) + echo "" + echo "***" + echo "" + (cd $dir ; time make -k depend) + echo "" + echo "***" + echo "" + (cd $dir ; time make -k) + echo "" + echo "***" + echo "" +done diff --git a/sys/arch/alpha/conf/ALPHA b/sys/arch/alpha/conf/ALPHA index 63ead133afd..2022ca5084d 100644 --- a/sys/arch/alpha/conf/ALPHA +++ b/sys/arch/alpha/conf/ALPHA @@ -1,10 +1,8 @@ -# $NetBSD: ALPHA,v 1.6 1995/08/03 00:09:17 cgd Exp $ +# $NetBSD: ALPHA,v 1.7 1995/11/23 02:34:53 cgd Exp $ # # Alpha kernel with all the options you'd want, and more. -machine alpha - -makeoptions DEBUG="-g" +include "std.alpha" maxusers 8 @@ -13,9 +11,11 @@ options GENERIC # CPU Support options DEC_3000_500 # Flamingo etc: 3000/[4-9]00* -options DEC_2000_300 # "Jensen": 2000/300 (DECpc AXP 150) options DEC_3000_300 # Pelican etc: 3000/300* -options DEC_2100_A50 # "Avanti": AlphaStation 400 4/233 +options DEC_2100_A50 # Avanti etc: AlphaStation 400, 200, etc. +options DEC_KN20AA # KN20AA: AlphaStation 600 +options DEC_AXPPCI_33 # NoName: AXPpci33, etc. +#options DEC_2000_300 # "Jensen": 2000/300 (DECpc AXP 150) # needs to be set per system options TIMEZONE="5*60" # Minutes west of GMT (for param.c) @@ -57,9 +57,9 @@ options GATEWAY # packet forwarding and more mbuf space # 4.3BSD compatibility. Should be optional, but necessary for now. options COMPAT_43 -# NetBSD compatibility. Mostly meaningless on the Alpha. +# Binary compatibility with previous versions of NetBSD. #options COMPAT_09 -#options COMPAT_10 +options COMPAT_10 # OSF/1 binary compatibility -- CURRENTLY DOES NOT WORK #options COMPAT_OSF1 @@ -81,17 +81,19 @@ options LKM #options INSECURE # Misc. options -options PCIVERBOSE # recognize "unknown" PCI devices +options PCIVERBOSE # recognize "unknown" PCI devices config netbsd swap generic #config netbsd root on sd0 swap on sd0 #config netbsd root nfs swap nfs mainbus0 at root - cpu* at mainbus0 +# TurboChannel bus support tc* at mainbus0 + +# TurboChannel devices asic0 at tc? slot ? offset ? clock0 at asic? offset ? le0 at asic? offset ? @@ -102,25 +104,45 @@ esp0 at tcds? slot ? esp1 at tcds? slot ? #sfb* at tc? slot ? offset ? +# PCI host bus adapter support apecs* at mainbus? -#lca* at cpu? +cia* at mainbus? +lca* at mainbus? +# PCI bus support pci* at apecs? -#pci* at lca? +pci* at cia? +pci* at lca? +pci* at ppb? +# PCI devices de* at pci? +ncr* at pci? +pceb* at pci? +pcivga* at pci? +ppb* at pci? sio* at pci? -#ncr* at pci? +tga* at pci? + +# ISA/EISA bus support +isa* at pceb? +eisa* at pceb? +isa* at sio? -isa0 at sio? +# ISA devices clock0 at isa? port 0x70 -#com0 at isa? port 0x3f8 irq 4 # standard serial ports +pckbd0 at isa? port 0x60 irq 1 # PC-ish ISA keyboard +#pms0 at isa? port 0x60 irq 12 # PS/2 auxiliary +com0 at isa? port 0x3f8 irq 4 # standard serial ports com1 at isa? port 0x2f8 irq 3 lpt0 at isa? port 0x3bc irq 7 # standard parallel port +#wss0 at isa? port 0x530 irq 9 drq 0 # Windows Sound System +# SCSI bus support scsibus* at esp? -#scsibus* at ncr? +scsibus* at ncr? +# SCSI devices sd* at scsibus? target ? lun ? st* at scsibus? target ? lun ? cd* at scsibus? target ? lun ? diff --git a/sys/arch/alpha/conf/BUNNY b/sys/arch/alpha/conf/BUNNY index 3ba1c980d40..aed65576e7e 100644 --- a/sys/arch/alpha/conf/BUNNY +++ b/sys/arch/alpha/conf/BUNNY @@ -1,4 +1,4 @@ -# $NetBSD: BUNNY,v 1.2 1995/08/03 00:09:18 cgd Exp $ +# $NetBSD: BUNNY,v 1.3 1995/11/23 02:34:55 cgd Exp $ # # Kernel for bunnahabhain.pdl.cs.cmu.edu. # @@ -9,9 +9,7 @@ # It also has no support for devices which aren't actually used # (sound, parallel port, keyboard, mouse, SCSI tape or CD-ROM, etc.). -machine alpha - -makeoptions DEBUG="-g" +include "std.alpha" maxusers 8 @@ -34,6 +32,7 @@ options KTRACE # System call tracing support options FIFO # POSIX fifo support (in all file systems) options FFS # Fast file system options MFS # Memory-based file system +options NFSSERVER # Sun NFS-compatible file system server options NFSCLIENT # Sun NFS-compatible file system client # Networking options @@ -42,6 +41,9 @@ options INET # Internet protocol suite # 4.3BSD compatibility. Should be optional, but necessary for now. options COMPAT_43 +# Binary compatibility with previous versions of NetBSD. +options COMPAT_10 + # Loadable Kernel Modules options LKM @@ -49,7 +51,7 @@ options LKM #options INSECURE # Misc. options -options PCIVERBOSE # recognize "unknown" PCI devices +options PCIVERBOSE # recognize "unknown" PCI devices config netbsd root on sd0 swap on sd0 @@ -64,11 +66,11 @@ pci* at apecs? # PCI devices de* at pci? +ncr0 at pci? sio* at pci? -ncr* at pci? -# ISA bus support -isa0 at sio? +# ISA/EISA bus support +isa* at sio? # ISA devices clock0 at isa? port 0x70 diff --git a/sys/arch/alpha/conf/DILLY b/sys/arch/alpha/conf/DILLY new file mode 100644 index 00000000000..b8236ee54ba --- /dev/null +++ b/sys/arch/alpha/conf/DILLY @@ -0,0 +1,96 @@ +# $NetBSD: DILLY,v 1.1 1995/11/23 02:34:58 cgd Exp $ +# +# Kernel for dilrod.nas.nasa.gov, and AlphaStation 600. + +include "std.alpha" + +maxusers 16 + +# bump up the number of buffers, for quicker compiles +options BUFPAGES=2048 # 16M of buffer cache + +# CPU Support +options DEC_KN20AA # KN20AA: AlphaStation 600 + +# needs to be set per system +options TIMEZONE="5*60" # Minutes west of GMT (for param.c) +options DST=1 # Daylight savings rules (for param.c) + +# Standard system options +options SWAPPAGER, VNODEPAGER, DEVPAGER # Paging (mandatory) +options DEBUG, DIAGNOSTIC # Extra kernel debugging +options KTRACE # System call tracing support + +# File system options +options FIFO # POSIX fifo support (in all file systems) +options FFS # Fast file system +options MFS # Memory-based file system +options NFSCLIENT # Sun NFS-compatible file system client + +# Networking options +options INET # Internet protocol suite + +# 4.3BSD compatibility. Should be optional, but necessary for now. +options COMPAT_43 + +# Binary compatibility with previous versions of NetBSD. +options COMPAT_10 + +# Loadable Kernel Modules +options LKM + +# Disable kernel security. +#options INSECURE + +# Misc. options +options PCIVERBOSE # recognize "unknown" PCI devices + +config netbsd root on sd0 swap on sd0 + +mainbus0 at root +cpu* at mainbus0 + +# PCI host bus adapter support +cia* at mainbus? + +# PCI bus support +pci0 at cia? +pci* at ppb? + +# PCI devices +de* at pci? +ncr0 at pci0 dev 9 +ncr* at pci? +pceb* at pci? +pcivga* at pci? +ppb* at pci? +tga* at pci? + +# ISA and EISA bus support +isa* at pceb? +eisa* at pceb? + +# ISA devices +clock0 at isa? port 0x70 +pckbd0 at isa? port 0x60 irq 1 # PC-ish ISA keyboard +#pms0 at isa? port 0x60 irq 12 # PS/2 auxiliary +com0 at isa? port 0x3f8 irq 4 # standard serial ports +com1 at isa? port 0x2f8 irq 3 +lpt0 at isa? port 0x3bc irq 7 # standard parallel port +#wss0 at isa? port 0x530 irq 9 drq 0 # Windows Sound System + +# SCSI bus support +scsibus0 at ncr0 +scsibus* at ncr? + +# SCSI devices +sd0 at scsibus0 target 1 lun 0 +sd* at scsibus? target ? lun ? +st* at scsibus? target ? lun ? +cd* at scsibus? target ? lun ? + +pseudo-device bpfilter +pseudo-device loop +pseudo-device pty +pseudo-device sl +pseudo-device vnd diff --git a/sys/arch/alpha/conf/GENERIC b/sys/arch/alpha/conf/GENERIC index 3f2ebcab3b3..916e67467c6 100644 --- a/sys/arch/alpha/conf/GENERIC +++ b/sys/arch/alpha/conf/GENERIC @@ -1,10 +1,8 @@ -# $NetBSD: GENERIC,v 1.8 1995/08/03 00:09:19 cgd Exp $ +# $NetBSD: GENERIC,v 1.9 1995/11/23 02:35:01 cgd Exp $ # # Generic Alpha kernel. Enough to get booted, etc., but not much more. -machine alpha - -makeoptions DEBUG="-g" +include "std.alpha" maxusers 8 @@ -13,9 +11,11 @@ options GENERIC # CPU Support options DEC_3000_500 # Flamingo etc: 3000/[4-9]00* -options DEC_2000_300 # "Jensen": 2000/300 (DECpc AXP 150) options DEC_3000_300 # Pelican etc: 3000/300* options DEC_2100_A50 # Avanti etc: AlphaStation 400, 200, etc. +options DEC_KN20AA # KN20AA: AlphaStation 600 +options DEC_AXPPCI_33 # NoName: AXPpci33, etc. +#options DEC_2000_300 # "Jensen": 2000/300 (DECpc AXP 150) # needs to be set per system options TIMEZONE="5*60" # Minutes west of GMT (for param.c) @@ -30,6 +30,7 @@ options KTRACE # System call tracing support options FIFO # POSIX fifo support (in all file systems) options FFS # Fast file system options MFS # Memory-based file system +options NFSSERVER # Sun NFS-compatible file system server options NFSCLIENT # Sun NFS-compatible file system client # Networking options @@ -38,6 +39,9 @@ options INET # Internet protocol suite # 4.3BSD compatibility. Should be optional, but necessary for now. options COMPAT_43 +# Binary compatibility with previous versions of NetBSD. +options COMPAT_10 + # OSF/1 binary compatibility -- CURRENTLY DOES NOT WORK #options COMPAT_OSF1 @@ -48,7 +52,7 @@ options LKM #options INSECURE # Misc. options -options PCIVERBOSE # recognize "unknown" PCI devices +options PCIVERBOSE # recognize "unknown" PCI devices config netbsd swap generic @@ -71,21 +75,28 @@ esp1 at tcds? slot ? # PCI host bus adapter support apecs* at mainbus? -#lca* at cpu? +cia* at mainbus? +lca* at mainbus? # PCI bus support pci* at apecs? -#pci* at lca? +pci* at cia? +pci* at lca? +pci* at ppb? # PCI devices de* at pci? -sio* at pci? ncr* at pci? -tga* at pci? +pceb* at pci? pcivga* at pci? +ppb* at pci? +sio* at pci? +tga* at pci? -# ISA bus support -isa0 at sio? +# ISA/EISA bus support +isa* at pceb? +eisa* at pceb? +isa* at sio? # ISA devices clock0 at isa? port 0x70 @@ -94,7 +105,7 @@ pckbd0 at isa? port 0x60 irq 1 # PC-ish ISA keyboard com0 at isa? port 0x3f8 irq 4 # standard serial ports com1 at isa? port 0x2f8 irq 3 lpt0 at isa? port 0x3bc irq 7 # standard parallel port -wss0 at isa? port 0x530 irq 9 drq 0 # Windows Sound System +#wss0 at isa? port 0x530 irq 9 drq 0 # Windows Sound System # SCSI bus support scsibus* at esp? diff --git a/sys/arch/alpha/conf/GENERIC_NFS b/sys/arch/alpha/conf/GENERIC_NFS index 74ed98239c8..d85cfab8627 100644 --- a/sys/arch/alpha/conf/GENERIC_NFS +++ b/sys/arch/alpha/conf/GENERIC_NFS @@ -1,18 +1,18 @@ -# $NetBSD: GENERIC_NFS,v 1.2 1995/08/03 00:09:20 cgd Exp $ +# $NetBSD: GENERIC_NFS,v 1.3 1995/11/23 02:35:06 cgd Exp $ # # Generic Alpha kernel. Enough to get booted, etc., but not much more. -machine alpha - -makeoptions DEBUG="-g" +include "std.alpha" maxusers 8 # CPU Support options DEC_3000_500 # Flamingo etc: 3000/[4-9]00* -options DEC_2000_300 # "Jensen": 2000/300 (DECpc AXP 150) options DEC_3000_300 # Pelican etc: 3000/300* options DEC_2100_A50 # Avanti etc: AlphaStation 400, 200, etc. +options DEC_KN20AA # KN20AA: AlphaStation 600 +options DEC_AXPPCI_33 # NoName: AXPpci33, etc. +#options DEC_2000_300 # "Jensen": 2000/300 (DECpc AXP 150) # needs to be set per system options TIMEZONE="5*60" # Minutes west of GMT (for param.c) @@ -27,6 +27,7 @@ options KTRACE # System call tracing support options FIFO # POSIX fifo support (in all file systems) options FFS # Fast file system options MFS # Memory-based file system +options NFSSERVER # Sun NFS-compatible file system server options NFSCLIENT # Sun NFS-compatible file system client # Networking options @@ -35,6 +36,9 @@ options INET # Internet protocol suite # 4.3BSD compatibility. Should be optional, but necessary for now. options COMPAT_43 +# Binary compatibility with previous versions of NetBSD. +options COMPAT_10 + # OSF/1 binary compatibility -- CURRENTLY DOES NOT WORK #options COMPAT_OSF1 @@ -45,7 +49,7 @@ options LKM #options INSECURE # Misc. options -options PCIVERBOSE # recognize "unknown" PCI devices +options PCIVERBOSE # recognize "unknown" PCI devices config netbsd_nfs root on nfs swap on nfs @@ -68,21 +72,28 @@ esp1 at tcds? slot ? # PCI host bus adapter support apecs* at mainbus? -#lca* at cpu? +cia* at mainbus? +lca* at mainbus? # PCI bus support pci* at apecs? -#pci* at lca? +pci* at cia? +pci* at lca? +pci* at ppb? # PCI devices de* at pci? -sio* at pci? ncr* at pci? -tga* at pci? +pceb* at pci? pcivga* at pci? +ppb* at pci? +sio* at pci? +tga* at pci? -# ISA bus support -isa0 at sio? +# ISA/EISA bus support +isa* at pceb? +eisa* at pceb? +isa* at sio? # ISA devices clock0 at isa? port 0x70 @@ -91,7 +102,7 @@ pckbd0 at isa? port 0x60 irq 1 # PC-ish ISA keyboard com0 at isa? port 0x3f8 irq 4 # standard serial ports com1 at isa? port 0x2f8 irq 3 lpt0 at isa? port 0x3bc irq 7 # standard parallel port -wss0 at isa? port 0x530 irq 9 drq 0 # Windows Sound System +#wss0 at isa? port 0x530 irq 9 drq 0 # Windows Sound System # SCSI bus support scsibus* at esp? diff --git a/sys/arch/alpha/conf/JURA b/sys/arch/alpha/conf/JURA index 10d1afd5823..9de2fa3bf2d 100644 --- a/sys/arch/alpha/conf/JURA +++ b/sys/arch/alpha/conf/JURA @@ -1,10 +1,8 @@ -# $NetBSD: JURA,v 1.3 1995/08/03 00:09:21 cgd Exp $ +# $NetBSD: JURA,v 1.4 1995/11/23 02:35:09 cgd Exp $ # # Kernel for jura.pdl.cs.cmu.edu. -include "std.alpha" - -makeoptions DEBUG="-g" +include "std.alpha" maxusers 8 @@ -34,42 +32,41 @@ options INET # Internet protocol suite # 4.3BSD compatibility. Should be optional, but necessary for now. options COMPAT_43 +# Binary compatibility with previous versions of NetBSD. +options COMPAT_10 + # Loadable Kernel Modules options LKM config netbsd root on nfs swap on nfs -# XXX Unfortunately, configuration isn't as simple as the following, -# because DEC engineers really biffed the DECpc AXP (in my opinion) -# See further below for information about how to really configure -# these systems. +mainbus0 at root + +ibus* at mainbus0 # "internal bus" + +jcombo* at ibus? # the VLSI combo chip +isa* at jcombo? + +clock0 at isa? port 0x70 +pckbd0 at isa? port 0x60 irq 1 # PC-ish ISA keyboard +#pms0 at isa? port 0x60 irq 12 # PS/2 auxiliary +com0 at isa? port 0x3f8 irq 4 # standard serial ports +com1 at isa? port 0x2f8 irq 3 +lpt0 at isa? port 0x3bc irq 7 # standard parallel port +#wss0 at isa? port 0x530 irq 9 drq 0 # Windows Sound System + +jeisa* at ibus? +eisa* at jeisa? +# ahb* at eisa0 EISA devices + +isa* at jeisa? -#isa* at mainbus0 -# -#com0 at isa? port 0x3f8 irq 4 -#com1 at isa? port 0x2f8 irq 3 -# -#ahb0 at isa? -# #scsibus* at scsi? # #sd* at scsibus? target ? lun ? #st* at scsibus? target ? lun ? #cd* at scsibus? target ? lun ? -# They should really look like: - -# ibus0 at mainbus0 "internal bus" -# combo0 at ibus0 the VLSI combo chip -# clock0 at combo0 ... periphs on combo chip -# com0 at combo0 ... . -# com1 at combo0 ... . -# lpt0 at combo0 ... . -# etc. -# eisa0 at ibus0 EISA attached to ibus -# ahb* at eisa0 EISA devices -# etc. - pseudo-device bpfilter pseudo-device loop pseudo-device pty diff --git a/sys/arch/alpha/conf/MACALLAN b/sys/arch/alpha/conf/MACALLAN index 242015d6903..bb81245b754 100644 --- a/sys/arch/alpha/conf/MACALLAN +++ b/sys/arch/alpha/conf/MACALLAN @@ -1,15 +1,13 @@ -# $NetBSD: MACALLAN,v 1.5 1995/08/03 00:09:22 cgd Exp $ +# $NetBSD: MACALLAN,v 1.6 1995/11/23 02:35:13 cgd Exp $ # # Kernel for macallan.dssc.cs.cmu.edu. -machine alpha - -makeoptions DEBUG="-g" +include "std.alpha" maxusers 8 # CPU Support -options DEC_3000_500 # 3000/[4-9]00 +options DEC_3000_500 # Flamingo etc: 3000/[4-9]00* # needs to be set per system options TIMEZONE="5*60" # Minutes west of GMT (for param.c) @@ -32,16 +30,21 @@ options INET # Internet protocol suite # 4.3BSD compatibility. Should be optional, but necessary for now. options COMPAT_43 +# Binary compatibility with previous versions of NetBSD. +options COMPAT_10 + # Loadable Kernel Modules options LKM config netbsd root on sd0 swap on sd0 and sd1 mainbus0 at root - cpu* at mainbus0 +# TurboChannel bus support tc* at mainbus0 + +# TurboChannel devices asic0 at tc? slot ? offset ? clock0 at asic? offset ? le0 at asic? offset ? @@ -52,9 +55,11 @@ esp0 at tcds? slot ? esp1 at tcds? slot ? #sfb* at tc? slot ? offset ? +# SCSI bus support scsibus0 at esp0 scsibus* at esp? +# SCSI devices sd0 at scsibus0 target 0 lun 0 sd* at scsibus? target ? lun ? st* at scsibus? target ? lun ? diff --git a/sys/arch/alpha/conf/Makefile.alpha b/sys/arch/alpha/conf/Makefile.alpha index 4d1ef6f0cb8..e6dd45bd03e 100644 --- a/sys/arch/alpha/conf/Makefile.alpha +++ b/sys/arch/alpha/conf/Makefile.alpha @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.alpha,v 1.7 1995/09/19 23:28:06 thorpej Exp $ +# $NetBSD: Makefile.alpha,v 1.8 1995/11/23 02:35:16 cgd Exp $ # # Makefile for NetBSD # @@ -34,7 +34,8 @@ ALPHA= ../.. INCLUDES= -I. -I$S/arch -I$S -I$S/sys COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -CFLAGS= -Werror -mno-fp-regs ${DEBUG} ${COPTS} -Dalpha +CFLAGS= -Werror -fno-builtin -mno-fp-regs ${DEBUG} ${COPTS} -Dalpha +#CFLAGS+=-Wmissing-prototypes -Wmissing-declarations AFLAGS= ${COPTS} ### find out what to use for libkern @@ -90,10 +91,15 @@ SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ SYSTEM_LD= -@echo ${LD} ${LDFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ${XXX}; \ ${LD} ${LDFLAGS} -o $@ ${SYSTEM_OBJ} vers.o ${XXX} SYSTEM_LD_TAIL= @size $@; chmod 755 $@ -#.if ${DEBUG} == "-g" -#SYSTEM_LD_TAIL+=; echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \ -# echo strip -d $@; strip -d $@ -#.endif +.if ${DEBUG} == "-g" +.if 0 +SYSTEM_LD_TAIL+=; echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \ + echo strip -d $@; strip -d $@ +.else +SYSTEM_LD_TAIL+=; echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \ + echo strip -g -X -x $@; strip -g -X -x $@ +.endif +.endif %LOAD @@ -107,7 +113,7 @@ clean:: locore.o: ${ALPHA}/alpha/locore.s ${ALPHA}/alpha/pal.s \ - ${ALPHA}/alpha/prom_disp.s assym.s + ${ALPHA}/alpha/prom_disp.s ${ALPHA}/include/intrcnt.h assym.s ${NORMAL_S_C} # depend on maxusers diff --git a/sys/arch/alpha/conf/NONAME b/sys/arch/alpha/conf/NONAME new file mode 100644 index 00000000000..9bbe12ec924 --- /dev/null +++ b/sys/arch/alpha/conf/NONAME @@ -0,0 +1,89 @@ +# $NetBSD: NONAME,v 1.1 1995/11/23 02:35:20 cgd Exp $ +# +# Should work on AXPpci33's (and maybe other AXPpci machines). + +include "std.alpha" + +maxusers 8 + +# CPU Support +options DEC_AXPPCI_33 # NoName: AXPpci33, etc. + +# needs to be set per system +options TIMEZONE="5*60" # Minutes west of GMT (for param.c) +options DST=1 # Daylight savings rules (for param.c) + +# Standard system options +options SWAPPAGER, VNODEPAGER, DEVPAGER # Paging (mandatory) +options DEBUG, DIAGNOSTIC # Extra kernel debugging +options KTRACE # System call tracing support + +# File system options +options FIFO # POSIX fifo support (in all file systems) +options FFS # Fast file system +options MFS # Memory-based file system +options NFSCLIENT # Sun NFS-compatible file system client + +# Networking options +options INET # Internet protocol suite + +# 4.3BSD compatibility. Should be optional, but necessary for now. +options COMPAT_43 + +# Binary compatibility with previous versions of NetBSD. +options COMPAT_10 + +# Loadable Kernel Modules +options LKM + +# Disable kernel security. +#options INSECURE + +# Misc. options +options PCIVERBOSE # recognize "unknown" PCI devices + +config netbsd root on sd0 swap on sd0 + +mainbus0 at root +cpu* at mainbus0 + +# PCI host bus adapter support +lca* at mainbus? + +# PCI bus support +pci* at lca? +pci* at ppb? + +# PCI devices +de* at pci? +ncr* at pci? +pcivga* at pci? +ppb* at pci? +sio* at pci? +tga* at pci? + +# ISA/EISA bus support +isa* at sio? + +# ISA devices +clock0 at isa? port 0x70 +pckbd0 at isa? port 0x60 irq 1 # PC-ish ISA keyboard +#pms0 at isa? port 0x60 irq 12 # PS/2 auxiliary +com0 at isa? port 0x3f8 irq 4 # standard serial ports +com1 at isa? port 0x2f8 irq 3 +lpt0 at isa? port 0x3bc irq 7 # standard parallel port +#wss0 at isa? port 0x530 irq 9 drq 0 # Windows Sound System + +# SCSI bus support +scsibus* at ncr? + +# SCSI devices +sd* at scsibus? target ? lun ? +st* at scsibus? target ? lun ? +cd* at scsibus? target ? lun ? + +pseudo-device bpfilter +pseudo-device loop +pseudo-device pty +pseudo-device sl +pseudo-device vnd diff --git a/sys/arch/alpha/conf/TOMMY b/sys/arch/alpha/conf/TOMMY index 5d8c625b54c..e97ca816a92 100644 --- a/sys/arch/alpha/conf/TOMMY +++ b/sys/arch/alpha/conf/TOMMY @@ -1,11 +1,9 @@ -# $NetBSD: TOMMY,v 1.1 1995/08/03 00:09:24 cgd Exp $ +# $NetBSD: TOMMY,v 1.3 1995/11/25 01:32:34 cgd Exp $ # # Kernel for tomintoul.pdl.cs.cmu.edu. # Should work on AlphaStation 400s and AlphaStation 200s -machine alpha - -makeoptions DEBUG="-g" +include "std.alpha" maxusers 8 @@ -25,6 +23,7 @@ options KTRACE # System call tracing support options FIFO # POSIX fifo support (in all file systems) options FFS # Fast file system options MFS # Memory-based file system +options NFSSERVER # Sun NFS-compatible file system server options NFSCLIENT # Sun NFS-compatible file system client # Networking options @@ -33,6 +32,9 @@ options INET # Internet protocol suite # 4.3BSD compatibility. Should be optional, but necessary for now. options COMPAT_43 +# Binary compatibility with previous versions of NetBSD. +options COMPAT_10 + # Loadable Kernel Modules options LKM @@ -40,7 +42,7 @@ options LKM #options INSECURE # Misc. options -options PCIVERBOSE # recognize "unknown" PCI devices +options PCIVERBOSE # recognize "unknown" PCI devices config netbsd root on sd0 swap on sd0 @@ -49,21 +51,21 @@ cpu* at mainbus0 # PCI host bus adapter support apecs* at mainbus? -#lca* at cpu? # PCI bus support pci* at apecs? -#pci* at lca? +pci* at ppb? # PCI devices de* at pci? +ncr0 at pci? +pcivga* at pci? +ppb* at pci? sio* at pci? -ncr* at pci? tga* at pci? -pcivga* at pci? -# ISA bus support -isa0 at sio? +# ISA/EISA bus support +isa* at sio? # ISA devices clock0 at isa? port 0x70 @@ -72,7 +74,7 @@ pckbd0 at isa? port 0x60 irq 1 # PC-ish ISA keyboard com0 at isa? port 0x3f8 irq 4 # standard serial ports com1 at isa? port 0x2f8 irq 3 lpt0 at isa? port 0x3bc irq 7 # standard parallel port -wss0 at isa? port 0x530 irq 9 drq 0 # Windows Sound System +#wss0 at isa? port 0x530 irq 9 drq 0 # Windows Sound System # SCSI bus support scsibus* at ncr? diff --git a/sys/arch/alpha/conf/files.alpha b/sys/arch/alpha/conf/files.alpha index e863926f69a..38253efb2dd 100644 --- a/sys/arch/alpha/conf/files.alpha +++ b/sys/arch/alpha/conf/files.alpha @@ -1,4 +1,4 @@ -# $NetBSD: files.alpha,v 1.7 1995/09/20 00:20:18 thorpej Exp $ +# $NetBSD: files.alpha,v 1.8 1995/11/23 02:35:27 cgd Exp $ # # alpha-specific configuration info @@ -17,6 +17,7 @@ device mainbus at root { } # no locators (yet?) device cpu at mainbus { } # not really optional; can be a 'bus' file arch/alpha/alpha/cpu.c cpu + # # Machine-independent SCSI drivers # @@ -26,21 +27,26 @@ major { st = 2 } major { cd = 3 } major { sd = 8 } + # # ansi/sun console emulator # + define ansicons file dev/pseudo/ansicons.c ansicons + # # raster console routines # + +include "../../../dev/rcons/files.rcons" + define rcons -file dev/pseudo/raster_op.c rcons -file dev/pseudo/raster_text.c rcons file dev/pseudo/rcons_init.c rcons file dev/pseudo/rcons_subr.c rcons + # # "Workstation Console" glue; attaches frame buffer to emulator & kbd. # XXX should be pseudo-device, with an ansicons attribute. @@ -48,6 +54,7 @@ file dev/pseudo/rcons_subr.c rcons define wsc # XXX should be pseudo-dev file arch/alpha/pci/wscons.c wsc needs-flag + # # TurboChannel Devices # @@ -60,7 +67,7 @@ file arch/alpha/tc/tc_3000_500.c dec_3000_500 # the TurboChannel IOCTL ASIC device asic at tc { offset = -1 } # not really optional -file arch/alpha/tc/asic.c asic +file arch/alpha/tc/asic.c asic needs-flag # the TurboChannel clock (XXX) # device clock at asic # not really optional @@ -87,33 +94,73 @@ file arch/alpha/tc/tcds_dma.c esp device le at asic: ifnet, ether file arch/alpha/tc/if_le.c le needs-count + +# +# ISA Bus support +# + +include "../../../dev/isa/files.isa" + +#file arch/alpha/isa/isafcns_jensen.c dec_2000_300 + + # -# PCI-bearing chipsets and "necessary" files. +# ISA Bus devices # -device apecs at mainbus { } +device ibus at mainbus { } +device jcombo at ibus: isabus +device jeisa at ibus: eisabus + +device pckbd at isa +file arch/alpha/isa/pckbd.c pckbd needs-flag +device pms at isa +file arch/alpha/isa/pms.c pms needs-flag + + +# +# EISA Bus support +# + +include "../../../dev/eisa/files.eisa" + + +# +# PCI Bus support +# + +include "../../../dev/pci/files.pci" + +device apecs at mainbus: pcibus file arch/alpha/pci/apecs.c apecs file arch/alpha/pci/apecs_isa.c apecs file arch/alpha/pci/apecs_pci.c apecs -device lca at cpu { } +device cia at mainbus: pcibus +file arch/alpha/pci/cia.c cia +file arch/alpha/pci/cia_isa.c cia +file arch/alpha/pci/cia_pci.c cia + +device lca at mainbus: pcibus file arch/alpha/pci/lca.c lca -file arch/alpha/pci/lca_pio.c lca +file arch/alpha/pci/lca_isa.c lca +file arch/alpha/pci/lca_pci.c lca file arch/alpha/pci/pci_2100_a50.c dec_2100_a50 +file arch/alpha/pci/pci_kn20aa.c dec_kn20aa +file arch/alpha/pci/pci_axppci_33.c dec_axppci_33 + # -# PCI devices +# PCI Bus devices # -device pci at apecs, lca {[bus = -1], [dev = -1]} - -include "../../../dev/pci/files.pci" file arch/alpha/pci/pci_machdep.c pci -device sio at pci { } -file arch/alpha/pci/sio.c sio -file arch/alpha/pci/sio_pic.c sio +device sio at pci: isabus +device pceb at pci: eisabus +file arch/alpha/pci/sio.c sio pceb needs-flag +file arch/alpha/pci/sio_pic.c sio pceb device tga at pci: rcons, wsc, ansicons file arch/alpha/pci/tga.c tga needs-flag @@ -121,31 +168,16 @@ file arch/alpha/pci/tga.c tga needs-flag device pcivga at pci: wsc, ansicons file arch/alpha/pci/pcivga.c pcivga needs-flag -# -# ISA Devices -# - -device isa at sio {[port = -1], [size = 0], # XXX - [iomem = -1], [iosiz = 0], - [irq = -1], [drq = -1]} -device clock at isa, asic # not really optional - -include "../../../dev/isa/files.isa" -file arch/alpha/isa/isa_machdep.c isa needs-flag # XXX - -#file arch/alpha/isa/isafcns_jensen.c dec_2000_300 - -device pckbd at isa -file arch/alpha/isa/pckbd.c pckbd needs-flag -device pms at isa -file arch/alpha/isa/pms.c pms needs-flag - # -# EISA Devices +# Devices that can live on multiple busses # -#include "../../../dev/eisa/files.eisa" +device clock at isa, asic # not really optional +file arch/alpha/alpha/clock.c clock +file arch/alpha/alpha/clock_mc.c dec_3000_500 dec_2000_300 dec_3000_300 + dec_2100_a50 dec_kn20aa dec_axppci_33 + dec_21000 # # Standard files @@ -168,23 +200,23 @@ file arch/alpha/alpha/disksubr.c file dev/cons.c file netinet/in_cksum.c + # -# Optional files +# Optional/miscellaneous files # file netns/ns_cksum.c ns -file arch/alpha/alpha/clock.c clock -file arch/alpha/alpha/clock_mc.c dec_3000_500 dec_2000_300 dec_3000_300 - dec_2100_a50 - # XXX file arch/alpha/alpha/promcons.c # XXX -file arch/alpha/alpha/dec_3000_500.c dec_3000_500 -file arch/alpha/alpha/dec_3000_300.c dec_3000_300 -file arch/alpha/alpha/dec_2100_a50.c dec_2100_a50 +file arch/alpha/alpha/dec_3000_500.c dec_3000_500 +file arch/alpha/alpha/dec_3000_300.c dec_3000_300 +file arch/alpha/alpha/dec_2100_a50.c dec_2100_a50 +file arch/alpha/alpha/dec_kn20aa.c dec_kn20aa +file arch/alpha/alpha/dec_axppci_33.c dec_axppci_33 +file arch/alpha/alpha/dec_21000.c dec_21000 # OSF/1 Binary Compatibility (COMPAT_OSF1) include "../../../compat/osf1/files.osf1" diff --git a/sys/arch/alpha/conf/std.alpha b/sys/arch/alpha/conf/std.alpha new file mode 100644 index 00000000000..d687ec824f4 --- /dev/null +++ b/sys/arch/alpha/conf/std.alpha @@ -0,0 +1,9 @@ +# $NetBSD: std.alpha,v 1.4 1995/11/25 01:34:38 cgd Exp $ +# +# Standard/required configuration info for NetBSD/alpha. + +machine alpha + +makeoptions DEBUG="-g" + +options EXEC_ECOFF diff --git a/sys/arch/alpha/include/ansi.h b/sys/arch/alpha/include/ansi.h index c3e6e2bfbf4..7502ca628f9 100644 --- a/sys/arch/alpha/include/ansi.h +++ b/sys/arch/alpha/include/ansi.h @@ -1,4 +1,4 @@ -/* $NetBSD: ansi.h,v 1.2 1995/02/16 03:08:04 cgd Exp $ */ +/* $NetBSD: ansi.h,v 1.3 1995/11/23 02:35:41 cgd Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -52,11 +52,11 @@ #define _BSD_SIZE_T_ unsigned long /* sizeof() */ #define _BSD_SSIZE_T_ long /* byte count or error */ #define _BSD_TIME_T_ int /* time() */ -struct __va_list { +typedef struct { char *base; long offset; -}; -#define _BSD_VA_LIST_ struct __va_list /* va_list */ +} __va_list; +#define _BSD_VA_LIST_ __va_list /* va_list */ /* * Runes (wchar_t) is declared to be an ``int'' instead of the more natural diff --git a/sys/arch/alpha/include/asm.h b/sys/arch/alpha/include/asm.h index 4283fbe52cc..e76b4c586a1 100644 --- a/sys/arch/alpha/include/asm.h +++ b/sys/arch/alpha/include/asm.h @@ -1,4 +1,4 @@ -/* $NetBSD: asm.h,v 1.1 1995/02/13 23:07:30 cgd Exp $ */ +/* $NetBSD: asm.h,v 1.2 1995/11/23 02:35:45 cgd Exp $ */ /* * Copyright (c) 1991,1990,1989,1994,1995 Carnegie Mellon University @@ -194,6 +194,28 @@ * */ +/* + * MCOUNT + */ + +#ifndef PROF +#define MCOUNT /* nothing */ +#else +#define MCOUNT \ + lda sp, -16(sp); \ + stq pv, 0(sp); \ + \ + br pv, 1f; \ +1: ldgp gp, 0(pv); \ + lda pv, _mcount; \ + jsr at_reg, (pv); \ + br pv, 2f; \ +2: ldgp gp, 0(pv); \ + \ + ldq pv, 0(sp); \ + lda sp, 16(sp) +#endif + /* * LEAF * Declare a global leaf function. @@ -204,6 +226,17 @@ #define LEAF(_name_,_n_args_) \ .globl _name_; \ .ent _name_ 0; \ +_name_:; \ + .frame sp,0,ra; \ + MCOUNT +/* should have been + .proc _name_,_n_args_; \ + .frame 0,ra,0,0 +*/ + +#define LEAF_NOPROFILE(_name_,_n_args_) \ + .globl _name_; \ + .ent _name_ 0; \ _name_:; \ .frame sp,0,ra /* should have been @@ -218,7 +251,8 @@ _name_:; \ #define STATIC_LEAF(_name_,_n_args_) \ .ent _name_ 0; \ _name_:; \ - .frame sp,0,ra + .frame sp,0,ra; \ + MCOUNT /* should have been .proc _name_,_n_args_; \ .frame 0,ra,0,0 @@ -255,6 +289,18 @@ _name_: #define NESTED(_name_, _n_args_, _framesize_, _pc_reg_, _i_mask_, _f_mask_ ) \ .globl _name_; \ .ent _name_ 0; \ +_name_:; \ + .frame sp,_framesize_,_pc_reg_; \ + .livereg _i_mask_,_f_mask_; \ + MCOUNT +/* should have been + .proc _name_,_n_args_; \ + .frame _framesize_, _pc_reg_, _i_mask_, _f_mask_ +*/ + +#define NESTED_NOPROFILE(_name_, _n_args_, _framesize_, _pc_reg_, _i_mask_, _f_mask_ ) \ + .globl _name_; \ + .ent _name_ 0; \ _name_:; \ .frame sp,_framesize_,_pc_reg_; \ .livereg _i_mask_,_f_mask_ @@ -271,7 +317,8 @@ _name_:; \ .ent _name_ 0; \ _name_:; \ .frame sp,_framesize_,_pc_reg_; \ - .livereg _i_mask_,_f_mask_ + .livereg _i_mask_,_f_mask_; \ + MCOUNT /* should have been .proc _name_,_n_args_; \ .frame _framesize_, _pc_reg_, _i_mask_, _f_mask_ @@ -385,11 +432,7 @@ _name_:; \ * MSG * Allocate space for a message (a read-only ascii string) */ -#ifdef __ALPHA_AS__ -#define ASCIZ .asciiz -#else #define ASCIZ .asciz -#endif #define MSG(msg,reg) \ lda reg, 9f; \ .data; \ @@ -555,15 +598,8 @@ _name_:; \ */ #define SETGP(pv) ldgp gp,0(pv) -#ifdef __ALPHA_AS__ -#define MF_FPCR(x) mf_fpcr x,x,x -#define MT_FPCR(x) mt_fpcr x,x,x -#define JMP(loc) jmp loc -#define CONST(c,reg) mov c, reg -#else #define MF_FPCR(x) mf_fpcr x #define MT_FPCR(x) mt_fpcr x #define JMP(loc) br zero,loc #define CONST(c,reg) ldiq reg, c -#endif diff --git a/sys/arch/alpha/include/autoconf.h b/sys/arch/alpha/include/autoconf.h index 167a214e34b..d4a10dd402f 100644 --- a/sys/arch/alpha/include/autoconf.h +++ b/sys/arch/alpha/include/autoconf.h @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.h,v 1.1 1995/02/13 23:07:31 cgd Exp $ */ +/* $NetBSD: autoconf.h,v 1.2 1995/11/23 02:35:50 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -69,6 +69,10 @@ struct confargs { struct abus *ca_bus; /* bus device resides on. */ }; -void set_clockintr __P((void (*)(struct clockframe *))); +void set_clockintr __P((void)); void set_iointr __P((void (*)(void *, int))); int badaddr __P((void *, u_int64_t)); + +#ifdef EVCNT_COUNTERS +extern struct evcnt clock_intr_evcnt; +#endif diff --git a/sys/arch/alpha/include/db_machdep.h b/sys/arch/alpha/include/db_machdep.h new file mode 100644 index 00000000000..986bfeb672f --- /dev/null +++ b/sys/arch/alpha/include/db_machdep.h @@ -0,0 +1,56 @@ +/* $NetBSD: db_machdep.h,v 1.1 1995/11/23 02:35:54 cgd Exp $ */ + +/* + * Copyright (c) 1995 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. + */ + +#ifndef _ALPHA_DB_MACHDEP_H_ +#define _ALPHA_DB_MACHDEP_H_ + +/* + * Machine-dependent defines for new kernel debugger. + */ + +#include +#include +#include + +typedef vm_offset_t db_addr_t; /* address - unsigned */ +typedef long db_expr_t; /* expression - signed */ + +typedef struct trapframe db_regs_t; +db_regs_t ddb_regs; /* register state */ +#define DDB_REGS (&ddb_regs) + +#define PC_REGS(regs) ((db_addr_t)(regs)->tf_pc) + +#define BKPT_INST 0x00000080 /* breakpoint instruction */ +#define BKPT_SIZE (4) /* size of breakpoint inst */ +#define BKPT_SET(inst) (BKPT_INST) + +#define FIXUP_PC_AFTER_BREAK ddb_regs.tf_pc -= BKPT_SIZE; + +#endif /* _ALPHA_DB_MACHDEP_H_ */ diff --git a/sys/arch/alpha/include/ecoff.h b/sys/arch/alpha/include/ecoff.h index c67b3286f16..b8fff03678f 100644 --- a/sys/arch/alpha/include/ecoff.h +++ b/sys/arch/alpha/include/ecoff.h @@ -1,4 +1,4 @@ -/* $NetBSD: ecoff.h,v 1.1 1995/02/13 23:07:35 cgd Exp $ */ +/* $NetBSD: ecoff.h,v 1.2 1995/11/23 02:35:57 cgd Exp $ */ /* * Copyright (c) 1994 Adam Glass @@ -48,3 +48,45 @@ ex->ef_magic != ECOFF_MAGIC_NETBSD_ALPHA) #define ECOFF_SEGMENT_ALIGNMENT(eap) (eap->ea_vstamp < 23 ? 8 : 16) + +struct ecoff_symhdr { + int16_t sh_magic; + int16_t sh_vstamp; + int32_t sh_linemax; + int32_t sh_densenummax; + int32_t sh_procmax; + int32_t sh_lsymmax; + int32_t sh_optsymmax; + int32_t sh_auxxymmax; + int32_t sh_lstrmax; + int32_t sh_estrmax; + int32_t sh_fdmax; + int32_t sh_rfdmax; + int32_t sh_esymmax; + long sh_linesize; + long sh_lineoff; + long sh_densenumoff; + long sh_procoff; + long sh_lsymoff; + long sh_optsymoff; + long sh_auxsymoff; + long sh_lstroff; + long sh_estroff; + long sh_fdoff; + long sh_rfdoff; + long sh_esymoff; +}; + +struct ecoff_extsym { + long es_value; + int es_strindex; + unsigned es_type:6; + unsigned es_class:5; + unsigned :1; + unsigned es_symauxindex:20; + unsigned es_jmptbl:1; + unsigned es_cmain:1; + unsigned es_weakext:1; + unsigned :29; + int es_indexfld; +}; diff --git a/sys/arch/alpha/include/eisa_machdep.h b/sys/arch/alpha/include/eisa_machdep.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/sys/arch/alpha/include/intrcnt.h b/sys/arch/alpha/include/intrcnt.h new file mode 100644 index 00000000000..abf39d0fc9c --- /dev/null +++ b/sys/arch/alpha/include/intrcnt.h @@ -0,0 +1,68 @@ + + +#define INTRNAMES_DEFINITION \ +/* 0x00 */ ASCIZ "clock"; \ + ASCIZ "isa irq 0"; \ + ASCIZ "isa irq 1"; \ + ASCIZ "isa irq 2"; \ + ASCIZ "isa irq 3"; \ + ASCIZ "isa irq 4"; \ + ASCIZ "isa irq 5"; \ + ASCIZ "isa irq 6"; \ + ASCIZ "isa irq 7"; \ + ASCIZ "isa irq 8"; \ + ASCIZ "isa irq 9"; \ + ASCIZ "isa irq 10"; \ + ASCIZ "isa irq 11"; \ + ASCIZ "isa irq 12"; \ + ASCIZ "isa irq 13"; \ + ASCIZ "isa irq 14"; \ +/* 0x10 */ ASCIZ "isa irq 15"; \ + ASCIZ "kn20aa irq 0"; \ + ASCIZ "kn20aa irq 1"; \ + ASCIZ "kn20aa irq 2"; \ + ASCIZ "kn20aa irq 3"; \ + ASCIZ "kn20aa irq 4"; \ + ASCIZ "kn20aa irq 5"; \ + ASCIZ "kn20aa irq 6"; \ + ASCIZ "kn20aa irq 7"; \ + ASCIZ "kn20aa irq 8"; \ + ASCIZ "kn20aa irq 9"; \ + ASCIZ "kn20aa irq 10"; \ + ASCIZ "kn20aa irq 11"; \ + ASCIZ "kn20aa irq 12"; \ + ASCIZ "kn20aa irq 13"; \ + ASCIZ "kn20aa irq 14"; \ +/* 0x20 */ ASCIZ "kn20aa irq 15"; \ + ASCIZ "kn20aa irq 16"; \ + ASCIZ "kn20aa irq 17"; \ + ASCIZ "kn20aa irq 18"; \ + ASCIZ "kn20aa irq 19"; \ + ASCIZ "kn20aa irq 20"; \ + ASCIZ "kn20aa irq 21"; \ + ASCIZ "kn20aa irq 22"; \ + ASCIZ "kn20aa irq 23"; \ + ASCIZ "kn20aa irq 24"; \ + ASCIZ "kn20aa irq 25"; \ + ASCIZ "kn20aa irq 26"; \ + ASCIZ "kn20aa irq 27"; \ + ASCIZ "kn20aa irq 28"; \ + ASCIZ "kn20aa irq 29"; \ + ASCIZ "kn20aa irq 30"; \ +/* 0x30 */ ASCIZ "kn20aa irq 31"; + +#define INTRCNT_DEFINITION \ +/* 0x00 */ .quad 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; \ +/* 0x10 */ .quad 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; \ +/* 0x20 */ .quad 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; \ +/* 0x30 */ .quad 0; + +#define INTRCNT_CLOCK 0 +#define INTRCNT_ISA_IRQ (INTRCNT_CLOCK + 1) +#define INTRCNT_ISA_IRQ_LEN 16 +#define INTRCNT_KN20AA_IRQ (INTRCNT_ISA_IRQ + INTRCNT_ISA_IRQ_LEN) +#define INTRCNT_KN20AA_IRQ_LEN 32 + +#ifndef LOCORE +extern long intrcnt[]; +#endif diff --git a/sys/arch/alpha/include/isa_machdep.h b/sys/arch/alpha/include/isa_machdep.h new file mode 100644 index 00000000000..a5636e42f51 --- /dev/null +++ b/sys/arch/alpha/include/isa_machdep.h @@ -0,0 +1,31 @@ +/* $NetBSD: isa_machdep.h,v 1.1 1995/11/23 02:36:11 cgd Exp $ */ + +/* + * Copyright (c) 1995 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. + */ + +/* not __ISA_MACHDEP_PIO_DEFINITIONS__ */ +/* not __ISA_MACHDEP_MEM_DEFINITIONS__ */ diff --git a/sys/arch/alpha/include/param.h b/sys/arch/alpha/include/param.h index 85a1b3e7925..7dbf026a91a 100644 --- a/sys/arch/alpha/include/param.h +++ b/sys/arch/alpha/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.8 1995/08/13 00:03:11 mycroft Exp $ */ +/* $NetBSD: param.h,v 1.9 1995/11/23 02:36:15 cgd Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -70,7 +70,7 @@ #define NBSEG (1 << SEGSHIFT) /* bytes/segment (8M) */ #define SEGOFSET (NBSEG-1) /* byte off. into seg */ -#define KERNBASE 0xfffffe0000000000 /* start of kernel virtual */ +#define KERNBASE 0xfffffc0000230000 /* start of kernel virtual */ #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) #define DEV_BSIZE 512 diff --git a/sys/arch/alpha/include/pci_machdep.h b/sys/arch/alpha/include/pci_machdep.h new file mode 100644 index 00000000000..5e474e396d2 --- /dev/null +++ b/sys/arch/alpha/include/pci_machdep.h @@ -0,0 +1,36 @@ +/* $NetBSD: pci_machdep.h,v 1.1 1995/11/23 02:36:19 cgd Exp $ */ + +/* + * Copyright (c) 1995 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. + */ +/* + * Machine-specific definitions for PCI autoconfiguration. + */ + +/* + * Configuration tag. + */ +typedef u_long pci_tag_t; diff --git a/sys/arch/alpha/include/pio.h b/sys/arch/alpha/include/pio.h deleted file mode 100644 index 9fd16f4af20..00000000000 --- a/sys/arch/alpha/include/pio.h +++ /dev/null @@ -1,88 +0,0 @@ -/* $NetBSD: pio.h,v 1.1 1995/06/28 01:16:33 cgd Exp $ */ - -/* - * Copyright (c) 1995 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. - */ - -/* Prototypes for ISA-ish I/O space access functions. */ - -/* - * XXX - * XXX THIS WILL LIKELY HAVE TO BE COMPLETELY CHANGED. - * XXX e.g. to take softc for bus. - * XXX - */ - -struct isa_pio_fcns { - /* input functions */ - u_int8_t (*isa_inb) __P((int port)); - void (*isa_insb) __P((int port, void *addr, int cnt)); - u_int16_t (*isa_inw) __P((int port)); - void (*isa_insw) __P((int port, void *addr, int cnt)); - u_int32_t (*isa_inl) __P((int port)); - void (*isa_insl) __P((int port, void *addr, int cnt)); - - /* output functions */ - void (*isa_outb) __P((int port, u_int8_t datum)); - void (*isa_outsb) __P((int port, void *addr, int cnt)); - void (*isa_outw) __P((int port, u_int16_t datum)); - void (*isa_outsw) __P((int port, void *addr, int cnt)); - void (*isa_outl) __P((int port, u_int32_t datum)); - void (*isa_outsl) __P((int port, void *addr, int cnt)); -}; - -/* - * Global which tells which set of functions are correct - * for this machine. - */ -struct isa_pio_fcns *isa_pio_fcns; - -/* - * Individual chipsets' versions. - */ -extern struct isa_pio_fcns apecs_pio_fcns; -extern struct isa_pio_fcns jensen_pio_fcns; - - -/* - * macros to use input functions - */ -#define inb(p) (*isa_pio_fcns->isa_inb)(p) -#define insb(p, a, c) (*isa_pio_fcns->isa_insb)(p, a, c) -#define inw(p) (*isa_pio_fcns->isa_inw)(p) -#define insw(p, a, c) (*isa_pio_fcns->isa_insw)(p, a, c) -#define inl(p) (*isa_pio_fcns->isa_inl)(p) -#define insl(p, a, c) (*isa_pio_fcns->isa_insl)(p, a, c) - -/* - * macros to use output functions - */ -#define outb(p, d) (*isa_pio_fcns->isa_outb)(p, d) -#define outsb(p, a, c) (*isa_pio_fcns->isa_outsb)(p, a, c) -#define outw(p, d) (*isa_pio_fcns->isa_outw)(p, d) -#define outsw(p, a, c) (*isa_pio_fcns->isa_outsw)(p, a, c) -#define outl(p, d) (*isa_pio_fcns->isa_outl)(p, d) -#define outsl(p, a, c) (*isa_pio_fcns->isa_outsl)(p, a, c) diff --git a/sys/arch/alpha/include/pmap.h b/sys/arch/alpha/include/pmap.h index 4339565011f..1b74e2317d6 100644 --- a/sys/arch/alpha/include/pmap.h +++ b/sys/arch/alpha/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.3 1995/04/10 12:41:38 mycroft Exp $ */ +/* $NetBSD: pmap.h,v 1.4 1995/11/23 02:36:25 cgd Exp $ */ /* * Copyright (c) 1987 Carnegie-Mellon University @@ -100,6 +100,12 @@ typedef struct pv_entry { #define PV_PTPAGE 0x01 /* header: entry maps a page table page */ +/* + * bits of pmap_attributes[] + */ +#define PMAP_ATTR_MOD 0x01 /* modified */ +#define PMAP_ATTR_REF 0x02 /* referenced */ + #ifdef _KERNEL pv_entry_t pv_table; /* array of entries, one per page */ @@ -111,6 +117,10 @@ pv_entry_t pv_table; /* array of entries, one per page */ extern pt_entry_t *Sysmap; extern char *vmmap; /* map for mem, dumps, etc. */ + +/* Machine-specific functions. */ +void pmap_emulate_reference __P((struct proc *p, vm_offset_t v, + int user, int write)); #endif /* _KERNEL */ #endif /* _PMAP_MACHINE_ */ diff --git a/sys/arch/alpha/include/profile.h b/sys/arch/alpha/include/profile.h index d3ba252db6f..08cebcd3359 100644 --- a/sys/arch/alpha/include/profile.h +++ b/sys/arch/alpha/include/profile.h @@ -1,4 +1,4 @@ -/* $NetBSD: profile.h,v 1.2 1995/03/28 18:13:57 jtc Exp $ */ +/* $NetBSD: profile.h,v 1.3 1995/11/23 02:36:28 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -27,13 +27,189 @@ * rights to redistribute these changes. */ -/* XXX XXX XXX XXX XXX */ +#define _MCOUNT_DECL void mcount -#define MCOUNT \ -extern void mcount() /* XXX asm("mcount") */; void mcount() { \ -} +#if 0 +/* + * XXX The definition of MCOUNT below is really the following code, run + * XXX through cpp, since the inline assembly isn't preprocessed. + */ +#define OFFSET_AT 0 +#define OFFSET_V0 8 +#define OFFSET_T0 16 +#define OFFSET_T1 24 +#define OFFSET_T2 32 +#define OFFSET_T3 40 +#define OFFSET_T4 48 +#define OFFSET_T5 56 +#define OFFSET_T6 64 +#define OFFSET_T7 72 +#define OFFSET_S6 80 +#define OFFSET_A0 88 +#define OFFSET_A1 96 +#define OFFSET_A2 104 +#define OFFSET_A3 112 +#define OFFSET_A4 120 +#define OFFSET_A5 128 +#define OFFSET_T8 136 +#define OFFSET_T9 144 +#define OFFSET_T10 152 +#define OFFSET_T11 160 +#define OFFSET_RA 168 +#define OFFSET_T12 176 +#define OFFSET_GP 184 +#define FRAME_SIZE 192 + +LEAF(_mcount,0) /* XXX */ + .set noat + .set noreorder + + lda sp, -FRAME_SIZE(sp) + + stq at_reg, OFFSET_AT(sp) + stq v0, OFFSET_V0(sp) + stq t0, OFFSET_T0(sp) + stq t1, OFFSET_T1(sp) + stq t2, OFFSET_T2(sp) + stq t3, OFFSET_T3(sp) + stq t4, OFFSET_T4(sp) + stq t5, OFFSET_T5(sp) + stq t6, OFFSET_T6(sp) + stq t7, OFFSET_T7(sp) + stq s6, OFFSET_S6(sp) /* XXX because run _after_ prologue. */ + stq a0, OFFSET_A0(sp) + stq a1, OFFSET_A1(sp) + stq a2, OFFSET_A2(sp) + stq a3, OFFSET_A3(sp) + stq a4, OFFSET_A4(sp) + stq a5, OFFSET_A5(sp) + stq t8, OFFSET_T8(sp) + stq t9, OFFSET_T9(sp) + stq t10, OFFSET_T10(sp) + stq t11, OFFSET_T11(sp) + stq ra, OFFSET_RA(sp) + stq t12, OFFSET_T12(sp) + stq gp, OFFSET_GP(sp) + + br pv, 1f +1: SETGP(pv) + mov ra, a0 + mov at_reg, a1 + CALL(mcount) + + ldq v0, OFFSET_V0(sp) + ldq t0, OFFSET_T0(sp) + ldq t1, OFFSET_T1(sp) + ldq t2, OFFSET_T2(sp) + ldq t3, OFFSET_T3(sp) + ldq t4, OFFSET_T4(sp) + ldq t5, OFFSET_T5(sp) + ldq t6, OFFSET_T6(sp) + ldq t7, OFFSET_T7(sp) + ldq s6, OFFSET_S6(sp) /* XXX because run _after_ prologue. */ + ldq a0, OFFSET_A0(sp) + ldq a1, OFFSET_A1(sp) + ldq a2, OFFSET_A2(sp) + ldq a3, OFFSET_A3(sp) + ldq a4, OFFSET_A4(sp) + ldq a5, OFFSET_A5(sp) + ldq t8, OFFSET_T8(sp) + ldq t9, OFFSET_T9(sp) + ldq t10, OFFSET_T10(sp) + ldq t11, OFFSET_T11(sp) + ldq gp, OFFSET_GP(sp) + ldq ra, OFFSET_RA(sp) + + ldq at_reg, OFFSET_AT(sp) + + lda sp, FRAME_SIZE(sp) + ret zero, (at_reg), 1 + + END(_mcount) +#endif /* 0 */ + +#define MCOUNT asm(" \ + .globl _mcount; \ + .ent _mcount 0; \ +_mcount:; \ + .frame $30,0,$26; \ + .set noat; \ + .set noreorder; \ + \ + lda $30, -192($30); \ + \ + stq $28, 0($30); \ + stq $0, 8($30); \ + stq $1, 16($30); \ + stq $2, 24($30); \ + stq $3, 32($30); \ + stq $4, 40($30); \ + stq $5, 48($30); \ + stq $6, 56($30); \ + stq $7, 64($30); \ + stq $8, 72($30); \ + stq $15, 80($30); \ + stq $16, 88($30); \ + stq $17, 96($30); \ + stq $18, 104($30); \ + stq $19, 112($30); \ + stq $20, 120($30); \ + stq $21, 128($30); \ + stq $22, 136($30); \ + stq $23, 144($30); \ + stq $24, 152($30); \ + stq $25, 160($30); \ + stq $26, 168($30); \ + stq $27, 176($30); \ + stq $29, 184($30); \ + \ + br $27, 1f; \ +1: ldgp $29,0($27); \ + mov $26, $16; \ + mov $28, $17; \ + jsr $26,mcount; \ + ldgp $29,0($26); \ + \ + ldq $0, 8($30); \ + ldq $1, 16($30); \ + ldq $2, 24($30); \ + ldq $3, 32($30); \ + ldq $4, 40($30); \ + ldq $5, 48($30); \ + ldq $6, 56($30); \ + ldq $7, 64($30); \ + ldq $8, 72($30); \ + ldq $15, 80($30); \ + ldq $16, 88($30); \ + ldq $17, 96($30); \ + ldq $18, 104($30); \ + ldq $19, 112($30); \ + ldq $20, 120($30); \ + ldq $21, 128($30); \ + ldq $22, 136($30); \ + ldq $23, 144($30); \ + ldq $24, 152($30); \ + ldq $25, 160($30); \ + ldq $29, 184($30); \ + ldq $26, 168($30); \ + \ + ldq $28, 0($30); \ + \ + lda $30, 192($30); \ + ret $31, ($28), 1; \ + \ + .end _mcount"); #ifdef _KERNEL -#define MCOUNT_ENTER -#define MCOUNT_EXIT +/* + * The following two macros do splhigh and splx respectively. + * profile_swpipl is a special version of pal_swpipl which + * doesn't include profiling support. + * + * XXX These macros should probably use inline assembly. + */ +#define MCOUNT_ENTER \ + s = profile_swpipl(PSL_IPL_HIGH) +#define MCOUNT_EXIT \ + (void)profile_swpipl(s); #endif diff --git a/sys/arch/alpha/include/psl.h b/sys/arch/alpha/include/psl.h index 3b019596c44..e14260c2bf6 100644 --- a/sys/arch/alpha/include/psl.h +++ b/sys/arch/alpha/include/psl.h @@ -1,4 +1,4 @@ -/* $NetBSD: psl.h,v 1.3 1995/08/03 00:03:09 cgd Exp $ */ +/* $NetBSD: psl.h,v 1.4 1995/11/23 02:36:33 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -27,6 +27,9 @@ * rights to redistribute these changes. */ +#ifndef __ALPHA_PSL_H__ +#define __ALPHA_PSL_H__ + /* * Processor Status register definitions. */ @@ -70,16 +73,17 @@ /* * Cache invalidation/flush routines. */ -#if 0 -#define wbflush() alpha_mb() /* Flush all write buffers */ -#else + /* Flush all write buffers */ -#define wbflush() __asm __volatile("mb") -#endif +static __inline int wbflush() { __asm __volatile("mb"); } /* XXX? wmb */ + #define IMB() pal_imb() /* Sync instruction cache w/data */ void alpha_mb __P((void)); /* Flush all write buffers */ void pal_imb __P((void)); /* Sync instruction cache */ u_int64_t pal_swpipl __P((u_int64_t)); /* write new IPL, return old */ +u_int64_t profile_swpipl __P((u_int64_t)); /* pal_swpipl w/o profiling */ void pal_tbi __P((u_int64_t, void *)); /* Invalidate TLB entries */ #endif /* _KERNEL */ + +#endif /* !__ALPHA_PSL_H__ */ diff --git a/sys/arch/alpha/include/pte.h b/sys/arch/alpha/include/pte.h index 7611d097cf4..95b3a84c06c 100644 --- a/sys/arch/alpha/include/pte.h +++ b/sys/arch/alpha/include/pte.h @@ -1,4 +1,4 @@ -/* $NetBSD: pte.h,v 1.2 1995/03/28 18:14:04 jtc Exp $ */ +/* $NetBSD: pte.h,v 1.3 1995/11/23 02:36:37 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -58,17 +58,15 @@ typedef u_int64_t pt_entry_t; #define PG_PROT 0x000000000000ff00 #define PG_RSVD 0x000000000000cc80 /* Reserved fpr hardware */ #define PG_WIRED 0x0000000000010000 /* Wired. [SOFTWARE] */ -#define PG_MOD 0x0000000000020000 /* Modified. [SOFTWARE] */ -#define PG_USED 0x0000000000040000 /* Referenced. [SOFTWARE] */ #define PG_FRAME 0xffffffff00000000 #define PG_SHIFT 32 #define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT) -#if defined(_KERNEL) && !defined(LOCORE) #define K0SEG_BEGIN 0xfffffc0000000000 /* unmapped, cached */ #define K0SEG_END 0xfffffe0000000000 #define PHYS_UNCACHED 0x0000000040000000 +#if !defined(LOCORE) #define k0segtophys(x) ((vm_offset_t)(x) & 0x00000003ffffffff) #define phystok0seg(x) ((vm_offset_t)(x) | K0SEG_BEGIN) @@ -81,9 +79,10 @@ typedef u_int64_t pt_entry_t; #define vatopa(va) \ ((PG_PFNUM(*kvtopte(va)) << PGSHIFT) | ((vm_offset_t)(va) & PGOFSET)) -#define ALPHA_STSIZE NBPG /* 8k */ -#define ALPHA_MAX_PTSIZE (NPTEPG * NBPG) /* 8M */ +#define ALPHA_STSIZE ((u_long)NBPG) /* 8k */ +#define ALPHA_MAX_PTSIZE ((u_long)(NPTEPG * NBPG)) /* 8M */ +#ifdef _KERNEL /* * Kernel virtual address to Sysmap entry and visa versa. */ @@ -107,3 +106,4 @@ extern pt_entry_t *Lev1map; /* Alpha Level One page table */ extern pt_entry_t *Sysmap; /* kernel pte table */ extern vm_size_t Sysmapsize; /* number of pte's in Sysmap */ #endif +#endif diff --git a/sys/arch/alpha/include/rpb.h b/sys/arch/alpha/include/rpb.h index ed931b87657..c738b061ac7 100644 --- a/sys/arch/alpha/include/rpb.h +++ b/sys/arch/alpha/include/rpb.h @@ -1,4 +1,4 @@ -/* $NetBSD: rpb.h,v 1.5 1995/06/28 01:14:41 cgd Exp $ */ +/* $NetBSD: rpb.h,v 1.6 1995/11/23 02:36:41 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -58,8 +58,10 @@ struct rpb { #define ST_DEC_2100_A500 9 /* "Sable" (?) */ #define ST_DEC_APXVME_64 10 /* "AXPvme" (VME?) */ #define ST_DEC_AXPPCI_33 11 /* "NoName" (PCI/ISA?) */ +#define ST_DEC_21000 12 /* "TurboLaser" (?) */ #define ST_DEC_2100_A50 13 /* "Avanti" (PCI/ISA) */ #define ST_DEC_MUSTANG 14 /* "Mustang" (?) */ +#define ST_DEC_KN20AA 15 /* kn20aa (PCI/EISA) */ #define ST_DEC_1000 17 /* "Mikasa" (PCI/ISA?) */ u_int64_t rpb_type; /* 50: */ diff --git a/sys/arch/alpha/include/vmparam.h b/sys/arch/alpha/include/vmparam.h index fa2b0360940..930ac5e7e21 100644 --- a/sys/arch/alpha/include/vmparam.h +++ b/sys/arch/alpha/include/vmparam.h @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.1 1995/02/13 23:08:01 cgd Exp $ */ +/* $NetBSD: vmparam.h,v 1.2 1995/11/23 02:36:46 cgd Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -169,7 +169,6 @@ #define VM_PHYS_SIZE (USRIOSIZE*CLBYTES) /* some Alpha-specific constants */ -#define VM_MAX_PHYSADDR ((vm_offset_t)0x0000000080000000) /* max phys addr */ #define VPTBASE ((vm_offset_t)0xfffffffc00000000) /* Virt. pg table */ #ifdef THESE_ARE_WRONG diff --git a/sys/arch/alpha/isa/isa_machdep.c b/sys/arch/alpha/isa/isa_machdep.c deleted file mode 100644 index 9e3a63f7634..00000000000 --- a/sys/arch/alpha/isa/isa_machdep.c +++ /dev/null @@ -1,169 +0,0 @@ -/* $NetBSD: isa_machdep.c,v 1.2 1995/08/03 01:23:08 cgd Exp $ */ - -/* - * Copyright (c) 1995 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 -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -int isamatch __P((struct device *, void *, void *)); -void isaattach __P((struct device *, struct device *, void *)); - -struct cfdriver isacd = { - NULL, "isa", isamatch, isaattach, DV_DULL, sizeof(struct isa_softc), 1 -}; - -int -isamatch(parent, cfdata, aux) - struct device *parent; - void *cfdata, *aux; -{ - struct cfdata *cf = cfdata; - struct confargs *ca = aux; - -#if 0 /* XXX -- Assume that it's valid if unit number OK */ - /* It can only occur on the mainbus. */ - if (ca->ca_bus->ab_type != BUS_MAIN) - return (0); - - /* Make sure that we're looking for this type of device. */ - if (!BUS_MATCHNAME(ca, "isa")) - return (0); -#endif /* XXX */ - - /* See if the unit number is valid. */ - switch (hwrpb->rpb_type) { -#if defined(DEC_2100_A50) - case ST_DEC_2100_A50: - if (cf->cf_unit > 0) - return (0); - break; -#endif - default: - return (0); - } - - return (1); -} - -void -isaattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct isa_softc *sc = (struct isa_softc *)self; - - printf("\n"); - - TAILQ_INIT(&sc->sc_subdevs); - - /* XXX set up ISA DMA controllers? */ - - config_scan(isascan, self); -} - -void * -isa_intr_establish(irq, type, level, ih_fun, ih_arg) - int irq; - isa_intrtype type; - isa_intrlevel level; - int (*ih_fun)(void *); - void *ih_arg; -{ - - return (*isa_intr_fcns->isa_intr_establish)(irq, type, level, - ih_fun, ih_arg); -} - -void -isa_intr_disestablish(handler) - void *handler; -{ - - (*isa_intr_fcns->isa_intr_disestablish)(handler); -} - -int -isadma_map(addr, size, mappings, flags) - caddr_t addr; - vm_size_t size; - vm_offset_t *mappings; - int flags; -{ - - (*isadma_fcns->isadma_map)(addr, size, mappings, flags); -} - -void -isadma_unmap(addr, size, nmappings, mappings) - caddr_t addr; - vm_size_t size; - int nmappings; - vm_offset_t *mappings; -{ - - (*isadma_fcns->isadma_unmap)(addr, size, nmappings, mappings); -} - -void -isadma_copytobuf(addr, size, nmappings, mappings) - caddr_t addr; - vm_size_t size; - int nmappings; - vm_offset_t *mappings; -{ - - (*isadma_fcns->isadma_copytobuf)(addr, size, nmappings, mappings); -} - -void -isadma_copyfrombuf(addr, size, nmappings, mappings) - caddr_t addr; - vm_size_t size; - int nmappings; - vm_offset_t *mappings; -{ - - (*isadma_fcns->isadma_copyfrombuf)(addr, size, nmappings, mappings); -} diff --git a/sys/arch/alpha/isa/pckbd.c b/sys/arch/alpha/isa/pckbd.c index 4dacd3f1d3b..cea8cd5f5de 100644 --- a/sys/arch/alpha/isa/pckbd.c +++ b/sys/arch/alpha/isa/pckbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: pckbd.c,v 1.1 1995/08/03 00:48:25 cgd Exp $ */ +/* $NetBSD: pckbd.c,v 1.2 1995/11/23 02:37:06 cgd Exp $ */ /*- * Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved. @@ -53,12 +53,16 @@ #include #include -#include #include #include #include +#include "wsc.h" +#if NWSC +#include +#endif + static volatile u_char ack, nak; /* Don't ask. */ static u_char async, kernel, polling; /* Really, you don't want to know. */ static u_char lock_state = 0x00, /* all off */ @@ -66,6 +70,11 @@ static u_char lock_state = 0x00, /* all off */ typematic_rate = 0xff, /* don't update until set by user */ old_typematic_rate = 0xff; +__const struct isa_intr_fns *pckbd_intr_fns; /* XXX */ +void *pckbd_intr_arg; /* XXX */ +__const struct isa_pio_fns *pckbd_pio_fns; /* XXX */ +void *pckbd_pio_arg; /* XXX */ + struct pckbd_softc { struct device sc_dev; void *sc_ih; @@ -100,10 +109,10 @@ void pccnpollc __P((void *, int)); #define NONE 0x0400 /* no function */ #define KBD_DELAY \ - { u_char x = inb(0x84); } \ - { u_char x = inb(0x84); } \ - { u_char x = inb(0x84); } \ - { u_char x = inb(0x84); } + { u_char x = INB(pckbd_pio_fns, pckbd_pio_arg, 0x84); } \ + { u_char x = INB(pckbd_pio_fns, pckbd_pio_arg, 0x84); } \ + { u_char x = INB(pckbd_pio_fns, pckbd_pio_arg, 0x84); } \ + { u_char x = INB(pckbd_pio_fns, pckbd_pio_arg, 0x84); } static inline int kbd_wait_output() @@ -111,7 +120,8 @@ kbd_wait_output() u_int i; for (i = 100000; i; i--) - if ((inb(KBSTATP) & KBS_IBF) == 0) { + if ((INB(pckbd_pio_fns, pckbd_pio_arg, KBSTATP) & KBS_IBF) + == 0) { KBD_DELAY; return 1; } @@ -124,7 +134,8 @@ kbd_wait_input() u_int i; for (i = 100000; i; i--) - if ((inb(KBSTATP) & KBS_DIB) != 0) { + if ((INB(pckbd_pio_fns, pckbd_pio_arg, KBSTATP) & KBS_DIB) + != 0) { KBD_DELAY; return 1; } @@ -137,10 +148,11 @@ kbd_flush_input() u_int i; for (i = 10; i; i--) { - if ((inb(KBSTATP) & KBS_DIB) == 0) + if ((INB(pckbd_pio_fns, pckbd_pio_arg, KBSTATP) & KBS_DIB) + == 0) return; KBD_DELAY; - (void) inb(KBDATAP); + (void) INB(pckbd_pio_fns, pckbd_pio_arg, KBDATAP); } } @@ -154,10 +166,10 @@ kbc_get8042cmd() if (!kbd_wait_output()) return -1; - outb(KBCMDP, K_RDCMDBYTE); + OUTB(pckbd_pio_fns, pckbd_pio_arg, KBCMDP, K_RDCMDBYTE); if (!kbd_wait_input()) return -1; - return inb(KBDATAP); + return INB(pckbd_pio_fns, pckbd_pio_arg, KBDATAP); } #endif @@ -171,10 +183,10 @@ kbc_put8042cmd(val) if (!kbd_wait_output()) return 0; - outb(KBCMDP, K_LDCMDBYTE); + OUTB(pckbd_pio_fns, pckbd_pio_arg, KBCMDP, K_LDCMDBYTE); if (!kbd_wait_output()) return 0; - outb(KBOUTP, val); + OUTB(pckbd_pio_fns, pckbd_pio_arg, KBOUTP, val); return 1; } @@ -193,14 +205,16 @@ kbd_cmd(val, polling) if (!kbd_wait_output()) return 0; ack = nak = 0; - outb(KBOUTP, val); + OUTB(pckbd_pio_fns, pckbd_pio_arg, KBOUTP, val); if (polling) for (i = 100000; i; i--) { - if (inb(KBSTATP) & KBS_DIB) { + if (INB(pckbd_pio_fns, pckbd_pio_arg, + KBSTATP) & KBS_DIB) { register u_char c; KBD_DELAY; - c = inb(KBDATAP); + c = INB(pckbd_pio_fns, pckbd_pio_arg, + KBDATAP); if (c == KBR_ACK || c == KBR_ECHO) { ack = 1; return 1; @@ -210,13 +224,15 @@ kbd_cmd(val, polling) break; } #ifdef DIAGNOSTIC - printf("kbd_cmd: input char %x lost\n", c); + printf("kbd_cmd: input char %x lost\n", + c); #endif } } else for (i = 100000; i; i--) { - (void) inb(KBSTATP); + (void) INB(pckbd_pio_fns, pckbd_pio_arg, + KBSTATP); if (ack) return 1; if (nak) @@ -236,9 +252,12 @@ pckbdprobe(parent, match, aux) struct device *parent; void *match, *aux; { - struct isa_attach_args *ia = aux; + struct isadev_attach_args *ida = aux; u_int i; + pckbd_pio_fns = ida->ida_piofns; /* XXX */ + pckbd_pio_arg = ida->ida_pioarg; /* XXX */ + /* Enable interrupts and keyboard, etc. */ if (!kbc_put8042cmd(CMDBYTE)) { printf("pcprobe: command error\n"); @@ -254,11 +273,13 @@ pckbdprobe(parent, match, aux) goto lose; } for (i = 600000; i; i--) - if ((inb(KBSTATP) & KBS_DIB) != 0) { + if ((INB(pckbd_pio_fns, pckbd_pio_arg, KBSTATP) & KBS_DIB) + != 0) { KBD_DELAY; break; } - if (i == 0 || inb(KBDATAP) != KBR_RSTDONE) { + if (i == 0 || INB(pckbd_pio_fns, pckbd_pio_arg, KBDATAP) + != KBR_RSTDONE) { printf("pcprobe: reset error %d\n", 2); goto lose; } @@ -308,8 +329,8 @@ lose: */ #endif - ia->ia_iosize = 16; - ia->ia_msize = 0; + ida->ida_nports[0] = 16; + ida->ida_iosiz[0] = 0; return 1; } @@ -319,12 +340,21 @@ pckbdattach(parent, self, aux) void *aux; { struct pckbd_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - + struct isadev_attach_args *ida = aux; + + pckbd_intr_fns = ida->ida_intrfns; /* XXX */ + pckbd_intr_arg = ida->ida_intrarg; /* XXX */ + pckbd_pio_fns = ida->ida_piofns; /* XXX */ + pckbd_pio_arg = ida->ida_pioarg; /* XXX */ + + sc->sc_ih = ISA_INTR_ESTABLISH(pckbd_intr_fns, pckbd_intr_arg, + ida->ida_irq[0], ISA_IST_EDGE, ISA_IPL_TTY, pckbdintr, sc); +#if NWSC printf("\n"); - sc->sc_ih = isa_intr_establish(ia->ia_irq, ISA_IST_EDGE, ISA_IPL_TTY, - pckbdintr, sc); wscattach_input(self, self, pccngetc, pccnpollc); +#else + printf(": no wsc driver; no input possible\n"); +#endif } /* @@ -339,15 +369,17 @@ pckbdintr(arg) struct pckbd_softc *sc = arg; u_char *cp; - if ((inb(KBSTATP) & KBS_DIB) == 0) + if ((INB(pckbd_pio_fns, pckbd_pio_arg, KBSTATP) & KBS_DIB) == 0) return 0; if (polling) return 1; do { cp = sget(); +#if NWSC if (cp) wscons_kbdinput(cp); - } while (inb(KBSTATP) & KBS_DIB); +#endif + } while (INB(pckbd_pio_fns, pckbd_pio_arg, KBSTATP) & KBS_DIB); return 1; } @@ -609,7 +641,7 @@ sget() top: KBD_DELAY; - dt = inb(KBDATAP); + dt = INB(pckbd_pio_fns, pckbd_pio_arg, KBDATAP); switch (dt) { case KBR_ACK: @@ -806,7 +838,7 @@ top: extended = 0; loop: - if ((inb(KBSTATP) & KBS_DIB) == 0) + if ((INB(pckbd_pio_fns, pckbd_pio_arg, KBSTATP) & KBS_DIB) == 0) return 0; goto top; } @@ -826,7 +858,8 @@ pccngetc(cookie) do { /* wait for byte */ - while ((inb(KBSTATP) & KBS_DIB) == 0); + while ((INB(pckbd_pio_fns, pckbd_pio_arg, KBSTATP) & KBS_DIB) + == 0); /* see if it's worthwhile */ cp = sget(); } while (!cp); diff --git a/sys/arch/alpha/pci/apecs.c b/sys/arch/alpha/pci/apecs.c index 7648f2cdd7e..76fd9fec019 100644 --- a/sys/arch/alpha/pci/apecs.c +++ b/sys/arch/alpha/pci/apecs.c @@ -1,4 +1,4 @@ -/* $NetBSD: apecs.c,v 1.3 1995/08/03 01:16:47 cgd Exp $ */ +/* $NetBSD: apecs.c,v 1.4 1995/11/23 02:37:11 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -35,37 +35,31 @@ #include #include -#include #include #include #include -#include #include #include -#include #include +#include int apecsmatch __P((struct device *, void *, void *)); void apecsattach __P((struct device *, struct device *, void *)); struct cfdriver apecscd = { - NULL, "apecs", apecsmatch, apecsattach, DV_DULL, sizeof(struct device) + NULL, "apecs", apecsmatch, apecsattach, DV_DULL, + sizeof(struct apecs_softc) }; static int apecsprint __P((void *, char *pnp)); -#ifdef DEC_2100_A50 -extern void pci_2100_a50_pickintr __P((void)); -#endif - #define REGVAL(r) (*(int32_t *)phystok0seg(r)) -static int nsgmapent = 1024; -static vm_offset_t sgmap_pci_base = 0x800000; -/*static */struct sgmapent *sgmap; -static char /* * */ sgbitmap[1024 / NBBY]; +/* There can be only one. */ +int apecsfound; +struct apecs_config apecs_configuration; int apecsmatch(parent, match, aux) @@ -73,9 +67,14 @@ apecsmatch(parent, match, aux) void *match, *aux; { struct cfdata *cf = match; - struct confargs *pa = aux; + struct confargs *ca = aux; - /* XXX */ + /* Make sure that we're looking for an APECS. */ + if (strcmp(ca->ca_name, apecscd.cd_name) != 0) + return (0); + + if (apecsfound) + return (0); return (1); } @@ -84,18 +83,36 @@ apecsmatch(parent, match, aux) * Set up the chipset's function pointers. */ void -apecs_init() +apecs_init(acp) + struct apecs_config *acp; { - int pass2_epic; - - pass2_epic = (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0; - isadma_fcns = &apecs_isadma_fcns; - isa_pio_fcns = &apecs_pio_fcns; - if (!pass2_epic) - pci_cs_fcns = &apecs_p1e_cs_fcns; - else - pci_cs_fcns = &apecs_p2e_cs_fcns; + acp->ac_comanche_pass2 = + (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0; + acp->ac_memwidth = + (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0 ? 128 : 64; + acp->ac_epic_pass2 = + (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0; + + /* + * Can't set up SGMAP data here; can be called before malloc(). + */ + + acp->ac_conffns = &apecs_conf_fns; + acp->ac_confarg = acp; + acp->ac_dmafns = &apecs_dma_fns; + acp->ac_dmaarg = acp; + /* Interrupt routines set up in 'attach' */ + acp->ac_memfns = &apecs_mem_fns; + acp->ac_memarg = acp; + acp->ac_piofns = &apecs_pio_fns; + acp->ac_pioarg = acp; + + /* Turn off DMA window enables in PCI Base Reg 1. */ + REGVAL(EPIC_PCI_BASE_1) = 0; + wbflush(); + + /* XXX SGMAP? */ } void @@ -104,46 +121,61 @@ apecsattach(parent, self, aux) void *aux; { struct confargs *ca = aux; - struct confargs nca; - int pass2_comanche, widemem, pass2_epic; + struct apecs_softc *sc = (struct apecs_softc *)self; + struct apecs_config *acp; + struct pci_attach_args pa; - pass2_comanche = (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0; - widemem = (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0; - pass2_epic = (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0; + /* note that we've attached the chipset; can't have 2 APECSes. */ + apecsfound = 1; - sgmap = (struct sgmapent *)malloc(1024 * sizeof(struct sgmapent), - M_DEVBUF, M_WAITOK); + /* + * set up the chipset's info; done once at console init time + * (maybe), but doesn't hurt to do twice. + */ + acp = sc->sc_acp = &apecs_configuration; + apecs_init(acp); + + /* XXX SGMAP FOO */ printf(": DECchip %s Core Logic chipset\n", - widemem ? "21072" : "21071"); + acp->ac_memwidth == 128 ? "21072" : "21071"); printf("%s: DC21071-CA pass %d, %d-bit memory bus\n", - self->dv_xname, pass2_comanche ? 2 : 1, widemem ? 128 : 64); - printf("%s: DC21071-DA pass %d\n", self->dv_xname, pass2_epic ? 2 : 1); + self->dv_xname, acp->ac_comanche_pass2 ? 2 : 1, acp->ac_memwidth); + printf("%s: DC21071-DA pass %d\n", self->dv_xname, + acp->ac_epic_pass2 ? 2 : 1); /* XXX print bcache size */ - if (!pass2_epic) + if (!acp->ac_epic_pass2) printf("WARNING: 21071-DA NOT PASS2... NO BETS...\n"); - /* set up the chipset's functions */ - apecs_init(); - switch (hwrpb->rpb_type) { #if defined(DEC_2100_A50) case ST_DEC_2100_A50: - pci_2100_a50_pickintr(); + pci_2100_a50_pickintr(acp->ac_conffns, acp->ac_confarg, + acp->ac_piofns, acp->ac_pioarg, + &acp->ac_intrfns, &acp->ac_intrarg); break; #endif default: panic("apecsattach: shouldn't be here, really..."); } - /* attach the PCI bus that hangs off of it... */ - nca.ca_name = "pci"; - nca.ca_slot = 0; - nca.ca_offset = 0; - nca.ca_bus = NULL; - if (!config_found(self, &nca, apecsprint)) - panic("apecsattach: couldn't attach PCI bus"); + pa.pa_bus = 0; + pa.pa_maxdev = 32; + pa.pa_burstlog2 = 8; + + pa.pa_conffns = acp->ac_conffns; + pa.pa_confarg = acp->ac_confarg; + pa.pa_dmafns = acp->ac_dmafns; + pa.pa_dmaarg = acp->ac_dmaarg; + pa.pa_intrfns = acp->ac_intrfns; + pa.pa_intrarg = acp->ac_intrarg; + pa.pa_memfns = acp->ac_memfns; + pa.pa_memarg = acp->ac_memarg; + pa.pa_piofns = acp->ac_piofns; + pa.pa_pioarg = acp->ac_pioarg; + + config_found(self, &pa, apecsprint); } static int @@ -151,121 +183,11 @@ apecsprint(aux, pnp) void *aux; char *pnp; { - register struct confargs *ca = aux; - - if (pnp) - printf("%s at %s", ca->ca_name, pnp); - return (UNCONF); -} - -vm_offset_t /* XXX? */ -apecs_sgmap_alloc(va, npg, nocross, waitok) - caddr_t va; - int npg; - vm_size_t nocross; - int waitok; -{ - int s; - int base, i, stride; - -#ifdef DIAGNOSTIC - /* Quick sanity checks. */ - if ((vm_offset_t)va & PGOFSET) - panic("apecs_sgmap_alloc: va not page aligned"); - if ((nocross & (nocross - 1)) != 0 || nocross == 0) - panic("apecs_sgmap_alloc: bogus alignment 0x%lx", nocross); - if (npg <= 0) - panic("apecs_sgmap_alloc: not allocating anything"); - if (npg > nsgmapent) - panic("apecs_sgmap_alloc: insane allocation"); - if (ptoa(npg) > nocross) - panic("apecs_sgmap_alloc: must cross boundary"); -#endif - - stride = atop(nocross); -#ifdef DIAGNOSTIC - if (stride > nsgmapent) - panic("apecs_sgmap_alloc: cheesy implementation loses"); -#endif - -top: - s = splhigh(); - for (base = 0; base < nsgmapent; base += stride) { - for (i = base; i < base + npg; i++) - if (isset(sgbitmap, i)) - goto nextstride; - break; -nextstride: - } - if (base < nsgmapent) /* found a free chunk, claim it */ - for (i = base; i < base + npg; i++) - setbit(sgbitmap, i); - splx(s); - - if (base >= nsgmapent) { /* didn't find a free chunk */ - if (!waitok) - return 0; - tsleep(&sgmap, PRIBIO+1, "sgmap", 0); - goto top; - } - - for (i = base; i < base + npg; i++) { -#ifdef DIAGNOSTIC - if ((sgmap[i].val & SGMAPENT_EVAL) != 0) - panic("apecs_sgmap_alloc: unallocated entry valid"); -#endif - sgmap[i].val = SGMAP_MAKEENTRY(atop(vtophys(va))); - va += PAGE_SIZE; - } - - /* Invalidate old cached entries. */ - REGVAL(EPIC_TBIA) = 1; - - /* Return the PCI address. */ - return (ptoa(base) + sgmap_pci_base); -} - -void -apecs_sgmap_dealloc(pa, npg) - vm_offset_t pa; - int npg; -{ - int i, pfn; - -#ifdef DIAGNOSTIC - /* Quick sanity checks. */ - if (pa & PGOFSET) - panic("apecs_sgmap_dealloc: pa not page aligned"); - if (npg <= 0) - panic("apecs_sgmap_dealloc: not deallocating anything"); - if (npg > nsgmapent) - panic("apecs_sgmap_dealloc: insane deallocation"); -#endif - - pfn = atop(pa - sgmap_pci_base); -#ifdef DIAGNOSTIC - /* Bounds check the deallocation range. Paranoid about wraparound. */ - if (pfn < 0 || pfn >= nsgmapent || (pfn + npg) >= nsgmapent) - panic("apecs_sgmap_dealloc: pa out of range (%s)", - pfn < 0 ? "too low" : "too high"); -#endif - - for (i = 0; i < npg; i++) { -#ifdef DIAGNOSTIC - /* Make sure it's actually allocated. */ - if (isclr(sgbitmap, i + pfn)) - panic("apecs_sgmap_dealloc: multiple frees: entry %d", - i + pfn); -#endif - - /* Clear the entries and the allocation map bits. */ - clrbit(sgbitmap, i + pfn); - sgmap[i + pfn].val &= ~SGMAPENT_EVAL; - } - - /* Invalidate old cached entries. */ - REGVAL(EPIC_TBIA) = 1; + register struct pci_attach_args *pa = aux; - /* Wake up anybody waiting for map entries. */ - wakeup(&sgmap); + /* only PCIs can attach to APECSes; easy. */ + if (pnp) + printf("pci at %s", pnp); + printf(" bus %d", pa->pa_bus); + return (UNCONF); } diff --git a/sys/arch/alpha/pci/apecs_isa.c b/sys/arch/alpha/pci/apecs_isa.c index d4bdb482f08..1d2729475dc 100644 --- a/sys/arch/alpha/pci/apecs_isa.c +++ b/sys/arch/alpha/pci/apecs_isa.c @@ -1,4 +1,4 @@ -/* $NetBSD: apecs_isa.c,v 1.3 1995/08/03 01:16:53 cgd Exp $ */ +/* $NetBSD: apecs_isa.c,v 1.4 1995/11/23 02:37:13 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -30,65 +30,88 @@ #include #include #include +#include #include -#include - -#include -#include -#include +#include #include +#include -static u_int8_t apecs_inb __P((int port)); -/* static void apecs_insb __P((int port, void *addr, int cnt)); */ -#define apecs_insb 0 /* XXX */ -static u_int16_t apecs_inw __P((int port)); -/* static void apecs_insw __P((int port, void *addr, int cnt)); */ -#define apecs_insw 0 /* XXX */ -u_int32_t apecs_inl __P((int port)); -/* static void apecs_insl __P((int port, void *addr, int cnt)); */ -#define apecs_insl 0 /* XXX */ +/* + * Allocation/deallocation functions. + */ +int apecs_pio_alloc __P((void *, isa_iooffset_t, isa_iosize_t)); +int apecs_pio_dealloc __P((void *, isa_iooffset_t, isa_iosize_t)); -static void apecs_outb __P((int port, u_int8_t datum)); -/* static void apecs_outsb __P((int port, void *addr, int cnt)); */ +/* + * Byte functions. + */ +isa_byte_t apecs_inb __P((void *, isa_iooffset_t)); +#define apecs_insb 0 /* XXX */ +void apecs_outb __P((void *, isa_iooffset_t, isa_byte_t)); #define apecs_outsb 0 /* XXX */ -static void apecs_outw __P((int port, u_int16_t datum)); -/* static void apecs_outsw __P((int port, void *addr, int cnt)); */ + +/* + * Word functions. + */ +isa_word_t apecs_inw __P((void *, isa_iooffset_t)); +#define apecs_insw 0 /* XXX */ +void apecs_outw __P((void *, isa_iooffset_t, isa_word_t)); #define apecs_outsw 0 /* XXX */ -static void apecs_outl __P((int port, u_int32_t datum)); -/* static void apecs_outsl __P((int port, void *addr, int cnt)); */ + +/* + * Longword functions. + */ +isa_long_t apecs_inl __P((void *, isa_iooffset_t)); +#define apecs_insl 0 /* XXX */ +void apecs_outl __P((void *, isa_iooffset_t, isa_long_t)); #define apecs_outsl 0 /* XXX */ -struct isa_pio_fcns apecs_pio_fcns = { +__const struct pci_pio_fns apecs_pio_fns = { + /* Allocation/deallocation functions. */ + apecs_pio_alloc, apecs_pio_dealloc, + + /* Byte functions. */ apecs_inb, apecs_insb, - apecs_inw, apecs_insw, - apecs_inl, apecs_insl, apecs_outb, apecs_outsb, + + /* Word functions. */ + apecs_inw, apecs_insw, apecs_outw, apecs_outsw, + + /* Longword functions. */ + apecs_inl, apecs_insl, apecs_outl, apecs_outsl, }; -static int apecs_isadma_map __P((caddr_t addr, vm_size_t size, - vm_offset_t *mappings, int flags)); -static void apecs_isadma_unmap __P((caddr_t addr, vm_size_t size, - int nmappings, vm_offset_t *mappings)); -static void apecs_isadma_copytobuf __P((caddr_t addr, vm_size_t size, - int nmappings, vm_offset_t *mappings)); -static void apecs_isadma_copyfrombuf __P((caddr_t addr, vm_size_t size, - int nmappings, vm_offset_t *mappings)); - -struct isadma_fcns apecs_isadma_fcns = { - apecs_isadma_map, apecs_isadma_unmap, - apecs_isadma_copytobuf, apecs_isadma_copyfrombuf, -}; +int +apecs_pio_alloc(ipfarg, start, size) + void *ipfarg; + isa_iooffset_t start; + isa_iosize_t size; +{ -u_int8_t -apecs_inb(ioaddr) - int ioaddr; + /* XXX should do something */ +} + +int +apecs_pio_dealloc(ipfarg, start, size) + void *ipfarg; + isa_iooffset_t start; + isa_iosize_t size; +{ + + /* XXX should do something */ +} + +isa_byte_t +apecs_inb(ipfa, ioaddr) + void *ipfa; + isa_iooffset_t ioaddr; { u_int32_t *port, val; - u_int8_t rval; + isa_byte_t rval; int offset; wbflush(); @@ -101,81 +124,86 @@ apecs_inb(ioaddr) return rval; } -u_int16_t -apecs_inw(ioaddr) - int ioaddr; +void +apecs_outb(ipfa, ioaddr, val) + void *ipfa; + isa_iooffset_t ioaddr; + isa_byte_t val; { - u_int32_t *port, val; - u_int16_t rval; + u_int32_t *port, nval; int offset; - wbflush(); offset = ioaddr & 3; - port = (int32_t *)phystok0seg(APECS_PCI_SIO | 1 << 3 | ioaddr << 5); - val = *port; - rval = ((val) >> (8 * offset)) & 0xffff; - rval = val & 0xffff; - -panic("inw(0x%x) => 0x%x @ %p => 0x%x\n", ioaddr, val, port, rval); + nval = val /*<< (8 * offset)*/; + nval = val << (8 * offset); + port = (int32_t *)phystok0seg(APECS_PCI_SIO | 0 << 3 | ioaddr << 5); - return rval; + *port = nval; + wbflush(); } -u_int32_t -apecs_inl(ioaddr) - int ioaddr; +isa_word_t +apecs_inw(ipfa, ioaddr) + void *ipfa; + isa_iooffset_t ioaddr; { u_int32_t *port, val; - u_int32_t rval; + isa_word_t rval; int offset; wbflush(); offset = ioaddr & 3; - port = (int32_t *)phystok0seg(APECS_PCI_SIO | 3 << 3 | ioaddr << 5); + port = (int32_t *)phystok0seg(APECS_PCI_SIO | 1 << 3 | ioaddr << 5); val = *port; - rval = ((val) >> (8 * offset)) & 0xffffffff; - rval = val & 0xffffffff; + rval = ((val) >> (8 * offset)) & 0xffff; + rval = val & 0xffff; + +panic("inw(0x%x) => 0x%x @ %p => 0x%x\n", ioaddr, val, port, rval); return rval; } void -apecs_outb(ioaddr, val) - int ioaddr; - u_int8_t val; +apecs_outw(ipfa, ioaddr, val) + void *ipfa; + isa_iooffset_t ioaddr; + isa_word_t val; { u_int32_t *port, nval; int offset; offset = ioaddr & 3; nval = val /*<< (8 * offset)*/; - nval = val << (8 * offset); - port = (int32_t *)phystok0seg(APECS_PCI_SIO | 0 << 3 | ioaddr << 5); + port = (int32_t *)phystok0seg(APECS_PCI_SIO | 1 << 3 | ioaddr << 5); *port = nval; wbflush(); } -void -apecs_outw(ioaddr, val) - int ioaddr; - u_int16_t val; +isa_long_t +apecs_inl(ipfa, ioaddr) + void *ipfa; + isa_iooffset_t ioaddr; { - u_int32_t *port, nval; + u_int32_t *port, val; + isa_long_t rval; int offset; + wbflush(); offset = ioaddr & 3; - nval = val /*<< (8 * offset)*/; - port = (int32_t *)phystok0seg(APECS_PCI_SIO | 1 << 3 | ioaddr << 5); + port = (int32_t *)phystok0seg(APECS_PCI_SIO | 3 << 3 | ioaddr << 5); + val = *port; + rval = ((val) >> (8 * offset)) & 0xffffffff; + rval = val & 0xffffffff; - *port = nval; - wbflush(); + return rval; } void -apecs_outl(ioaddr, val) - int ioaddr; - u_int32_t val; +apecs_outl(ipfa, ioaddr, val) + void *ipfa; + isa_iooffset_t ioaddr; + isa_long_t val; { u_int32_t *port, nval; int offset; @@ -188,156 +216,131 @@ apecs_outl(ioaddr, val) wbflush(); } -static caddr_t bounced_addr; -static caddr_t bounce_buffer; -static vm_size_t bounce_size; +/* XXX XXX XXX */ + +#define pf(fn, args) fn args { panic(__STRING(fn)); } + +void pf(apecs_dma_cascade, (void *idfa, isa_drq_t chan)) +void pf(apecs_dma_copytobuf, ()) +void pf(apecs_dma_copyfrombuf, ()) +void pf(apecs_dma_start, (void *idfa, vm_offset_t addr, + isa_msize_t size, isa_drq_t chan, int flags)) +void pf(apecs_dma_abort, (void *idfa, isa_drq_t chan)) +void pf(apecs_dma_done, (void *idfa, isa_drq_t chan)) + +int apecs_dma_map __P((void *, vm_offset_t, isa_msize_t, + isa_moffset_t *, int)); +void apecs_dma_unmap __P((void *, vm_offset_t, isa_msize_t, int, + isa_moffset_t *)); + +__const struct isa_dma_fns apecs_dma_fns = { + apecs_dma_cascade, + apecs_dma_map, + apecs_dma_unmap, + apecs_dma_copytobuf, + apecs_dma_copyfrombuf, + apecs_dma_start, + apecs_dma_abort, + apecs_dma_done, +}; int -apecs_isadma_map(addr, size, mappings, flags) - caddr_t addr; - vm_size_t size; - vm_offset_t *mappings; +apecs_dma_map(idfa, va, isasize, mappingsp, flags) + void *idfa; + vm_offset_t va; + isa_msize_t isasize; + isa_moffset_t *mappingsp; int flags; { - vm_offset_t off, truncaddr; - vm_offset_t isa_truncpa; /* XXX? */ - vm_size_t alignment; - int i, npages, waitok; - - /* - * ISADMA_MAP_{,NO}BOUNCE and ISADMA_MAP_{CONTIG,SCATTER} are - * completely ignored, because all allocations will be in the - * low 16M and will be contiguous. I LOVE VIRTUAL DMA! - */ - - truncaddr = trunc_page(addr); - off = (vm_offset_t)addr - truncaddr; - npages = num_pages(size + off); - if (npages == 0) - panic("apecs_isadma_map: map nothing"); - - alignment = 64 * 1024; - if ((flags & ISADMA_MAP_16BIT) != 0) - alignment <<= 1; - waitok = (flags & ISADMA_MAP_WAITOK) != 0; - - if (npages > atop(alignment)) { - int s; - void *tmpbb; - - /* - * Allocate a bounce buffer. - */ - s = splhigh(); -retry: - while (bounce_buffer != NULL) { - /* - * If a bounce buffer is in use and we can't - * wait, bug out now, otherwise sleep. - */ - if (!waitok) { - splx(s); - return 0; - } - - tsleep(&bounce_buffer, PRIBIO+1, "apecsbb", 0); - } - - /* - * Try to allocate a bounce buffer. - */ - tmpbb = malloc(alignment, M_DEVBUF, - waitok ? M_WAITOK : M_NOWAIT); - if (tmpbb == NULL) { /* couldn't wait, and failed */ - splx(s); - return 0; - } - - /* - * If we slept in malloc() and somebody else got it, - * give it up and try it again! - */ - if (bounce_buffer != NULL) { - free(tmpbb, M_DEVBUF); - goto retry; - } - - /* - * It's ours, all ours! - */ - bounce_buffer = tmpbb; - splx(s); - - bounced_addr = addr; - bounce_size = size; - truncaddr = (vm_offset_t)bounce_buffer; - npages = atop(alignment); + struct apecs_config *acp = idfa; + long todo; + int i; + + if (ISA_DMA_NEEDCONTIG(flags) && isasize > NBPG || + ISA_DMA_SIZEBOUND(flags) != ISA_DMA_SIZEBOUND_NONE || + ISA_DMA_ADDRBOUND(flags) != ISA_DMA_ADDRBOUND_NONE) + panic("apecs_dma_map: punt"); + + i = 0; + todo = isasize; + + while (todo > 0) { + mappingsp[i] = vtophys(va) | 0x40000000; +#if 0 + printf("a_pd_m mapping %d: %lx -> %lx -> %lx\n", i, va, + vtophys(va), mappingsp[i]); +#endif + i++; + todo -= PAGE_SIZE - (va - trunc_page(va)); + va += PAGE_SIZE - (va - trunc_page(va)); } - - isa_truncpa = apecs_sgmap_alloc(truncaddr, npages, alignment, waitok); - - mappings[0] = isa_truncpa + off; - for (i = 1; i < npages; i++) - mappings[i] = isa_truncpa + ptoa(i); - - return (npages); + return (i); } void -apecs_isadma_unmap(addr, size, nmappings, mappings) - caddr_t addr; - vm_size_t size; +apecs_dma_unmap(idfa, va, isasize, nmappings, mappingsp) + void *idfa; + vm_offset_t va; + isa_msize_t isasize; int nmappings; - vm_offset_t *mappings; + isa_moffset_t *mappingsp; { - int npages; - - npages = nmappings; - if (npages == 0) - panic("apecs_isadma_unmap: unmap nothing"); - apecs_sgmap_dealloc(trunc_page(mappings[0]), npages); - - if (addr == bounced_addr) { - /* - * Free the bounce buffer and wake up anybody who - * wants to bounce. - */ - bounced_addr = NULL; - bounce_size = 0; - free(bounce_buffer, M_DEVBUF); - bounce_buffer = NULL; - wakeup(&bounce_buffer); - } + + printf("apecs_dma_unmap: called\n"); } -void -apecs_isadma_copytobuf(addr, size, nmappings, mappings) - caddr_t addr; - vm_size_t size; - int nmappings; - vm_offset_t *mappings; +vm_offset_t apecs_mem_map __P((void *, isa_moffset_t, isa_msize_t, int)); +void apecs_mem_unmap __P((void *, vm_offset_t, isa_msize_t)); + +#if 0 +void apecs_mem_copytoisa __P((void *, char *, vm_offset_t, + isa_moffset_t, isa_msize_t)); +void apecs_mem_copyfromisa __P((void *, char *, vm_offset_t, + isa_moffset_t, isa_msize_t)); +void apecs_mem_zero __P((void *, vm_offset_t, isa_moffset_t, + isa_msize_t)); +#else +void pf(apecs_mem_copytoisa, ()) +void pf(apecs_mem_copyfromisa, ()) +void pf(apecs_mem_zero, ()) +#endif + +__const struct isa_mem_fns apecs_mem_fns = { + apecs_mem_map, + apecs_mem_unmap, + apecs_mem_copytoisa, + apecs_mem_copyfromisa, + apecs_mem_zero, +}; + +vm_offset_t +apecs_mem_map(imfa, isapa, isasize, cacheable) + void *imfa; + isa_moffset_t isapa; + isa_msize_t isasize; + int cacheable; { + vm_offset_t sbpa; - if (addr != bounced_addr) - return; + /* XXX sanity checks on sizes, use of windows, etc. */ - log(LOG_NOTICE, "apecs_isa_copytobuf: copied %d byte buffer\n", - bounce_size); - bcopy(addr, bounce_buffer, bounce_size); + /* XXX MAGIC NUMBERS */ + if (cacheable) + sbpa = (isapa & 0xffffffff) | APECS_PCI_DENSE; + else + sbpa = ((isapa & 0x7ffffff) << 5) | APECS_PCI_SPARSE; + + return phystok0seg(sbpa); } void -apecs_isadma_copyfrombuf(addr, size, nmappings, mappings) - caddr_t addr; - vm_size_t size; - int nmappings; - vm_offset_t *mappings; +apecs_mem_unmap(imfa, va, isasize) + void *imfa; + vm_offset_t va; + isa_msize_t isasize; { - if (addr != bounced_addr) - return; + /* XXX sanity checks on va */ - log(LOG_NOTICE, "apecs_isa_copyfrombuf: copied %d byte buffer\n", - bounce_size); - bcopy(bounce_buffer, addr, bounce_size); + /* Nothing to do; mapping was done in direct-mapped segment. */ } diff --git a/sys/arch/alpha/pci/apecs_pci.c b/sys/arch/alpha/pci/apecs_pci.c index c8ca57bbff7..42be1862efa 100644 --- a/sys/arch/alpha/pci/apecs_pci.c +++ b/sys/arch/alpha/pci/apecs_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: apecs_pci.c,v 1.3 1995/08/03 01:16:57 cgd Exp $ */ +/* $NetBSD: apecs_pci.c,v 1.4 1995/11/23 02:37:16 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -33,330 +33,190 @@ #include #include -#include -#include - -#include - #include #include -#include #include +#include -void apecs_setup __P((void)); -pcitag_t apecs_make_tag __P((int, int, int)); -pcireg_t apecs_conf_read __P((pcitag_t, int)); -void apecs_conf_write __P((pcitag_t, int, pcireg_t)); -int apecs_map_io __P((pcitag_t, int, int *)); -int apecs_map_mem __P((pcitag_t, int, vm_offset_t *, vm_offset_t *)); -int apecs_pcidma_map __P((caddr_t, vm_size_t, vm_offset_t *)); -void apecs_pcidma_unmap __P((caddr_t, vm_size_t, int, vm_offset_t *)); +pci_confreg_t apecs_conf_read __P((void *, pci_conftag_t, pci_confoffset_t)); +void apecs_conf_write __P((void *, pci_conftag_t, + pci_confoffset_t, pci_confreg_t)); +int apecs_find_io __P((void *, pci_conftag_t, + pci_confoffset_t, pci_iooffset_t *, pci_iosize_t *)); +int apecs_find_mem __P((void *, pci_conftag_t, + pci_confoffset_t, pci_moffset_t *, pci_msize_t *, int *)); -struct pci_cs_fcns apecs_p1e_cs_fcns = { /* XXX WHAT'S DIFFERENT? */ - apecs_setup, - apecs_make_tag, +__const struct pci_conf_fns apecs_conf_fns = { apecs_conf_read, apecs_conf_write, - apecs_map_io, - apecs_map_mem, - apecs_pcidma_map, - apecs_pcidma_unmap, + apecs_find_io, + apecs_find_mem, }; -struct pci_cs_fcns apecs_p2e_cs_fcns = { /* XXX WHAT'S DIFFERENT? */ - apecs_setup, - apecs_make_tag, - apecs_conf_read, - apecs_conf_write, - apecs_map_io, - apecs_map_mem, - apecs_pcidma_map, - apecs_pcidma_unmap, -}; - -#define REGVAL(r) (*(u_int32_t *)phystok0seg(r)) - -void -apecs_setup() -{ - - /* - * Set up PCI bus mastering DMA windows on the APECS chip. - * - * What the PROM wants: - * a 1G direct-mapped window that maps the PCI address - * space from 4G -> 5G to memory addresses 0 -> 1G, - * set up in window two. - * - * What we want: - * a 1G direct-mapped window that maps the PCI address - * space from 0 -> 1G to memory addresses 0 -> 1G. - * - * Unless we satisfy the PROM, we can't live through a reboot. - * If we don't do what we want, I have to write more code. - - * So: - * Leave window two alone, map window 1 the way I want it. - * - * XXX verify that windows don't overlap - * XXX be trickier - * XXX magic numbers - */ - -#if 0 /* should be routine to dump regs */ - printf("old base1 was 0x%x\n", REGVAL(EPIC_PCI_BASE_1)); - printf("old mask1 was 0x%x\n", REGVAL(EPIC_PCI_MASK_1)); - printf("old tbase1 was 0x%x\n", REGVAL(EPIC_TBASE_1)); - - printf("old base2 was 0x%x\n", REGVAL(EPIC_PCI_BASE_2)); - printf("old mask2 was 0x%x\n", REGVAL(EPIC_PCI_MASK_2)); - printf("old tbase2 was 0x%x\n", REGVAL(EPIC_TBASE_2)); -#endif - -#if 0 /* XXX STUPID PROM; MUST LEAVE WINDOW 2 ALONE. See above */ - /* Turn off DMA window enables in PCI Base Reg 2. */ - REGVAL(EPIC_PCI_BASE_2) = 0; - - /* Set up Translated Base Register 2; translate to sybBus addr 0. */ - REGVAL(EPIC_TBASE_2) = 0; - - /* Set up PCI mask register 2; map 1G space. */ - REGVAL(EPIC_PCI_MASK_2) = 0x3ff00000; - - /* Enable window 2; from PCI address 4G, direct mapped. */ - REGVAL(EPIC_PCI_BASE_2) = 0x40080000; -#endif /* STUPID PROM */ - - /* Turn off DMA window enables in PCI Base Reg 1. */ - REGVAL(EPIC_PCI_BASE_1) = 0; - - /* Set up Translated Base Register 1; translate to sybBus addr 0. */ -{ /* XXX */ -extern struct sgmapent *sgmap; - REGVAL(EPIC_TBASE_1) = vtophys(sgmap) >> 1; -} /* XXX */ - - /* Set up PCI mask register 1; map 8MB space. */ - REGVAL(EPIC_PCI_MASK_1) = 0x00700000; - - /* Enable window 1; from PCI address 8MB, direct mapped. */ - REGVAL(EPIC_PCI_BASE_1) = 0x008c0000; - - /* - * Should set up HAXR1 and HAXR2... However, the PROM again - * wants them where they're set to be... - */ -#if 0 - printf("old haxr0 was 0x%x\n", REGVAL(EPIC_HAXR0)); - printf("old haxr1 was 0x%x\n", REGVAL(EPIC_HAXR1)); - printf("old haxr2 was 0x%x\n", REGVAL(EPIC_HAXR2)); -#endif - -#if 0 /* XXX STUPID PROM */ - /* HAXR0 is wired zero; no op. */ - REGVAL(EPIC_HAXR0) = 0; - - /* HAXR1: maps PCI memory space above 16M. 16M -> 2G+16M. */ - REGVAL(EPIC_HAXR1) = 0x80000000; - - /* HAXR2: maps PCI I/O space above 256K. 256K -> 256k. */ - REGVAL(EPIC_HAXR2) = 0; -#endif -} - -pcitag_t -apecs_make_tag(bus, device, function) - int bus, device, function; -{ - pcitag_t tag; - - if (bus >= 256 || device >= 32 || function >= 8) - panic("apecs_make_tag: bad request"); - - tag = (bus << 21) | (device << 16) | (function << 13); -#if 0 - printf("apecs_make_tag: bus %d, device %d, function %d -> 0x%lx\n", bus, - device, function, tag); -#endif - return tag; -} - -pcireg_t -apecs_conf_read(tag, offset) - pcitag_t tag; - int offset; /* XXX */ +pci_confreg_t +apecs_conf_read(cpv, tag, offset) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t offset; { - pcireg_t *datap, data; - int reg = offset >> 2; /* XXX */ + struct apecs_config *acp = cpv; + pci_confreg_t *datap, data; + int s, secondary, ba; + int32_t old_haxr2; /* XXX */ + + secondary = PCI_TAG_BUS(tag) != 0; + if (secondary) { + s = splhigh(); + old_haxr2 = REGVAL(EPIC_HAXR2); + wbflush(); + REGVAL(EPIC_HAXR2) = old_haxr2 | 0x1; + wbflush(); + } - if ((tag & 0x1fe00000) != 0) { - panic("apecs_conf_read: bus != 0?"); + datap = (pci_confreg_t *)phystok0seg(APECS_PCI_CONF | + tag << 5UL | /* XXX */ + (offset & ~0x03) << 5 | /* XXX */ + 0 << 5 | /* XXX */ + 0x3 << 3); /* XXX */ + data = (pci_confreg_t)-1; + if (!(ba = badaddr(datap, sizeof *datap))) + data = *datap; + + if (secondary) { + wbflush(); + REGVAL(EPIC_HAXR2) = old_haxr2; + wbflush(); + splx(s); } - /* XXX FILL IN HAXR2 bits. */ - datap = (pcireg_t *) - phystok0seg(APECS_PCI_CONF | tag | reg << 7 | 0 << 5 | 0x3 << 3); - if (badaddr(datap, sizeof *datap)) - return ((pcireg_t)-1); - data = *datap; #if 0 - printf("apecs_conf_read: tag 0x%lx, reg 0x%lx -> %x @ %p\n", tag, reg, - data, datap); + printf("apecs_conf_read: tag 0x%lx, reg 0x%lx -> %x @ %p%s\n", tag, reg, + data, datap, ba ? " (badaddr)" : ""); #endif + return data; } void -apecs_conf_write(tag, offset, data) - pcitag_t tag; - int offset; /* XXX */ - pcireg_t data; +apecs_conf_write(cpv, tag, offset, data) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t offset; + pci_confreg_t data; { - pcireg_t *datap; - int reg = offset >> 2; /* XXX */ + struct apecs_config *acp = cpv; + pci_confreg_t *datap; + int s, secondary; + int32_t old_haxr2; /* XXX */ + + secondary = PCI_TAG_BUS(tag) != 0; + if (secondary) { + s = splhigh(); + old_haxr2 = REGVAL(EPIC_HAXR2); + wbflush(); + REGVAL(EPIC_HAXR2) = old_haxr2 | 0x1; + wbflush(); + } - if ((tag & 0x1fe00000) != 0) { - panic("apecs_conf_read: bus != 0?"); + datap = (pci_confreg_t *)phystok0seg(APECS_PCI_CONF | + tag << 5UL | /* XXX */ + (offset & ~0x03) << 5 | /* XXX */ + 0 << 5 | /* XXX */ + 0x3 << 3); /* XXX */ + *datap = data; + + if (secondary) { + wbflush(); + REGVAL(EPIC_HAXR2) = old_haxr2; + wbflush(); + splx(s); } - /* XXX FILL IN HAXR2 bits. */ - datap = (pcireg_t *) - phystok0seg(APECS_PCI_CONF | tag | reg << 7 | 0 << 5 | 0x3 << 3); #if 0 printf("apecs_conf_write: tag 0x%lx, reg 0x%lx -> 0x%x @ %p\n", tag, reg, data, datap); #endif - *datap = data; } int -apecs_map_io(tag, reg, iobasep) - pcitag_t tag; - int reg; - int *iobasep; +apecs_find_io(cpv, tag, reg, iobasep, sizep) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t reg; + pci_iooffset_t *iobasep; + pci_iosize_t *sizep; { - pcireg_t data; - int pci_iobase; + struct apecs_config *acp = cpv; + pci_confreg_t addrdata, sizedata; + pci_iooffset_t pci_iobase; - if (reg < PCI_MAP_REG_START || reg >= PCI_MAP_REG_END || (reg & 3)) + if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3)) panic("apecs_map_io: bad request"); - data = pci_conf_read(tag, reg); + addrdata = PCI_CONF_READ(acp->ac_conffns, acp->ac_confarg, tag, reg); - if ((data & PCI_MAP_IO) == 0) + PCI_CONF_WRITE(acp->ac_conffns, acp->ac_confarg, tag, reg, 0xffffffff); + sizedata = PCI_CONF_READ(acp->ac_conffns, acp->ac_confarg, tag, reg); + PCI_CONF_WRITE(acp->ac_conffns, acp->ac_confarg, tag, reg, addrdata); + + if (PCI_MAPREG_TYPE(addrdata) == PCI_MAPREG_TYPE_MEM) panic("apecs_map_io: attempt to I/O map an memory region"); - /* figure out where it was mapped... */ - pci_iobase = data & PCI_MAP_MEMORY_ADDRESS_MASK; /* PCI I/O addr */ + if (iobasep != NULL) + *iobasep = PCI_MAPREG_IO_ADDRESS(addrdata); + if (sizep != NULL) + *sizep = ~PCI_MAPREG_IO_ADDRESS(sizedata) + 1; - return (pci_iobase); + return (0); } int -apecs_map_mem(tag, reg, vap, pap) - pcitag_t tag; - int reg; - vm_offset_t *vap, *pap; +apecs_find_mem(cpv, tag, reg, paddrp, sizep, cacheablep) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t reg; + pci_moffset_t *paddrp; + pci_msize_t *sizep; + int *cacheablep; { - pcireg_t data; - vm_offset_t pci_pa, sb_pa; + struct apecs_config *acp = cpv; + pci_confreg_t addrdata, sizedata; - if (reg < PCI_MAP_REG_START || reg >= PCI_MAP_REG_END || (reg & 3)) + if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3)) panic("apecs_map_mem: bad request"); /* - * "HERE WE GO AGAIN!!!" - * - * The PROM has already mapped the device for us. The PROM is - * our friend. We wouldn't want to make the PROM unhappy. - * - * So, we take the address that's been assigned (already) to - * the register, and figure out what physical and virtual addresses - * go with it... + * The PROM has mapped the device for us. We take the address + * that's been assigned to the register, and figure out what + * physical and virtual addresses go with it... */ - /* - * Section 6.2.5.1, `Address Maps', says that a device which wants 2^n - * bytes of memory will hardwire the bottom n bits of the address to 0. - * As recommended, we write all 1s and see what we get back. - */ - data = pci_conf_read(tag, reg); + addrdata = PCI_CONF_READ(acp->ac_conffns, acp->ac_confarg, tag, reg); + + PCI_CONF_WRITE(acp->ac_conffns, acp->ac_confarg, tag, reg, 0xffffffff); + sizedata = PCI_CONF_READ(acp->ac_conffns, acp->ac_confarg, tag, reg); + PCI_CONF_WRITE(acp->ac_conffns, acp->ac_confarg, tag, reg, addrdata); - if (data & PCI_MAP_IO) + if (PCI_MAPREG_TYPE(addrdata) == PCI_MAPREG_TYPE_IO) panic("apecs_map_mem: attempt to memory map an I/O region"); - switch (data & PCI_MAP_MEMORY_TYPE_MASK) { - case PCI_MAP_MEMORY_TYPE_32BIT: + switch (PCI_MAPREG_MEM_TYPE(addrdata)) { + case PCI_MAPREG_MEM_TYPE_32BIT: + case PCI_MAPREG_MEM_TYPE_32BIT_1M: break; - case PCI_MAP_MEMORY_TYPE_32BIT_1M: - printf("apecs_map_mem: attempt to map restricted 32-bit region\n"); - return EOPNOTSUPP; - case PCI_MAP_MEMORY_TYPE_64BIT: - printf("apecs_map_mem: attempt to map 64-bit region\n"); - return EOPNOTSUPP; + case PCI_MAPREG_MEM_TYPE_64BIT: +/* XXX */ printf("apecs_map_mem: attempt to map 64-bit region\n"); +/* XXX */ break; default: printf("apecs_map_mem: reserved mapping type\n"); return EINVAL; } - /* figure out where it was mapped... */ - pci_pa = data & PCI_MAP_MEMORY_ADDRESS_MASK; /* PCI bus address */ - - /* calcluate sysBus address -- should be a better way to get space */ - if (data & PCI_MAP_MEMORY_CACHABLE) { - /* Dense space */ - sb_pa = (pci_pa & 0xffffffff) | (3L << 32); /* XXX */ - } else { - /* Sparse space */ - sb_pa = ((pci_pa & 0x7ffffff) << 5) | (2L << 32); /* XXX */ - } - - /* and tell the driver. */ - *vap = phystok0seg(sb_pa); - *pap = pci_pa; - -#if 0 - printf("pci_map_mem: memory mapped at 0x%lx\n", *pap); - printf("pci_map_mem: virtual 0x%lx\n", *vap); -#endif + if (paddrp != NULL) + *paddrp = PCI_MAPREG_MEM_ADDRESS(addrdata); /* PCI addr */ + if (sizep != NULL) + *sizep = ~PCI_MAPREG_MEM_ADDRESS(sizedata) + 1; + if (cacheablep != NULL) + *cacheablep = PCI_MAPREG_MEM_CACHEABLE(addrdata); return 0; } - -int -apecs_pcidma_map(addr, size, mappings) - caddr_t addr; - vm_size_t size; - vm_offset_t *mappings; -{ - vm_offset_t va; - long todo; - int i; - - i = 0; - va = (vm_offset_t)addr; - todo = size; - - while (todo > 0) { - mappings[i] = vtophys(va) | 0x40000000; -#if 0 - printf("a_pd_m mapping %d: %lx -> %lx -> %lx\n", i, va, - vtophys(va), mappings[i]); -#endif - i++; - todo -= PAGE_SIZE - (va - trunc_page(va)); - va += PAGE_SIZE - (va - trunc_page(va)); - } - return (i); -} - -void -apecs_pcidma_unmap(addr, size, nmappings, mappings) - caddr_t addr; - vm_size_t size; - int nmappings; - vm_offset_t *mappings; -{ - - /* maybe XXX if diagnostic, check that mapping happened. */ - printf("apecs_pcidma_unmap: nada\n"); -} diff --git a/sys/arch/alpha/pci/apecsreg.h b/sys/arch/alpha/pci/apecsreg.h index 186173f2bb7..864bfac54fe 100644 --- a/sys/arch/alpha/pci/apecsreg.h +++ b/sys/arch/alpha/pci/apecsreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: apecsreg.h,v 1.2 1995/08/03 01:17:04 cgd Exp $ */ +/* $NetBSD: apecsreg.h,v 1.3 1995/11/23 02:37:19 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -34,6 +34,8 @@ * Sheet'' (DEC order number EC-QAEMA-TE), pages 4-1 - 4-27, 10-21 - 10-38. */ +#define REGVAL(r) (*(int32_t *)phystok0seg(r)) + /* * Base addresses */ @@ -278,7 +280,9 @@ #define EPIC_HAXR1_EADDR 0xf8000000 #define EPIC_HAXR2 (EPIC_BASE + 0x01c0) /* Host Addr Extn 2 */ -#define EPIC_HAXR2_CONF_ADDR 0x00000003 +#define EPIC_HAXR2_CONF_TYPE 0x00000003 +#define EPIC_HAXR2_CONF_TYPO0 0x00000000 +#define EPIC_HAXR2_CONF_TYPE1 0x00000001 #define EPIC_HAXR2_RSVD 0x00fffffc #define EPIC_HAXR2_EADDR 0xff000000 diff --git a/sys/arch/alpha/pci/apecsvar.h b/sys/arch/alpha/pci/apecsvar.h new file mode 100644 index 00000000000..a63cc275922 --- /dev/null +++ b/sys/arch/alpha/pci/apecsvar.h @@ -0,0 +1,72 @@ +/* $NetBSD: apecsvar.h,v 1.1 1995/11/23 02:37:21 cgd Exp $ */ + +/* + * Copyright (c) 1995 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 +#include + +/* + * An APECS chipset's configuration. + * + * All of the information that the chipset-specific functions need to + * do their dirty work (and more!). + */ +struct apecs_config { + int ac_comanche_pass2; + int ac_epic_pass2; + int ac_memwidth; + + __const struct pci_conf_fns *ac_conffns; + void *ac_confarg; + + __const struct pci_dma_fns *ac_dmafns; + void *ac_dmaarg; + + __const struct pci_intr_fns *ac_intrfns; + void *ac_intrarg; + + __const struct pci_mem_fns *ac_memfns; + void *ac_memarg; + + __const struct pci_pio_fns *ac_piofns; + void *ac_pioarg; +}; + +struct apecs_softc { + struct device sc_dev; + + struct apecs_config *sc_acp; +}; + +extern __const struct pci_conf_fns apecs_conf_fns; +extern __const struct pci_dma_fns apecs_dma_fns; +/* pci interrupt functions handled elsewhere */ +extern __const struct pci_mem_fns apecs_mem_fns; +extern __const struct pci_pio_fns apecs_pio_fns; + +void apecs_init __P((struct apecs_config *)); diff --git a/sys/arch/alpha/pci/cia.c b/sys/arch/alpha/pci/cia.c new file mode 100644 index 00000000000..fa2f49fc6cc --- /dev/null +++ b/sys/arch/alpha/pci/cia.c @@ -0,0 +1,176 @@ +/* $NetBSD: cia.c,v 1.1 1995/11/23 02:37:24 cgd Exp $ */ + +/* + * Copyright (c) 1995 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 +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#if defined(DEC_KN20AA) +#include +#endif + +int ciamatch __P((struct device *, void *, void *)); +void ciaattach __P((struct device *, struct device *, void *)); + +struct cfdriver ciacd = { + NULL, "cia", ciamatch, ciaattach, DV_DULL, + sizeof(struct cia_softc) +}; + +static int ciaprint __P((void *, char *pnp)); + +#define REGVAL(r) (*(int32_t *)phystok0seg(r)) + +/* There can be only one. */ +int ciafound; +struct cia_config cia_configuration; + +int +ciamatch(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct cfdata *cf = match; + struct confargs *ca = aux; + + /* Make sure that we're looking for a CIA. */ + if (strcmp(ca->ca_name, ciacd.cd_name) != 0) + return (0); + + if (ciafound) + return (0); + + return (1); +} + +/* + * Set up the chipset's function pointers. + */ +void +cia_init(ccp) + struct cia_config *ccp; +{ + + /* + * Can't set up SGMAP data here; can be called before malloc(). + */ + + ccp->cc_conffns = &cia_conf_fns; + ccp->cc_confarg = ccp; + ccp->cc_dmafns = &cia_dma_fns; + ccp->cc_dmaarg = ccp; + /* Interrupt routines set up in 'attach' */ + ccp->cc_memfns = &cia_mem_fns; + ccp->cc_memarg = ccp; + ccp->cc_piofns = &cia_pio_fns; + ccp->cc_pioarg = ccp; +} + +void +ciaattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct confargs *ca = aux; + struct cia_softc *sc = (struct cia_softc *)self; + struct cia_config *ccp; + struct pci_attach_args pa; + + /* note that we've attached the chipset; can't have 2 CIAs. */ + ciafound = 1; + + /* + * set up the chipset's info; done once at console init time + * (maybe), but doesn't hurt to do twice. + */ + ccp = sc->sc_ccp = &cia_configuration; + cia_init(ccp); + + /* XXX print chipset information */ + printf("\n"); + + switch (hwrpb->rpb_type) { +#if defined(DEC_KN20AA) + case ST_DEC_KN20AA: + pci_kn20aa_pickintr(ccp->cc_conffns, ccp->cc_confarg, + ccp->cc_piofns, ccp->cc_pioarg, + &ccp->cc_intrfns, &ccp->cc_intrarg); +#ifdef EVCNT_COUNTERS + evcnt_attach(self, "intr", &kn20aa_intr_evcnt); +#endif + break; +#endif + default: + panic("ciaattach: shouldn't be here, really..."); + } + + pa.pa_bus = 0; + pa.pa_maxdev = 32; + pa.pa_burstlog2 = 8; + + pa.pa_conffns = ccp->cc_conffns; + pa.pa_confarg = ccp->cc_confarg; + pa.pa_dmafns = ccp->cc_dmafns; + pa.pa_dmaarg = ccp->cc_dmaarg; + pa.pa_intrfns = ccp->cc_intrfns; + pa.pa_intrarg = ccp->cc_intrarg; + pa.pa_memfns = ccp->cc_memfns; + pa.pa_memarg = ccp->cc_memarg; + pa.pa_piofns = ccp->cc_piofns; + pa.pa_pioarg = ccp->cc_pioarg; + + config_found(self, &pa, ciaprint); +} + +static int +ciaprint(aux, pnp) + void *aux; + char *pnp; +{ + register struct pci_attach_args *pa = aux; + + /* only PCIs can attach to CIAs; easy. */ + if (pnp) + printf("pci at %s", pnp); + printf(" bus %d", pa->pa_bus); + return (UNCONF); +} diff --git a/sys/arch/alpha/pci/cia_isa.c b/sys/arch/alpha/pci/cia_isa.c new file mode 100644 index 00000000000..6ccb0ae4a3e --- /dev/null +++ b/sys/arch/alpha/pci/cia_isa.c @@ -0,0 +1,346 @@ +/* $NetBSD: cia_isa.c,v 1.1 1995/11/23 02:37:26 cgd Exp $ */ + +/* + * Copyright (c) 1995 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 +#include +#include +#include +#include + +#include + +#include +#include + +/* + * Allocation/deallocation functions. + */ +int cia_pio_alloc __P((void *, isa_iooffset_t, isa_iosize_t)); +int cia_pio_dealloc __P((void *, isa_iooffset_t, isa_iosize_t)); + +/* + * Byte functions. + */ +isa_byte_t cia_inb __P((void *, isa_iooffset_t)); +#define cia_insb 0 /* XXX */ +void cia_outb __P((void *, isa_iooffset_t, isa_byte_t)); +#define cia_outsb 0 /* XXX */ + +/* + * Word functions. + */ +isa_word_t cia_inw __P((void *, isa_iooffset_t)); +#define cia_insw 0 /* XXX */ +void cia_outw __P((void *, isa_iooffset_t, isa_word_t)); +#define cia_outsw 0 /* XXX */ + +/* + * Longword functions. + */ +isa_long_t cia_inl __P((void *, isa_iooffset_t)); +#define cia_insl 0 /* XXX */ +void cia_outl __P((void *, isa_iooffset_t, isa_long_t)); +#define cia_outsl 0 /* XXX */ + +__const struct pci_pio_fns cia_pio_fns = { + /* Allocation/deallocation functions. */ + cia_pio_alloc, cia_pio_dealloc, + + /* Byte functions. */ + cia_inb, cia_insb, + cia_outb, cia_outsb, + + /* Word functions. */ + cia_inw, cia_insw, + cia_outw, cia_outsw, + + /* Longword functions. */ + cia_inl, cia_insl, + cia_outl, cia_outsl, +}; + +int +cia_pio_alloc(ipfarg, start, size) + void *ipfarg; + isa_iooffset_t start; + isa_iosize_t size; +{ + + /* XXX should do something */ +} + +int +cia_pio_dealloc(ipfarg, start, size) + void *ipfarg; + isa_iooffset_t start; + isa_iosize_t size; +{ + + /* XXX should do something */ +} + +isa_byte_t +cia_inb(ipfa, ioaddr) + void *ipfa; + isa_iooffset_t ioaddr; +{ + u_int32_t *port, val; + isa_byte_t rval; + int offset; + + wbflush(); + offset = ioaddr & 3; + port = (int32_t *)phystok0seg(CIA_PCI_SIO0 | 0 << 3 | ioaddr << 5); + val = *port; + rval = ((val) >> (8 * offset)) & 0xff; +/* rval = val & 0xff; */ + + return rval; +} + +void +cia_outb(ipfa, ioaddr, val) + void *ipfa; + isa_iooffset_t ioaddr; + isa_byte_t val; +{ + u_int32_t *port, nval; + int offset; + + offset = ioaddr & 3; + nval = val /*<< (8 * offset)*/; + nval = val << (8 * offset); + port = (int32_t *)phystok0seg(CIA_PCI_SIO0 | 0 << 3 | ioaddr << 5); + + *port = nval; + wbflush(); +} + +isa_word_t +cia_inw(ipfa, ioaddr) + void *ipfa; + isa_iooffset_t ioaddr; +{ + u_int32_t *port, val; + isa_word_t rval; + int offset; + + wbflush(); + offset = ioaddr & 3; + port = (int32_t *)phystok0seg(CIA_PCI_SIO0 | 1 << 3 | ioaddr << 5); + val = *port; + rval = ((val) >> (8 * offset)) & 0xffff; + rval = val & 0xffff; + +panic("inw(0x%x) => 0x%x @ %p => 0x%x\n", ioaddr, val, port, rval); + + return rval; +} + +void +cia_outw(ipfa, ioaddr, val) + void *ipfa; + isa_iooffset_t ioaddr; + isa_word_t val; +{ + u_int32_t *port, nval; + int offset; + + offset = ioaddr & 3; + nval = val /*<< (8 * offset)*/; + port = (int32_t *)phystok0seg(CIA_PCI_SIO0 | 1 << 3 | ioaddr << 5); + + *port = nval; + wbflush(); +} + +isa_long_t +cia_inl(ipfa, ioaddr) + void *ipfa; + isa_iooffset_t ioaddr; +{ + u_int32_t *port, val; + isa_long_t rval; + int offset; + + wbflush(); + offset = ioaddr & 3; + port = (int32_t *)phystok0seg(CIA_PCI_SIO0 | 3 << 3 | ioaddr << 5); + val = *port; + rval = ((val) >> (8 * offset)) & 0xffffffff; + rval = val & 0xffffffff; + + return rval; +} + +void +cia_outl(ipfa, ioaddr, val) + void *ipfa; + isa_iooffset_t ioaddr; + isa_long_t val; +{ + u_int32_t *port, nval; + int offset; + + offset = ioaddr & 3; + nval = val /*<< (8 * offset)*/; + port = (int32_t *)phystok0seg(CIA_PCI_SIO0 | 3 << 3 | ioaddr << 5); + + *port = nval; + wbflush(); +} + +/* XXX XXX XXX */ + +#define pf(fn, args) fn args { panic(__STRING(fn)); } + +void pf(cia_dma_cascade, (void *idfa, isa_drq_t chan)) +void pf(cia_dma_copytobuf, ()) +void pf(cia_dma_copyfrombuf, ()) +void pf(cia_dma_start, (void *idfa, vm_offset_t addr, + isa_msize_t size, isa_drq_t chan, int flags)) +void pf(cia_dma_abort, (void *idfa, isa_drq_t chan)) +void pf(cia_dma_done, (void *idfa, isa_drq_t chan)) + +int cia_dma_map __P((void *, vm_offset_t, isa_msize_t, + isa_moffset_t *, int)); +void cia_dma_unmap __P((void *, vm_offset_t, isa_msize_t, int, + isa_moffset_t *)); + +__const struct isa_dma_fns cia_dma_fns = { + cia_dma_cascade, + cia_dma_map, + cia_dma_unmap, + cia_dma_copytobuf, + cia_dma_copyfrombuf, + cia_dma_start, + cia_dma_abort, + cia_dma_done, +}; + +int +cia_dma_map(idfa, va, isasize, mappingsp, flags) + void *idfa; + vm_offset_t va; + isa_msize_t isasize; + isa_moffset_t *mappingsp; + int flags; +{ + struct apecs_config *acp = idfa; + long todo; + int i; + + if (ISA_DMA_NEEDCONTIG(flags) && isasize > NBPG || + ISA_DMA_SIZEBOUND(flags) != ISA_DMA_SIZEBOUND_NONE || + ISA_DMA_ADDRBOUND(flags) != ISA_DMA_ADDRBOUND_NONE) + panic("cia_dma_map: punt"); + + i = 0; + todo = isasize; + + while (todo > 0) { + mappingsp[i] = vtophys(va) | 0x40000000; +#if 0 + printf("a_pd_m mapping %d: %lx -> %lx -> %lx\n", i, va, + vtophys(va), mappingsp[i]); +#endif + i++; + todo -= PAGE_SIZE - (va - trunc_page(va)); + va += PAGE_SIZE - (va - trunc_page(va)); + } + return (i); +} + +void +cia_dma_unmap(idfa, va, isasize, nmappings, mappingsp) + void *idfa; + vm_offset_t va; + isa_msize_t isasize; + int nmappings; + isa_moffset_t *mappingsp; +{ + + printf("cia_dma_unmap: called\n"); +} + +vm_offset_t cia_mem_map __P((void *, isa_moffset_t, isa_msize_t, int)); +void cia_mem_unmap __P((void *, vm_offset_t, isa_msize_t)); + +#if 0 +void cia_mem_copytoisa __P((void *, char *, vm_offset_t, + isa_moffset_t, isa_msize_t)); +void cia_mem_copyfromisa __P((void *, char *, vm_offset_t, + isa_moffset_t, isa_msize_t)); +void cia_mem_zero __P((void *, vm_offset_t, isa_moffset_t, + isa_msize_t)); +#else +void pf(cia_mem_copytoisa, ()) +void pf(cia_mem_copyfromisa, ()) +void pf(cia_mem_zero, ()) +#endif + +__const struct isa_mem_fns cia_mem_fns = { + cia_mem_map, + cia_mem_unmap, + cia_mem_copytoisa, + cia_mem_copyfromisa, + cia_mem_zero, +}; + +vm_offset_t +cia_mem_map(imfa, isapa, isasize, cacheable) + void *imfa; + isa_moffset_t isapa; + isa_msize_t isasize; + int cacheable; +{ + vm_offset_t sbpa; + + /* XXX sanity checks on sizes, use of windows, etc. */ + + /* XXX MAGIC NUMBERS */ + if (cacheable) + sbpa = (isapa & 0xffffffff) | CIA_PCI_DENSE; + else + sbpa = ((isapa & 0x7ffffff) << 5) | CIA_PCI_SPARSE0; + + return phystok0seg(sbpa); +} + +void +cia_mem_unmap(imfa, va, isasize) + void *imfa; + vm_offset_t va; + isa_msize_t isasize; +{ + + /* XXX sanity checks on va */ + + /* Nothing to do; mapping was done in direct-mapped segment. */ +} diff --git a/sys/arch/alpha/pci/cia_pci.c b/sys/arch/alpha/pci/cia_pci.c new file mode 100644 index 00000000000..ef918cd84d6 --- /dev/null +++ b/sys/arch/alpha/pci/cia_pci.c @@ -0,0 +1,222 @@ +/* $NetBSD: cia_pci.c,v 1.1 1995/11/23 02:37:29 cgd Exp $ */ + +/* + * Copyright (c) 1995 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 +#include +#include +#include +#include + +#include +#include +#include +#include + +pci_confreg_t cia_conf_read __P((void *, pci_conftag_t, pci_confoffset_t)); +void cia_conf_write __P((void *, pci_conftag_t, + pci_confoffset_t, pci_confreg_t)); +int cia_find_io __P((void *, pci_conftag_t, + pci_confoffset_t, pci_iooffset_t *, pci_iosize_t *)); +int cia_find_mem __P((void *, pci_conftag_t, + pci_confoffset_t, pci_moffset_t *, pci_msize_t *, int *)); + +__const struct pci_conf_fns cia_conf_fns = { + cia_conf_read, + cia_conf_write, + cia_find_io, + cia_find_mem, +}; + +pci_confreg_t +cia_conf_read(cpv, tag, offset) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t offset; +{ + struct cia_config *acp = cpv; + pci_confreg_t *datap, data; + int s, secondary, ba; + int32_t old_haxr2; /* XXX */ + + secondary = PCI_TAG_BUS(tag) != 0; + if (secondary) { + s = splhigh(); + old_haxr2 = REGVAL(CIA_CSRS + 0x480); /* XXX */ + wbflush(); + REGVAL(CIA_CSRS + 0x480) = old_haxr2 | 0x1; /* XXX */ + wbflush(); + } + + datap = (pci_confreg_t *)phystok0seg(CIA_PCI_CONF | + tag << 5UL | /* XXX */ + (offset & ~0x03) << 5 | /* XXX */ + 0 << 5 | /* XXX */ + 0x3 << 3); /* XXX */ + data = (pci_confreg_t)-1; + if (!(ba = badaddr(datap, sizeof *datap))) + data = *datap; + + if (secondary) { + wbflush(); + REGVAL(CIA_CSRS + 0x480) = old_haxr2; /* XXX */ + wbflush(); + splx(s); + } + +#if 0 + printf("cia_conf_read: tag 0x%lx, reg 0x%lx -> %x @ %p%s\n", tag, reg, + data, datap, ba ? " (badaddr)" : ""); +#endif + + return data; +} + +void +cia_conf_write(cpv, tag, offset, data) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t offset; + pci_confreg_t data; +{ + struct cia_config *acp = cpv; + pci_confreg_t *datap; + int s, secondary; + int32_t old_haxr2; /* XXX */ + + secondary = PCI_TAG_BUS(tag) != 0; + if (secondary) { + s = splhigh(); + old_haxr2 = REGVAL(CIA_CSRS + 0x480); /* XXX */ + wbflush(); + REGVAL(CIA_CSRS + 0x480) = old_haxr2 | 0x1; /* XXX */ + wbflush(); + } + + datap = (pci_confreg_t *)phystok0seg(CIA_PCI_CONF | + tag << 5UL | /* XXX */ + (offset & ~0x03) << 5 | /* XXX */ + 0 << 5 | /* XXX */ + 0x3 << 3); /* XXX */ + *datap = data; + + if (secondary) { + wbflush(); + REGVAL(CIA_CSRS + 0x480) = old_haxr2; /* XXX */ + wbflush(); + splx(s); + } + +#if 0 + printf("cia_conf_write: tag 0x%lx, reg 0x%lx -> 0x%x @ %p\n", tag, + reg, data, datap); +#endif +} + +int +cia_find_io(cpv, tag, reg, iobasep, sizep) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t reg; + pci_iooffset_t *iobasep; + pci_iosize_t *sizep; +{ + struct cia_config *acp = cpv; + pci_confreg_t addrdata, sizedata; + pci_iooffset_t pci_iobase; + + if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3)) + panic("cia_map_io: bad request"); + + addrdata = PCI_CONF_READ(acp->cc_conffns, acp->cc_confarg, tag, reg); + + PCI_CONF_WRITE(acp->cc_conffns, acp->cc_confarg, tag, reg, 0xffffffff); + sizedata = PCI_CONF_READ(acp->cc_conffns, acp->cc_confarg, tag, reg); + PCI_CONF_WRITE(acp->cc_conffns, acp->cc_confarg, tag, reg, addrdata); + + if (PCI_MAPREG_TYPE(addrdata) == PCI_MAPREG_TYPE_MEM) + panic("cia_map_io: attempt to I/O map an memory region"); + + if (iobasep != NULL) + *iobasep = PCI_MAPREG_IO_ADDRESS(addrdata); + if (sizep != NULL) + *sizep = ~PCI_MAPREG_IO_ADDRESS(sizedata) + 1; + + return (0); +} + +int +cia_find_mem(cpv, tag, reg, paddrp, sizep, cacheablep) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t reg; + pci_moffset_t *paddrp; + pci_msize_t *sizep; + int *cacheablep; +{ + struct cia_config *acp = cpv; + pci_confreg_t addrdata, sizedata; + + if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3)) + panic("cia_map_mem: bad request"); + + /* + * The PROM has mapped the device for us. We take the address + * that's been assigned to the register, and figure out what + * physical and virtual addresses go with it... + */ + addrdata = PCI_CONF_READ(acp->cc_conffns, acp->cc_confarg, tag, reg); + + PCI_CONF_WRITE(acp->cc_conffns, acp->cc_confarg, tag, reg, 0xffffffff); + sizedata = PCI_CONF_READ(acp->cc_conffns, acp->cc_confarg, tag, reg); + PCI_CONF_WRITE(acp->cc_conffns, acp->cc_confarg, tag, reg, addrdata); + + if (PCI_MAPREG_TYPE(addrdata) == PCI_MAPREG_TYPE_IO) + panic("cia_map_mem: attempt to memory map an I/O region"); + + switch (PCI_MAPREG_MEM_TYPE(addrdata)) { + case PCI_MAPREG_MEM_TYPE_32BIT: + case PCI_MAPREG_MEM_TYPE_32BIT_1M: + break; + case PCI_MAPREG_MEM_TYPE_64BIT: +/* XXX */ printf("cia_map_mem: attempt to map 64-bit region\n"); +/* XXX */ break; + default: + printf("cia_map_mem: reserved mapping type\n"); + return EINVAL; + } + + if (paddrp != NULL) + *paddrp = PCI_MAPREG_MEM_ADDRESS(addrdata); /* PCI addr */ + if (sizep != NULL) + *sizep = ~PCI_MAPREG_MEM_ADDRESS(sizedata) + 1; + if (cacheablep != NULL) + *cacheablep = PCI_MAPREG_MEM_CACHEABLE(addrdata); + + return 0; +} diff --git a/sys/arch/alpha/isa/isa_intr.h b/sys/arch/alpha/pci/ciareg.h similarity index 61% rename from sys/arch/alpha/isa/isa_intr.h rename to sys/arch/alpha/pci/ciareg.h index 8f53ab9f699..5fc6ae9435a 100644 --- a/sys/arch/alpha/isa/isa_intr.h +++ b/sys/arch/alpha/pci/ciareg.h @@ -1,4 +1,4 @@ -/* $NetBSD: isa_intr.h,v 1.1 1995/06/28 01:24:57 cgd Exp $ */ +/* $NetBSD: ciareg.h,v 1.1 1995/11/23 02:37:31 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -27,28 +27,25 @@ * rights to redistribute these changes. */ -/* Prototypes for ISA-ish I/O interrupt functions. */ - /* - * XXX - * XXX THIS WILL LIKELY HAVE TO BE COMPLETELY CHANGED. - * XXX + * 21171 Chipset registers and constants. + * + * Taken from XXX */ -struct isa_intr_fcns { - void (*isa_intr_setup) __P((void)); - - void *(*isa_intr_establish) __P((int irq, isa_intrtype type, - isa_intrlevel level, int (*ih_fun)(void *), void *ih_arg)); - void (*isa_intr_disestablish) __P((void *handler)); - - void (*isa_iointr) __P((void *framep, int vec)); -}; +#define REGVAL(r) (*(int32_t *)phystok0seg(r)) /* - * Global which tells which set of functions are correct - * for this machine. + * Base addresses */ -struct isa_intr_fcns *isa_intr_fcns; - -struct isa_intr_fcns sio_intr_fcns; /* SIO ISA ICU handling */ +#define CIA_PCI_SPARSE0 0x8000000000L +#define CIA_PCI_SPARSE1 0x8400000000L +#define CIA_PCI_SPARSE2 0x8500000000L +#define CIA_PCI_SIO0 0x8580000000L +#define CIA_PCI_SIO1 0x85c0000000L +#define CIA_PCI_DENSE 0x8600000000L +#define CIA_PCI_CONF 0x8700000000L +#define CIA_PCI_IACK 0x8720000000L +#define CIA_CSRS 0x8740000000L +#define CIA_PCI_MC_CSRS 0x8750000000L +#define CIA_PCI_ATRANS 0x8760000000L diff --git a/sys/arch/alpha/pci/ciavar.h b/sys/arch/alpha/pci/ciavar.h new file mode 100644 index 00000000000..d9241010d89 --- /dev/null +++ b/sys/arch/alpha/pci/ciavar.h @@ -0,0 +1,69 @@ +/* $NetBSD: ciavar.h,v 1.1 1995/11/23 02:37:35 cgd Exp $ */ + +/* + * Copyright (c) 1995 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 +#include + +/* + * A 21171 chipset's configuration. + * + * All of the information that the chipset-specific functions need to + * do their dirty work (and more!). + */ +struct cia_config { + __const struct pci_conf_fns *cc_conffns; + void *cc_confarg; + + __const struct pci_dma_fns *cc_dmafns; + void *cc_dmaarg; + + __const struct pci_intr_fns *cc_intrfns; + void *cc_intrarg; + + __const struct pci_mem_fns *cc_memfns; + void *cc_memarg; + + __const struct pci_pio_fns *cc_piofns; + void *cc_pioarg; +}; + +struct cia_softc { + struct device sc_dev; + + struct cia_config *sc_ccp; + /* XXX SGMAP info */ +}; + +extern __const struct pci_conf_fns cia_conf_fns; +extern __const struct pci_dma_fns cia_dma_fns; +/* pci interrupt functions handled elsewhere */ +extern __const struct pci_mem_fns cia_mem_fns; +extern __const struct pci_pio_fns cia_pio_fns; + +void cia_init __P((struct cia_config *)); diff --git a/sys/arch/alpha/pci/lca.c b/sys/arch/alpha/pci/lca.c new file mode 100644 index 00000000000..ac6514fee99 --- /dev/null +++ b/sys/arch/alpha/pci/lca.c @@ -0,0 +1,210 @@ +/* $NetBSD: lca.c,v 1.1 1995/11/23 02:37:38 cgd Exp $ */ + +/* + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Jeffrey Hsu + * + * 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 +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +int lcamatch __P((struct device *, void *, void *)); +void lcaattach __P((struct device *, struct device *, void *)); + +struct cfdriver lcacd = { + NULL, "lca", lcamatch, lcaattach, DV_DULL, + sizeof(struct lca_softc) +}; + +static int lcaprint __P((void *, char *pnp)); + +/* There can be only one. */ +int lcafound; +struct lca_config lca_configuration; + +int +lcamatch(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct cfdata *cf = match; + struct confargs *ca = aux; + + /* Make sure that we're looking for a LCA. */ + if (strcmp(ca->ca_name, lcacd.cd_name) != 0) + return (0); + + if (lcafound) + return (0); + + return (1); +} + +/* + * Set up the chipset's function pointers. + */ +void +lca_init(lcp) + struct lca_config *lcp; +{ + + /* + * Can't set up SGMAP data here; can be called before malloc(). + */ + + lcp->lc_conffns = &lca_conf_fns; + lcp->lc_confarg = lcp; + lcp->lc_dmafns = &lca_dma_fns; + lcp->lc_dmaarg = lcp; + /* Interrupt routines set up in 'attach' */ + lcp->lc_memfns = &lca_mem_fns; + lcp->lc_memarg = lcp; + lcp->lc_piofns = &lca_pio_fns; + lcp->lc_pioarg = lcp; + +/* +printf("lca_init: before IOC_HAE=0x%x\n", REGVAL(LCA_IOC_HAE)); + REGVAL(LCA_IOC_HAE) = 0; */ + + REGVAL(LCA_IOC_CONF) = 0; + + /* Turn off DMA window enables in Window Base Registers */ +/* REGVAL(LCA_IOC_W_BASE0) = 0; + REGVAL(LCA_IOC_W_BASE1) = 0; */ + wbflush(); +} + +#ifdef notdef +void +lca_init_sgmap(lcp) + struct lca_config *lcp; +{ + + /* XXX */ + lcp->lc_sgmap = malloc(1024 * 8, M_DEVBUF, M_WAITOK); + bzero(lcp->lc_sgmap, 1024 * 8); /* clear all entries. */ + + REGVAL(LCA_IOC_W_BASE0) = 0; + wbflush(); + + /* Set up Translated Base Register 1; translate to sybBus addr 0. */ + /* check size against APEC XXX JH */ + REGVAL(LCA_IOC_T_BASE_0) = vtophys(lcp->lc_sgmap) >> 1; + + /* Set up PCI mask register 1; map 8MB space. */ + REGVAL(LCA_IOC_W_MASK0) = 0x00700000; + + /* Enable window 1; from PCI address 8MB, direct mapped. */ + REGVAL(LCA_IOC_W_BASE0) = 0x300800000; + wbflush(); +} +#endif + +void +lcaattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct confargs *ca = aux; + struct lca_softc *sc = (struct lca_softc *)self; + struct lca_config *lcp; + struct pci_attach_args pa; + + /* note that we've attached the chipset; can't have 2 LCAs. */ + /* Um, not sure about this. XXX JH */ + lcafound = 1; + + /* + * set up the chipset's info; done once at console init time + * (maybe), but doesn't hurt to do twice. + */ + lcp = sc->sc_lcp = &lca_configuration; + lca_init(lcp); +#ifdef notdef + lca_init_sgmap(lcp); +#endif + + /* XXX print chipset information */ + printf("\n"); + + switch (hwrpb->rpb_type) { +#if defined(DEC_AXPPCI_33) + case ST_DEC_AXPPCI_33: + pci_axppci_33_pickintr(lcp->lc_conffns, lcp->lc_confarg, + lcp->lc_piofns, lcp->lc_pioarg, + &lcp->lc_intrfns, &lcp->lc_intrarg); + break; +#endif + default: + panic("lcaattach: shouldn't be here, really..."); + } + + pa.pa_bus = 0; + pa.pa_maxdev = 13; + pa.pa_burstlog2 = 8; + + pa.pa_conffns = lcp->lc_conffns; + pa.pa_confarg = lcp->lc_confarg; + pa.pa_dmafns = lcp->lc_dmafns; + pa.pa_dmaarg = lcp->lc_dmaarg; + pa.pa_intrfns = lcp->lc_intrfns; + pa.pa_intrarg = lcp->lc_intrarg; + pa.pa_memfns = lcp->lc_memfns; + pa.pa_memarg = lcp->lc_memarg; + pa.pa_piofns = lcp->lc_piofns; + pa.pa_pioarg = lcp->lc_pioarg; + + config_found(self, &pa, lcaprint); +} + +static int +lcaprint(aux, pnp) + void *aux; + char *pnp; +{ + register struct pci_attach_args *pa = aux; + + /* what does this do? XXX JH */ + /* only PCIs can attach to LCAes; easy. */ + if (pnp) + printf("pci at %s", pnp); + printf(" bus %d", pa->pa_bus); + return (UNCONF); +} diff --git a/sys/arch/alpha/pci/lca_isa.c b/sys/arch/alpha/pci/lca_isa.c new file mode 100644 index 00000000000..205d8708663 --- /dev/null +++ b/sys/arch/alpha/pci/lca_isa.c @@ -0,0 +1,346 @@ +/* $NetBSD: lca_isa.c,v 1.1 1995/11/23 02:37:40 cgd Exp $ */ + +/* + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Jeffrey Hsu + * + * 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 +#include +#include +#include +#include + +#include + +#include +#include + +/* + * Allocation/deallocation functions. + */ +int lca_pio_alloc __P((void *, isa_iooffset_t, isa_iosize_t)); +int lca_pio_dealloc __P((void *, isa_iooffset_t, isa_iosize_t)); + +/* + * Byte functions. + */ +isa_byte_t lca_inb __P((void *, isa_iooffset_t)); +#define lca_insb 0 /* XXX */ +void lca_outb __P((void *, isa_iooffset_t, isa_byte_t)); +#define lca_outsb 0 /* XXX */ + +/* + * Word functions. + */ +isa_word_t lca_inw __P((void *, isa_iooffset_t)); +#define lca_insw 0 /* XXX */ +void lca_outw __P((void *, isa_iooffset_t, isa_word_t)); +#define lca_outsw 0 /* XXX */ + +/* + * Longword functions. + */ +isa_long_t lca_inl __P((void *, isa_iooffset_t)); +#define lca_insl 0 /* XXX */ +void lca_outl __P((void *, isa_iooffset_t, isa_long_t)); +#define lca_outsl 0 /* XXX */ + +__const struct pci_pio_fns lca_pio_fns = { + /* Allocation/deallocation functions. */ + lca_pio_alloc, lca_pio_dealloc, + + /* Byte functions. */ + lca_inb, lca_insb, + lca_outb, lca_outsb, + + /* Word functions. */ + lca_inw, lca_insw, + lca_outw, lca_outsw, + + /* Longword functions. */ + lca_inl, lca_insl, + lca_outl, lca_outsl, +}; + +int +lca_pio_alloc(ipfarg, start, size) + void *ipfarg; + isa_iooffset_t start; + isa_iosize_t size; +{ + + /* XXX should do something */ +} + +int +lca_pio_dealloc(ipfarg, start, size) + void *ipfarg; + isa_iooffset_t start; + isa_iosize_t size; +{ + + /* XXX should do something */ +} + +isa_byte_t +lca_inb(ipfa, ioaddr) + void *ipfa; + isa_iooffset_t ioaddr; +{ + u_int32_t *port, val; + isa_byte_t rval; + int offset; + + wbflush(); + offset = ioaddr & 3; + port = (int32_t *)phystok0seg(LCA_PCI_SIO | 0 << 3 | ioaddr << 5); + val = *port; + rval = ((val) >> (8 * offset)) & 0xff; +/* rval = val & 0xff; */ + + return rval; +} + +void +lca_outb(ipfa, ioaddr, val) + void *ipfa; + isa_iooffset_t ioaddr; + isa_byte_t val; +{ + u_int32_t *port, nval; + int offset; + + offset = ioaddr & 3; + nval = val /*<< (8 * offset)*/; + nval = val << (8 * offset); + port = (int32_t *)phystok0seg(LCA_PCI_SIO | 0 << 3 | ioaddr << 5); + + *port = nval; + wbflush(); +} + +isa_word_t +lca_inw(ipfa, ioaddr) + void *ipfa; + isa_iooffset_t ioaddr; +{ + u_int32_t *port, val; + isa_word_t rval; + int offset; + + wbflush(); + offset = ioaddr & 3; + port = (int32_t *)phystok0seg(LCA_PCI_SIO | 1 << 3 | ioaddr << 5); + val = *port; + rval = ((val) >> (8 * offset)) & 0xffff; + rval = val & 0xffff; + +panic("inw(0x%x) => 0x%x @ %p => 0x%x\n", ioaddr, val, port, rval); + + return rval; +} + +void +lca_outw(ipfa, ioaddr, val) + void *ipfa; + isa_iooffset_t ioaddr; + isa_word_t val; +{ + u_int32_t *port, nval; + int offset; + + offset = ioaddr & 3; + nval = val /*<< (8 * offset)*/; + port = (int32_t *)phystok0seg(LCA_PCI_SIO | 1 << 3 | ioaddr << 5); + + *port = nval; + wbflush(); +} + +isa_long_t +lca_inl(ipfa, ioaddr) + void *ipfa; + isa_iooffset_t ioaddr; +{ + u_int32_t *port, val; + isa_long_t rval; + int offset; + + wbflush(); + offset = ioaddr & 3; + port = (int32_t *)phystok0seg(LCA_PCI_SIO | 3 << 3 | ioaddr << 5); + val = *port; + rval = ((val) >> (8 * offset)) & 0xffffffff; + rval = val & 0xffffffff; + + return rval; +} + +void +lca_outl(ipfa, ioaddr, val) + void *ipfa; + isa_iooffset_t ioaddr; + isa_long_t val; +{ + u_int32_t *port, nval; + int offset; + + offset = ioaddr & 3; + nval = val /*<< (8 * offset)*/; + port = (int32_t *)phystok0seg(LCA_PCI_SIO | 3 << 3 | ioaddr << 5); + + *port = nval; + wbflush(); +} + +/* XXX XXX XXX */ + +#define pf(fn, args) fn args { panic(__STRING(fn)); } + +void pf(lca_dma_cascade, (void *idfa, isa_drq_t chan)) +void pf(lca_dma_copytobuf, ()) +void pf(lca_dma_copyfrombuf, ()) +void pf(lca_dma_start, (void *idfa, vm_offset_t addr, + isa_msize_t size, isa_drq_t chan, int flags)) +void pf(lca_dma_abort, (void *idfa, isa_drq_t chan)) +void pf(lca_dma_done, (void *idfa, isa_drq_t chan)) + +int lca_dma_map __P((void *, vm_offset_t, isa_msize_t, + isa_moffset_t *, int)); +void lca_dma_unmap __P((void *, vm_offset_t, isa_msize_t, int, + isa_moffset_t *)); + +__const struct isa_dma_fns lca_dma_fns = { + lca_dma_cascade, + lca_dma_map, + lca_dma_unmap, + lca_dma_copytobuf, + lca_dma_copyfrombuf, + lca_dma_start, + lca_dma_abort, + lca_dma_done, +}; + +int +lca_dma_map(idfa, va, isasize, mappingsp, flags) + void *idfa; + vm_offset_t va; + isa_msize_t isasize; + isa_moffset_t *mappingsp; + int flags; +{ + struct lca_config *acp = idfa; + long todo; + int i; + + if (ISA_DMA_NEEDCONTIG(flags) && isasize > NBPG || + ISA_DMA_SIZEBOUND(flags) != ISA_DMA_SIZEBOUND_NONE || + ISA_DMA_ADDRBOUND(flags) != ISA_DMA_ADDRBOUND_NONE) + panic("lca_dma_map: punt"); + + i = 0; + todo = isasize; + + while (todo > 0) { + mappingsp[i] = vtophys(va) | 0x40000000; +#if 0 + printf("a_pd_m mapping %d: %lx -> %lx -> %lx\n", i, va, + vtophys(va), mappingsp[i]); +#endif + i++; + todo -= PAGE_SIZE - (va - trunc_page(va)); + va += PAGE_SIZE - (va - trunc_page(va)); + } + return (i); +} + +void +lca_dma_unmap(idfa, va, isasize, nmappings, mappingsp) + void *idfa; + vm_offset_t va; + isa_msize_t isasize; + int nmappings; + isa_moffset_t *mappingsp; +{ + + printf("lca_dma_unmap: called\n"); +} + +vm_offset_t lca_mem_map __P((void *, isa_moffset_t, isa_msize_t, int)); +void lca_mem_unmap __P((void *, vm_offset_t, isa_msize_t)); + +#if 0 +void lca_mem_copytoisa __P((void *, char *, vm_offset_t, + isa_moffset_t, isa_msize_t)); +void lca_mem_copyfromisa __P((void *, char *, vm_offset_t, + isa_moffset_t, isa_msize_t)); +void lca_mem_zero __P((void *, vm_offset_t, isa_moffset_t, + isa_msize_t)); +#else +void pf(lca_mem_copytoisa, ()) +void pf(lca_mem_copyfromisa, ()) +void pf(lca_mem_zero, ()) +#endif + +__const struct isa_mem_fns lca_mem_fns = { + lca_mem_map, + lca_mem_unmap, + lca_mem_copytoisa, + lca_mem_copyfromisa, + lca_mem_zero, +}; + +vm_offset_t +lca_mem_map(imfa, isapa, isasize, cacheable) + void *imfa; + isa_moffset_t isapa; + isa_msize_t isasize; + int cacheable; +{ + vm_offset_t sbpa; + + /* XXX sanity checks on sizes, use of windows, etc. */ + + /* XXX MAGIC NUMBERS */ + if (cacheable) + sbpa = (isapa & 0xffffffff) | LCA_PCI_DENSE; + else + sbpa = ((isapa & 0x7ffffff) << 5) | LCA_PCI_SPARSE; + + return phystok0seg(sbpa); +} + +void +lca_mem_unmap(imfa, va, isasize) + void *imfa; + vm_offset_t va; + isa_msize_t isasize; +{ + + /* XXX sanity checks on va */ + + /* Nothing to do; mapping was done in direct-mapped segment. */ +} diff --git a/sys/arch/alpha/pci/lca_pci.c b/sys/arch/alpha/pci/lca_pci.c new file mode 100644 index 00000000000..1b151dcefb9 --- /dev/null +++ b/sys/arch/alpha/pci/lca_pci.c @@ -0,0 +1,226 @@ +/* $NetBSD: lca_pci.c,v 1.1 1995/11/23 02:37:42 cgd Exp $ */ + +/* + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Jeffrey Hsu + * + * 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 +#include +#include +#include +#include + +#include +#include +#include +#include + +pci_confreg_t lca_conf_read __P((void *, pci_conftag_t, pci_confoffset_t)); +void lca_conf_write __P((void *, pci_conftag_t, + pci_confoffset_t, pci_confreg_t)); +int lca_find_io __P((void *, pci_conftag_t, + pci_confoffset_t, pci_iooffset_t *, pci_iosize_t *)); +int lca_find_mem __P((void *, pci_conftag_t, + pci_confoffset_t, pci_moffset_t *, pci_msize_t *, int *)); + +__const struct pci_conf_fns lca_conf_fns = { + lca_conf_read, + lca_conf_write, + lca_find_io, + lca_find_mem, +}; + +pci_confreg_t +lca_conf_read(cpv, tag, offset) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t offset; +{ + pci_confreg_t *datap, data; + int s, secondary, ba; + int32_t old_ioc_conf; /* XXX */ + u_int64_t dev_sel; + + dev_sel = 1 << PCI_TAG_DEVICE(tag) + 11; + + secondary = PCI_TAG_BUS(tag) != 0; + if (secondary) { + s = splhigh(); + old_ioc_conf = REGVAL(LCA_IOC_CONF); + wbflush(); + REGVAL(LCA_IOC_CONF) = old_ioc_conf | 0x1; + wbflush(); + } + + datap = (pci_confreg_t *)phystok0seg(LCA_PCI_CONF | + dev_sel << 5UL | /* XXX */ + (offset & ~0x03) << 5 | /* XXX */ + 0 << 5 | /* XXX */ + 0x3 << 3); /* XXX */ + data = (pci_confreg_t)-1; + if (!(ba = badaddr(datap, sizeof *datap))) + data = *datap; + + if (secondary) { + wbflush(); + REGVAL(LCA_IOC_CONF) = old_ioc_conf; + wbflush(); + splx(s); + } + +#if 0 + printf("lca_conf_read: tag 0x%x, offset 0x%x -> %x @ %p%s\n", tag, + offset, data, datap, ba ? " (badaddr)" : ""); +#endif + + return data; +} + +void +lca_conf_write(cpv, tag, offset, data) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t offset; + pci_confreg_t data; +{ + pci_confreg_t *datap; + int s, secondary; + int32_t old_ioc_conf; /* XXX */ + int32_t dev_sel; + + dev_sel = 1 << PCI_TAG_DEVICE(tag) + 11; + + secondary = PCI_TAG_BUS(tag) != 0; + if (secondary) { + s = splhigh(); + old_ioc_conf = REGVAL(LCA_IOC_CONF); + wbflush(); + REGVAL(LCA_IOC_CONF) = old_ioc_conf | 0x1; + wbflush(); + } + + datap = (pci_confreg_t *)phystok0seg(LCA_PCI_CONF | + dev_sel << 5UL | /* XXX */ + (offset & ~0x03) << 5 | /* XXX */ + 0 << 5 | /* XXX */ + 0x3 << 3); /* XXX */ + *datap = data; + + if (secondary) { + wbflush(); + REGVAL(LCA_IOC_CONF) = old_ioc_conf; + wbflush(); + splx(s); + } + +#if 0 + printf("lca_conf_write: tag 0x%x, offset 0x%x -> 0x%x @ %p\n", tag, + offset, data, datap); +#endif +} + +int +lca_find_io(cpv, tag, reg, iobasep, sizep) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t reg; + pci_iooffset_t *iobasep; + pci_iosize_t *sizep; +{ + struct lca_config *lcp = cpv; + pci_confreg_t addrdata, sizedata; + pci_iooffset_t pci_iobase; + + if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3)) + panic("lca_map_io: bad request"); + + addrdata = PCI_CONF_READ(lcp->lc_conffns, lcp->lc_confarg, tag, reg); + + PCI_CONF_WRITE(lcp->lc_conffns, lcp->lc_confarg, tag, reg, 0xffffffff); + sizedata = PCI_CONF_READ(lcp->lc_conffns, lcp->lc_confarg, tag, reg); + PCI_CONF_WRITE(lcp->lc_conffns, lcp->lc_confarg, tag, reg, addrdata); + + if (PCI_MAPREG_TYPE(addrdata) == PCI_MAPREG_TYPE_MEM) + panic("lca_map_io: attempt to I/O map an memory region"); + + if (iobasep != NULL) + *iobasep = PCI_MAPREG_IO_ADDRESS(addrdata); + if (sizep != NULL) + *sizep = ~PCI_MAPREG_IO_ADDRESS(sizedata) + 1; + + return (0); +} + +int +lca_find_mem(cpv, tag, reg, paddrp, sizep, cacheablep) + void *cpv; + pci_conftag_t tag; + pci_confoffset_t reg; + pci_moffset_t *paddrp; + pci_msize_t *sizep; + int *cacheablep; +{ + struct lca_config *lcp = cpv; + pci_confreg_t addrdata, sizedata; + + if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3)) + panic("lca_map_mem: bad request"); + + /* + * The PROM has mapped the device for us. We take the address + * that's been assigned to the register, and figure out what + * physical and virtual addresses go with it... + */ + addrdata = PCI_CONF_READ(lcp->lc_conffns, lcp->lc_confarg, tag, reg); + + PCI_CONF_WRITE(lcp->lc_conffns, lcp->lc_confarg, tag, reg, 0xffffffff); + sizedata = PCI_CONF_READ(lcp->lc_conffns, lcp->lc_confarg, tag, reg); + PCI_CONF_WRITE(lcp->lc_conffns, lcp->lc_confarg, tag, reg, addrdata); + + if (PCI_MAPREG_TYPE(addrdata) == PCI_MAPREG_TYPE_IO) + panic("lca_map_mem: attempt to memory map an I/O region"); + + switch (PCI_MAPREG_MEM_TYPE(addrdata)) { + case PCI_MAPREG_MEM_TYPE_32BIT: + case PCI_MAPREG_MEM_TYPE_32BIT_1M: + break; + case PCI_MAPREG_MEM_TYPE_64BIT: +/* XXX */ printf("lca_map_mem: attempt to map 64-bit region\n"); +/* XXX */ break; + default: + printf("lca_map_mem: reserved mapping type\n"); + return EINVAL; + } + + if (paddrp != NULL) + *paddrp = PCI_MAPREG_MEM_ADDRESS(addrdata); /* PCI addr */ + if (sizep != NULL) + *sizep = ~PCI_MAPREG_MEM_ADDRESS(sizedata) + 1; + if (cacheablep != NULL) + *cacheablep = PCI_MAPREG_MEM_CACHEABLE(addrdata); + + return 0; +} diff --git a/sys/arch/alpha/pci/lcareg.h b/sys/arch/alpha/pci/lcareg.h new file mode 100644 index 00000000000..ac876e3110d --- /dev/null +++ b/sys/arch/alpha/pci/lcareg.h @@ -0,0 +1,55 @@ +/* $NetBSD: lcareg.h,v 1.1 1995/11/23 02:37:44 cgd Exp $ */ + +/* + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Jeffrey Hsu + * + * 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. + */ + +/* + * 21066 chip registers + */ + +#define REGVAL(r) (*(int32_t *)phystok0seg(r)) + +/* + * Base addresses + */ +#define LCA_IOC_BASE 0x180000000L /* LCA IOC Regs */ +#define LCA_PCI_SIO 0x1c0000000L /* PCI Sp. I/O Space */ +#define LCA_PCI_CONF 0x1e0000000L /* PCI Conf. Space */ +#define LCA_PCI_SPARSE 0x200000000L /* PCI Sparse Space */ +#define LCA_PCI_DENSE 0x300000000L /* PCI Dense Space */ + +#define LCA_IOC_HAE LCA_IOC_BASE /* Host Address Extension */ + +#define LCA_IOC_CONF (LCA_IOC_BASE + 0x020) /* Configuration Cycle Type */ + +#define LCA_IOC_W_BASE0 (LCA_IOC_BASE + 0x100) /* Window Base */ +#define LCA_IOC_W_MASK0 (LCA_IOC_BASE + 0x140) /* Window Mask */ +#define LCA_IOC_W_T_BASE0 (LCA_IOC_BASE + 0x180) /* Translated Base */ + +#define LCA_IOC_W_BASE1 (LCA_IOC_BASE + 0x120) /* Window Base */ +#define LCA_IOC_W_MASK1 (LCA_IOC_BASE + 0x160) /* Window Mask */ +#define LCA_IOC_W_T_BASE1 (LCA_IOC_BASE + 0x1a0) /* Translated Base */ diff --git a/sys/arch/alpha/pci/lcavar.h b/sys/arch/alpha/pci/lcavar.h new file mode 100644 index 00000000000..80c70807172 --- /dev/null +++ b/sys/arch/alpha/pci/lcavar.h @@ -0,0 +1,68 @@ +/* $NetBSD: lcavar.h,v 1.1 1995/11/23 02:37:47 cgd Exp $ */ + +/* + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Jeffrey Hsu + * + * 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 +#include + +/* + * LCA chipset's configuration. + * + * All of the information that the chipset-specific functions need to + * do their dirty work (and more!). + */ +struct lca_config { + __const struct pci_conf_fns *lc_conffns; + void *lc_confarg; + + __const struct pci_dma_fns *lc_dmafns; + void *lc_dmaarg; + + __const struct pci_intr_fns *lc_intrfns; + void *lc_intrarg; + + __const struct pci_mem_fns *lc_memfns; + void *lc_memarg; + + __const struct pci_pio_fns *lc_piofns; + void *lc_pioarg; +}; + +struct lca_softc { + struct device sc_dev; + + struct lca_config *sc_lcp; +}; + +extern __const struct pci_conf_fns lca_conf_fns; +extern __const struct pci_dma_fns lca_dma_fns; +/* pci interrupt functions handled elsewhere */ +extern __const struct pci_mem_fns lca_mem_fns; +extern __const struct pci_pio_fns lca_pio_fns; + +void lca_init __P((struct lca_config *)); diff --git a/sys/arch/alpha/pci/pci_2100_a50.c b/sys/arch/alpha/pci/pci_2100_a50.c index 9390f581e54..c33a9a83b0e 100644 --- a/sys/arch/alpha/pci/pci_2100_a50.c +++ b/sys/arch/alpha/pci/pci_2100_a50.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci_2100_a50.c,v 1.2 1995/08/03 01:17:10 cgd Exp $ */ +/* $NetBSD: pci_2100_a50.c,v 1.3 1995/11/23 02:37:49 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -33,68 +33,54 @@ #include #include #include - #include #include -#include - -#include #include -#include +#include -void pci_2100_a50_attach __P((struct device *, struct device *, void *)); -void *pci_2100_a50_map_int __P((pcitag_t, pci_intrlevel, int (*) (void *), - void *, int)); +#include -struct pci_cfg_fcns pci_2100_a50_sio1_cfg_fcns = { /* XXX diff? */ - pci_2100_a50_attach, pci_2100_a50_map_int, -}; +#include +#include -struct pci_cfg_fcns pci_2100_a50_sio2_cfg_fcns = { - pci_2100_a50_attach, pci_2100_a50_map_int, -}; +#include "sio.h" -void -pci_2100_a50_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - int bus, device; +void *dec_2100_a50_pci_map_int __P((void *, pci_conftag_t, + pci_intr_pin_t, pci_intr_line_t, pci_intrlevel_t, + int (*func)(void *), void *)); +void dec_2100_a50_pci_unmap_int __P((void *, void *)); -#if 0 - for (bus = 0; bus <= 255; bus++) -#else - /* - * XXX - * Some current chipsets do wacky things with bus numbers > 0. - * This seems like a violation of protocol, but the PCI BIOS does - * allow one to query the maximum bus number, and eventually we - * should do so. - */ - for (bus = 0; bus <= 0; bus++) -#endif - for (device = 0; device <= 31; device++) - pci_attach_subdev(self, bus, device); -} +__const struct pci_intr_fns dec_2100_a50_pci_intr_fns = { + dec_2100_a50_pci_map_int, + dec_2100_a50_pci_unmap_int, +}; void * -pci_2100_a50_map_int(tag, level, func, arg, pin) - pcitag_t tag; - pci_intrlevel level; +dec_2100_a50_pci_map_int(acv, tag, pin, line, level, func, arg) + void *acv; + pci_conftag_t tag; + pci_intr_pin_t pin; + pci_intr_line_t line; + pci_intrlevel_t level; int (*func) __P((void *)); void *arg; - int pin; { + struct apecs_config *acp = acv; int bus, device, pirq; - pcireg_t pirqreg; - u_int8_t line; + pci_confreg_t irreg, pirqreg; + u_int8_t pirqline; - bus = (tag >> 21) & 0xff; /* XXX */ - device = (tag >> 16) & 0x1f; + if (pin == 0) { + /* No IRQ used. */ + return 0; + } + if (pin > 4) { + printf("pci_map_int: bad interrupt pin %d\n", pin); + return NULL; + } - if (bus != 0) /* XXX */ - return NULL; + device = PCI_TAG_DEVICE(tag); switch (device) { case 6: /* NCR SCSI */ @@ -147,43 +133,65 @@ pci_2100_a50_map_int(tag, level, func, arg, pin) break; } - pirqreg = pci_conf_read(pci_make_tag(0, 7, 0), 0x60); /* XXX */ + pirqreg = PCI_CONF_READ(acp->ac_conffns, acp->ac_confarg, + PCI_MAKE_TAG(0, 7, 0), 0x60); /* XXX */ #if 0 printf("pci_2100_a50_map_int: device %d pin %c: pirq %d, reg = %x\n", device, '@' + pin, pirq, pirqreg); #endif - line = (pirqreg >> (pirq * 8)) & 0xff; - if ((line & 0x80) != 0) + pirqline = (pirqreg >> (pirq * 8)) & 0xff; + if ((pirqline & 0x80) != 0) return 0; /* not routed? */ - line &= 0xf; + pirqline &= 0xf; #if 0 printf("pci_2100_a50_map_int: device %d pin %c: mapped to line %d\n", - device, '@' + pin, line); + device, '@' + pin, pirqline); #endif - return isa_intr_establish(line, ISA_IST_LEVEL, pcilevel_to_isa(level), +#if NSIO + return ISA_INTR_ESTABLISH(&sio_isa_intr_fns, NULL, /* XXX */ + pirqline, ISA_IST_LEVEL, pci_intrlevel_to_isa(level), func, arg); +#else + panic("dec_2100_a50_pci_map_int: no sio!"); +#endif +} + +void +dec_2100_a50_pci_unmap_int(pifa, cookie) + void *pifa; + void *cookie; +{ + + panic("dec_2100_a50_pci_unmap_int not implemented"); /* XXX */ } void -pci_2100_a50_pickintr() +pci_2100_a50_pickintr(pcf, pcfa, ppf, ppfa, pifp, pifap) + __const struct pci_conf_fns *pcf; + __const struct pci_pio_fns *ppf; + void *pcfa, *ppfa; + __const struct pci_intr_fns **pifp; + void **pifap; { - pcireg_t sioclass; + pci_confreg_t sioclass; int sioII; /* XXX MAGIC NUMBER */ - sioclass = pci_conf_read(pci_make_tag(0, 7, 0), PCI_CLASS_REG); + sioclass = PCI_CONF_READ(pcf, pcfa, PCI_MAKE_TAG(0, 7, 0), + PCI_CLASS_REG); sioII = (sioclass & 0xff) >= 3; - if (!sioII) - printf("WARNING: SIO NOT SIO II... NO BETS...\n"); if (!sioII) - pci_cfg_fcns = &pci_2100_a50_sio1_cfg_fcns; - else - pci_cfg_fcns = &pci_2100_a50_sio2_cfg_fcns; + printf("WARNING: SIO NOT SIO II... NO BETS...\n"); - isa_intr_fcns = &sio_intr_fcns; - (*isa_intr_fcns->isa_intr_setup)(); - set_iointr(isa_intr_fcns->isa_iointr); + *pifp = &dec_2100_a50_pci_intr_fns; + *pifap = pcfa; /* XXX assumes apecs_config ptr */ +#if NSIO + sio_intr_setup(ppf, ppfa); + set_iointr(&sio_iointr); +#else + panic("pci_2100_a50_pickintr: no I/O interrupt handler (no sio)"); +#endif } diff --git a/sys/arch/alpha/pci/pci_2100_a50.h b/sys/arch/alpha/pci/pci_2100_a50.h new file mode 100644 index 00000000000..08c22aef089 --- /dev/null +++ b/sys/arch/alpha/pci/pci_2100_a50.h @@ -0,0 +1,32 @@ +/* $NetBSD: pci_2100_a50.h,v 1.1 1995/11/23 02:37:51 cgd Exp $ */ + +/* + * Copyright (c) 1995 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. + */ + +void pci_2100_a50_pickintr __P((__const struct pci_conf_fns *, void *, + __const struct pci_pio_fns *, void *, + __const struct pci_intr_fns **, void **)); diff --git a/sys/arch/alpha/pci/pci_axppci_33.c b/sys/arch/alpha/pci/pci_axppci_33.c new file mode 100644 index 00000000000..74fb338e91f --- /dev/null +++ b/sys/arch/alpha/pci/pci_axppci_33.c @@ -0,0 +1,204 @@ +/* $NetBSD: pci_axppci_33.c,v 1.1 1995/11/23 02:37:54 cgd Exp $ */ + +/* + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Jeffrey Hsu + * + * 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include + +#include "sio.h" + +void *dec_axppci_33_pci_map_int __P((void *, pci_conftag_t, + pci_intr_pin_t, pci_intr_line_t, pci_intrlevel_t, + int (*func)(void *), void *)); +void dec_axppci_33_pci_unmap_int __P((void *, void *)); + +__const struct pci_intr_fns dec_axppci_33_pci_intr_fns = { + dec_axppci_33_pci_map_int, + dec_axppci_33_pci_unmap_int, +}; + +void * +dec_axppci_33_pci_map_int(lcv, tag, pin, line, level, func, arg) + void *lcv; + pci_conftag_t tag; + pci_intr_pin_t pin; + pci_intr_line_t line; + pci_intrlevel_t level; + int (*func) __P((void *)); + void *arg; +{ + struct lca_config *lcp = lcv; + int bus, device, pirq; + pci_confreg_t irreg, pirqreg; + u_int8_t pirqline; + + if (pin == 0) { + /* No IRQ used. */ + return 0; + } + if (pin > 4) { + printf("dec_axppci_33_map_int: bad interrupt pin %d\n", pin); + return NULL; + } + + device = PCI_TAG_DEVICE(tag); + + switch (device) { + case 6: /* NCR SCSI */ + pirq = 3; + break; + + case 11: /* slot 1 */ + switch (pin) { + case PCI_INTERRUPT_PIN_A: + case PCI_INTERRUPT_PIN_D: + pirq = 0; + break; + case PCI_INTERRUPT_PIN_B: + pirq = 2; + break; + case PCI_INTERRUPT_PIN_C: + pirq = 1; + break; + }; + break; + + case 12: /* slot 2 */ + switch (pin) { + case PCI_INTERRUPT_PIN_A: + case PCI_INTERRUPT_PIN_D: + pirq = 1; + break; + case PCI_INTERRUPT_PIN_B: + pirq = 0; + break; + case PCI_INTERRUPT_PIN_C: + pirq = 2; + break; + }; + break; + + case 8: /* slot 3 */ + switch (pin) { + case PCI_INTERRUPT_PIN_A: + case PCI_INTERRUPT_PIN_D: + pirq = 2; + break; + case PCI_INTERRUPT_PIN_B: + pirq = 1; + break; + case PCI_INTERRUPT_PIN_C: + pirq = 0; + break; + }; + break; + default: + printf("dec_axppci_33_pci_map_int: unknown device %d\n", + device); + panic("dec_axppci_33_pci_map_int: bad device number"); + } + +#define LCA_SIO_DEVICE 7 /* XXX */ + + pirqreg = PCI_CONF_READ(lcp->lc_conffns, lcp->lc_confarg, + PCI_MAKE_TAG(0, LCA_SIO_DEVICE, 0), 0x60); /* XXX */ +#if 0 + printf("dec_pci_axppci_33_map_int: device %d pin %c: pirq %d, reg = %x\n", + device, '@' + pin, pirq, pirqreg); +#endif + pirqline = (pirqreg >> (pirq * 8)) & 0xff; + if ((pirqline & 0x80) != 0) + return 0; /* not routed? */ + pirqline &= 0xf; + +#if 0 + printf("dec_pci_axppci_33_map_int: device %d pin %c: mapped to line %d\n", + device, '@' + pin, pirqline); +#endif + +#if NSIO + return ISA_INTR_ESTABLISH(&sio_isa_intr_fns, NULL, /* XXX */ + pirqline, ISA_IST_LEVEL, pci_intrlevel_to_isa(level), + func, arg); +#else + panic("dec_axppci_33_pci_map_int: no sio!"); +#endif +} + +void +dec_axppci_33_pci_unmap_int(pifa, cookie) + void *pifa; + void *cookie; +{ + + panic("dec_axppci_33_pci_unmap_int not implemented"); /* XXX */ +} + +void +pci_axppci_33_pickintr(pcf, pcfa, ppf, ppfa, pifp, pifap) + __const struct pci_conf_fns *pcf; + __const struct pci_pio_fns *ppf; + void *pcfa, *ppfa; + __const struct pci_intr_fns **pifp; + void **pifap; +{ + pci_confreg_t sioclass; + int sioII; + + /* XXX MAGIC NUMBER */ + sioclass = PCI_CONF_READ(pcf, pcfa, PCI_MAKE_TAG(0, LCA_SIO_DEVICE, 0), + PCI_CLASS_REG); + sioII = (sioclass & 0xff) >= 3; + + if (!sioII) + printf("WARNING: SIO NOT SIO II... NO BETS...\n"); + + *pifp = &dec_axppci_33_pci_intr_fns; + *pifap = pcfa; /* XXX assumes apecs_config ptr */ +#if NSIO + sio_intr_setup(ppf, ppfa); + set_iointr(&sio_iointr); +#else + panic("pci_axppci_33_pickintr: no I/O interrupt handler (no sio)"); +#endif +} diff --git a/sys/arch/alpha/pci/pci_axppci_33.h b/sys/arch/alpha/pci/pci_axppci_33.h new file mode 100644 index 00000000000..342eb0dfd71 --- /dev/null +++ b/sys/arch/alpha/pci/pci_axppci_33.h @@ -0,0 +1,32 @@ +/* $NetBSD: pci_axppci_33.h,v 1.1 1995/11/23 02:37:56 cgd Exp $ */ + +/* + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Jeffrey Hsu + * + * 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. + */ + +void pci_axppci_33_pickintr __P((__const struct pci_conf_fns *, void *, + __const struct pci_pio_fns *, void *, + __const struct pci_intr_fns **, void **)); diff --git a/sys/arch/alpha/pci/pci_chipset.h b/sys/arch/alpha/pci/pci_chipset.h deleted file mode 100644 index 4d333aee27e..00000000000 --- a/sys/arch/alpha/pci/pci_chipset.h +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: pci_chipset.h,v 1.3 1995/08/03 01:17:14 cgd Exp $ */ - -/* - * Copyright (c) 1995 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. - */ - -/* - * Function switch to implement the various PCI bus interfaces. - * XXX this probably needs some work... - */ - -struct pci_cs_fcns { - void (*cs_setup) __P((void)); - pcitag_t (*cs_make_tag) __P((int, int, int)); - pcireg_t (*cs_conf_read) __P((pcitag_t, int)); - void (*cs_conf_write) __P((pcitag_t, int, pcireg_t)); - int (*cs_map_io) __P((pcitag_t, int, int *)); - int (*cs_map_mem) __P((pcitag_t, int, vm_offset_t *, - vm_offset_t *)); - int (*cs_pcidma_map) __P((caddr_t, vm_size_t, - vm_offset_t *)); - void (*cs_pcidma_unmap) __P((caddr_t, vm_size_t, int, - vm_offset_t *)); -}; - -struct pci_cs_fcns *pci_cs_fcns; -extern struct pci_cs_fcns apecs_p1e_cs_fcns; -extern struct pci_cs_fcns apecs_p2e_cs_fcns; -extern struct pci_cs_fcns lca_cs_fcns; - - -/* - * Function switch to implement the various PCI configuration schemes. - * XXX this probably needs some work... - */ - -struct pci_cfg_fcns { - void (*cfg_attach) __P((struct device *, struct - device *, void *)); - void *(*cfg_map_int) __P((pcitag_t, pci_intrlevel, - int (*) (void *), void *, int)); -}; - -struct pci_cfg_fcns *pci_cfg_fcns; -extern struct pci_cfg_fcns pci_2100_a50_sio1_cfg_fcns; -extern struct pci_cfg_fcns pci_2100_a50_sio2_cfg_fcns; - -/* - * Miscellaneous functions. - */ -isa_intrlevel pcilevel_to_isa __P((pci_intrlevel)); diff --git a/sys/arch/alpha/pci/pci_kn20aa.c b/sys/arch/alpha/pci/pci_kn20aa.c new file mode 100644 index 00000000000..c5c64d636b8 --- /dev/null +++ b/sys/arch/alpha/pci/pci_kn20aa.c @@ -0,0 +1,294 @@ +/* $NetBSD: pci_kn20aa.c,v 1.1 1995/11/23 02:38:00 cgd Exp $ */ + +/* + * Copyright (c) 1995 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 +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include + +#ifndef EVCNT_COUNTERS +#include +#endif + +#include "sio.h" +#if NSIO +#include +#endif + +void *kn20aa_pci_map_int __P((void *, pci_conftag_t, pci_intr_pin_t, + pci_intr_line_t, pci_intrlevel_t, int (*func)(void *), void *)); +void kn20aa_pci_unmap_int __P((void *, void *)); + +__const struct pci_intr_fns kn20aa_pci_intr_fns = { + kn20aa_pci_map_int, + kn20aa_pci_unmap_int, +}; + +#define KN20AA_PCEB_IRQ 31 +#define KN20AA_MAX_IRQ 32 +#define PCI_STRAY_MAX 5 + +struct kn20aa_intrhand { + TAILQ_ENTRY(kn20aa_intrhand) ih_q; + int (*ih_fun)(); + void *ih_arg; + u_long ih_count; + int ih_level; +}; +TAILQ_HEAD(kn20aa_intrchain, kn20aa_intrhand); + +struct kn20aa_intrchain kn20aa_pci_intrs[KN20AA_MAX_IRQ]; +int kn20aa_pci_strayintrcnt[KN20AA_MAX_IRQ]; +#ifdef EVCNT_COUNTERS +struct evcnt kn20aa_intr_evcnt; +#endif + +void kn20aa_pci_strayintr __P((int irq)); +void kn20aa_iointr __P((void *framep, int vec)); +void kn20aa_enable_intr __P((int irq)); +struct kn20aa_intrhand *kn20aa_attach_intr __P((struct kn20aa_intrchain *, + pci_intrlevel_t, int (*) (void *), void *)); + +void +pci_kn20aa_pickintr(pcf, pcfa, ppf, ppfa, pifp, pifap) + __const struct pci_conf_fns *pcf; + __const struct pci_pio_fns *ppf; + void *pcfa, *ppfa; + __const struct pci_intr_fns **pifp; + void **pifap; +{ + int i; + struct kn20aa_intrhand *nintrhand; + + + for (i = 0; i < KN20AA_MAX_IRQ; i++) + TAILQ_INIT(&kn20aa_pci_intrs[i]); + + *pifp = &kn20aa_pci_intr_fns; + *pifap = NULL; /* XXX ? */ + +#if NSIO + sio_intr_setup(ppf, ppfa); +#endif + + set_iointr(kn20aa_iointr); + +#if NSIO + kn20aa_enable_intr(KN20AA_PCEB_IRQ); +#if 0 /* XXX init PCEB interrupt handler? */ + kn20aa_attach_intr(&kn20aa_pci_intrs[KN20AA_PCEB_IRQ], ???, ???, ???); +#endif +#endif +} + +void * +kn20aa_pci_map_int(ccv, tag, pin, line, level, func, arg) + void *ccv; + pci_conftag_t tag; + pci_intr_pin_t pin; + pci_intr_line_t line; + pci_intrlevel_t level; + int (*func) __P((void *)); + void *arg; +{ + int device; + int kn20aa_slot, kn20aa_irq; + void *ih; + + if (pin == 0) { + /* No IRQ used. */ + return 0; + } + if (pin > 4) { + printf("pci_map_int: bad interrupt pin %d\n", pin); + return NULL; + } + + /* + * Slot->interrupt translation. Appears to work, though it + * may not hold up forever. + * + * The DEC engineers who did this hardware obviously engaged + * in random drug testing. + */ + switch (device = PCI_TAG_DEVICE(tag)) { + case 11: + case 12: + kn20aa_slot = (device - 11) + 0; + break; + + case 7: + kn20aa_slot = 2; + break; + + case 8: + kn20aa_slot = 4; + break; + + case 9: + kn20aa_slot = 3; + break; + + default: + panic("pci_kn20aa_map_int: invalid device number %d\n", + device); + } + + kn20aa_irq = (kn20aa_slot * 4) + pin - 1; + if (kn20aa_irq > KN20AA_MAX_IRQ) + panic("pci_kn20aa_map_int: kn20aa_irq too large (%d)\n", + kn20aa_irq); + +#if 0 + printf("kn20aa_attach_intr: func 0x%lx, arg 0x%lx, level %d, irq %d\n", + func, arg, level, kn20aa_irq); +#endif + + ih = kn20aa_attach_intr(&kn20aa_pci_intrs[kn20aa_irq], level, + func, arg); + kn20aa_enable_intr(kn20aa_irq); + return (ih); +} + +void +kn20aa_pci_unmap_int(pifa, cookie) + void *pifa; + void *cookie; +{ + + panic("kn20aa_pci_unmap_int not implemented"); /* XXX */ +} + +/* + * caught a stray interrupt; notify if not too many seen already. + */ +void +kn20aa_pci_strayintr(irq) + int irq; +{ + + if (++kn20aa_pci_strayintrcnt[irq] <= PCI_STRAY_MAX) + log(LOG_ERR, "stray PCI interrupt %d%s\n", irq, + kn20aa_pci_strayintrcnt[irq] >= PCI_STRAY_MAX ? + "; stopped logging" : ""); +} + +void +kn20aa_iointr(framep, vec) + void *framep; + int vec; +{ + struct kn20aa_intrhand *ih; + int irq, handled; + + if (vec >= 0x900) { + if (vec >= 0x900 + (KN20AA_MAX_IRQ << 4)) + panic("kn20aa_iointr: vec 0x%x out of range\n", vec); + irq = (vec - 0x900) >> 4; + +#ifdef EVCNT_COUNTERS + kn20aa_intr_evcnt.ev_count++; +#else + if (KN20AA_MAX_IRQ != INTRCNT_KN20AA_IRQ_LEN) + panic("kn20aa interrupt counter sizes inconsistent"); + intrcnt[INTRCNT_KN20AA_IRQ + irq]++; +#endif + + for (ih = kn20aa_pci_intrs[irq].tqh_first, handled = 0; + ih != NULL; ih = ih->ih_q.tqe_next) { + int rv; + + rv = (*ih->ih_fun)(ih->ih_arg); + + ih->ih_count++; + handled = handled || (rv != 0); + } + if (!handled) + kn20aa_pci_strayintr(irq); + return; + } + if (vec >= 0x800) { +#if NSIO + sio_iointr(framep, vec); +#endif + return; + } + panic("kn20aa_iointr: weird vec 0x%x\n", vec); +} + +void +kn20aa_enable_intr(irq) + int irq; +{ + + /* + * From disassembling the OSF/1 source code: + * the following appears to enable a given interrupt request. + * "blech." I'd give valuable body parts for better docs or + * for a good decompiler. + */ + wbflush(); + REGVAL(0x8780000000L + 0x40L) |= (1 << irq); /* XXX */ + wbflush(); +} + +struct kn20aa_intrhand * +kn20aa_attach_intr(chain, level, func, arg) + struct kn20aa_intrchain *chain; + pci_intrlevel_t level; + int (*func) __P((void *)); + void *arg; +{ + struct kn20aa_intrhand *nintrhand; + + nintrhand = (struct kn20aa_intrhand *) + malloc(sizeof *nintrhand, M_DEVBUF, M_WAITOK); + + nintrhand->ih_fun = func; + nintrhand->ih_arg = arg; + nintrhand->ih_count = 0; + nintrhand->ih_level = level; + TAILQ_INSERT_TAIL(chain, nintrhand, ih_q); + + return (nintrhand); +} diff --git a/sys/arch/alpha/pci/pci_kn20aa.h b/sys/arch/alpha/pci/pci_kn20aa.h new file mode 100644 index 00000000000..4e499317ea0 --- /dev/null +++ b/sys/arch/alpha/pci/pci_kn20aa.h @@ -0,0 +1,36 @@ +/* $NetBSD: pci_kn20aa.h,v 1.1 1995/11/23 02:38:05 cgd Exp $ */ + +/* + * Copyright (c) 1995 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. + */ + +void pci_kn20aa_pickintr __P((__const struct pci_conf_fns *, void *, + __const struct pci_pio_fns *, void *, + __const struct pci_intr_fns **, void **)); + +#ifdef EVCNT_COUNTERS +extern struct evcnt kn20aa_intr_evcnt; +#endif diff --git a/sys/arch/alpha/pci/pci_machdep.c b/sys/arch/alpha/pci/pci_machdep.c index bacb5273362..02eb57caeaa 100644 --- a/sys/arch/alpha/pci/pci_machdep.c +++ b/sys/arch/alpha/pci/pci_machdep.c @@ -1,32 +1,30 @@ -/* $NetBSD: pci_machdep.c,v 1.2 1995/08/03 00:33:58 cgd Exp $ */ +/* $NetBSD: pci_machdep.c,v 1.3 1995/11/23 02:38:07 cgd Exp $ */ /* - * Copyright (c) 1994 Charles Hannum. All rights reserved. + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. * - * 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 Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 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 * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + * 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. */ /* @@ -43,206 +41,56 @@ #include #include -#include #include +#include #include -#include #include "pcivga.h" -#include "tga.h" - -int pcimatch __P((struct device *, void *, void *)); -void pciattach __P((struct device *, struct device *, void *)); - -struct cfdriver pcicd = { - NULL, "pci", pcimatch, pciattach, DV_DULL, sizeof(struct device) -}; - -int -pcimatch(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - - return 1; -} - -void -pciattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - - printf("\n"); - (*pci_cs_fcns->cs_setup)(); - (*pci_cfg_fcns->cfg_attach)(parent, self, aux); -} - -pcitag_t -pci_make_tag(bus, device, function) - int bus, device, function; -{ - - return (*pci_cs_fcns->cs_make_tag)(bus, device, function); -} - -pcireg_t -pci_conf_read(tag, offset) - pcitag_t tag; - int offset; /* XXX */ -{ - - return (*pci_cs_fcns->cs_conf_read)(tag, offset); -} - -void -pci_conf_write(tag, offset, data) - pcitag_t tag; - int offset; /* XXX */ - pcireg_t data; -{ - - (*pci_cs_fcns->cs_conf_write)(tag, offset, data); -} - -int -pci_map_io(tag, reg, iobasep) - pcitag_t tag; - int reg; - int *iobasep; -{ - - return (*pci_cs_fcns->cs_map_io)(tag, reg, iobasep); -} - -int -pci_map_mem(tag, reg, vap, pap) - pcitag_t tag; - int reg; - vm_offset_t *vap, *pap; -{ - - return (*pci_cs_fcns->cs_map_mem)(tag, reg, vap, pap); -} - -int -pcidma_map(addr, size, mappings) - caddr_t addr; - vm_size_t size; - vm_offset_t *mappings; -{ - - return (*pci_cs_fcns->cs_pcidma_map)(addr, size, mappings); -} - -void -pcidma_unmap(addr, size, nmappings, mappings) - caddr_t addr; - vm_size_t size; - int nmappings; - vm_offset_t *mappings; -{ - - (*pci_cs_fcns->cs_pcidma_unmap)(addr, size, nmappings, mappings); -} - -void * -pci_map_int(tag, level, func, arg) - pcitag_t tag; - pci_intrlevel level; - int (*func) __P((void *)); - void *arg; -{ - pcireg_t data; - int pin; - - data = pci_conf_read(tag, PCI_INTERRUPT_REG); - - pin = PCI_INTERRUPT_PIN(data); - - if (pin == 0) { - /* No IRQ used. */ - return 0; - } - - if (pin > 4) { - printf("pci_map_int: bad interrupt pin %d\n", pin); - return NULL; - } - - return (*pci_cfg_fcns->cfg_map_int)(tag, level, func, arg, pin); -} - -isa_intrlevel -pcilevel_to_isa(level) - pci_intrlevel level; -{ - - switch (level) { - case PCI_IPL_NONE: - return (ISA_IPL_NONE); - - case PCI_IPL_BIO: - return (ISA_IPL_BIO); - - case PCI_IPL_NET: - return (ISA_IPL_NET); - - case PCI_IPL_TTY: - return (ISA_IPL_TTY); - - case PCI_IPL_CLOCK: - return (ISA_IPL_CLOCK); +#if NPCIVGA +#include +#endif - default: - panic("pcilevel_to_isa: unknown level %d\n", level); - } -} +#include "tga.h" +#if NTGA +#include +#endif void -pci_display_console(bus, device, function) - int bus, device, function; +pci_display_console(pcf, pcfa, pmf, pmfa, ppf, ppfa, bus, device, function) + __const struct pci_conf_fns *pcf; + __const struct pci_mem_fns *pmf; + __const struct pci_pio_fns *ppf; + void *pcfa, *pmfa, *ppfa; + pci_bus_t bus; + pci_device_t device; + pci_function_t function; { - pcitag_t tag; - pcireg_t id, class; - - /* XXX */ - tag = pci_make_tag(bus, device, function); + pci_conftag_t tag; + pci_confreg_t id, class; - id = pci_conf_read(tag, PCI_ID_REG); + tag = PCI_MAKE_TAG(bus, device, function); + id = PCI_CONF_READ(pcf, pcfa, tag, PCI_ID_REG); if (id == 0 || id == 0xffffffff) panic("pci_display_console: no device at %d/%d/%d", bus, device, function); - class = pci_conf_read(tag, PCI_CLASS_REG); - - if (PCI_CLASS(class) != PCI_CLASS_DISPLAY && - !(PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && - PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) - panic("pci_display_console: device at %d/%d/%d not a display", - bus, device, function); + class = PCI_CONF_READ(pcf, pcfa, tag, PCI_CLASS_REG); - if ((PCI_CLASS(class) == PCI_CLASS_DISPLAY && - PCI_SUBCLASS(class) == PCI_SUBCLASS_DISPLAY_VGA) || - (PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && - PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) { #if NPCIVGA - pcivga_console(bus, device, function); -#else - panic("pci_display_console: pcivga is console, not configured"); -#endif + if (DEVICE_IS_PCIVGA(class, id)) { + pcivga_console(pcf, pcfa, pmf, pmfa, ppf, ppfa, bus, + device, function); return; } +#endif - if (PCI_VENDOR(id) == PCI_VENDOR_DEC && - PCI_PRODUCT(id) == PCI_PRODUCT_DEC_21030) { #if NTGA - tga_console(bus, device, function); -#else - panic("pci_display_console: tga is console, not configured"); -#endif + if (DEVICE_IS_TGA(class, id)) { + tga_console(pcf, pcfa, pmf, pmfa, ppf, ppfa, bus, + device, function); return; } +#endif - panic("pci_display_console: unsupported device at %d/%d/%d", + panic("pci_display_console: unconfigured device at %d/%d/%d", bus, device, function); } diff --git a/sys/arch/alpha/pci/pci_machdep.h b/sys/arch/alpha/pci/pci_machdep.h deleted file mode 100644 index 6f4a8459b6e..00000000000 --- a/sys/arch/alpha/pci/pci_machdep.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: pci_machdep.h,v 1.1 1995/06/28 01:26:01 cgd Exp $ */ - -/* - * Copyright (c) 1994 Charles Hannum. All rights reserved. - * - * 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 Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - */ - -/* - * Machine-specific definitions for PCI autoconfiguration. - * - * See the comments in pci_machdep.c for more explanation. - */ - -/* - * Configuration tag; created from a {bus,device,function} triplet by - * pci_make_tag(), and passed to pci_conf_read() and pci_conf_write(). - * We could instead always pass the {bus,device,function} triplet to - * the read and write routines, but this would cause extra overhead. - */ -typedef u_long pcitag_t; - -/* - * Type of a value read from or written to a configuration register. - * Always 32 bits. - */ -typedef u_int32_t pcireg_t; - -extern int pci_mode; -extern int pci_mode_detect __P((void)); diff --git a/sys/arch/alpha/pci/pcivga.c b/sys/arch/alpha/pci/pcivga.c index b155f8f5951..10b2f3cbbec 100644 --- a/sys/arch/alpha/pci/pcivga.c +++ b/sys/arch/alpha/pci/pcivga.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcivga.c,v 1.2 1995/08/03 01:17:17 cgd Exp $ */ +/* $NetBSD: pcivga.c,v 1.3 1995/11/23 02:38:11 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -35,7 +35,6 @@ #include #include -#include #include #include @@ -43,6 +42,7 @@ #include #include +#include int pcivgamatch __P((struct device *, void *, void *)); void pcivgaattach __P((struct device *, struct device *, void *)); @@ -52,8 +52,19 @@ struct cfdriver pcivgacd = { sizeof(struct pcivga_softc) }; +void pcivga_getdevconfig __P((__const struct pci_conf_fns *, void *, + __const struct pci_mem_fns *, void *, + __const struct pci_pio_fns *, void *, + pci_conftag_t tag, struct pcivga_devconfig *dc)); + struct pcivga_devconfig pcivga_console_dc; +void pcivga_cursor __P((void *, int, int)); +void pcivga_putstr __P((void *, int, int, char *, int)); +void pcivga_copycols __P((void *, int, int, int,int)); +void pcivga_erasecols __P((void *, int, int, int)); +void pcivga_copyrows __P((void *, int, int, int)); +void pcivga_eraserows __P((void *, int, int)); void pcivga_bell __P((void *)); /* XXX */ struct ansicons_functions pcivga_acf = { @@ -74,54 +85,43 @@ pcivgamatch(parent, match, aux) void *match, *aux; { struct cfdata *cf = match; - struct pci_attach_args *pa = aux; + struct pcidev_attach_args *pda = aux; /* * If it's prehistoric/vga or display/vga, we match. */ - if ((PCI_CLASS(pa->pa_class) == PCI_CLASS_PREHISTORIC && - PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_PREHISTORIC_VGA) || - (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY && - PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_DISPLAY_VGA)) + if (PCI_CLASS(pda->pda_class) == PCI_CLASS_PREHISTORIC && + PCI_SUBCLASS(pda->pda_class) == PCI_SUBCLASS_PREHISTORIC_VGA) + return (1); + if (PCI_CLASS(pda->pda_class) == PCI_CLASS_DISPLAY && + PCI_SUBCLASS(pda->pda_class) == PCI_SUBCLASS_DISPLAY_VGA) return (1); return (0); } void -pcivga_getdevconfig(tag, dc) - pcitag_t tag; +pcivga_getdevconfig(pcf, pcfa, pmf, pmfa, ppf, ppfa, tag, dc) + __const struct pci_conf_fns *pcf; + __const struct pci_mem_fns *pmf; + __const struct pci_pio_fns *ppf; + void *pcfa, *pmfa, *ppfa; + pci_conftag_t tag; struct pcivga_devconfig *dc; { + dc->dc_pcf = pcf; + dc->dc_pcfa = pcfa; + dc->dc_pmf = pmf; + dc->dc_pmfa = pmfa; + dc->dc_ppf = ppf; + dc->dc_ppfa = ppfa; dc->dc_pcitag = tag; -#if 0 - vm_offset_t pciva, pcipa; - int i; - - dc->dc_vaddr = 0; - if (pci_map_mem(tag, 0x10, &dc->dc_vaddr, &pcipa)) - return; -#endif - -#if 0 - int i; - pcireg_t old; - - printf("\n"); - for (i = PCI_MAP_REG_START; i < PCI_MAP_REG_END; i += 4) { - old = pci_conf_read(tag, i); - pci_conf_write(tag, i, 0xffffffff); - printf("pcivga_getdevconfig: "); - printf("mapping reg @ %d = 0x%x (mask 0x%x)\n", - i, old, pci_conf_read(tag, i)); - pci_conf_write(tag, i, old); - } - printf("foo"); -#endif + /* XXX deal with mapping foo */ - dc->dc_crtat = (u_short *)phystok0seg(0xb8000 | (3L << 32)); /* XXX */ + /* XXX */ + dc->dc_crtat = (u_short *)PCI_MEM_MAP(pmf, pmfa, 0xb8000, 0x8000, 1); dc->dc_iobase = 0x3d4; /* XXX */ dc->dc_nrow = 25; @@ -141,26 +141,29 @@ pcivgaattach(parent, self, aux) struct device *parent, *self; void *aux; { - struct pci_attach_args *pa = aux; + struct pcidev_attach_args *pda = aux; struct pcivga_softc *sc = (struct pcivga_softc *)self; char devinfo[256]; int console; - console = (pa->pa_tag == pcivga_console_dc.dc_pcitag); + console = (pda->pda_tag == pcivga_console_dc.dc_pcitag); if (console) sc->sc_dc = &pcivga_console_dc; else { sc->sc_dc = (struct pcivga_devconfig *) malloc(sizeof(struct pcivga_devconfig), M_DEVBUF, M_WAITOK); - pcivga_getdevconfig(pa->pa_tag, sc->sc_dc); + pcivga_getdevconfig(pda->pda_conffns, pda->pda_confarg, + pda->pda_memfns, pda->pda_memarg, pda->pda_piofns, + pda->pda_memarg, pda->pda_tag, sc->sc_dc); } if (sc->sc_dc->dc_crtat == NULL) { printf(": couldn't map memory space; punt!\n"); return; } - pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, NULL); - printf(": %s (revision 0x%x)\n", devinfo, PCI_REVISION(pa->pa_class)); + pci_devinfo(pda->pda_id, pda->pda_class, 0, devinfo); + printf(": %s (rev. 0x%02x)\n", devinfo, + PCI_REVISION(pda->pda_class)); #if 0 if (sc->sc_dc->dc_tgaconf == NULL) { @@ -209,21 +212,28 @@ tgammap(dev, offset, nprot) #endif void -pcivga_console(bus, device, function) - int bus, device, function; +pcivga_console(pcf, pcfa, pmf, pmfa, ppf, ppfa, bus, device, function) + __const struct pci_conf_fns *pcf; + __const struct pci_mem_fns *pmf; + __const struct pci_pio_fns *ppf; + void *pcfa, *pmfa, *ppfa; + pci_bus_t bus; + pci_device_t device; + pci_function_t function; { struct pcivga_devconfig *dcp = &pcivga_console_dc; - pcivga_getdevconfig(pci_make_tag(bus, device, function), dcp); + pcivga_getdevconfig(pcf, pcfa, pmf, pmfa, ppf, ppfa, + PCI_MAKE_TAG(bus, device, function), dcp); /* sanity checks */ if (dcp->dc_crtat == NULL) - panic("pcivga_console(%d, %d, %d): couldn't map memory space", - bus, device, function); + panic("pcivga_console(%d, %d): couldn't map memory space", + device, function); #if 0 if (dcp->dc_pcivgaconf == NULL) - panic("pcivga_console(%d, %d, %d): unknown board configuration", - bus, device, function); + panic("pcivga_console(%d, %d): unknown board configuration", + device, function); #endif wsc_console(&dcp->dc_ansicons, &pcivga_acf, dcp, @@ -265,10 +275,10 @@ pcivga_cursor(id, row, col) pos = row * dc->dc_ncol + col; - outb(dc->dc_iobase, 14); - outb(dc->dc_iobase+1, pos >> 8); - outb(dc->dc_iobase, 15); - outb(dc->dc_iobase+1, pos); + OUTB(dc->dc_ppf, dc->dc_ppfa, dc->dc_iobase, 14); + OUTB(dc->dc_ppf, dc->dc_ppfa, dc->dc_iobase+1, pos >> 8); + OUTB(dc->dc_ppf, dc->dc_ppfa, dc->dc_iobase, 15); + OUTB(dc->dc_ppf, dc->dc_ppfa, dc->dc_iobase+1, pos); } void diff --git a/sys/arch/alpha/pci/pcivgavar.h b/sys/arch/alpha/pci/pcivgavar.h index 049fd2dca51..579ad4ca0a4 100644 --- a/sys/arch/alpha/pci/pcivgavar.h +++ b/sys/arch/alpha/pci/pcivgavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: pcivgavar.h,v 1.2 1995/08/03 01:17:21 cgd Exp $ */ +/* $NetBSD: pcivgavar.h,v 1.3 1995/11/23 02:38:13 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -27,8 +27,17 @@ * rights to redistribute these changes. */ +#include + struct pcivga_devconfig { - pcitag_t dc_pcitag; /* PCI tag */ + __const struct pci_conf_fns *dc_pcf; + void *dc_pcfa; + __const struct pci_mem_fns *dc_pmf; + void *dc_pmfa; + __const struct pci_pio_fns *dc_ppf; + void *dc_ppfa; + + pci_tag_t dc_pcitag; /* PCI tag */ u_int16_t *dc_crtat; /* VGA screen memory */ int dc_iobase; /* VGA I/O address */ @@ -52,9 +61,13 @@ struct pcivga_softc { #define PCIVGA_CURSOR_OFF -1 /* pass to pcivga_cpos to disable */ -void pcivga_cursor __P((void *, int, int)); -void pcivga_putstr __P((void *, int, int, char *, int)); -void pcivga_copycols __P((void *, int, int, int,int)); -void pcivga_erasecols __P((void *, int, int, int)); -void pcivga_copyrows __P((void *, int, int, int)); -void pcivga_eraserows __P((void *, int, int)); +#define DEVICE_IS_PCIVGA(class, id) \ + ((PCI_CLASS(class) == PCI_CLASS_DISPLAY && \ + PCI_SUBCLASS(class) == PCI_SUBCLASS_DISPLAY_VGA) || \ + (PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && \ + PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) + +void pcivga_console __P((__const struct pci_conf_fns *, void *, + __const struct pci_mem_fns *, void *, + __const struct pci_pio_fns *, void *, + pci_bus_t, pci_device_t, pci_function_t)); diff --git a/sys/arch/alpha/pci/sio.c b/sys/arch/alpha/pci/sio.c index 5e37a5e0edc..a8b6b8a0a24 100644 --- a/sys/arch/alpha/pci/sio.c +++ b/sys/arch/alpha/pci/sio.c @@ -1,4 +1,4 @@ -/* $NetBSD: sio.c,v 1.2 1995/08/03 01:17:25 cgd Exp $ */ +/* $NetBSD: sio.c,v 1.3 1995/11/23 02:38:16 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -32,11 +32,14 @@ #include #include +#include +#include + #include #include #include -#include +#include int siomatch __P((struct device *, void *, void *)); void sioattach __P((struct device *, struct device *, void *)); @@ -45,6 +48,12 @@ struct cfdriver siocd = { NULL, "sio", siomatch, sioattach, DV_DULL, sizeof(struct device) }; +int pcebmatch __P((struct device *, void *, void *)); + +struct cfdriver pcebcd = { + NULL, "pceb", pcebmatch, sioattach, DV_DULL, sizeof(struct device) +}; + static int sioprint __P((void *, char *pnp)); int @@ -53,10 +62,25 @@ siomatch(parent, match, aux) void *match, *aux; { struct cfdata *cf = match; - struct pci_attach_args *pa = aux; + struct pcidev_attach_args *pda = aux; + + if (PCI_VENDOR(pda->pda_id) != PCI_VENDOR_INTEL || + PCI_PRODUCT(pda->pda_id) != PCI_PRODUCT_INTEL_SIO) + return (0); + + return (1); +} + +int +pcebmatch(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct cfdata *cf = match; + struct pcidev_attach_args *pda = aux; - if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL || - PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_INTEL_SIO) + if (PCI_VENDOR(pda->pda_id) != PCI_VENDOR_INTEL || + PCI_PRODUCT(pda->pda_id) != PCI_PRODUCT_INTEL_PCEB) return (0); return (1); @@ -67,31 +91,56 @@ sioattach(parent, self, aux) struct device *parent, *self; void *aux; { - struct pci_attach_args *pa = aux; - struct confargs nca; - u_int rev; - char *type; - - rev = pa->pa_class & 0xff; - if (rev < 3) { - type = "I"; - /* XXX PCI IRQ MAPPING FUNCTION */ - } else { - type = "II"; - /* XXX PCI IRQ MAPPING FUNCTION */ + struct pcidev_attach_args *pda = aux; + struct isa_attach_args ia; + struct eisa_attach_args ea; + int sio, haseisa; + char devinfo[256]; + + sio = (PCI_PRODUCT(pda->pda_id) == PCI_PRODUCT_INTEL_SIO); + haseisa = (PCI_PRODUCT(pda->pda_id) == PCI_PRODUCT_INTEL_PCEB); + + pci_devinfo(pda->pda_id, pda->pda_class, 0, devinfo); + printf(": %s (rev. 0x%02x)\n", devinfo, + PCI_REVISION(pda->pda_class)); + + if (sio) { + pci_revision_t rev; + + rev = PCI_REVISION(pda->pda_class); + + if (rev < 3) + printf("%s: WARNING: SIO I SUPPORT UNTESTED\n", + self->dv_xname); + } + +#ifdef EVCNT_COUNTERS + evcnt_attach(self, "intr", &sio_intr_evcnt); +#endif + + ia.ia_bus = BUS_ISA; + ia.ia_dmafns = pda->pda_dmafns; + ia.ia_dmaarg = pda->pda_dmaarg; + ia.ia_intrfns = &sio_isa_intr_fns; + ia.ia_intrarg = NULL; /* XXX needs nothing */ + ia.ia_memfns = pda->pda_memfns; + ia.ia_memarg = pda->pda_memarg; + ia.ia_piofns = pda->pda_piofns; + ia.ia_pioarg = pda->pda_pioarg; + config_found(self, &ia, sioprint); + + if (haseisa) { + ea.ea_bus = BUS_EISA; + ea.ea_dmafns = pda->pda_dmafns; + ea.ea_dmaarg = pda->pda_dmaarg; + ea.ea_intrfns = &sio_isa_intr_fns; + ea.ea_intrarg = NULL; /* XXX needs nothing */ + ea.ea_memfns = pda->pda_memfns; + ea.ea_memarg = pda->pda_memarg; + ea.ea_piofns = pda->pda_piofns; + ea.ea_pioarg = pda->pda_pioarg; + config_found(self, &ea, sioprint); } - printf(": Saturn %s PCI->ISA bridge (revision 0x%x)\n", type, rev); - if (rev < 3) - printf("%s: WARNING: SIO I SUPPORT UNTESTED\n", - parent->dv_xname); - - /* attach the ISA bus that hangs off of it... */ - nca.ca_name = "isa"; - nca.ca_slot = 0; - nca.ca_offset = 0; - nca.ca_bus = NULL; - if (!config_found(self, &nca, sioprint)) - panic("sioattach: couldn't attach ISA bus"); } static int @@ -99,9 +148,14 @@ sioprint(aux, pnp) void *aux; char *pnp; { - register struct confargs *ca = aux; + register struct isa_attach_args *ia = aux; + + /* + * XXX Assumes that the first fields of 'struct isa_attach_args' + * XXX and 'struct eisa_attach_args' are the same. + */ if (pnp) - printf("%s at %s", ca->ca_name, pnp); + printf("%s at %s", isa_bustype_name(ia->ia_bus), pnp); return (UNCONF); } diff --git a/sys/arch/alpha/pci/sio_pic.c b/sys/arch/alpha/pci/sio_pic.c index e2f7e8cefdb..ec24ec96c5c 100644 --- a/sys/arch/alpha/pci/sio_pic.c +++ b/sys/arch/alpha/pci/sio_pic.c @@ -1,4 +1,4 @@ -/* $NetBSD: sio_pic.c,v 1.1 1995/06/28 01:26:13 cgd Exp $ */ +/* $NetBSD: sio_pic.c,v 1.2 1995/11/23 02:38:19 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -33,11 +33,15 @@ #include #include -#include #include -#include +#include +#include + +#ifndef EVCNT_COUNTERS +#include +#endif -#include +#include "sio.h" /* * To add to the long history of wonderful PROM console traits, @@ -49,18 +53,25 @@ */ #define BROKEN_PROM_CONSOLE -static void sio_intr_setup __P((void)); -static void *sio_intr_establish __P((int intr, isa_intrtype type, - isa_intrlevel level, int (*ih_fun)(void *), void *ih_arg)); -static void sio_intr_disestablish __P((void *handler)); -static void sio_iointr __P((void *framep, int vec)); +/* + * Private functions and variables. + */ +static void *sio_intr_establish __P((void *, isa_irq_t, + isa_intrsharetype_t, isa_intrlevel_t, + int (*)(void *), void *)); +static void sio_intr_disestablish __P((void *, void *)); +static void sio_strayintr __P((isa_irq_t)); -struct isa_intr_fcns sio_intr_fcns = { - sio_intr_setup, sio_intr_establish, - sio_intr_disestablish, sio_iointr, -}; +static __const struct isa_pio_fns *sio_ipf; /* XXX */ +static void *sio_ipfa; /* XXX */ -static void sio_strayintr __P((int irq)); +void sio_intr_setup __P((__const struct isa_pio_fns *, void *)); +void sio_iointr __P((void *framep, int vec)); + +struct isa_intr_fns sio_isa_intr_fns = { + sio_intr_establish, + sio_intr_disestablish, +}; /* * Interrupt handler chains. sio_intr_establish() inserts a handler into @@ -78,8 +89,11 @@ struct intrhand { #define ICU_LEN 16 /* number of ISA IRQs */ static struct intrhand *sio_intrhand[ICU_LEN]; -static isa_intrtype sio_intrtype[ICU_LEN]; +static isa_intrsharetype_t sio_intrsharetype[ICU_LEN]; static u_long sio_strayintrcnt[ICU_LEN]; +#ifdef EVCNT_COUNTERS +struct evcnt sio_intr_evcnt; +#endif #ifndef STRAY_MAX #ifdef BROKEN_PROM_CONSOLE @@ -112,7 +126,7 @@ u_int8_t initial_elcr[2]; void sio_setirqstat(irq, enabled, type) int irq, enabled; - isa_intrtype type; + isa_intrsharetype_t type; { u_int8_t ocw1[2], elcr[2]; int icu, bit; @@ -122,15 +136,15 @@ sio_setirqstat(irq, enabled, type) enabled ? "enabled" : "disabled", isa_intr_typename(type)); #endif - sio_intrtype[irq] = type; + sio_intrsharetype[irq] = type; icu = irq / 8; bit = irq % 8; - ocw1[0] = inb(IO_ICU1 + 1); - ocw1[1] = inb(IO_ICU2 + 1); - elcr[0] = inb(0x4d0); /* XXX */ - elcr[1] = inb(0x4d1); /* XXX */ + ocw1[0] = INB(sio_ipf, sio_ipfa, IO_ICU1 + 1); + ocw1[1] = INB(sio_ipf, sio_ipfa, IO_ICU2 + 1); + elcr[0] = INB(sio_ipf, sio_ipfa, 0x4d0); /* XXX */ + elcr[1] = INB(sio_ipf, sio_ipfa, 0x4d1); /* XXX */ /* * interrupt enable: set bit to mask (disable) interrupt. @@ -174,25 +188,30 @@ sio_setirqstat(irq, enabled, type) } #endif - outb(IO_ICU1 + 1, ocw1[0]); - outb(IO_ICU2 + 1, ocw1[1]); - outb(0x4d0, elcr[0]); /* XXX */ - outb(0x4d1, elcr[1]); /* XXX */ + OUTB(sio_ipf, sio_ipfa, IO_ICU1 + 1, ocw1[0]); + OUTB(sio_ipf, sio_ipfa, IO_ICU2 + 1, ocw1[1]); + OUTB(sio_ipf, sio_ipfa, 0x4d0, elcr[0]); /* XXX */ + OUTB(sio_ipf, sio_ipfa, 0x4d1, elcr[1]); /* XXX */ } void -sio_intr_setup() +sio_intr_setup(ipf, ipfa) + __const struct isa_pio_fns *ipf; + void *ipfa; { int i; + sio_ipf = ipf; + sio_ipfa = ipfa; + #ifdef BROKEN_PROM_CONSOLE /* * Remember the initial values, because the prom is stupid. */ - initial_ocw1[0] = inb(IO_ICU1 + 1); - initial_ocw1[1] = inb(IO_ICU2 + 1); - initial_elcr[0] = inb(0x4d0); /* XXX */ - initial_elcr[1] = inb(0x4d1); /* XXX */ + initial_ocw1[0] = INB(sio_ipf, sio_ipfa, IO_ICU1 + 1); + initial_ocw1[1] = INB(sio_ipf, sio_ipfa, IO_ICU2 + 1); + initial_elcr[0] = INB(sio_ipf, sio_ipfa, 0x4d0); /* XXX */ + initial_elcr[1] = INB(sio_ipf, sio_ipfa, 0x4d1); /* XXX */ #if 0 printf("initial_ocw1[0] = 0x%x\n", initial_ocw1[0]); printf("initial_ocw1[1] = 0x%x\n", initial_ocw1[1]); @@ -245,10 +264,11 @@ sio_intr_setup() } void * -sio_intr_establish(irq, type, level, ih_fun, ih_arg) - int irq; - isa_intrtype type; - isa_intrlevel level; +sio_intr_establish(siifa, irq, type, level, ih_fun, ih_arg) + void *siifa; + isa_irq_t irq; + isa_intrsharetype_t type; + isa_intrlevel_t level; int (*ih_fun)(void *); void *ih_arg; { @@ -260,19 +280,19 @@ sio_intr_establish(irq, type, level, ih_fun, ih_arg) if (ih == NULL) panic("sio_intr_establish: can't malloc handler info"); - if (irq < 0 || irq > ICU_LEN || type == ISA_IST_NONE) + if (irq > ICU_LEN || type == ISA_IST_NONE) panic("sio_intr_establish: bogus irq or type"); - switch (sio_intrtype[irq]) { + switch (sio_intrsharetype[irq]) { case ISA_IST_EDGE: case ISA_IST_LEVEL: - if (type == sio_intrtype[irq]) + if (type == sio_intrsharetype[irq]) break; case ISA_IST_PULSE: if (type != ISA_IST_NONE) panic("intr_establish: can't share %s with %s", - isa_intr_typename(sio_intrtype[irq]), - isa_intr_typename(type)); + isa_intrsharetype_name(sio_intrsharetype[irq]), + isa_intrsharetype_name(type)); break; } @@ -301,7 +321,8 @@ sio_intr_establish(irq, type, level, ih_fun, ih_arg) } void -sio_intr_disestablish(handler) +sio_intr_disestablish(siifa, handler) + void *siifa; void *handler; { @@ -317,7 +338,7 @@ sio_intr_disestablish(handler) */ void sio_strayintr(irq) - int irq; + isa_irq_t irq; { if (++sio_strayintrcnt[irq] <= STRAY_MAX) @@ -340,6 +361,14 @@ sio_iointr(framep, vec) panic("sio_iointr: irq out of range (%d)", irq); #endif +#ifdef EVCNT_COUNTERS + sio_intr_evcnt.ev_count++; +#else + if (ICU_LEN != INTRCNT_ISA_IRQ_LEN) + panic("sio interrupt counter sizes inconsistent"); + intrcnt[INTRCNT_ISA_IRQ + irq]++; +#endif + /* * We cdr down the intrhand chain, calling each handler with * its appropriate argument; @@ -373,6 +402,8 @@ sio_iointr(framep, vec) * by the interrupt handler. */ if (irq > 7) - outb(IO_ICU2 + 0, 0x20 | (irq & 0x07)); /* XXX */ - outb(IO_ICU1 + 0, 0x20 | (irq > 7 ? 2 : irq)); /* XXX */ + OUTB(sio_ipf, sio_ipfa, + IO_ICU2 + 0, 0x20 | (irq & 0x07)); /* XXX */ + OUTB(sio_ipf, sio_ipfa, + IO_ICU1 + 0, 0x20 | (irq > 7 ? 2 : irq)); /* XXX */ } diff --git a/sys/arch/alpha/pci/siovar.h b/sys/arch/alpha/pci/siovar.h new file mode 100644 index 00000000000..746b9a89abb --- /dev/null +++ b/sys/arch/alpha/pci/siovar.h @@ -0,0 +1,36 @@ +/* $NetBSD: siovar.h,v 1.1 1995/11/23 02:38:22 cgd Exp $ */ + +/* + * Copyright (c) 1995 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. + */ + +void sio_intr_setup __P((__const struct isa_pio_fns *, void *)); +void sio_iointr __P((void *framep, int vec)); + +#ifdef EVCNT_COUNTERS +extern struct evcnt sio_intr_evcnt; +#endif +extern __const struct isa_intr_fns sio_isa_intr_fns; diff --git a/sys/arch/alpha/pci/tga.c b/sys/arch/alpha/pci/tga.c index 0be0c2dd238..739c0d812c1 100644 --- a/sys/arch/alpha/pci/tga.c +++ b/sys/arch/alpha/pci/tga.c @@ -1,4 +1,4 @@ -/* $NetBSD: tga.c,v 1.2 1995/08/03 01:17:28 cgd Exp $ */ +/* $NetBSD: tga.c,v 1.3 1995/11/23 02:38:25 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -32,8 +32,9 @@ #include #include #include +#include -#include +#include #include #include @@ -43,6 +44,7 @@ #include #include #include +#include #include #include @@ -54,11 +56,20 @@ struct cfdriver tgacd = { NULL, "tga", tgamatch, tgaattach, DV_DULL, sizeof(struct tga_softc) }; +int tga_identify __P((tga_reg_t *)); +__const struct tga_conf *tga_getconf __P((int)); +void tga_getdevconfig __P((__const struct pci_conf_fns *, void *, + __const struct pci_mem_fns *, void *, + pci_conftag_t tag, struct tga_devconfig *dc)); + +void tga_bell __P((void *)); /* XXX */ + struct tga_devconfig tga_console_dc; -int tga_identify __P((tga_reg_t *)); -struct tga_conf *tga_getconf __P((int)); -void tga_bell __P((void *)); +#if 0 +dev_decl(tga, mmap); +dev_decl(tga, ioctl); +#endif struct ansicons_functions tga_acf = { tga_bell, @@ -72,19 +83,23 @@ struct ansicons_functions tga_acf = { #define TGAUNIT(dev) minor(dev) -struct tga_ramdac_conf tga_ramdac_bt463 = { +void tga_builtin_set_cpos __P((struct tga_devconfig *, int, int)); +void tga_builtin_get_cpos __P((struct tga_devconfig *, int *, int *)); + +__const struct tga_ramdac_conf tga_ramdac_bt463 = { "Bt463", -#if 0 - XXX, - YYY, -#endif + tga_builtin_set_cpos, + tga_builtin_get_cpos, /* XXX */ }; +void tga_bt485_wr_reg __P((volatile tga_reg_t *, u_int, u_int8_t)); +u_int8_t tga_bt485_rd_reg __P((volatile tga_reg_t *, u_int)); + void tga_bt485_set_cpos __P((struct tga_devconfig *, int, int)); void tga_bt485_get_cpos __P((struct tga_devconfig *, int *, int *)); -struct tga_ramdac_conf tga_ramdac_bt485 = { +__const struct tga_ramdac_conf tga_ramdac_bt485 = { "Bt485", tga_bt485_set_cpos, tga_bt485_get_cpos, @@ -96,7 +111,7 @@ struct tga_ramdac_conf tga_ramdac_bt485 = { #undef MB #define MB * 1024 * 1024 -struct tga_conf tga_configs[TGA_TYPE_UNKNOWN] = { +__const struct tga_conf tga_configs[TGA_TYPE_UNKNOWN] = { /* TGA_TYPE_T8_01 */ { "T8-01", @@ -177,10 +192,10 @@ tgamatch(parent, match, aux) void *match, *aux; { struct cfdata *cf = match; - struct pci_attach_args *pa = aux; + struct pcidev_attach_args *pda = aux; - if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_DEC || - PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_DEC_21030) + if (PCI_VENDOR(pda->pda_id) != PCI_VENDOR_DEC || + PCI_PRODUCT(pda->pda_id) != PCI_PRODUCT_DEC_21030) return (0); return (1); @@ -241,7 +256,7 @@ tga_identify(regs) return (type); } -struct tga_conf * +__const struct tga_conf * tga_getconf(type) int type; { @@ -253,31 +268,51 @@ tga_getconf(type) } void -tga_getdevconfig(tag, dc) - pcitag_t tag; +tga_getdevconfig(pcf, pcfa, pmf, pmfa, tag, dc) + __const struct pci_conf_fns *pcf; + __const struct pci_mem_fns *pmf; + void *pcfa, *pmfa; + pci_conftag_t tag; struct tga_devconfig *dc; { - struct tga_conf *tgac; - struct tga_ramdac_conf *tgar; + __const struct tga_conf *tgac; + __const struct tga_ramdac_conf *tgar; struct raster *rap; struct rcons *rcp; - vm_offset_t pcipa; - int i; + pci_msize_t pcisize; + int i, cacheable; + + dc->dc_pcf = pcf; + dc->dc_pcfa = pcfa; + dc->dc_pmf = pmf; + dc->dc_pmfa = pmfa; dc->dc_pcitag = tag; - dc->dc_vaddr = 0; - if (pci_map_mem(tag, 0x10, &dc->dc_vaddr, &pcipa)) + /* XXX MAGIC NUMBER */ + PCI_FIND_MEM(pcf, pcfa, tag, 0x10, &dc->dc_pcipaddr, &pcisize, + &cacheable); + if (!cacheable) /* sanity */ + panic("tga_getdevconfig: memory not cacheable?"); + + dc->dc_vaddr = PCI_MEM_MAP(pmf, pmfa, dc->dc_pcipaddr, pcisize, 1); + if (dc->dc_vaddr == 0) return; - /* PA filled in by pci_map_mem is the PCI-bus PA, i.e. not shifted */ - dc->dc_paddr = k0segtophys(dc->dc_vaddr); + dc->dc_paddr = k0segtophys(dc->dc_vaddr); /* XXX */ dc->dc_regs = (tga_reg_t *)(dc->dc_vaddr + TGA_MEM_CREGS); dc->dc_tga_type = tga_identify(dc->dc_regs); tgac = dc->dc_tgaconf = tga_getconf(dc->dc_tga_type); if (tgac == NULL) return; + +#if 0 + /* XXX on the Alpha, pcisize = 4 * cspace_size. */ + if (tgac->tgac_cspace_size != pcisize) /* sanity */ + panic("tga_getdevconfig: memory size mismatch?"); +#endif + tgar = tgac->tgac_ramdac; switch (dc->dc_regs[TGA_REG_VHCR] & 0x1ff) { /* XXX */ @@ -306,6 +341,13 @@ tga_getdevconfig(tag, dc) dc->dc_regs[TGA_REG_VVBR] = 1; dc->dc_videobase = dc->dc_vaddr + tgac->tgac_dbuf[0] + 1 * tgac->tgac_vvbr_units; + + /* + * Set all bits in the pixel mask, to enable writes to all pixels. + * It seems that the console firmware clears some of them + * under some circumstances, which causes cute vertical stripes. + */ + dc->dc_regs[TGA_REG_GPXR_P] = 0xffffffff; /* disable the cursor */ (*tgar->tgar_set_cpos)(dc, TGA_CURSOR_OFF, 0); @@ -342,19 +384,19 @@ tgaattach(parent, self, aux) struct device *parent, *self; void *aux; { - struct pci_attach_args *pa = aux; + struct pcidev_attach_args *pda = aux; struct tga_softc *sc = (struct tga_softc *)self; pci_revision_t rev; - pcireg_t pci_intrdata; int console; - console = (pa->pa_tag == tga_console_dc.dc_pcitag); + console = (pda->pda_tag == tga_console_dc.dc_pcitag); if (console) sc->sc_dc = &tga_console_dc; else { sc->sc_dc = (struct tga_devconfig *) malloc(sizeof(struct tga_devconfig), M_DEVBUF, M_WAITOK); - tga_getdevconfig(pa->pa_tag, sc->sc_dc); + tga_getdevconfig(pda->pda_conffns, pda->pda_confarg, + pda->pda_memfns, pda->pda_memarg, pda->pda_tag, sc->sc_dc); } if (sc->sc_dc->dc_vaddr == NULL) { printf(": couldn't map memory space; punt!\n"); @@ -362,7 +404,7 @@ tgaattach(parent, self, aux) } printf(": DC21030 "); - rev = PCI_REVISION(pa->pa_class); + rev = PCI_REVISION(pda->pda_class); switch (rev) { case 1: case 2: case 3: printf("step %c", 'A' + rev - 1); @@ -381,23 +423,11 @@ tgaattach(parent, self, aux) printf("board type %s\n", sc->sc_dc->dc_tgaconf->tgac_name); printf("%s: %d x %d, %dbpp, %s RAMDAC\n", sc->sc_dev.dv_xname, sc->sc_dc->dc_wid, sc->sc_dc->dc_ht, - sc->sc_dc->dc_tgaconf->tgac_phys_depth, + sc->sc_dc->dc_tgaconf->tgac_phys_depth, sc->sc_dc->dc_tgaconf->tgac_ramdac->tgar_name); -#if 0 - /* not done here; printed by wscons attach. */ - if (console) - printf("%s: console\n", sc->sc_dev.dv_xname); -#endif #if 0 - pci_intrdata = pci_conf_read(sc->sc_pcitag, PCI_INTERRUPT_REG); - if (PCI_INTERRUPT_PIN(pci_intrdata) != PCI_INTERRUPT_PIN_NONE) { - sc->sc_intr = pci_map_int(sc->sc_pcitag, PCI_IPL_TTY, - tgaintr, sc); - if (sc->sc_intr == NULL) - printf("%s: WARNING: couldn't map interrupt\n", - sc->sc_dev.dv_xname); - } + /* XXX intr foo? */ #endif if (!wscattach_output(self, console, &sc->sc_dc->dc_ansicons, &tga_acf, @@ -408,35 +438,7 @@ tgaattach(parent, self, aux) } } -int -tgaopen(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - struct tga_softc *sc; - int unit = TGAUNIT(dev); - - if (unit >= tgacd.cd_ndevs) - return ENXIO; - sc = tgacd.cd_devs[unit]; - if ((sc = tgacd.cd_devs[unit]) == NULL || sc->sc_dc->dc_tgaconf == NULL) - return ENXIO; - - return (0); -} - -int -tgaclose(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - struct tga_softc *sc = tgacd.cd_devs[TGAUNIT(dev)]; - - return (0); -} - +#if 0 int tgaioctl(dev, cmd, data, flag, p) dev_t dev; @@ -462,6 +464,7 @@ tgammap(dev, offset, nprot) return -1; return alpha_btop(sc->sc_dc->dc_paddr + offset); } +#endif void tga_bell(id) @@ -472,6 +475,43 @@ tga_bell(id) printf("tga_bell: not implemented\n"); } +void +tga_builtin_set_cpos(dc, x, y) + struct tga_devconfig *dc; + int x, y; +{ + + if (x == TGA_CURSOR_OFF || y == TGA_CURSOR_OFF) { + + dc->dc_regs[TGA_REG_VVVR] &= ~0x04; /* XXX */ + wbflush(); + return; + } + + /* + * TGA builtin cursor is 0-based, and position is top-left corner. + */ + dc->dc_regs[TGA_REG_CXYR] = + (x & 0xfff) | ((y & 0xfff) << 12); /* XXX */ + wbflush(); +} + +void +tga_builtin_get_cpos(dc, xp, yp) + struct tga_devconfig *dc; + int *xp, *yp; +{ + tga_reg_t regval; + + if ((dc->dc_regs[TGA_REG_VVVR] & 0x04) == 0) { /* XXX */ + *xp = *yp = TGA_CURSOR_OFF; + return; + } + + regval = dc->dc_regs[TGA_REG_CXYR]; + *xp = regval & 0xfff; /* XXX */ + *yp = (regval >> 12) & 0xfff; /* XXX */ +} /* * Bt485-specific functions. @@ -521,6 +561,7 @@ tga_bt485_set_cpos(dc, x, y) regval &= ~0x03; /* XXX */ regval |= 0x00; /* XXX */ tga_bt485_wr_reg(dc->dc_regs, BT485_REG_COMMAND_2, regval); + return; } /* @@ -531,14 +572,14 @@ tga_bt485_set_cpos(dc, x, y) y += 64; /* XXX CONSTANTS */ - tga_bt485_rd_reg(dc->dc_regs, BT485_REG_CURSOR_X_LOW, - x & 0xff); - tga_bt485_rd_reg(dc->dc_regs, BT485_REG_CURSOR_X_HIGH, - (x >> 8) & 0x0f); - tga_bt485_rd_reg(dc->dc_regs, BT485_REG_CURSOR_Y_LOW, - y & 0xff); - tga_bt485_rd_reg(dc->dc_regs, BT485_REG_CURSOR_Y_HIGH, - (y >> 8) & 0x0f); + tga_bt485_rd_reg(dc->dc_regs, BT485_REG_CURSOR_X_LOW/*, + x & 0xff*/); + tga_bt485_rd_reg(dc->dc_regs, BT485_REG_CURSOR_X_HIGH/*, + (x >> 8) & 0x0f*/); + tga_bt485_rd_reg(dc->dc_regs, BT485_REG_CURSOR_Y_LOW/*, + y & 0xff*/); + tga_bt485_rd_reg(dc->dc_regs, BT485_REG_CURSOR_Y_HIGH/*, + (y >> 8) & 0x0f*/); } void @@ -573,20 +614,27 @@ tga_bt485_get_cpos(dc, xp, yp) } void -tga_console(bus, device, function) - int bus, device, function; +tga_console(pcf, pcfa, pmf, pmfa, ppf, ppfa, bus, device, function) + __const struct pci_conf_fns *pcf; + __const struct pci_mem_fns *pmf; + __const struct pci_pio_fns *ppf; + void *pcfa, *pmfa, *ppfa; + pci_bus_t bus; + pci_device_t device; + pci_function_t function; { struct tga_devconfig *dcp = &tga_console_dc; - tga_getdevconfig(pci_make_tag(bus, device, function), dcp); + tga_getdevconfig(pcf, pcfa, pmf, pmfa, + PCI_MAKE_TAG(bus, device, function), dcp); /* sanity checks */ if (dcp->dc_vaddr == NULL) - panic("tga_console(%d, %d, %d): couldn't map memory space", - bus, device, function); + panic("tga_console(%d, %d): couldn't map memory space", + device, function); if (dcp->dc_tgaconf == NULL) - panic("tga_console(%d, %d, %d): unknown board configuration", - bus, device, function); + panic("tga_console(%d, %d): unknown board configuration", + device, function); wsc_console(&dcp->dc_ansicons, &tga_acf, &dcp->dc_rcons, dcp->dc_rcons.rc_maxrow, dcp->dc_rcons.rc_maxcol, 0, 0); diff --git a/sys/arch/alpha/pci/tgareg.h b/sys/arch/alpha/pci/tgareg.h index 80b37557860..6c335cf9a28 100644 --- a/sys/arch/alpha/pci/tgareg.h +++ b/sys/arch/alpha/pci/tgareg.h @@ -1,4 +1,4 @@ -/* $NetBSD: tgareg.h,v 1.2 1995/08/03 01:17:34 cgd Exp $ */ +/* $NetBSD: tgareg.h,v 1.3 1995/11/23 02:38:28 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -27,6 +27,9 @@ * rights to redistribute these changes. */ +#ifndef _ALPHA_PCI_TGAREG_H_ +#define _ALPHA_PCI_TGAREG_H_ + /* * Device-specific PCI register offsets and contents. */ @@ -152,3 +155,5 @@ typedef int32_t tga_reg_t; #define TGA_REG_SCSR 0x07e /* Command Status */ /* reserved 0x07f */ + +#endif /* _ALPHA_PCI_TGAREG_H_ */ diff --git a/sys/arch/alpha/pci/tgavar.h b/sys/arch/alpha/pci/tgavar.h index 8ce95ddd87b..b1ab195c624 100644 --- a/sys/arch/alpha/pci/tgavar.h +++ b/sys/arch/alpha/pci/tgavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: tgavar.h,v 1.2 1995/08/03 01:17:37 cgd Exp $ */ +/* $NetBSD: tgavar.h,v 1.3 1995/11/23 02:38:31 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -27,6 +27,11 @@ * rights to redistribute these changes. */ +#include +#include +#include +#include + struct tga_devconfig; struct tga_ramdac_conf { @@ -42,7 +47,7 @@ struct tga_ramdac_conf { struct tga_conf { char *tgac_name; /* name for this board type */ - struct tga_ramdac_conf + __const struct tga_ramdac_conf *tgac_ramdac; /* the RAMDAC type; see above */ int tgac_phys_depth; /* physical frame buffer depth */ vm_size_t tgac_cspace_size; /* core space size */ @@ -58,12 +63,20 @@ struct tga_conf { }; struct tga_devconfig { - pcitag_t dc_pcitag; /* PCI tag */ + __const struct pci_conf_fns *dc_pcf; + void *dc_pcfa; + __const struct pci_mem_fns *dc_pmf; + void *dc_pmfa; + __const struct pci_pio_fns *dc_ppf; + void *dc_ppfa; + + pci_conftag_t dc_pcitag; /* PCI tag */ + pci_moffset_t dc_pcipaddr; /* PCI phys addr. */ tga_reg_t *dc_regs; /* registers; XXX: need aliases */ int dc_tga_type; /* the device type; see below */ - struct tga_conf *dc_tgaconf; /* device buffer configuration */ + __const struct tga_conf *dc_tgaconf; /* device buffer configuration */ vm_offset_t dc_vaddr; /* memory space virtual base address */ vm_offset_t dc_paddr; /* memory space physical base address */ @@ -96,3 +109,12 @@ struct tga_softc { #define TGA_TYPE_UNKNOWN 7 /* unknown */ #define TGA_CURSOR_OFF -1 /* pass to tgar_cpos to disable */ + +#define DEVICE_IS_TGA(class, id) \ + (PCI_VENDOR(id) == PCI_VENDOR_DEC && \ + PCI_PRODUCT(id) == PCI_PRODUCT_DEC_21030) + +void tga_console __P((__const struct pci_conf_fns *, void *, + __const struct pci_mem_fns *, void *, + __const struct pci_pio_fns *, void *, + pci_bus_t, pci_device_t, pci_function_t)); diff --git a/sys/arch/alpha/pci/wscons.c b/sys/arch/alpha/pci/wscons.c index 8307e1d0d07..fa5a988cf09 100644 --- a/sys/arch/alpha/pci/wscons.c +++ b/sys/arch/alpha/pci/wscons.c @@ -1,4 +1,4 @@ -/* $NetBSD: wscons.c,v 1.2 1995/08/03 01:17:40 cgd Exp $ */ +/* $NetBSD: wscons.c,v 1.3 1995/11/23 02:38:36 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -39,6 +39,7 @@ #include #include +#include #define NWSC 16 /* XXX XXX XXX */ @@ -105,6 +106,7 @@ wscattach_output(dev, console, acp, acf, acfarg, mrow, mcol, crow, ccol) } wsc_sc[nextowsc].sc_flags |= WSC_OUTPUT; + wsc_sc[nextowsc].sc_tty = ttymalloc(); printf("wsc%d: %s attached as output\n", nextowsc, dev->dv_xname); if (console) @@ -149,9 +151,8 @@ wscopen(dev, flag, mode, p) return ENXIO; if (!sc->sc_tty) - tp = sc->sc_tty = ttymalloc(); - else - tp = sc->sc_tty; + panic("wscopen: no tty!"); + tp = sc->sc_tty; tp->t_oproc = wscstart; tp->t_param = wscparam; diff --git a/sys/arch/alpha/isa/isa_dma.h b/sys/arch/alpha/pci/wsconsvar.h similarity index 60% rename from sys/arch/alpha/isa/isa_dma.h rename to sys/arch/alpha/pci/wsconsvar.h index 8c277908351..77347e07faa 100644 --- a/sys/arch/alpha/isa/isa_dma.h +++ b/sys/arch/alpha/pci/wsconsvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: isa_dma.h,v 1.1 1995/06/28 01:24:50 cgd Exp $ */ +/* $NetBSD: wsconsvar.h,v 1.1 1995/11/23 02:38:39 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -27,21 +27,14 @@ * rights to redistribute these changes. */ -struct isadma_fcns { - int (*isadma_map) __P((caddr_t addr, vm_size_t size, - vm_offset_t *mappings, int flags)); - void (*isadma_unmap) __P((caddr_t addr, vm_size_t size, - int nmappings, vm_offset_t *mappings)); - void (*isadma_copytobuf) __P((caddr_t addr, vm_size_t size, - int nmappings, vm_offset_t *mappings)); - void (*isadma_copyfrombuf) __P((caddr_t addr, vm_size_t size, - int nmappings, vm_offset_t *mappings)); -}; +struct device; +struct ansicons; +struct ansicons_functions; -/* - * Global which tells which set of functions are correct - * for this machine. - */ -struct isadma_fcns *isadma_fcns; - -struct isadma_fcns apecs_isadma_fcns; /* APECS DMA mapping */ +int wscattach_output __P((struct device *, int, struct ansicons *, + struct ansicons_functions *, void *, int, int, int, int)); +void wscattach_input __P((struct device *, void *, int (*)(void *), + void (*)(void *, int))); +void wscons_kbdinput __P((char *)); +void wsc_console __P((struct ansicons *, struct ansicons_functions *, + void *, int, int, int, int)); diff --git a/sys/arch/alpha/stand/Makefile b/sys/arch/alpha/stand/Makefile index f58b7cdd78e..9587f1fa0a5 100644 --- a/sys/arch/alpha/stand/Makefile +++ b/sys/arch/alpha/stand/Makefile @@ -1,7 +1,5 @@ -# $NetBSD: Makefile,v 1.2 1995/02/27 16:36:43 cgd Exp $ +# $NetBSD: Makefile,v 1.3 1995/11/23 02:38:45 cgd Exp $ -SUBDIR= boot xxboot bootxx - -obj: +SUBDIR= boot bootxx installboot .include diff --git a/sys/arch/alpha/stand/Makefile.inc b/sys/arch/alpha/stand/Makefile.inc new file mode 100644 index 00000000000..73c404a4bac --- /dev/null +++ b/sys/arch/alpha/stand/Makefile.inc @@ -0,0 +1,9 @@ +# $NetBSD: Makefile.inc,v 1.1 1995/11/23 02:38:48 cgd Exp $ + +BINDIR= /usr/mdec + +PRIMARY_LOAD_ADDRESS= 20000000 +SECONDARY_LOAD_ADDRESS= 20020000 + +CPPFLAGS+= -DPRIMARY_LOAD_ADDRESS="0x${PRIMARY_LOAD_ADDRESS}" +CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS="0x${SECONDARY_LOAD_ADDRESS}" diff --git a/sys/arch/alpha/stand/OSFpal.c b/sys/arch/alpha/stand/OSFpal.c new file mode 100644 index 00000000000..bfe46b2d727 --- /dev/null +++ b/sys/arch/alpha/stand/OSFpal.c @@ -0,0 +1,26 @@ + +#include + +#include +#include + +void +OSFpal() +{ + struct rpb *r; + struct ctb *t; + struct pcs *p; + long result; + int offset; + + r = (struct rpb *)HWRPB_ADDR; + offset = r->rpb_pcs_size * cpu_number(); + p = (struct pcs *)((u_int8_t *)r + r->rpb_pcs_off + offset); + + printf("VMS PAL revision: 0x%lx\n", + p->pcs_palrevisions[PALvar_OpenVMS]); + printf("OSF PAL rev: 0x%lx\n", p->pcs_palrevisions[PALvar_OSF1]); + (void)switch_palcode(); + printf("Switch to OSF PAL code succeeded.\n"); +} + diff --git a/sys/arch/alpha/stand/bbinfo.h b/sys/arch/alpha/stand/bbinfo.h new file mode 100644 index 00000000000..8da100b28db --- /dev/null +++ b/sys/arch/alpha/stand/bbinfo.h @@ -0,0 +1,14 @@ + +struct bbinfoloc { + u_int64_t magic1; + u_int64_t start; + u_int64_t end; + u_int64_t magic2; +}; + +struct bbinfo { + int32_t cksum; + int32_t nblocks; + int32_t bsize; + int32_t blocks[1]; +}; diff --git a/sys/arch/alpha/stand/boot/Makefile b/sys/arch/alpha/stand/boot/Makefile index 03d7c126bfa..23c3c283e7c 100644 --- a/sys/arch/alpha/stand/boot/Makefile +++ b/sys/arch/alpha/stand/boot/Makefile @@ -1,61 +1,51 @@ -# $NetBSD: Makefile,v 1.4 1995/06/28 00:58:44 cgd Exp $ -# -# BSD Boot blocks for the Alpha -# -# XXX should generate a primary boot block, too... - -INCPATH=-I../../../.. -I. - -# Boot relocation address -RELOC1= 20020000 -# Low memory test program relocation address -#RELOC2= 20004000 -# High memory test program relocation address -RELOC2= fffffc0000230000 - -# Compiler and assembler flags used to generate boot blocks. -# -DEFS= -DSTANDALONE -AFLAGS+=-DASSEMBLER ${INCPATH} -CFLAGS= -mno-fp-regs ${INCPATH} ${DEFS} - -LIBS= libsa/libsa.a -lc -SRCS= boot.c disk.c conf.c prom.c test.c - -all: boot - -libsa/libsa.a:: - cd libsa; make - -# This boot is supposed to be installed in this way: -# cp boot /boot -BOBJS= boot.o conf.o disk.o prom.o prom_disp.o prom_swpal.o vers.o -boot: start.o ${BOBJS} ${LIBS} - ${LD} -Ttext ${RELOC1} -N \ - -e start -o ${.TARGET} start.o ${BOBJS} ${LIBS} - -# This boot is supposed to be installed in this way: -# cp test_boot /test_boot -# -# It is used presumably in this way: -# boot -fi "test_boot" dka300 -TOBJS= prom.o prom_disp.o prom_swpal.o test.o -test_boot: start.o ${TOBJS} ${LIBS} - ${LD} -T ${RELOC2} -N -e start -o ${.TARGET} start.o ${TOBJS} ${LIBS} - -clean cleandir: - rm -f .depend *.o *.exe *.i errs make.out core* vers.c - rm -f a.out boot test_boot - cd libsa && make cleandir +# $NetBSD: Makefile,v 1.5 1995/11/23 02:39:20 cgd Exp $ + +.PATH: ${.CURDIR}/.. ${.CURDIR}/../../../../lib/libsa + +BOOT_PROG = boot +BOOT_RELOC = ${SECONDARY_LOAD_ADDRESS} + +BOOT_SRCS = start.S boot.c disk.c conf.c prom.c prom_disp.S OSFpal.c +BOOT_SRCS+= alloc.c bzero.c close.c dev.c devopen.c disklabel.c +BOOT_SRCS+= getfile.c gets.c ioctl.c lseek.c open.c printf.c read.c +BOOT_SRCS+= strcmp.c ufs.c write.c bcopy.c filesystem.c strlen.c +BOOT_SRCS+= ntohl.c prom_swpal.S +BOOT_OBJS = ${BOOT_SRCS:N*.h:R:S/$/.o/g} + +HEADERSIZE_PROG = headersize + +AFLAGS += -DASSEMBLER +CPPFLAGS += -I${.CURDIR}/../.. -I${.CURDIR}/../../../.. +CFLAGS = -Werror -mno-fp-regs -g -DCOMPAT_UFS + +CLEANFILES+= vers.c vers.o + +.PATH: ${.CURDIR}/../../../../lib/libkern + +all: ${BOOT_PROG} + +${BOOT_PROG}: ${BOOT_OBJS} ${HEADERSIZE_PROG} + sh ${.CURDIR}/newvers.sh ${.CURDIR}/version + ${COMPILE.c} vers.c + ${LD} -Ttext ${BOOT_RELOC} -N -e start -o ${BOOT_PROG}.coff \ + ${BOOT_OBJS} vers.o -lc # XXX + size ${BOOT_PROG}.coff + strip ${BOOT_PROG}.coff + dd if=${BOOT_PROG}.coff of=${BOOT_PROG} \ + bs=`./${HEADERSIZE_PROG} < ${BOOT_PROG}.coff` skip=1 install: - install -c -o root -g wheel -m 555 boot ${DESTDIR}/ + install -c -o bin -g bin -m 444 ${BOOT_PROG} \ + ${DESTDIR}${BINDIR}/${BOOT_PROG} -depend: ${SRCS} - mkdep -p ${INCPATH} ${DEFS} ${SRCS} - cd libsa && make depend +clean: _SUBDIRUSE + rm -f a.out [Ee]rrs mklog core *.core \ + ${BOOT_PROG} ${BOOT_OBJS} ${CLEANFILES} \ + ${BOOT_PROG}.coff ${HEADERSIZE_PROG} -newvers: - sh newvers.sh +cleandir: _SUBDIRUSE clean -vers.c: newvers +.include "${.CURDIR}/../Makefile.inc" +.include +.include +.include diff --git a/sys/arch/alpha/stand/boot/TODO b/sys/arch/alpha/stand/boot/TODO deleted file mode 100644 index 57c1ab2f87d..00000000000 --- a/sys/arch/alpha/stand/boot/TODO +++ /dev/null @@ -1,7 +0,0 @@ -$NetBSD: TODO,v 1.2 1995/02/16 02:32:53 cgd Exp $ - -libsa/devopen.c should replace the PMAX source code, and -they should then share it. - -Standalone programs should load against libkern, and sys/stand -should lose things like strchr() in favor of the libkern versions. diff --git a/sys/arch/alpha/stand/boot/boot.c b/sys/arch/alpha/stand/boot/boot.c index 375b0070834..0abbb15e7e8 100644 --- a/sys/arch/alpha/stand/boot/boot.c +++ b/sys/arch/alpha/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.3 1995/06/28 00:58:48 cgd Exp $ */ +/* $NetBSD: boot.c,v 1.4 1995/11/23 02:39:27 cgd Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,15 +39,16 @@ */ #include +#include #include #include #include -#include "../../include/coff.h" +#include "include/coff.h" #define _KERNEL -#include "../../include/pte.h" +#include "include/pte.h" static int aout_exec __P((int, struct exec *, u_int64_t *)); static int coff_exec __P((int, struct exechdr *, u_int64_t *)); diff --git a/sys/arch/alpha/stand/boot/conf.c b/sys/arch/alpha/stand/boot/conf.c index 9cc3d1b6621..4e81e277451 100644 --- a/sys/arch/alpha/stand/boot/conf.c +++ b/sys/arch/alpha/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.2 1995/02/16 02:32:54 cgd Exp $ */ +/* $NetBSD: conf.c,v 1.3 1995/11/23 02:39:31 cgd Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,11 +41,11 @@ #include #include -int errno; -int noioctl __P((void)); +#include "disk.h" + +int diskopen __P((struct open_file *, ...)); /* XXX */ -int diskstrategy(), diskopen(), diskclose(); -#define diskioctl noioctl +int errno; struct devsw devsw[] = { { "disk", diskstrategy, diskopen, diskclose, diskioctl }, /*0*/ diff --git a/sys/arch/alpha/stand/boot/libsa/devopen.c b/sys/arch/alpha/stand/boot/devopen.c similarity index 98% rename from sys/arch/alpha/stand/boot/libsa/devopen.c rename to sys/arch/alpha/stand/boot/devopen.c index 78a8cc8efc1..33c5695b286 100644 --- a/sys/arch/alpha/stand/boot/libsa/devopen.c +++ b/sys/arch/alpha/stand/boot/devopen.c @@ -1,4 +1,4 @@ -/* $NetBSD: devopen.c,v 1.2 1995/02/16 02:33:04 cgd Exp $ */ +/* $NetBSD: devopen.c,v 1.1 1995/11/23 02:39:37 cgd Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -57,7 +57,7 @@ devopen(f, fname, file) char namebuf[20]; int rc; - cp = fname; + cp = (char *)fname; ncp = namebuf; /* look for a string like '5/rz0/vmunix' or '5/rz3f/vmunix */ diff --git a/sys/arch/alpha/stand/boot/disk.c b/sys/arch/alpha/stand/boot/disk.c index f03c0bc2daa..c80cc60a911 100644 --- a/sys/arch/alpha/stand/boot/disk.c +++ b/sys/arch/alpha/stand/boot/disk.c @@ -1,4 +1,4 @@ -/* $NetBSD: disk.c,v 1.2 1995/02/16 02:32:55 cgd Exp $ */ +/* $NetBSD: disk.c,v 1.3 1995/11/23 02:39:40 cgd Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,6 +45,8 @@ #include +#include "disk.h" + struct disk_softc { int sc_fd; /* PROM channel number */ int sc_ctlr; /* controller number */ @@ -54,19 +56,24 @@ struct disk_softc { }; int -diskstrategy(devdata, rw, bn, reqcnt, addr, cnt) +diskstrategy(devdata, rw, bn, reqcnt, addrvoid, cnt) void *devdata; int rw; daddr_t bn; - u_int reqcnt; - char *addr; - u_int *cnt; /* out: number of bytes transfered */ + size_t reqcnt; + void *addrvoid; + size_t *cnt; /* out: number of bytes transfered */ { + char *addr = addrvoid; struct disk_softc *sc; struct partition *pp; prom_return_t ret; int s; + if ((reqcnt & 0xffffff) != reqcnt || + reqcnt == 0) + asm("call_pal 0"); + twiddle(); /* Partial-block transfers not handled. */ @@ -92,7 +99,8 @@ diskopen(f, ctlr, unit, part) { struct disklabel *lp; prom_return_t ret; - int cnt, devlen, i; + size_t cnt; + int devlen, i; char *msg, buf[DEV_BSIZE], devname[32]; static struct disk_softc *sc; diff --git a/sys/arch/alpha/stand/boot/disk.h b/sys/arch/alpha/stand/boot/disk.h new file mode 100644 index 00000000000..c60583c11e2 --- /dev/null +++ b/sys/arch/alpha/stand/boot/disk.h @@ -0,0 +1,7 @@ +/* $NetBSD: disk.h,v 1.1 1995/11/23 02:39:42 cgd Exp $ */ + +int diskstrategy __P((void *, int, daddr_t, size_t, void *, size_t *)); +/* int diskopen __P((struct open_file *, int, int, int)); */ +int diskclose __P((struct open_file *)); + +#define diskioctl noioctl diff --git a/sys/arch/alpha/stand/boot/libsa/filesystem.c b/sys/arch/alpha/stand/boot/filesystem.c similarity index 96% rename from sys/arch/alpha/stand/boot/libsa/filesystem.c rename to sys/arch/alpha/stand/boot/filesystem.c index 514e6e809bf..8f963e9e673 100644 --- a/sys/arch/alpha/stand/boot/libsa/filesystem.c +++ b/sys/arch/alpha/stand/boot/filesystem.c @@ -1,4 +1,4 @@ -/* $NetBSD: filesystem.c,v 1.2 1995/02/16 02:33:05 cgd Exp $ */ +/* $NetBSD: filesystem.c,v 1.1 1995/11/23 02:39:46 cgd Exp $ */ /* * Copyright (c) 1993 Philip A. Nelson. diff --git a/sys/arch/alpha/stand/boot/libsa/Makefile b/sys/arch/alpha/stand/boot/libsa/Makefile deleted file mode 100644 index c84169984f7..00000000000 --- a/sys/arch/alpha/stand/boot/libsa/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $NetBSD: Makefile,v 1.2 1995/02/16 02:33:03 cgd Exp $ - -LIB= sa -SRCS= alloc.c bzero.c close.c dev.c devopen.c disklabel.c getfile.c \ - gets.c ioctl.c lseek.c open.c printf.c read.c strcmp.c ufs.c \ - write.c bcopy.c filesystem.c strlen.c ntohl.c - -.PATH: ../../../../../lib/libsa ../../../../../lib/libkern -NOPIC=nopic -NOPROFILE=noprofile - -.include - -CFLAGS= -mno-fp-regs -I../../../../.. -I. -DCOMPAT_UFS diff --git a/sys/arch/alpha/stand/boot/newvers.sh b/sys/arch/alpha/stand/boot/newvers.sh index 8e4737c48a6..135bb35fd58 100644 --- a/sys/arch/alpha/stand/boot/newvers.sh +++ b/sys/arch/alpha/stand/boot/newvers.sh @@ -1,6 +1,6 @@ #!/bin/sh - # -# $NetBSD: newvers.sh,v 1.1 1995/02/13 23:08:10 cgd Exp $ +# $NetBSD: newvers.sh,v 1.2 1995/11/23 02:39:48 cgd Exp $ # # Copyright (c) 1984, 1986, 1990, 1993 # The Regents of the University of California. All rights reserved. @@ -36,7 +36,7 @@ # @(#)newvers.sh 8.1 (Berkeley) 4/20/94 u=${USER-root} h=`hostname` t=`date` -r=`head -1 version` +r=`head -1 $1` echo "char bootprog_name[] = \"NetBSD/Alpha boot\";" > vers.c echo "char bootprog_rev[] = \"${r}\";" >> vers.c diff --git a/sys/arch/alpha/stand/boot/prom.c b/sys/arch/alpha/stand/boot/prom.c deleted file mode 100644 index 92e58cfefe3..00000000000 --- a/sys/arch/alpha/stand/boot/prom.c +++ /dev/null @@ -1,135 +0,0 @@ -/* $NetBSD: prom.c,v 1.3 1995/06/28 00:58:49 cgd Exp $ */ - -/* - * Mach Operating System - * Copyright (c) 1992 Carnegie Mellon University - * All Rights Reserved. - * - * 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 Mellon - * the rights to redistribute these changes. - */ - -#include - -#include -#include - -int console; - -void -init_prom_calls() -{ - extern struct prom_vec prom_dispatch_v; - struct rpb *r; - struct crb *c; - char buf[4]; - - r = (struct rpb *)HWRPB_ADDR; - c = (struct crb *)((u_int8_t *)r + r->rpb_crb_off); - - prom_dispatch_v.routine_arg = c->crb_v_dispatch; - prom_dispatch_v.routine = c->crb_v_dispatch->code; - - /* Look for console tty. */ - prom_getenv(PROM_E_TTY_DEV, buf, 4); - console = buf[0] - '0'; -} - -void -OSFpal() -{ - struct rpb *r; - struct ctb *t; - struct pcs *p; - long result; - int offset; - - r = (struct rpb *)HWRPB_ADDR; - offset = r->rpb_pcs_size * cpu_number(); - p = (struct pcs *)((u_int8_t *)r + r->rpb_pcs_off + offset); - - printf("VMS PAL revision: 0x%lx\n", - p->pcs_palrevisions[PALvar_OpenVMS]); - printf("OSF PAL rev: 0x%lx\n", p->pcs_palrevisions[PALvar_OSF1]); - (void)switch_palcode(); - printf("Switch to OSF PAL code succeeded.\n"); -} - -int -getchar() -{ - prom_return_t ret; - - for (;;) { - ret.bits = prom_dispatch(PROM_R_GETC, console); - if (ret.u.status == 0 || ret.u.status == 1) - return (ret.u.retval); - } -} - -void -putchar(c) - int c; -{ - prom_return_t ret; - char cbuf; - - if (c == '\r' || c == '\n') { - cbuf = '\r'; - do { - ret.bits = prom_dispatch(PROM_R_PUTS, console, - &cbuf, 1); - } while ((ret.u.retval & 1) == 0); - cbuf = '\n'; - } else - cbuf = c; - do { - ret.bits = prom_dispatch(PROM_R_PUTS, console, &cbuf, 1); - } while ((ret.u.retval & 1) == 0); -} - -int -prom_getenv(id, buf, len) - int id, len; - char *buf; -{ - prom_return_t ret; - - ret.bits = prom_dispatch(PROM_R_GETENV, id, buf, len-1); - if (ret.u.status & 0x4) - ret.u.retval = 0; - buf[ret.u.retval] = '\0'; - - return (ret.u.retval); -} - -int -prom_open(dev, len) - char *dev; - int len; -{ - prom_return_t ret; - - ret.bits = prom_dispatch(PROM_R_OPEN, dev, len); - if (ret.u.status & 0x4) - return (-1); - else - return (ret.u.retval); -} diff --git a/sys/arch/alpha/stand/boot/prom_disp.S b/sys/arch/alpha/stand/boot/prom_disp.S deleted file mode 100644 index 8387dadc9b2..00000000000 --- a/sys/arch/alpha/stand/boot/prom_disp.S +++ /dev/null @@ -1,116 +0,0 @@ -/* $NetBSD: prom_disp.S,v 1.2 1995/02/16 02:32:57 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 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. - */ - -#ifndef LOCORE -#include "../../include/asm.h" -#include "../../include/prom.h" -#include "../../include/rpb.h" -#endif - - .globl prom_dispatch_v - .comm prom_dispatch_v 16 - - .text - .align 4 - -/* - * Dispatcher routine. Implements prom's calling machinery, saves our - * callee-saved registers as required by C. - */ -#define D_RA (7*8) -#define D_S0 (8*8) -#define D_S1 (9*8) -#define D_S2 (10*8) -#define D_S3 (11*8) -#define D_S4 (12*8) -#define D_S5 (13*8) -#define D_S6 (14*8) -#define DISPATCH_FRAME_SIZE (15*8) -#define DISPATCH_REGS IM_RA|IM_S0|IM_S1|IM_S2|IM_S3|IM_S4|IM_S5|IM_S6 - -NESTED(prom_dispatch, 5, DISPATCH_FRAME_SIZE, ra, DISPATCH_REGS, 0) - -/* ldgp gp, 0(pv)*/ - SETGP(pv) - - lda sp, -DISPATCH_FRAME_SIZE(sp) - stq ra, D_RA(sp) - stq s0, D_S0(sp) - stq s1, D_S1(sp) - stq s2, D_S2(sp) - stq s3, D_S3(sp) - stq s4, D_S4(sp) - stq s5, D_S5(sp) - stq s6, D_S6(sp) - - /* Lord have mercy because.. I would not. */ -/* #define STUPID_PROM_IS_32_BITS */ -#ifdef STUPID_PROM_IS_32_BITS - ldah s0, 0x2000(zero) /* hack for hack */ - lda s0, (0x2000-8)(s0) - - stq sp, 0(s0) - or s0, zero, sp -#endif /* STUPID_PROM_IS_32_BITS */ - - lda pv, prom_dispatch_v - ldq v0, 0(pv) /* routine */ - ldq pv, 8(pv) /* routine_arg */ - - jsr ra, (v0) - -#ifdef STUPID_PROM_IS_32_BITS - ldah s0, 0x2000(zero) /* hack for hack */ - lda s0, (0x2000-8)(s0) - - ldq sp, 0(s0) -#endif /* STUPID_PROM_IS_32_BITS */ - - ldq ra, D_RA(sp) - ldq s0, D_S0(sp) - ldq s1, D_S1(sp) - ldq s2, D_S2(sp) - ldq s3, D_S3(sp) - ldq s4, D_S4(sp) - ldq s5, D_S5(sp) - ldq s6, D_S6(sp) - lda sp, DISPATCH_FRAME_SIZE(sp) - RET -END(prom_dispatch) - -#undef D_RA -#undef D_S0 -#undef D_S1 -#undef D_S2 -#undef D_S3 -#undef D_S4 -#undef D_S5 -#undef D_S6 -#undef DISPATCH_FRAME_SIZE -#undef DISPATCH_REGS diff --git a/sys/arch/alpha/stand/boot/version b/sys/arch/alpha/stand/boot/version index d6a53b8ab55..a7634431ffb 100644 --- a/sys/arch/alpha/stand/boot/version +++ b/sys/arch/alpha/stand/boot/version @@ -1,5 +1,7 @@ -$NetBSD: version,v 1.3 1995/06/28 00:58:52 cgd Exp $ +$NetBSD: version,v 1.4 1995/11/23 02:40:09 cgd Exp $ 1.1: Initial version 1.2: don't forget the Id string! 1.3: make it work on AlphaStations +1.4: Re-import from master sources. +1.5: Complete rewrite of boot block code. diff --git a/sys/arch/alpha/stand/bootxx.c b/sys/arch/alpha/stand/bootxx.c new file mode 100644 index 00000000000..48c21f3c7fa --- /dev/null +++ b/sys/arch/alpha/stand/bootxx.c @@ -0,0 +1,122 @@ +#include +#include + +#include "bbinfo.h" + +extern _end, start; + +struct bbinfoloc desc = { + 0xbabefacedeadbeef, + (u_int64_t)&start, + (u_int64_t)&_end, + 0xdeadbeeffacebabe +}; + +int +open_dev(fd) + int *fd; +{ + prom_return_t ret; + char devname[64]; + int devlen; + + /* + * XXX + * We don't know what device names look like yet, + * so we can't change them. + */ + ret.bits = prom_getenv(PROM_E_BOOTED_DEV, devname, sizeof(devname)); + devlen = ret.u.retval; + + ret.bits = prom_open(devname, devlen); + if (ret.u.status) + return 0; + + *fd = ret.u.retval; + + return 1; +} + +int +load_file(bbinfop, loadaddr) + struct bbinfo *bbinfop; + char *loadaddr; +{ + prom_return_t ret; + int32_t cksum, *int32p; + int i, n, fd, rv; + char *cp; + + if (bbinfop->nblocks <= 0) { + puts("invalid number of blocks in boot program description\n"); + return 0; + } + if (bbinfop->bsize < 4096 || bbinfop->bsize > MAXBSIZE) { + puts("invalid block size in boot program description\n"); + return 0; + } + + int32p = (int32_t *)&_end; + n = bbinfop->nblocks + + (sizeof(*bbinfop) / sizeof(bbinfop->blocks[0])) - 1; + if ((long)&_end - (long)&start + sizeof(bbinfop->blocks[0]) * n > + 15 * 512) { + puts("way too many blocks\n"); + return 0; + } + + for (i = 0, cksum = 0; i < n; i++) + cksum += *int32p++; + if (cksum != 0) { + puts("invalid checksum in boot program description\n"); + return 0; + } + + if (!open_dev(&fd)) { + puts("couldn't open disk device\n"); + return 0; + } + + cp = loadaddr; + rv = 1; + for (i = 0; i < bbinfop->nblocks; i++) { +puts("."); + ret.bits = prom_read(fd, bbinfop->bsize, cp, + bbinfop->blocks[i]); +puts("\b"); + if (ret.u.status) { + rv = 0; + puts("BLOCK READ ERROR!\n"); + break; + } + cp += bbinfop->bsize; + } + prom_close(fd); + + return (rv); +} + +void +main() +{ + struct bbinfo *bbinfop; + char *loadaddr; + void (*entry) __P((void)); + + /* Init prom callback vector. */ + init_prom_calls(); + + puts("\nNetBSD/Alpha primary boot...\n"); + + bbinfop = (struct bbinfo *)&_end; + loadaddr = (char *)SECONDARY_LOAD_ADDRESS; + if (!load_file(bbinfop, loadaddr)) { + puts("\nLOAD FAILED!\n\n"); + return; + } + + puts("Jumping to entry point...\n"); + entry = (void (*)())loadaddr; + (*entry)(); + puts("SECONDARY BOOT BLOCK RETURNED!\n"); +} diff --git a/sys/arch/alpha/stand/bootxx/Makefile b/sys/arch/alpha/stand/bootxx/Makefile index 75f5f9f8caa..937657352f7 100644 --- a/sys/arch/alpha/stand/bootxx/Makefile +++ b/sys/arch/alpha/stand/bootxx/Makefile @@ -1,67 +1,44 @@ -# $NetBSD: Makefile,v 1.3 1995/02/27 16:36:55 cgd Exp $ -# -# BSD Boot blocks for the Alpha -# -# XXX should generate a primary boot block, too... +# $NetBSD: Makefile,v 1.4 1995/11/23 02:40:29 cgd Exp $ -#INCPATH=-I../../.. -I. -INCPATH=-I/sys -I. -I/sys/arch/alpha/stand +.PATH: ${.CURDIR}/.. ${.CURDIR}/../../../../lib/libsa -# Boot relocation address -RELOC1= 20000000 -# Low memory test program relocation address -#RELOC2= 20004000 -# High memory test program relocation address -RELOC2= fffffc0000230000 +BOOT_PROG = bootxx +BOOT_RELOC = ${PRIMARY_LOAD_ADDRESS} -# Compiler and assembler flags used to generate boot blocks. -# -DEFS= -DSMALL -DSTANDALONE -AFLAGS+=-DASSEMBLER ${INCPATH} -#CFLAGS= -O6 -mno-fp-regs ${INCPATH} ${DEFS} -CFLAGS= -mno-fp-regs ${INCPATH} ${DEFS} -finline-functions -O6 +BOOT_SRCS = start.S bootxx.c prom.c prom_disp.S bzero.c puts.c +BOOT_OBJS = ${BOOT_SRCS:N*.h:R:S/$/.o/g} -LIBS= libsa/libsa.a -lc -SRCS= boot.c conf.c prom.c test.c +HEADERSIZE_PROG = headersize -all: bootxx +AFLAGS += -DASSEMBLER +CPPFLAGS += -I${.CURDIR}/../.. -DPRIMARY_BOOTBLOCK +CFLAGS = -Werror -mno-fp-regs -g -libsa/libsa.a:: - cd libsa; make +.PATH: ${.CURDIR}/../../../../lib/libkern -# This boot is supposed to be installed in this way: -# cp boot /boot -BOBJS= boot.o prom.o prom_disp.o -bootxx.coff: start.o ${BOBJS} ${LIBS} - ${LD} -Ttext ${RELOC1} -N \ - -e start -o ${.TARGET} start.o ${BOBJS} ${LIBS} +all: ${BOOT_PROG} -bootxx: headersize bootxx.coff - dd if=bootxx.coff of=bootxx.nohdr bs=`./headersize /test_boot -# -# It is used presumably in this way: -# boot -fi "test_boot" dka300 -TOBJS= prom.o prom_disp.o prom_swpal.o test.o -test_boot: start.o ${TOBJS} ${LIBS} - ${LD} -T ${RELOC2} -N -e start -o ${.TARGET} start.o ${TOBJS} ${LIBS} - -clean cleandir: - rm -f .depend *.o *.exe *.i errs make.out core* vers.c - rm -f a.out boot test_boot bootxx bootxx.nohdr bootxx.coff headersize - cd libsa && make cleandir +${BOOT_PROG}: ${BOOT_OBJS} ${HEADERSIZE_PROG} + ${LD} -Ttext ${BOOT_RELOC} -N -e start -o ${BOOT_PROG}.coff \ + ${BOOT_OBJS} + size ${BOOT_PROG}.coff + strip ${BOOT_PROG}.coff + dd if=${BOOT_PROG}.coff of=${BOOT_PROG}.nohdr \ + bs=`./${HEADERSIZE_PROG} < ${BOOT_PROG}.coff` skip=1 + dd if=${BOOT_PROG}.nohdr of=${BOOT_PROG} bs=`expr 15 \* 512` conv=sync install: - install -c -o bin -g bin -m 444 bootxx ${DESTDIR}/usr/mdec/bootsd + install -c -o bin -g bin -m 444 ${BOOT_PROG} \ + ${DESTDIR}${BINDIR}/${BOOT_PROG} -depend: ${SRCS} - mkdep -p ${INCPATH} ${DEFS} ${SRCS} - cd libsa && make depend +clean: _SUBDIRUSE + rm -f a.out [Ee]rrs mklog core *.core \ + ${BOOT_PROG} ${BOOT_OBJS} ${CLEANFILES} \ + ${BOOT_PROG}.coff ${BOOT_PROG}.nohdr ${HEADERSIZE_PROG} -newvers: - sh newvers.sh +cleandir: _SUBDIRUSE clean -vers.c: newvers +.include "${.CURDIR}/../Makefile.inc" +.include +.include +.include diff --git a/sys/arch/alpha/stand/bootxx/TODO b/sys/arch/alpha/stand/bootxx/TODO deleted file mode 100644 index 34e314a9616..00000000000 --- a/sys/arch/alpha/stand/bootxx/TODO +++ /dev/null @@ -1,7 +0,0 @@ -$NetBSD: TODO,v 1.2 1995/02/16 02:33:07 cgd Exp $ - -libsa/devopen.c should replace the PMAX source code, and -they should then share it. - -Standalone programs should load against libkern, and sys/stand -should lose things like strchr() in favor of the libkern versions. diff --git a/sys/arch/alpha/stand/bootxx/boot.c b/sys/arch/alpha/stand/bootxx/boot.c deleted file mode 100644 index 0d9cda391f6..00000000000 --- a/sys/arch/alpha/stand/bootxx/boot.c +++ /dev/null @@ -1,186 +0,0 @@ -/* $NetBSD: boot.c,v 1.3 1995/06/28 00:58:58 cgd Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * @(#)boot.c 8.1 (Berkeley) 6/10/93 - */ - -#include "stand.h" - -#include -#include - -#include - -#include "../include/coff.h" -#define KERNEL -#include "../include/pte.h" - -#include "libsa/open.c" - -#if 0 -static void aout_exec __P((int, struct exec *)); -#endif -static void coff_exec __P((int, struct exechdr *)); -static void loadfile __P((char *)); - -#if 0 -static inline int -aout_exec(fd, aout, entryp) - int fd; - struct exec *aout; - u_int64_t *entryp; -{ - size_t sz; - - /* Check the magic number. */ - if (N_GETMAGIC(*aout) != OMAGIC) - return (1); - - /* Read in text, data. */ - if (lseek(fd, (off_t)N_TXTOFF(*aout), SEEK_SET) < 0) - return (1); - sz = aout->a_text + aout->a_data; - if (read(fd, aout->a_entry, sz) != sz) - return (1); - - /* Zero out bss. */ - if (aout->a_bss != 0) - bzero(aout->a_entry + sz, aout->a_bss); - - ffp_save = aout->a_entry + aout->a_text + aout->a_data + aout->a_bss; - ffp_save = k0segtophys((ffp_save + PGOFSET & ~PGOFSET)) >> PGSHIFT; - ffp_save += 2; /* XXX OSF/1 does this, no idea why. */ - - *entryp = aout->a_entry; - return (0); -} -#endif - -static inline void -coff_exec(fd, coff) - int fd; - struct exechdr *coff; -{ - - /* Read in text. */ - (void)lseek(fd, N_COFFTXTOFF(coff->f, coff->a), 0); - if (read(fd, coff->a.text_start, coff->a.tsize) != coff->a.tsize) { -/*puts("text read failed\n");*/ - return; - } - - /* Read in data. */ - if (coff->a.dsize != 0) { - if (read(fd, - coff->a.data_start, coff->a.dsize) != coff->a.dsize) { -/*puts("data read failed\n");*/ - return; - } - } - - /* Zero out bss. */ - if (coff->a.bsize != 0) - bzero(coff->a.bss_start, coff->a.bsize); - -#if 0 - ffp_save = coff->a.text_start + coff->a.tsize; - if (ffp_save < coff->a.data_start + coff->a.dsize) - ffp_save = coff->a.data_start + coff->a.dsize; - if (ffp_save < coff->a.bss_start + coff->a.bsize) - ffp_save = coff->a.bss_start + coff->a.bsize; - ffp_save = k0segtophys((ffp_save + PGOFSET & ~PGOFSET)) >> PGSHIFT; - ffp_save += 2; /* XXX OSF/1 does this, no idea why. */ -#endif - - { - extern int diskdev; - prom_close(diskdev); - } - (*(void (*)())coff->a.entry)(); -} - -/* - * Open 'filename', read in program and return the entry point or -1 if error. - */ -static inline void -loadfile(fname) - char *fname; -{ - struct devices *dp; - union { - struct exec aout; - struct exechdr coff; - } hdr; - ssize_t nr; - int fd, rval; - - /* Open the file. */ - /* rval = 1; */ - if ((fd = open(fname, 0)) < 0) { -/*puts("open failed\n");*/ - return; - } - - /* Read the exec header. */ - if ((nr = read(fd, &hdr, sizeof(hdr))) != sizeof(hdr)) { -/*puts("header read failed\n");*/ - return; - } - -#if 0 - /* Exec a.out or COFF. */ - rval = N_COFFBADMAG(hdr.coff.a) ? - aout_exec(fd, &hdr.aout, entryp) : - coff_exec(fd, &hdr.coff, entryp); -#endif - coff_exec(fd, &hdr.coff); -/*puts("coff_exec returned\n");*/ -} - -void -main() -{ - - /* Init prom callback vector. */ - init_prom_calls(); - - /* print a banner */ -/* puts("loading /boot...\n");*/ - - loadfile("/boot"); -/* puts("couln't load /boot.\n");*/ -} diff --git a/sys/arch/alpha/stand/bootxx/disk.c b/sys/arch/alpha/stand/bootxx/disk.c deleted file mode 100644 index a7ab02f742b..00000000000 --- a/sys/arch/alpha/stand/bootxx/disk.c +++ /dev/null @@ -1,152 +0,0 @@ -/* $NetBSD: disk.c,v 1.3 1995/06/28 00:59:02 cgd Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Van Jacobson of Lawrence Berkeley Laboratory and Ralph Campbell. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * @(#)rz.c 8.1 (Berkeley) 6/10/93 - */ - - -#if 0 -/*#include "stand.h"*/ -#include -#include -#endif -#include - -#include "libsa/disklabel.c" - -struct disk_softc { - int sc_fd; /* PROM channel number */ - int sc_ctlr; /* controller number */ - int sc_unit; /* disk unit number */ - int sc_part; /* disk partition number */ - struct disklabel sc_label; /* disk label for this disk */ -}; - -int -diskstrategy(devdata, rw, bn, reqcnt, addr, cnt) - void *devdata; - int rw; - daddr_t bn; - u_int reqcnt; - char *addr; - u_int *cnt; /* out: number of bytes transfered */ -{ - struct disk_softc *sc; - struct partition *pp; - prom_return_t ret; - int s; - - /* Partial-block transfers not handled. */ - if (reqcnt & (DEV_BSIZE - 1)) { - *cnt = 0; - return (EINVAL); - } - - sc = (struct disk_softc *)devdata; - pp = &sc->sc_label.d_partitions[sc->sc_part]; - - ret.bits = prom_read(sc->sc_fd, reqcnt, addr, bn + pp->p_offset); - if (ret.u.status) - return (EIO); - *cnt = ret.u.retval; - return (0); -} - -int diskdev; - -static inline int -diskopen(f, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; -{ - struct disklabel *lp; - prom_return_t ret; - int cnt, devlen, i; - char *msg, buf[DEV_BSIZE], devname[32]; - struct disk_softc *sc; - -#if 0 - if (unit >= 8 || part >= 8) - return (ENXIO); -#endif - - /* - * XXX - * We don't know what device names look like yet, - * so we can't change them. - */ - ret.bits = prom_getenv(PROM_E_BOOTED_DEV, devname, sizeof(devname)); - devlen = ret.u.retval; - - ret.bits = prom_open(devname, devlen); - if (ret.u.status) - return (EIO); - - sc = alloc(sizeof(struct disk_softc)); - f->f_devdata = (void *)sc; - - diskdev = sc->sc_fd = ret.u.retval; -#if 0 - sc->sc_ctlr = ctlr; - sc->sc_unit = unit; - sc->sc_part = part; -#endif - - /* Try to read disk label and partition table information. */ - lp = &sc->sc_label; - lp->d_secsize = DEV_BSIZE; - lp->d_secpercyl = 1; - lp->d_npartitions = MAXPARTITIONS; - lp->d_partitions[part].p_offset = 0; - lp->d_partitions[part].p_size = 0x7fffffff; - i = diskstrategy(sc, F_READ, - (daddr_t)LABELSECTOR, DEV_BSIZE, buf, &cnt); - if (i || cnt != DEV_BSIZE) { - goto bad; - } else { - msg = getdisklabel(buf, lp); - if (msg) { - goto bad; - } - } - - if (part >= lp->d_npartitions || lp->d_partitions[part].p_size == 0) { -bad: free(sc, sizeof(struct disk_softc)); - return (ENXIO); - } - return (0); -} diff --git a/sys/arch/alpha/stand/bootxx/libsa/Makefile b/sys/arch/alpha/stand/bootxx/libsa/Makefile deleted file mode 100644 index 697e1aac980..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# $NetBSD: Makefile,v 1.2 1995/02/16 02:33:14 cgd Exp $ - -LIB= sa -#SRCS= alloc.c bzero.c close.c dev.c devopen.c disklabel.c getfile.c \ -# gets.c ioctl.c lseek.c open.c printf.c read.c strcmp.c ufs.c \ -# write.c bcopy.c filesystem.c strlen.c ntohl.c -SRCS+= alloc.c bzero.c ufs.c read.c bcopy.c lseek.c #open.c - -#.PATH: ../../../../lib/libsa ../../../../lib/libkern -#.PATH: /sys/lib/libsa /sys/lib/libkern -.PATH: /sys/lib/libkern -NOPIC=nopic -NOPROFILE=noprofile - -.include - -#CFLAGS= -mno-fp-regs -I../../../.. -I. -DCOMPAT_UFS -#CFLAGS= -O6 -mno-fp-regs -I.. -I/sys -I. -DCOMPAT_UFS -CFLAGS= -mno-fp-regs -I.. -I/sys -I. -DCOMPAT_UFS -finline-functions -O6 diff --git a/sys/arch/alpha/stand/bootxx/libsa/alloc.c b/sys/arch/alpha/stand/bootxx/libsa/alloc.c deleted file mode 100644 index a71313f9a04..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/alloc.c +++ /dev/null @@ -1,110 +0,0 @@ -/* $NetBSD: alloc.c,v 1.1 1995/02/13 23:08:35 cgd Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * The Mach Operating System project at Carnegie-Mellon University. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * @(#)alloc.c 8.1 (Berkeley) 6/11/93 - * - * - * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Author: Alessandro Forin - * - * 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 - -/* - * Dynamic memory allocator - */ -struct fl { - struct fl *next; - unsigned size; -} *freelist = (struct fl *)0; - -extern char _end[]; -static char *top = _end; - -void * -alloc(size) - unsigned size; -{ - register struct fl *f = freelist, **prev; - - prev = &freelist; - while (f && f->size < size) { - prev = &f->next; - f = f->next; - } - if (f == (struct fl *)0) { - f = (struct fl *)top; - top += ALIGN(size); - } else - *prev = f->next; - bzero(f, size); - return ((void *)f); -} - -void -free(ptr, size) - void *ptr; - unsigned size; -{ - register struct fl *f = (struct fl *)ptr; - - f->size = ALIGN(size); - f->next = freelist; - freelist = f; -} diff --git a/sys/arch/alpha/stand/bootxx/libsa/bcopy.c b/sys/arch/alpha/stand/bootxx/libsa/bcopy.c deleted file mode 100644 index 4f1f4d0b2b2..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/bcopy.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: bcopy.c,v 1.1 1995/02/13 23:08:35 cgd Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * @(#)bcopy.c 8.1 (Berkeley) 6/11/93 - */ - -#include - -/* - * This is designed to be small, not fast. - */ -void -bcopy(s1, s2, n) - const void *s1; - void *s2; - size_t n; -{ - register const char *f = s1; - register char *t = s2; - - if (f < t) { - f += n; - t += n; - while (n-- > 0) - *--t = *--f; - } else - while (n-- > 0) - *t++ = *f++; -} - -#if 0 -void * -memcpy(s1, s2, n) - void *s1; - const void *s2; - size_t n; -{ - bcopy(s2, s1, n); - return s1; -} -#endif diff --git a/sys/arch/alpha/stand/bootxx/libsa/devopen.c b/sys/arch/alpha/stand/bootxx/libsa/devopen.c deleted file mode 100644 index 321d02d0fa3..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/devopen.c +++ /dev/null @@ -1,165 +0,0 @@ -/* $NetBSD: devopen.c,v 1.2 1995/02/16 02:33:15 cgd Exp $ */ - -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * @(#)devopen.c 8.1 (Berkeley) 6/10/93 - */ - -#if 0 -#include "stand.h" -#endif - -/* - * Decode the string 'fname', open the device and return the remaining - * file name if any. - */ -static inline int -devopen(f, fname, file) - struct open_file *f; - const char *fname; - char **file; /* out */ -{ -#if 0 - register char *cp; - register char *ncp; - register struct devsw *dp; - register int c, i; - int ctlr = 0, unit = 0, part = 0; - char namebuf[20]; - int rc; - - cp = fname; - ncp = namebuf; - - /* look for a string like '5/rz0/vmunix' or '5/rz3f/vmunix */ - if ((c = *cp) >= '0' && c <= '9') { - ctlr = c - '0'; - /* skip the '/' */ - if (*++cp != '/') - return (ENXIO); - cp++; - while ((c = *cp) != '\0') { - if (c == '/') - break; - if (c >= '0' && c <= '9') { - /* read unit number */ - unit = c - '0'; - - /* look for a partition */ - if ((c = *++cp) >= 'a' && c <= 'h') { - part = c - 'a'; - c = *++cp; - } - if (c != '/') - return (ENXIO); - break; - } - if (ncp < namebuf + sizeof(namebuf) - 1) - *ncp++ = c; - cp++; - } - *ncp = '\0'; - /* - * XXX - * pulling strchr from the C library, should pull from libkern. - */ - } else if (strchr(cp, '(')) { - /* expect a string like 'rz(0,0,0)vmunix' */ - while ((c = *cp) != '\0') { - if (c == '(') { - cp++; - break; - } - if (ncp < namebuf + sizeof(namebuf) - 1) - *ncp++ = c; - cp++; - } - - /* get controller number */ - if ((c = *cp) >= '0' && c <= '9') { - ctlr = c - '0'; - c = *++cp; - } - - if (c == ',') { - /* get SCSI device number */ - if ((c = *++cp) >= '0' && c <= '9') { - unit = c - '0'; - c = *++cp; - } - - if (c == ',') { - /* get partition number */ - if ((c = *++cp) >= '0' && c <= '9') { - part = c - '0'; - c = *++cp; - } - } - } - if (c != ')') - return (ENXIO); - cp++; - *ncp = '\0'; - } else { - dp = devsw; - ctlr = unit = part = 0; - goto fnd; - } - - for (dp = devsw, i = 0; i < ndevs; dp++, i++) - if (dp->dv_name && strcmp(namebuf, dp->dv_name) == 0) - goto fnd; - printf("Unknown device '%s'\nKnown devices are:", namebuf); - for (dp = devsw, i = 0; i < ndevs; dp++, i++) - if (dp->dv_name) - printf(" %s", dp->dv_name); - printf("\n"); - return (ENXIO); - -fnd: - rc = (dp->dv_open)(f, ctlr, unit, part); - if (rc) - return (rc); - - f->f_dev = dp; - if (file && *cp != '\0') - *file = cp; - return (0); -#endif - - *file = fname; - return (diskopen(f, 0, 0,0)); -} diff --git a/sys/arch/alpha/stand/bootxx/libsa/disklabel.c b/sys/arch/alpha/stand/bootxx/libsa/disklabel.c deleted file mode 100644 index 70ee3c0ecaf..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/disklabel.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: disklabel.c,v 1.1 1995/02/13 23:08:38 cgd Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * @(#)disklabel.c 8.1 (Berkeley) 6/11/93 - */ - -#if 0 -#include -#include -#endif - -static inline char * -getdisklabel(buf, lp) - const char *buf; - struct disklabel *lp; -{ - struct disklabel *dlp, *elp; - char *msg = (char *)0; - - *lp = *(struct disklabel *)(buf + LABELOFFSET); - return (msg); -} diff --git a/sys/arch/alpha/stand/bootxx/libsa/lseek.c b/sys/arch/alpha/stand/bootxx/libsa/lseek.c deleted file mode 100644 index 445f4f03607..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/lseek.c +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: lseek.c,v 1.1 1995/02/13 23:08:39 cgd Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * The Mach Operating System project at Carnegie-Mellon University. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * @(#)lseek.c 8.1 (Berkeley) 6/11/93 - * - * - * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Author: Alessandro Forin - * - * 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 "stand.h" - -off_t -lseek(fd, offset, where) - int fd; - off_t offset; - int where; -{ - register struct open_file *f = &files[fd]; - -#if 0 - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { - return (-1); - } - - /* seek is not supported on raw devices */ - if (f->f_flags & F_RAW) { - return ((off_t)-1); - } -#endif - - return ufs_seek(f, offset, where); -} diff --git a/sys/arch/alpha/stand/bootxx/libsa/open.c b/sys/arch/alpha/stand/bootxx/libsa/open.c deleted file mode 100644 index 0af547acabe..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/open.c +++ /dev/null @@ -1,125 +0,0 @@ -/* $NetBSD: open.c,v 1.1 1995/02/13 23:08:40 cgd Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * The Mach Operating System project at Carnegie-Mellon University. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * @(#)open.c 8.1 (Berkeley) 6/11/93 - * - * - * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Author: Alessandro Forin - * - * 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. - */ - -#if 0 -#include "stand.h" -#endif - -#include "../disk.c" -#include "devopen.c" - -struct open_file files[SOPEN_MAX]; - - -/* - * File primitives proper - */ - -static inline int -open(fname, mode) - const char *fname; - int mode; -{ - register struct open_file *f; - register int fd, i, error; - char *file; - - /* find a free file descriptor */ - for (fd = 0, f = files; fd < SOPEN_MAX; fd++, f++) - if (f->f_flags == 0) - goto fnd; - return (-1); -fnd: - /* - * Try to open the device. - * Convert open mode (0,1,2) to F_READ, F_WRITE. - */ - f->f_flags = /* 0 + */ 1; - file = (char *)0; - error = devopen(f, fname, &file); -/*puts("just devopened\n");*/ - if (error) - goto err; - - /* see if we opened a raw device; otherwise, 'file' is the file name. */ - if (file == (char *)0) { - f->f_flags |= F_RAW; -/*puts("was raw, return");*/ - return (0); - } - - /* pass file name to the different filesystem open routines */ -/*puts("going to ufs_open: ");*/ -/*puts(file);*/ -/*puts("\n");*/ - error = ufs_open(file, f); - if (error == 0) - return (fd); - -err: - f->f_flags = 0; - return (-1); -} diff --git a/sys/arch/alpha/stand/bootxx/libsa/read.c b/sys/arch/alpha/stand/bootxx/libsa/read.c deleted file mode 100644 index 895b2ecdd7a..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/read.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $NetBSD: read.c,v 1.1 1995/02/13 23:08:41 cgd Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * The Mach Operating System project at Carnegie-Mellon University. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * @(#)read.c 8.1 (Berkeley) 6/11/93 - * - * - * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Author: Alessandro Forin - * - * 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 "stand.h" - -int -read(fd, dest, bcount) - int fd; - void *dest; - u_int bcount; -{ - register struct open_file *f = &files[fd]; - u_int resid; - -#if 0 - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) { - return (-1); - } -#endif - if (f->f_flags & F_RAW) { - if (diskstrategy(f->f_devdata, F_READ, - (daddr_t)0, bcount, dest, &resid)) - return (-1); - return (resid); - } - resid = bcount; - if (ufs_read(f, dest, bcount, &resid)) - return (-1); - return (bcount - resid); -} diff --git a/sys/arch/alpha/stand/bootxx/libsa/strcmp.c b/sys/arch/alpha/stand/bootxx/libsa/strcmp.c deleted file mode 100644 index 355a29134dd..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/strcmp.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: strcmp.c,v 1.1 1995/02/13 23:08:42 cgd Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef -static char *sccsid = "@(#)strcmp.c 5.5 (Berkeley) 1/26/91"; -#endif -static char *rcsid = "$NetBSD: strcmp.c,v 1.1 1995/02/13 23:08:42 cgd Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#if 0 -#include -#include -#endif - -/* - * Compare strings. - */ -static inline int -strcmp(s1, s2) - register const char *s1, *s2; -{ - while (*s1 == *s2++) - if (*s1++ == 0) - return (0); - return (*(unsigned char *)s1 - *(unsigned char *)--s2); -} diff --git a/sys/arch/alpha/stand/bootxx/libsa/strlen.c b/sys/arch/alpha/stand/bootxx/libsa/strlen.c deleted file mode 100644 index fb33e6ddac8..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/strlen.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: strlen.c,v 1.1 1995/02/13 23:08:43 cgd Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef -static char *sccsid = "@(#)strlen.c 5.5 (Berkeley) 1/26/91"; -#endif -static char *rcsid = "$NetBSD: strlen.c,v 1.1 1995/02/13 23:08:43 cgd Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#if 0 -#include -/*#include */ -#include -#endif - -static inline size_t -strlen(str) - const char *str; -{ - register const char *s; - - for (s = str; *s; ++s); - return(s - str); -} - diff --git a/sys/arch/alpha/stand/bootxx/libsa/ufs.c b/sys/arch/alpha/stand/bootxx/libsa/ufs.c deleted file mode 100644 index e8b4bb60c8a..00000000000 --- a/sys/arch/alpha/stand/bootxx/libsa/ufs.c +++ /dev/null @@ -1,690 +0,0 @@ -/* $NetBSD: ufs.c,v 1.1 1995/02/13 23:08:44 cgd Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * The Mach Operating System project at Carnegie-Mellon University. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * - * Copyright (c) 1990, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Author: David Golub - * - * 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. - */ - -/* - * Stand-alone file reading package. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "stand.h" - -#include "strcmp.c" -#include "strlen.c" - -/* - * In-core open file. - */ -struct file { - off_t f_seekp; /* seek pointer */ - struct fs *f_fs; /* pointer to super-block */ - struct dinode f_di; /* copy of on-disk inode */ - int f_nindir[NIADDR]; - /* number of blocks mapped by - indirect block at level i */ - char *f_blk[NIADDR]; /* buffer for indirect block at - level i */ - u_int f_blksize[NIADDR]; - /* size of buffer */ - daddr_t f_blkno[NIADDR];/* disk address of block in buffer */ - char *f_buf; /* buffer for data block */ - u_int f_buf_size; /* size of data block */ - daddr_t f_buf_blkno; /* block number of data block */ -}; - -#ifdef COMPAT_UFS -/* - * Sanity checks for old file systems. - * - * XXX - goes away some day. - */ -static inline void -ffs_oldfscompat(fs) - struct fs *fs; -{ - int i; - - fs->fs_npsect = max(fs->fs_npsect, fs->fs_nsect); /* XXX */ - fs->fs_interleave = max(fs->fs_interleave, 1); /* XXX */ - if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */ - fs->fs_nrpos = 8; /* XXX */ - if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ - quad_t sizepb = fs->fs_bsize; /* XXX */ - /* XXX */ - fs->fs_maxfilesize = fs->fs_bsize * NDADDR - 1; /* XXX */ - for (i = 0; i < NIADDR; i++) { /* XXX */ - sizepb *= NINDIR(fs); /* XXX */ - fs->fs_maxfilesize += sizepb; /* XXX */ - } /* XXX */ - fs->fs_qbmask = ~fs->fs_bmask; /* XXX */ - fs->fs_qfmask = ~fs->fs_fmask; /* XXX */ - } /* XXX */ -} -#endif - -/* - * Read a new inode into a file structure. - */ -static int -read_inode(inumber, f) - ino_t inumber; - struct open_file *f; -{ - register struct file *fp = (struct file *)f->f_fsdata; - register struct fs *fs = fp->f_fs; - char *buf; - u_int rsize; - int rc; - - /* - * Read inode and save it. - */ - buf = alloc(fs->fs_bsize); - rc = diskstrategy(f->f_devdata, F_READ, - fsbtodb(fs, ino_to_fsba(fs, inumber)), fs->fs_bsize, buf, &rsize); - if (rc || rsize != fs->fs_bsize) - goto out; - - { - register struct dinode *dp; - - dp = (struct dinode *)buf; - fp->f_di = dp[ino_to_fsbo(fs, inumber)]; - } - - /* - * Clear out the old buffers - */ - { - register int level; - - for (level = 0; level < NIADDR; level++) - fp->f_blkno[level] = -1; - fp->f_buf_blkno = -1; - } -out: - free(buf, fs->fs_bsize); - return (0); -} - -/* - * Given an offset in a file, find the disk block number that - * contains that block. - */ -static int -block_map(f, file_block, disk_block_p) - struct open_file *f; - daddr_t file_block; - daddr_t *disk_block_p; /* out */ -{ - register struct file *fp = (struct file *)f->f_fsdata; - register struct fs *fs = fp->f_fs; - int level; - int idx; - daddr_t ind_block_num; - daddr_t *ind_p; - int rc; - - /* - * Index structure of an inode: - * - * di_db[0..NDADDR-1] hold block numbers for blocks - * 0..NDADDR-1 - * - * di_ib[0] index block 0 is the single indirect block - * holds block numbers for blocks - * NDADDR .. NDADDR + NINDIR(fs)-1 - * - * di_ib[1] index block 1 is the double indirect block - * holds block numbers for INDEX blocks for blocks - * NDADDR + NINDIR(fs) .. - * NDADDR + NINDIR(fs) + NINDIR(fs)**2 - 1 - * - * di_ib[2] index block 2 is the triple indirect block - * holds block numbers for double-indirect - * blocks for blocks - * NDADDR + NINDIR(fs) + NINDIR(fs)**2 .. - * NDADDR + NINDIR(fs) + NINDIR(fs)**2 - * + NINDIR(fs)**3 - 1 - */ - - if (file_block < NDADDR) { - /* Direct block. */ - *disk_block_p = fp->f_di.di_db[file_block]; - return (0); - } - - file_block -= NDADDR; - - /* - * nindir[0] = NINDIR - * nindir[1] = NINDIR**2 - * nindir[2] = NINDIR**3 - * etc - */ - for (level = 0; level < NIADDR; level++) { - if (file_block < fp->f_nindir[level]) - break; - file_block -= fp->f_nindir[level]; - } - if (level == NIADDR) { - /* Block number too high */ - return (EFBIG); - } - - ind_block_num = fp->f_di.di_ib[level]; - - for (; level >= 0; level--) { - if (ind_block_num == 0) { - *disk_block_p = 0; /* missing */ - return (0); - } - - if (fp->f_blkno[level] != ind_block_num) { - if (fp->f_blk[level] == (char *)0) - fp->f_blk[level] = - alloc(fs->fs_bsize); - rc = diskstrategy(f->f_devdata, F_READ, - fsbtodb(fp->f_fs, ind_block_num), - fs->fs_bsize, - fp->f_blk[level], - (u_int *)&fp->f_blksize[level]); - if (rc) - return (rc); - if (fp->f_blksize[level] != fs->fs_bsize) - return (EIO); - fp->f_blkno[level] = ind_block_num; - } - - ind_p = (daddr_t *)fp->f_blk[level]; - - if (level > 0) { - idx = file_block / fp->f_nindir[level - 1]; - file_block %= fp->f_nindir[level - 1]; - } else - idx = file_block; - - ind_block_num = ind_p[idx]; - } - - *disk_block_p = ind_block_num; - - return (0); -} - -/* - * Read a portion of a file into an internal buffer. Return - * the location in the buffer and the amount in the buffer. - */ -static int -buf_read_file(f, buf_p, size_p) - struct open_file *f; - char **buf_p; /* out */ - u_int *size_p; /* out */ -{ - register struct file *fp = (struct file *)f->f_fsdata; - register struct fs *fs = fp->f_fs; - long off; - register daddr_t file_block; - daddr_t disk_block; - long block_size; - int rc; - - off = blkoff(fs, fp->f_seekp); - file_block = lblkno(fs, fp->f_seekp); - block_size = dblksize(fs, &fp->f_di, file_block); - - if (file_block != fp->f_buf_blkno) { - rc = block_map(f, file_block, &disk_block); - if (rc) - return (rc); - - if (fp->f_buf == (char *)0) - fp->f_buf = alloc(fs->fs_bsize); - - if (disk_block == 0) { - bzero(fp->f_buf, block_size); - fp->f_buf_size = block_size; - } else { - rc = diskstrategy(f->f_devdata, F_READ, - fsbtodb(fs, disk_block), - block_size, fp->f_buf, &fp->f_buf_size); - if (rc) - return (rc); - } - - fp->f_buf_blkno = file_block; - } - - /* - * Return address of byte in buffer corresponding to - * offset, and size of remainder of buffer after that - * byte. - */ - *buf_p = fp->f_buf + off; - *size_p = block_size - off; - - /* - * But truncate buffer at end of file. - */ - if (*size_p > fp->f_di.di_size - fp->f_seekp) - *size_p = fp->f_di.di_size - fp->f_seekp; - - return (0); -} - -/* - * Search a directory for a name and return its - * i_number. - */ -static inline int -search_directory(name, f, inumber_p) - char *name; - struct open_file *f; - ino_t *inumber_p; /* out */ -{ - register struct file *fp = (struct file *)f->f_fsdata; - register struct direct *dp; - struct direct *edp; - char *buf; - u_int buf_size; - int namlen, length; - int rc; - - length = strlen(name); - - fp->f_seekp = 0; - while (fp->f_seekp < fp->f_di.di_size) { - rc = buf_read_file(f, &buf, &buf_size); - if (rc) - return (rc); - - dp = (struct direct *)buf; - edp = (struct direct *)(buf + buf_size); - while (dp < edp) { - if (dp->d_ino == (ino_t)0) - goto next; -#if BYTE_ORDER == LITTLE_ENDIAN - if (fp->f_fs->fs_maxsymlinklen <= 0) - namlen = dp->d_type; - else -#endif - namlen = dp->d_namlen; - if (namlen == length && - !strcmp(name, dp->d_name)) { - /* found entry */ - *inumber_p = dp->d_ino; - return (0); - } - next: - dp = (struct direct *)((char *)dp + dp->d_reclen); - } - fp->f_seekp += buf_size; - } - return (ENOENT); -} - -/* - * Open a file. - */ -int -ufs_open(path, f) - char *path; - struct open_file *f; -{ - register char *cp, *ncp; - register int c; - ino_t inumber, parent_inumber; - struct file *fp; - struct fs *fs; - int rc; - u_int buf_size; -#if 0 - int nlinks = 0; - char namebuf[MAXPATHLEN+1]; -#endif - - /* allocate file system specific data structure */ - fp = alloc(sizeof(struct file)); - f->f_fsdata = (void *)fp; - - /* allocate space and read super block */ - fs = alloc(SBSIZE); - fp->f_fs = fs; - rc = diskstrategy(f->f_devdata, F_READ, - SBLOCK, SBSIZE, (char *)fs, &buf_size); - if (rc) - goto out; - - if (buf_size != SBSIZE || fs->fs_magic != FS_MAGIC || - fs->fs_bsize > MAXBSIZE || fs->fs_bsize < sizeof(struct fs)) { - rc = EINVAL; - goto out; - } -#ifdef COMPAT_UFS - ffs_oldfscompat(fs); -#endif - - /* - * Calculate indirect block levels. - */ - { - register int mult; - register int level; - - mult = 1; - for (level = 0; level < NIADDR; level++) { - mult *= NINDIR(fs); - fp->f_nindir[level] = mult; - } - } - - inumber = ROOTINO; - if ((rc = read_inode(inumber, f)) != 0) - goto out; - - cp = path; - while (*cp) { - - /* - * Remove extra separators - */ - while (*cp == '/') - cp++; - if (*cp == '\0') - break; - - /* - * Check that current node is a directory. - */ - if ((fp->f_di.di_mode & IFMT) != IFDIR) { - rc = ENOTDIR; - goto out; - } - - /* - * Get next component of path name. - */ - { - register int len = 0; - - ncp = cp; - while ((c = *cp) != '\0' && c != '/') { - if (++len > MAXNAMLEN) { - rc = ENOENT; - goto out; - } - cp++; - } - *cp = '\0'; - } - - /* - * Look up component in current directory. - * Save directory inumber in case we find a - * symbolic link. - */ - parent_inumber = inumber; - rc = search_directory(ncp, f, &inumber); - *cp = c; - if (rc) - goto out; - - /* - * Open next component. - */ - if ((rc = read_inode(inumber, f)) != 0) - goto out; - -#if 0 - /* - * Check for symbolic link. - */ - if ((fp->i_mode & IFMT) == IFLNK) { - int link_len = fp->f_di.di_size; - int len; - - len = strlen(cp) + 1; - - if (fp->f_di.di_size >= MAXPATHLEN - 1 || - ++nlinks > MAXSYMLINKS) { - rc = ENOENT; - goto out; - } - - strcpy(&namebuf[link_len], cp); - - if ((fp->i_flags & IC_FASTLINK) != 0) { - bcopy(fp->i_symlink, namebuf, (unsigned) link_len); - } else { - /* - * Read file for symbolic link - */ - char *buf; - u_int buf_size; - daddr_t disk_block; - register struct fs *fs = fp->f_fs; - - (void) block_map(f, (daddr_t)0, &disk_block); - rc = device_read(&fp->f_dev, - fsbtodb(fs, disk_block), - blksize(fs, fp, 0), - &buf, &buf_size); - if (rc) - goto out; - - bcopy((char *)buf, namebuf, (unsigned)link_len); - free(buf, buf_size); - } - - /* - * If relative pathname, restart at parent directory. - * If absolute pathname, restart at root. - */ - cp = namebuf; - if (*cp != '/') - inumber = parent_inumber; - else - inumber = (ino_t)ROOTINO; - - if ((rc = read_inode(inumber, fp)) != 0) - goto out; - } -#endif - } - - /* - * Found terminal component. - */ - rc = 0; -out: - if (rc) - free(fp, sizeof(struct file)); - return (rc); -} - -int -ufs_close(f) - struct open_file *f; -{ - register struct file *fp = (struct file *)f->f_fsdata; - int level; - - f->f_fsdata = (void *)0; - if (fp == (struct file *)0) - return (0); - - for (level = 0; level < NIADDR; level++) { - if (fp->f_blk[level]) - free(fp->f_blk[level], fp->f_fs->fs_bsize); - } - if (fp->f_buf) - free(fp->f_buf, fp->f_fs->fs_bsize); - free(fp->f_fs, SBSIZE); - free(fp, sizeof(struct file)); - return (0); -} - -/* - * Copy a portion of a file into kernel memory. - * Cross block boundaries when necessary. - */ -int -ufs_read(f, start, size, resid) - struct open_file *f; - char *start; - u_int size; - u_int *resid; /* out */ -{ - register struct file *fp = (struct file *)f->f_fsdata; - register u_int csize; - char *buf; - u_int buf_size; - int rc = 0; - - while (size != 0) { - if (fp->f_seekp >= fp->f_di.di_size) - break; - - rc = buf_read_file(f, &buf, &buf_size); - if (rc) - break; - - csize = size; - if (csize > buf_size) - csize = buf_size; - - bcopy(buf, start, csize); - - fp->f_seekp += csize; - start += csize; - size -= csize; - } - if (resid) - *resid = size; - return (rc); -} - -#if 0 -/* - * Not implemented. - */ -int -ufs_write(f, start, size, resid) - struct open_file *f; - char *start; - u_int size; - u_int *resid; /* out */ -{ - - return (EROFS); -} -#endif - -off_t -ufs_seek(f, offset, where) - struct open_file *f; - off_t offset; - int where; -{ - register struct file *fp = (struct file *)f->f_fsdata; - - switch (where) { - case SEEK_SET: - fp->f_seekp = offset; - break; - case SEEK_CUR: - fp->f_seekp += offset; - break; - case SEEK_END: - fp->f_seekp = fp->f_di.di_size - offset; - break; - default: - return (-1); - } - return (fp->f_seekp); -} - -#if 0 -int -ufs_stat(f, sb) - struct open_file *f; - struct stat *sb; -{ - register struct file *fp = (struct file *)f->f_fsdata; - - /* only important stuff */ - sb->st_mode = fp->f_di.di_mode; - sb->st_uid = fp->f_di.di_uid; - sb->st_gid = fp->f_di.di_gid; - sb->st_size = fp->f_di.di_size; - return (0); -} -#endif diff --git a/sys/arch/alpha/stand/bootxx/stand.h b/sys/arch/alpha/stand/bootxx/stand.h deleted file mode 100644 index 66f93ebcad2..00000000000 --- a/sys/arch/alpha/stand/bootxx/stand.h +++ /dev/null @@ -1,98 +0,0 @@ -/* $NetBSD: stand.h,v 1.1 1995/02/13 23:08:31 cgd Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. - * - * @(#)stand.h 8.1 (Berkeley) 6/11/93 - */ - -#include -#include -#include -#include -#include - -#ifndef NULL -#define NULL 0 -#endif - -/* where values for lseek(2) */ -#define SEEK_SET 0 /* set file offset to offset */ -#define SEEK_CUR 1 /* set file offset to current plus offset */ -#define SEEK_END 2 /* set file offset to EOF plus offset */ - -struct open_file { - int f_flags; /* see F_* below */ - void *f_devdata; /* device specific data */ - void *f_fsdata; /* file system specific data */ -}; - -#define SOPEN_MAX 2 -extern struct open_file files[SOPEN_MAX]; -extern int nfsys; - -/* f_flags values */ -#define F_READ 0x0001 /* file opened for reading */ -#define F_WRITE 0x0002 /* file opened for writing */ -#define F_RAW 0x0004 /* raw device open - no file system */ -#define F_NODEV 0x0008 /* network open - no device */ - -#define isupper(c) ((c) >= 'A' && (c) <= 'Z') -#define tolower(c) ((c) - 'A' + 'a') -#define isspace(c) ((c) == ' ' || (c) == '\t') -#define isdigit(c) ((c) >= '0' && (c) <= '9') - -int devopen __P((struct open_file *f, const char *fname, char **file)); -void *alloc __P((unsigned size)); -void free __P((void *ptr, unsigned size)); -struct disklabel; -char *getdisklabel __P((const char *buf, struct disklabel *lp)); - -void printf __P((const char *, ...)); -void gets __P((char *)); -__dead void panic __P((const char *, ...)) - __attribute__((noreturn)); -int getchar __P((void)); -int exec __P((char *, char *, int)); -int open __P((const char *,int)); -int close __P((int)); -int read __P((int, void *, u_int)); -int write __P((int, void *, u_int)); - -int nodev(), noioctl(); -void nullsys(); - -/* Machine dependent functions */ -void machdep_start __P((char *, int, char *, char *, char *)); -int machdep_exec __P((char *, char *, int)); -int getchar __P((void)); -void putchar __P((int)); diff --git a/sys/arch/alpha/stand/bootxx/start.S b/sys/arch/alpha/stand/bootxx/start.S deleted file mode 100644 index d694bc84374..00000000000 --- a/sys/arch/alpha/stand/bootxx/start.S +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: start.S,v 1.2 1995/02/16 02:33:13 cgd Exp $ */ - -/* - * Mach Operating System - * Copyright (c) 1992 Carnegie Mellon University - * All Rights Reserved. - * - * 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 Mellon - * the rights to redistribute these changes. - */ - -#include "../include/asm.h" - -/* - * start -- - * Entry point for boot/standalone programs. - * - * Arguments: - * a0 long (first free physical page) - * - * This is where the prom comes to. Leaves all exception and interrupts - * to prom, runs off prom's stack too. No return values. - */ - .text - .set noreorder /* don't reorder instructions */ - -#define ENTRY_FRAME 32 - -NESTED(start, 1, ENTRY_FRAME, ra, 0, 0) - br pv,1f /* XXX I have no idea what this does. */ -1: SETGP(pv) - -#if 0 - lda sp,start /* start stack below text */ - lda sp,-ENTRY_FRAME(sp) -#endif - lda a0,_EDATA - lda a1,_end - subq a1,a0,a1 - CALL(bzero) - - CALL(main) /* transfer to C */ - - call_pal PAL_halt /* halt if we ever return */ -END(start) - -/* - * Dummy routine for GCC2. - */ -LEAF(__main,0) - RET -END(__main) diff --git a/sys/arch/alpha/stand/bootxx/headersize.c b/sys/arch/alpha/stand/headersize.c similarity index 93% rename from sys/arch/alpha/stand/bootxx/headersize.c rename to sys/arch/alpha/stand/headersize.c index 11f8a963678..f586ff2d734 100644 --- a/sys/arch/alpha/stand/bootxx/headersize.c +++ b/sys/arch/alpha/stand/headersize.c @@ -1,4 +1,4 @@ -/* $NetBSD: headersize.c,v 1.2 1995/02/16 02:33:10 cgd Exp $ */ +/* $NetBSD: headersize.c,v 1.1 1995/11/23 02:38:59 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -31,7 +31,7 @@ #include #include -#define HDR_BUFSIZE 8192 +#define HDR_BUFSIZE 512 main() { diff --git a/sys/arch/alpha/stand/installboot.c b/sys/arch/alpha/stand/installboot.c new file mode 100644 index 00000000000..b0eb593395e --- /dev/null +++ b/sys/arch/alpha/stand/installboot.c @@ -0,0 +1,389 @@ +/* $NetBSD: installboot.c,v 1.1 1995/11/23 02:39:02 cgd Exp $ */ + +/* + * Copyright (c) 1994 Paul Kranenburg + * All rights reserved. + * + * 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 Paul Kranenburg. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bbinfo.h" + +int verbose, nowrite, hflag; +char *boot, *proto, *dev; + +struct bbinfoloc *bbinfolocp; +struct bbinfo *bbinfop; +int max_block_count; + + +char *loadprotoblocks __P((char *, long *)); +int loadblocknums __P((char *, int)); +static void devread __P((int, void *, daddr_t, size_t, char *)); +static void usage __P((void)); +int main __P((int, char *[])); + + +static void +usage() +{ + fprintf(stderr, + "usage: installboot [-n] [-v] \n"); + exit(1); +} + +int +main(argc, argv) + int argc; + char *argv[]; +{ + int c; + int devfd; + char *protostore; + long protosize; + int mib[2]; + size_t size; + + while ((c = getopt(argc, argv, "vn")) != EOF) { + switch (c) { + case 'n': + /* Do not actually write the bootblock to disk */ + nowrite = 1; + break; + case 'v': + /* Chat */ + verbose = 1; + break; + default: + usage(); + } + } + + if (argc - optind < 3) { + usage(); + } + + boot = argv[optind]; + proto = argv[optind + 1]; + dev = argv[optind + 2]; + + if (verbose) { + printf("boot: %s\n", boot); + printf("proto: %s\n", proto); + printf("device: %s\n", dev); + } + + /* Load proto blocks into core */ + if ((protostore = loadprotoblocks(proto, &protosize)) == NULL) + exit(1); + + /* Open and check raw disk device */ + if ((devfd = open(dev, O_RDONLY, 0)) < 0) + err(1, "open: %s", dev); + + /* Extract and load block numbers */ + if (loadblocknums(boot, devfd) != 0) + exit(1); + + (void)close(devfd); + + if (nowrite) + return 0; + +#if 0 + /* Write patched proto bootblocks into the superblock */ + if (protosize > SBSIZE - DEV_BSIZE) + errx(1, "proto bootblocks too big"); +#endif + + if ((devfd = open(dev, O_RDWR, 0)) < 0) + err(1, "open: %s", dev); + + if (lseek(devfd, DEV_BSIZE, SEEK_SET) != DEV_BSIZE) + err(1, "lseek bootstrap"); + + /* Sync filesystems (to clean in-memory superblock?) */ + sync(); + sleep(3); + + if (write(devfd, protostore, protosize) != protosize) + err(1, "write bootstrap"); + + { + +#define BBPAD 0x1e0 + struct bb { + char bb_pad[BBPAD]; /* disklabel lives in here, actually */ + long bb_secsize; /* size of secondary boot block */ + long bb_secstart; /* start of secondary boot block */ + long bb_flags; /* unknown; always zero */ + long bb_cksum; /* checksum of the the boot block, as longs. */ + } bb; + long *lp, *ep; + + if (lseek(devfd, 0, SEEK_SET) != 0) + err(1, "lseek label"); + + if (read(devfd, &bb, sizeof (bb)) != sizeof (bb)) + err(1, "read label"); + + bb.bb_secsize = 15; + bb.bb_secstart = 1; + bb.bb_flags = 0; + bb.bb_cksum = 0; + + for (lp = (long *)&bb, ep = &bb.bb_cksum; lp < ep; lp++) + bb.bb_cksum += *lp; + + if (lseek(devfd, 0, SEEK_SET) != 0) + err(1, "lseek label 2"); + + if (write(devfd, &bb, sizeof bb) != sizeof bb) + err(1, "write label "); + } + + (void)close(devfd); + return 0; +} + +char * +loadprotoblocks(fname, size) + char *fname; + long *size; +{ + int fd, sz; + char *bp; + struct stat statbuf; + struct exec *hp; + long off; + u_int64_t *matchp; + + /* + * Read the prototype boot block into memory. + */ + if ((fd = open(fname, O_RDONLY)) < 0) { + warn("open: %s", fname); + return NULL; + } + if (fstat(fd, &statbuf) != 0) { + warn("fstat: %s", fname); + close(fd); + return NULL; + } + sz = roundup(statbuf.st_size, DEV_BSIZE); + if ((bp = calloc(sz, 1)) == NULL) { + warnx("malloc: %s: no memory", fname); + close(fd); + return NULL; + } + if (read(fd, bp, statbuf.st_size) != statbuf.st_size) { + warn("read: %s", fname); + free(bp); + close(fd); + return NULL; + } + close(fd); + + /* + * Find the magic area of the program, and figure out where + * the 'blocks' struct is, from that. + */ + bbinfolocp = NULL; + for (matchp = (u_int64_t *)bp; (char *)matchp < bp + sz; matchp++) { + if (*matchp != 0xbabefacedeadbeef) + continue; + bbinfolocp = (struct bbinfoloc *)matchp; + if (bbinfolocp->magic1 == 0xbabefacedeadbeef && + bbinfolocp->magic2 == 0xdeadbeeffacebabe) + break; + bbinfolocp = NULL; + } + + if (bbinfolocp == NULL) { + warnx("%s: not a valid boot block?", fname); + return NULL; + } + + bbinfop = (struct bbinfo *)(bp + bbinfolocp->end - bbinfolocp->start); + memset(bbinfop, 0, sz - (bbinfolocp->end - bbinfolocp->start)); + max_block_count = + ((char *)bbinfop->blocks - bp) / sizeof (bbinfop->blocks[0]); + + if (verbose) { + printf("boot block info locator at offset 0x%x\n", + (char *)bbinfolocp - bp); + printf("boot block info at offset 0x%x\n", + (char *)bbinfop - bp); + printf("max number of blocks: %d\n", max_block_count); + } + + *size = sz; + return (bp); +} + +static void +devread(fd, buf, blk, size, msg) + int fd; + void *buf; + daddr_t blk; + size_t size; + char *msg; +{ + if (lseek(fd, dbtob(blk), SEEK_SET) != dbtob(blk)) + err(1, "%s: devread: lseek", msg); + + if (read(fd, buf, size) != size) + err(1, "%s: devread: read", msg); +} + +static char sblock[SBSIZE]; + +int +loadblocknums(boot, devfd) +char *boot; +int devfd; +{ + int i, fd; + struct stat statbuf; + struct statfs statfsbuf; + struct fs *fs; + char *buf; + daddr_t blk, *ap; + struct dinode *ip; + int ndb; + int32_t cksum; + + /* + * Open 2nd-level boot program and record the block numbers + * it occupies on the filesystem represented by `devfd'. + */ + if ((fd = open(boot, O_RDONLY)) < 0) + err(1, "open: %s", boot); + + if (fstatfs(fd, &statfsbuf) != 0) + err(1, "statfs: %s", boot); + + if (strncmp(statfsbuf.f_fstypename, "ufs", MFSNAMELEN)) + errx(1, "%s: must be on a UFS filesystem", boot); + + if (fsync(fd) != 0) + err(1, "fsync: %s", boot); + + if (fstat(fd, &statbuf) != 0) + err(1, "fstat: %s", boot); + + close(fd); + + /* Read superblock */ + devread(devfd, sblock, btodb(SBOFF), SBSIZE, "superblock"); + fs = (struct fs *)sblock; + + /* Read inode */ + if ((buf = malloc(fs->fs_bsize)) == NULL) + errx(1, "No memory for filesystem block"); + + blk = fsbtodb(fs, ino_to_fsba(fs, statbuf.st_ino)); + devread(devfd, buf, blk, fs->fs_bsize, "inode"); + ip = (struct dinode *)(buf) + ino_to_fsbo(fs, statbuf.st_ino); + + /* + * Register filesystem block size. + */ + bbinfop->bsize = fs->fs_bsize; + + /* + * Get the block numbers; we don't handle fragments + */ + ndb = howmany(ip->di_size, fs->fs_bsize); + if (ndb > max_block_count) + errx(1, "%s: Too many blocks", boot); + + /* + * Register block count. + */ + bbinfop->nblocks = ndb; + + if (verbose) + printf("%s: block numbers: ", boot); + ap = ip->di_db; + for (i = 0; i < NDADDR && *ap && ndb; i++, ap++, ndb--) { + blk = fsbtodb(fs, *ap); + bbinfop->blocks[i] = blk; + if (verbose) + printf("%d ", blk); + } + if (verbose) + printf("\n"); + + if (ndb == 0) + goto checksum; + + /* + * Just one level of indirections; there isn't much room + * for more in the 1st-level bootblocks anyway. + */ + if (verbose) + printf("%s: block numbers (indirect): ", boot); + blk = ip->di_ib[0]; + devread(devfd, buf, blk, fs->fs_bsize, "indirect block"); + ap = (daddr_t *)buf; + for (; i < NINDIR(fs) && *ap && ndb; i++, ap++, ndb--) { + blk = fsbtodb(fs, *ap); + bbinfop->blocks[i] = blk; + if (verbose) + printf("%d ", blk); + } + if (verbose) + printf("\n"); + + if (ndb) + errx(1, "%s: Too many blocks", boot); + +checksum: + cksum = 0; + for (i = 0; i < bbinfop->nblocks + + (sizeof (*bbinfop) / sizeof (bbinfop->blocks[0])) - 1; i++) { + cksum += ((int32_t *)bbinfop)[i]; + } + bbinfop->cksum = -cksum; + + return 0; +} diff --git a/sys/arch/alpha/stand/bootxx/prom.c b/sys/arch/alpha/stand/prom.c similarity index 90% rename from sys/arch/alpha/stand/bootxx/prom.c rename to sys/arch/alpha/stand/prom.c index 5038ef2321f..262f5f3828e 100644 --- a/sys/arch/alpha/stand/bootxx/prom.c +++ b/sys/arch/alpha/stand/prom.c @@ -1,4 +1,4 @@ -/* $NetBSD: prom.c,v 1.3 1995/06/28 00:59:04 cgd Exp $ */ +/* $NetBSD: prom.c,v 1.1 1995/11/23 02:39:07 cgd Exp $ */ /* * Mach Operating System @@ -31,11 +31,7 @@ #include #include -#define PUTS 0 - -#if PUTS int console; -#endif void init_prom_calls() @@ -51,18 +47,28 @@ init_prom_calls() prom_dispatch_v.routine_arg = c->crb_v_dispatch; prom_dispatch_v.routine = c->crb_v_dispatch->code; -#if PUTS /* Look for console tty. */ prom_getenv(PROM_E_TTY_DEV, buf, 4); console = buf[0] - '0'; -#endif } -#if PUTS -static inline void +int +getchar() +{ + prom_return_t ret; + + for (;;) { + ret.bits = prom_dispatch(PROM_R_GETC, console); + if (ret.u.status == 0 || ret.u.status == 1) + return (ret.u.retval); + } +} + +void putchar(c) int c; { + prom_return_t ret; char cbuf; if (c == '\r' || c == '\n') { @@ -79,15 +85,6 @@ putchar(c) } while ((ret.u.retval & 1) == 0); } -void -puts(s) - char *s; -{ - while (*s) - putchar(*s++); -} -#endif - int prom_getenv(id, buf, len) int id, len; diff --git a/sys/arch/alpha/stand/bootxx/prom_disp.S b/sys/arch/alpha/stand/prom_disp.S similarity index 94% rename from sys/arch/alpha/stand/bootxx/prom_disp.S rename to sys/arch/alpha/stand/prom_disp.S index b0ff78df367..aed575a0d98 100644 --- a/sys/arch/alpha/stand/bootxx/prom_disp.S +++ b/sys/arch/alpha/stand/prom_disp.S @@ -1,4 +1,4 @@ -/* $NetBSD: prom_disp.S,v 1.2 1995/02/16 02:33:12 cgd Exp $ */ +/* $NetBSD: prom_disp.S,v 1.1 1995/11/23 02:39:10 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -28,9 +28,9 @@ */ #ifndef LOCORE -#include "../include/asm.h" -#include "../include/prom.h" -#include "../include/rpb.h" +#include "include/asm.h" +#include "include/prom.h" +#include "include/rpb.h" #endif .globl prom_dispatch_v @@ -55,8 +55,6 @@ #define DISPATCH_REGS IM_RA|IM_S0|IM_S1|IM_S2|IM_S3|IM_S4|IM_S5|IM_S6 NESTED(prom_dispatch, 5, DISPATCH_FRAME_SIZE, ra, DISPATCH_REGS, 0) - -/* ldgp gp, 0(pv)*/ SETGP(pv) lda sp, -DISPATCH_FRAME_SIZE(sp) diff --git a/sys/arch/alpha/stand/puts.c b/sys/arch/alpha/stand/puts.c new file mode 100644 index 00000000000..b3c2d9479a2 --- /dev/null +++ b/sys/arch/alpha/stand/puts.c @@ -0,0 +1,9 @@ + +void +puts(s) + char *s; +{ + + while (*s) + putchar(*s++); +} diff --git a/sys/arch/alpha/stand/boot/start.S b/sys/arch/alpha/stand/start.S similarity index 89% rename from sys/arch/alpha/stand/boot/start.S rename to sys/arch/alpha/stand/start.S index fe7b93a23dc..8d8001ffbdd 100644 --- a/sys/arch/alpha/stand/boot/start.S +++ b/sys/arch/alpha/stand/start.S @@ -1,4 +1,4 @@ -/* $NetBSD: start.S,v 1.2 1995/02/16 02:32:59 cgd Exp $ */ +/* $NetBSD: start.S,v 1.1 1995/11/23 02:39:15 cgd Exp $ */ /* * Mach Operating System @@ -26,7 +26,7 @@ * the rights to redistribute these changes. */ -#include "../../include/asm.h" +#include "include/asm.h" /* * start -- @@ -44,14 +44,22 @@ #define ENTRY_FRAME 32 NESTED(start, 1, ENTRY_FRAME, ra, 0, 0) - br pv,1f /* XXX I have no idea what this does. */ + br pv,1f 1: SETGP(pv) +#ifndef PRIMARY_BOOTBLOCK lda sp,start /* start stack below text */ lda sp,-ENTRY_FRAME(sp) +#endif + + lda a0,_EDATA + lda a1,_end + subq a1,a0,a1 + CALL(bzero) CALL(main) /* transfer to C */ +XLEAF(halt, 0) call_pal PAL_halt /* halt if we ever return */ END(start) @@ -70,12 +78,3 @@ LEAF(cpu_number, 0) call_pal PAL_VMS_mfpr_whami RET END(cpu_number) - -/* - * halt - * Halt - */ -LEAF(halt, 0) - call_pal PAL_halt - RET -END(halt) diff --git a/sys/arch/alpha/stand/xxboot/Makefile b/sys/arch/alpha/stand/xxboot/Makefile deleted file mode 100644 index 49c94548730..00000000000 --- a/sys/arch/alpha/stand/xxboot/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# $NetBSD: Makefile,v 1.1 1995/02/13 23:08:46 cgd Exp $ - -all: xxboot - -xxboot: makexxboot - /bin/rm -f xxboot - ./makexxboot > xxboot - -clean cleandir: - /bin/rm -f xxboot makexxboot - -install: - install -c -o bin -g bin -m 444 xxboot ${DESTDIR}/usr/mdec/sdboot diff --git a/sys/arch/alpha/tc/if_le.c b/sys/arch/alpha/tc/if_le.c index 8bcd86157ff..d7c47ff0514 100644 --- a/sys/arch/alpha/tc/if_le.c +++ b/sys/arch/alpha/tc/if_le.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_le.c,v 1.7 1995/08/03 00:52:13 cgd Exp $ */ +/* $NetBSD: if_le.c,v 1.9 1995/11/25 01:31:09 cgd Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -62,10 +62,11 @@ #include #include #include +#define LE_NEED_BUF_CONTIG +#define LE_NEED_BUF_GAP2 +#define LE_NEED_BUF_GAP16 #include -#define SPARSE - /* access LANCE registers */ void lewritereg(); #define LERDWR(cntl, src, dst) { (dst) = (src); wbflush(); } @@ -88,12 +89,6 @@ struct cfdriver lecd = { NULL, "le", lematch, leattach, DV_IFNET, sizeof (struct le_softc) }; -void copytobuf_gap16 __P((struct le_softc *, void *, int, int)); -void copyfrombuf_gap16 __P((struct le_softc *, void *, int, int)); -void zerobuf_gap16 __P((struct le_softc *, int, int)); -void copytobuf_gap2 __P((struct le_softc *, void *, int, int)); -void copyfrombuf_gap2 __P((struct le_softc *, void *, int, int)); - integrate void lewrcsr(sc, port, val) struct le_softc *sc; @@ -172,9 +167,7 @@ leattach(parent, self, aux) volatile u_int *ldp; sc->sc_r1 = (struct lereg1 *)BUS_CVTADDR(ca); -#ifdef SPARSE sc->sc_r1 = TC_DENSE_TO_SPARSE(sc->sc_r1); -#endif sc->sc_mem = (void *)le_iomem; /* XXX */ cp = (u_char *)ASIC_SYS_ETHER_ADDRESS(asic_base); @@ -201,8 +194,8 @@ leattach(parent, self, aux) (BUS_CVTADDR(ca) + LE_OFFSET_RAM); cp = (u_char *)(BUS_CVTADDR(ca) + LE_OFFSET_ROM + 2); - sc->sc_copytodesc = copytodesc_contig; /* XXX desc */ - sc->sc_copyfromdesc = copyfromdesc_contig; /* XXX desc */ + sc->sc_copytodesc = copytobuf_contig; + sc->sc_copyfromdesc = copyfrombuf_contig; sc->sc_copytobuf = copytobuf_contig; sc->sc_copyfrombuf = copyfrombuf_contig; sc->sc_zerobuf = zerobuf_contig; @@ -253,155 +246,4 @@ lewritereg(regptr, val) } } -/* - * Routines for accessing the transmit and receive buffers. Unfortunately, - * CPU addressing of these buffers is done in one of 3 ways: - * - contiguous (for the 3max and turbochannel option card) - * - gap2, which means shorts (2 bytes) interspersed with short (2 byte) - * spaces (for the pmax) - * - gap16, which means 16bytes interspersed with 16byte spaces - * for buffers which must begin on a 32byte boundary (for 3min and maxine) - * The buffer offset is the logical byte offset, assuming contiguous storage. - */ - -/* - * For the 3min and maxine, the buffers are in main memory filled in with - * 16byte blocks interspersed with 16byte spaces. - */ -void -copytobuf_gap16(sc, fromv, boff, len) - struct le_softc *sc; - void *fromv; - int boff; - register int len; -{ - volatile caddr_t buf = sc->sc_mem; - register caddr_t from = fromv; - register caddr_t bptr; - register int xfer; - - bptr = buf + ((boff << 1) & ~0x1f); - boff &= 0xf; - xfer = min(len, 16 - boff); - while (len > 0) { - bcopy(from, bptr + boff, xfer); - from += xfer; - bptr += 32; - boff = 0; - len -= xfer; - xfer = min(len, 16); - } -} - -void -copyfrombuf_gap16(sc, tov, boff, len) - struct le_softc *sc; - void *tov; - int boff, len; -{ - volatile caddr_t buf = sc->sc_mem; - register caddr_t to = tov; - register caddr_t bptr; - register int xfer; - - bptr = buf + ((boff << 1) & ~0x1f); - boff &= 0xf; - xfer = min(len, 16 - boff); - while (len > 0) { - bcopy(bptr + boff, to, xfer); - to += xfer; - bptr += 32; - boff = 0; - len -= xfer; - xfer = min(len, 16); - } -} - -void -zerobuf_gap16(sc, boff, len) - struct le_softc *sc; - int boff, len; -{ - volatile caddr_t buf = sc->sc_mem; - register caddr_t bptr; - register int xfer; - - bptr = buf + ((boff << 1) & ~0x1f); - boff &= 0xf; - xfer = min(len, 16 - boff); - while (len > 0) { - bzero(bptr + boff, xfer); - bptr += 32; - boff = 0; - len -= xfer; - xfer = min(len, 16); - } -} - -/* - * For the pmax the buffer consists of shorts (2 bytes) interspersed with - * short (2 byte) spaces and must be accessed with halfword load/stores. - * (don't worry about doing an extra byte) - */ -void -copytobuf_gap2(sc, fromv, boff, len) - struct le_softc *sc; - void *fromv; - int boff; - register int len; -{ - volatile caddr_t buf = sc->sc_mem; - register caddr_t from = fromv; - register volatile u_short *bptr; - register int xfer; - - if (boff & 0x1) { - /* handle unaligned first byte */ - bptr = ((volatile u_short *)buf) + (boff - 1); - *bptr = (*from++ << 8) | (*bptr & 0xff); - bptr += 2; - len--; - } else - bptr = ((volatile u_short *)buf) + boff; - while (len > 1) { - *bptr = (from[1] << 8) | (from[0] & 0xff); - bptr += 2; - from += 2; - len -= 2; - } - if (len == 1) - *bptr = (u_short)*from; -} - -void -copyfrombuf_gap2(sc, tov, boff, len) - struct le_softc *sc; - void *tov; - int boff, len; -{ - volatile caddr_t buf = sc->sc_mem; - register caddr_t to = tov; - register volatile u_short *bptr; - register u_short tmp; - register int xfer; - - if (boff & 0x1) { - /* handle unaligned first byte */ - bptr = ((volatile u_short *)buf) + (boff - 1); - *to++ = (*bptr >> 8) & 0xff; - bptr += 2; - len--; - } else - bptr = ((volatile u_short *)buf) + boff; - while (len > 1) { - tmp = *bptr; - *to++ = tmp & 0xff; - *to++ = (tmp >> 8) & 0xff; - bptr += 2; - len -= 2; - } - if (len == 1) - *to = *bptr & 0xff; -} - #include diff --git a/sys/arch/alpha/tc/scc.c b/sys/arch/alpha/tc/scc.c index 5128c33c280..fff9e26bf3c 100644 --- a/sys/arch/alpha/tc/scc.c +++ b/sys/arch/alpha/tc/scc.c @@ -1,4 +1,4 @@ -/* $NetBSD: scc.c,v 1.9 1995/08/03 00:52:17 cgd Exp $ */ +/* $NetBSD: scc.c,v 1.10 1995/11/23 02:41:29 cgd Exp $ */ /* * Copyright (c) 1991,1990,1989,1994,1995 Carnegie Mellon University @@ -96,7 +96,9 @@ #include #include #include +#if 0 #include +#endif #include #include @@ -874,6 +876,7 @@ sccintr(xxxunit) * Now for mousey */ } else if (tp == scc_tty[SCCMOUSE_PORT] && sccMouseButtons) { +#if 0 register MouseReport *mrp; static MouseReport currentRep; @@ -906,6 +909,7 @@ sccintr(xxxunit) } (*sccMouseButtons)(mrp); } +#endif continue; } if (!(tp->t_state & TS_ISOPEN)) { -- 2.20.1