cbus.h revision 19269
167754Smsmith/*-
267754Smsmith * Copyright (c) 1990 The Regents of the University of California.
367754Smsmith * All rights reserved.
467754Smsmith *
567754Smsmith * This code is derived from software contributed to Berkeley by
667754Smsmith * William Jolitz.
767754Smsmith *
8217365Sjkim * Redistribution and use in source and binary forms, with or without
9229989Sjkim * modification, are permitted provided that the following conditions
1070243Smsmith * are met:
1167754Smsmith * 1. Redistributions of source code must retain the above copyright
12217365Sjkim *    notice, this list of conditions and the following disclaimer.
13217365Sjkim * 2. Redistributions in binary form must reproduce the above copyright
14217365Sjkim *    notice, this list of conditions and the following disclaimer in the
15217365Sjkim *    documentation and/or other materials provided with the distribution.
16217365Sjkim * 3. All advertising materials mentioning features or use of this software
17217365Sjkim *    must display the following acknowledgement:
18217365Sjkim *	This product includes software developed by the University of
19217365Sjkim *	California, Berkeley and its contributors.
20217365Sjkim * 4. Neither the name of the University nor the names of its contributors
21217365Sjkim *    may be used to endorse or promote products derived from this software
22217365Sjkim *    without specific prior written permission.
23217365Sjkim *
24217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25217365Sjkim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2667754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27217365Sjkim * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28217365Sjkim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3067754Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32217365Sjkim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33217365Sjkim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34217365Sjkim * SUCH DAMAGE.
35217365Sjkim *
36217365Sjkim *	from: @(#)isa.h	5.7 (Berkeley) 5/9/91
37217365Sjkim *	$Id: pc98.h,v 1.6 1996/10/23 07:25:22 asami Exp $
38217365Sjkim */
39217365Sjkim
40217365Sjkim#ifndef _PC98_PC98_PC98_H_
41217365Sjkim#define	_PC98_PC98_PC98_H_
42217365Sjkim
43217365Sjkim/* BEWARE:  Included in both assembler and C code */
4467754Smsmith
4567754Smsmith/*
4667754Smsmith * PC98 Bus conventions
4767754Smsmith */
48193341Sjkim/*
49193341Sjkim * PC98 Bus conventions
50193341Sjkim * modified for PC9801 by A.Kojima F.Ukai M.Ishii
5167754Smsmith *			Kyoto University Microcomputer Club (KMC)
5267754Smsmith */
5377424Smsmith
5491116Smsmith/*
5567754Smsmith * Input / Output Port Assignments
5667754Smsmith */
5767754Smsmith
5867754Smsmith#ifndef IO_ISABEGIN
5967754Smsmith#define	IO_ISABEGIN	0x000		/* 0x000 - Beginning of I/O Registers */
6067754Smsmith
61151937Sjkim/* PC98 IO address ... very dirty (^_^; */
6267754Smsmith
6367754Smsmith#define IO_ICU1		0x000		/* 8259A Interrupt Controller #1 */
6467754Smsmith#define IO_DMA		0x001		/* 8237A DMA Controller */
6567754Smsmith#define IO_ICU2		0x008		/* 8259A Interrupt Controller #2 */
6667754Smsmith#define IO_RTC		0x020		/* 4990A RTC */
6767754Smsmith#define IO_DMAPG	0x021		/* DMA Page Registers */
6867754Smsmith#define IO_COM1		0x030		/* 8251A RS232C serial I/O (int) */
6967754Smsmith#define IO_SYSPORT	0x031		/* 8255A System Port */
7067754Smsmith#define IO_PPI		0x035		/* Programmable Peripheral Interface */
7167754Smsmith#define IO_LPT		0x040		/* 8255A Printer Port */
7267754Smsmith#define IO_KBD		0x041		/* 8251A Keyboard */
7367754Smsmith#define IO_NMI		0x050		/* NMI Control */
7467754Smsmith#define IO_WAIT		0x05F		/* WAIT 0.6 us */
7591116Smsmith#define IO_GDC1		0x060		/* 7220 GDC Text Control */
7667754Smsmith#define IO_TIMER1	0x071		/* 8253C Timer */
7767754Smsmith#define IO_SASI		0x080		/* SASI Hard Disk Controller */
7867754Smsmith#define IO_FD1		0x090		/* 765A 1MB FDC */
7967754Smsmith#define	IO_GDC2		0x0a0		/* 7220 GDC Graphic Control */
8067754Smsmith#define	IO_CGROM	0x0a1		/* Character ROM */
8167754Smsmith#define	IO_COM2		0x0b1		/* 8251A RS232C serial I/O (ext) */
8267754Smsmith#define	IO_COM3		0x0b9		/* 8251A RS232C serial I/O (ext) */
8367754Smsmith#define IO_FDPORT	0x0be		/* FD I/F port (1M<->640K,EMTON) */
8467754Smsmith#define IO_FD2		0x0c8		/* 765A 640KB FDC */
8567754Smsmith#define IO_SIO1		0x0d0		/* MC16550II ext RS232C */
8667754Smsmith#define IO_REEST	0x0F0		/* CPU FPU reset */
8767754Smsmith#define IO_A2OEN	0x0F2		/* A20 enable */
8867754Smsmith#define IO_A20CT	0x0F6		/* A20 control enable/disable */
8967754Smsmith#define IO_NPX		0x0F8		/* Numeric Coprocessor */
9067754Smsmith#define	IO_SOUND	0x188		/* YM2203 FM sound board */
9167754Smsmith#define	IO_EGC		0x4a0		/* 7220 GDC Graphic Control */
9267754Smsmith#define IO_SCSI		0xcc0		/* SCSI Controller */
9367754Smsmith#define IO_SIO2		0x8d0		/* MC16550II ext RS232C */
9467754Smsmith#define IO_BEEPF	0x3fdb		/* beep frequency */
9591116Smsmith#define IO_MOUSE	0x7fd9		/* mouse */
9691116Smsmith#define IO_BMS		0x7fd9		/* Bus Mouse */
9791116Smsmith#define IO_MSE		0x7fd9		/* Bus Mouse */
9891116Smsmith#define IO_MOUSETM	0xdfbd		/* mouse timer */
9991116Smsmith
10067754Smsmith#define IO_WD1_NEC	0x640		/* 98note IDE Hard disk controller */
10167754Smsmith#define IO_WD1_EPSON	0x80		/* 386note Hard disk controller */
10267754Smsmith#define	IO_WD1		IO_WD1_NEC	/* IDE Hard disk controller */
103200553Sjkim
10467754Smsmith#define	IO_ISAEND	0xFFFF		/* - 0x3FF End of I/O Registers */
10567754Smsmith#endif /* !IO_ISABEGIN */
10691116Smsmith
10767754Smsmith/*
10867754Smsmith * Input / Output Port Sizes - these are from several sources, and tend
10967754Smsmith * to be the larger of what was found, ie COM ports can be 4, but some
11067754Smsmith * boards do not fully decode the address, thus 8 ports are used.
11167754Smsmith */
11267754Smsmith
11391116Smsmith#ifndef	IO_ISASIZES
11491116Smsmith#define	IO_ISASIZES
11567754Smsmith
11667754Smsmith#define	IO_COMSIZE	8		/* 8250, 16X50 com controllers (4?) */
117167802Sjkim#define	IO_CGASIZE	16		/* CGA controllers */
11867754Smsmith#define	IO_DMASIZE	16		/* 8237 DMA controllers */
119167802Sjkim#define	IO_DPGSIZE	32		/* 74LS612 DMA page registers */
12067754Smsmith#define	IO_FDCSIZE	8		/* Nec765 floppy controllers */
12167754Smsmith#define	IO_WDCSIZE	8		/* WD compatible disk controllers */
12267754Smsmith#define	IO_GAMSIZE	16		/* AT compatible game controllers */
12367754Smsmith#define	IO_ICUSIZE	16		/* 8259A interrupt controllers */
12467754Smsmith#define	IO_KBDSIZE	16		/* 8042 Keyboard controllers */
12567754Smsmith#define	IO_LPTSIZE	8		/* LPT controllers, some use only 4 */
12667754Smsmith#define	IO_MDASIZE	16		/* Monochrome display controllers */
12767754Smsmith#define	IO_RTCSIZE	16		/* CMOS real time clock, NMI control */
12867754Smsmith#define	IO_TMRSIZE	16		/* 8253 programmable timers */
12967754Smsmith#define	IO_NPXSIZE	16		/* 80387/80487 NPX registers */
13067754Smsmith#define	IO_VGASIZE	16		/* VGA controllers */
13167754Smsmith#define IO_EISASIZE	4096		/* EISA controllers */
13267754Smsmith#define	IO_PMPSIZE	2		/* 82347 power management peripheral */
13367754Smsmith
13467754Smsmith#endif /* !IO_ISASIZES */
13567754Smsmith
13667754Smsmith/*
13767754Smsmith * Input / Output Memory Physical Addresses
13867754Smsmith */
13967754Smsmith
140193267Sjkim#ifndef	IOM_BEGIN
14191116Smsmith#define	IOM_BEGIN	0x0a0000		/* Start of I/O Memory "hole" */
14267754Smsmith#define	IOM_END		0x100000		/* End of I/O Memory "hole" */
14367754Smsmith#define	IOM_SIZE	(IOM_END - IOM_BEGIN)
14467754Smsmith#endif /* !RAM_BEGIN */
14567754Smsmith
14667754Smsmith/*
14767754Smsmith * RAM Physical Address Space (ignoring the above mentioned "hole")
14867754Smsmith */
14967754Smsmith
15067754Smsmith#ifndef	RAM_BEGIN
15167754Smsmith#define	RAM_BEGIN	0x0000000	/* Start of RAM Memory */
15267754Smsmith#ifdef	EPSON_BOUNCEDMA
15367754Smsmith#define	RAM_END		0x0f00000	/* End of EPSON GR?? RAM Memory */
15467754Smsmith#else
15567754Smsmith#define	RAM_END		0x1000000	/* End of RAM Memory */
15691116Smsmith#endif
15791116Smsmith#define	RAM_SIZE	(RAM_END - RAM_BEGIN)
15891116Smsmith#endif /* !RAM_BEGIN */
15991116Smsmith
16091116Smsmith#ifndef PC98 /* IBM-PC */
16167754Smsmith/*
16267754Smsmith * Oddball Physical Memory Addresses
16367754Smsmith */
164200553Sjkim#ifndef	COMPAQ_RAMRELOC
16567754Smsmith#define	COMPAQ_RAMRELOC	0x80c00000	/* Compaq RAM relocation/diag */
16667754Smsmith#define	COMPAQ_RAMSETUP	0x80c00002	/* Compaq RAM setup */
16767754Smsmith#define	WEITEK_FPU	0xC0000000	/* WTL 2167 */
16867754Smsmith#define	CYRIX_EMC	0xC0000000	/* Cyrix EMC */
16967754Smsmith#endif	COMPAQ_RAMRELOC
17067754Smsmith#endif
17167754Smsmith
17267754Smsmith#define PC98_VECTOR_SIZE			(0x400)
173209746Sjkim#define PC98_SYSTEM_PARAMETER_SIZE		(0x230)
174200553Sjkim
17567754Smsmith#define PC98_SAVE_AREA(highreso_flag)	(0xa1000)
176114237Snjl#define PC98_SAVE_AREA_ADDRESS		(0x10)
17767754Smsmith
178193267Sjkim#define OFS_BOOT_boothowto 0x210
17967754Smsmith#define OFS_BOOT_bootdev   0x214
18067754Smsmith#define OFS_BOOT_cyloffset 0x218
18167754Smsmith#define OFS_WD_BIOS_SECSIZE(i)	(0x200+(i)*6)
18267754Smsmith#define OFS_WD_BIOS_NCYL(i) (0x202+(i)*6)
18367754Smsmith#define OFS_WD_BIOS_HEAD(i) (0x205+(i)*6)
18467754Smsmith#define OFS_WD_BIOS_SEC(i) (0x204+(i)*6)
18567754Smsmith#define OFS_pc98_machine_type 0x220
18691116Smsmith#define OFS_epson_machine_id	0x224
18767754Smsmith#define OFS_epson_bios_id	0x225
18867754Smsmith#define OFS_epson_system_type	0x226
18967754Smsmith
190167802Sjkim#define	M_NEC_PC98	0x0001
19167754Smsmith#define	M_EPSON_PC98	0x0002
192167802Sjkim#define	M_NOT_H98	0x0010
19367754Smsmith#define	M_H98		0x0020
19467754Smsmith#define	M_NOTE		0x0040
195100966Siwasaki#define	M_NORMAL	0x1000
19667754Smsmith#define	M_8M		0x8000
197100966Siwasaki
198100966Siwasaki#if defined(KERNEL) && !defined(LOCORE)
199100966Siwasaki/* BIOS parameter block */
200100966Siwasakiextern unsigned char	pc98_system_parameter[]; /* in locore.c */
201100966Siwasaki#define PC98_SYSTEM_PARAMETER(x)	pc98_system_parameter[(x)-0x400]
20267754Smsmith#define BOOT_boothowto (*(unsigned long*)(&pc98_system_parameter[OFS_BOOT_boothowto]))
203100966Siwasaki#define BOOT_bootdev   (*(unsigned long*)(&pc98_system_parameter[OFS_BOOT_bootdev]))
20467754Smsmith#define BOOT_cyloffset (*(unsigned long*)(&pc98_system_parameter[OFS_BOOT_cyloffset]))
205241973Sjkim#define WD_BIOS_SECSIZE(i) (*(unsigned short*)(&pc98_system_parameter[OFS_WD_BIOS_SECSIZE(i)]))
206241973Sjkim#define WD_BIOS_NCYL(i) (*(unsigned short*)(&pc98_system_parameter[OFS_WD_BIOS_NCYL(i)]))
207100966Siwasaki#define WD_BIOS_HEAD(i) (pc98_system_parameter[OFS_WD_BIOS_HEAD(i)])
20867754Smsmith#define WD_BIOS_SEC(i) (pc98_system_parameter[OFS_WD_BIOS_SEC(i)])
20967754Smsmith#define pc98_machine_type (*(unsigned long*)&pc98_system_parameter[OFS_pc98_machine_type])
21067754Smsmith#define epson_machine_id	(pc98_system_parameter[OFS_epson_machine_id])
21167754Smsmith#define epson_bios_id		(pc98_system_parameter[OFS_epson_bios_id])
212100966Siwasaki#define epson_system_type	(pc98_system_parameter[OFS_epson_system_type])
21367754Smsmith
214100966Siwasaki# define PC98_TYPE_CHECK(x)	((pc98_machine_type & (x)) == (x))
215100966Siwasaki
216100966Siwasaki#endif /* KERNEL */
21767754Smsmith
21867754Smsmith/*
219100966Siwasaki * Obtained from NetBSD/pc98
220100966Siwasaki */
221100966Siwasaki#define MADDRUNK	-1
22267754Smsmith#define IRQUNK		 0
22367754Smsmith#define DRQUNK		-1
22467754Smsmith
22567754Smsmith#endif /* !_PC98_PC98_PC98_H_ */
226107325Siwasaki