1 /* $NetBSD: cia.h,v 1.13 2002/04/25 09:20:27 aymeric Exp $ */ 2 3 /* 4 * Mach Operating System 5 * Copyright (c) 1992 Carnegie Mellon University 6 * All Rights Reserved. 7 * 8 * Permission to use, copy, modify and distribute this software and its 9 * documentation is hereby granted, provided that both the copyright 10 * notice and this permission notice appear in all copies of the 11 * software, derivative works or modified versions, and any portions 12 * thereof, and that both notices appear in supporting documentation. 13 * 14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 17 * 18 * Carnegie Mellon requests users of this software to return to 19 * 20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 21 * School of Computer Science 22 * Carnegie Mellon University 23 * Pittsburgh PA 15213-3890 24 * 25 * any improvements or extensions that they make and grant Carnegie Mellon 26 * the rights to redistribute these changes. 27 */ 28 29 /* 30 * This is a rewrite (retype) of the Amiga's CIA chip register map, based 31 * on the Hardware Reference Manual. It is NOT based on the Amiga's 32 * hardware/cia.h. 33 */ 34 35 #ifndef _AMIGA_CIA_ 36 #define _AMIGA_CIA_ 37 38 struct CIA { 39 volatile unsigned char pra; char pad0[0xff]; 40 volatile unsigned char prb; char pad1[0xff]; 41 volatile unsigned char ddra; char pad2[0xff]; 42 volatile unsigned char ddrb; char pad3[0xff]; 43 volatile unsigned char talo; char pad4[0xff]; 44 volatile unsigned char tahi; char pad5[0xff]; 45 volatile unsigned char tblo; char pad6[0xff]; 46 volatile unsigned char tbhi; char pad7[0xff]; 47 volatile unsigned char todlo; char pad8[0xff]; 48 volatile unsigned char todmid; char pad9[0xff]; 49 volatile unsigned char todhi; char pada[0x1ff]; 50 volatile unsigned char sdr; char padc[0xff]; 51 volatile unsigned char icr; char padd[0xff]; 52 volatile unsigned char cra; char pade[0xff]; 53 volatile unsigned char crb; char padf[0xff]; 54 }; 55 56 #ifdef _KERNEL 57 #ifndef _LOCORE 58 extern vaddr_t CIAAbase, CIABbase, CIAADDR; 59 #define CIABASE (0x00BFC000) 60 #define CIATOP (0x00C00000) 61 #define NCIAPG btoc(CIATOP - CIABASE) 62 #endif 63 64 #define ciaa (*((volatile struct CIA *)CIAAbase)) 65 #define ciab (*((volatile struct CIA *)CIABbase)) 66 #endif 67 68 /* 69 * bits in CIA-B 70 */ 71 #define CIAB_PRA_BUSY (1<<0) 72 #define CIAB_PRA_POUT (1<<1) 73 #define CIAB_PRA_SEL (1<<2) 74 #define CIAB_PRA_DSR (1<<3) 75 #define CIAB_PRA_CTS (1<<4) 76 #define CIAB_PRA_CD (1<<5) 77 #define CIAB_PRA_RTS (1<<6) 78 #define CIAB_PRA_DTR (1<<7) 79 80 #define CIAB_PRB_STEP (1<<0) 81 #define CIAB_PRB_DIR (1<<1) 82 #define CIAB_PRB_SIDE (1<<2) 83 #define CIAB_PRB_SEL0 (1<<3) 84 #define CIAB_PRB_SEL1 (1<<4) 85 #define CIAB_PRB_SEL2 (1<<5) 86 #define CIAB_PRB_SEL3 (1<<6) 87 #define CIAB_PRB_MTR (1<<7) 88 89 /* 90 * bits in CIA-A 91 */ 92 #define CIAA_PRA_OVL (1<<0) 93 #define CIAA_PRA_LED (1<<1) 94 #define CIAA_PRA_CHNG (1<<2) 95 #define CIAA_PRA_WPRO (1<<3) 96 #define CIAA_PRA_TK0 (1<<4) 97 #define CIAA_PRA_RDY (1<<5) 98 #define CIAA_PRA_FIR0 (1<<6) 99 #define CIAA_PRA_FIR1 (1<<7) 100 101 /* 102 * ciaa-prb is centronics interface 103 */ 104 105 106 /* 107 * interrupt bits 108 */ 109 #define CIA_ICR_TA (1<<0) 110 #define CIA_ICR_TB (1<<1) 111 #define CIA_ICR_ALARM (1<<2) 112 #define CIA_ICR_SP (1<<3) 113 #define CIA_ICR_FLG (1<<4) 114 #define CIA_ICR_IR_SC (1<<7) 115 116 117 /* 118 * since many CIA signals are low-active, these defines should make the 119 * code more readable 120 */ 121 #define SETDCD(c) (c &= ~CIAB_PRA_CD) 122 #define CLRDCD(c) (c |= CIAB_PRA_CD) 123 #define ISDCD(c) (!(c & CIAB_PRA_CD)) 124 125 #define SETCTS(c) (c &= ~CIAB_PRA_CTS) 126 #define CLRCTS(c) (c |= CIAB_PRA_CTS) 127 #define ISCTS(c) (!(c & CIAB_PRA_CTS)) 128 129 #define SETRTS(c) (c &= ~CIAB_PRA_RTS) 130 #define CLRRTS(c) (c |= CIAB_PRA_RTS) 131 #define ISRTS(c) (!(c & CIAB_PRA_RTS)) 132 133 #define SETDTR(c) (c &= ~CIAB_PRA_DTR) 134 #define CLRDTR(c) (c |= CIAB_PRA_DTR) 135 #define ISDTR(c) (!(c & CIAB_PRA_DTR)) 136 137 #define SETDSR(c) (c &= ~CIAB_PRA_DSR) 138 #define CLRDSR(c) (c |= CIAB_PRA_DSR) 139 #define ISDSR(c) (!(c & CIAB_PRA_DSR)) 140 141 void dispatch_cia_ints(int, int); 142 void ciaa_intr(void); 143 void ciab_intr(void); 144 145 #endif /* _AMIGA_CIA_ */ 146