|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: #ifndef _POWERMAC_H_
26: #define _POWERMAC_H_
27:
28: #ifndef __ASSEMBLER__
29:
30: #include <mach/ppc/vm_types.h>
31: #include <machdep/ppc/boot.h>
32: #include <machdep/ppc/dbdma.h>
33:
34: /*
35: * Machine class
36: */
37:
38: #define POWERMAC_CLASS_PDM 1 /* PowerMac 61/71/8100 */
39: #define POWERMAC_CLASS_PERFORMA 2 /* PowerMac 52/6200 */
40: #define POWERMAC_CLASS_POWERSURGE 3 /* PowerMac 72/75/85/9500 */
41: #define POWERMAC_CLASS_POWEREXPRESS 4 /* PowerMac 9700 */
42: #define POWERMAC_CLASS_POWERBOOK 5 /* PowerBook 2300/5300 */
43: #define POWERMAC_CLASS_GOSSAMER 6 /* PowerMac G3 Desk/Mini-Twr */
44: #define POWERMAC_CLASS_POWERSTAR 7 /* PowerBook 2400/3400/G3 */
45: #define POWERMAC_CLASS_YOSEMITE 8 /* 1st Gen New World */
46:
47: /* Some macros for easy machine identification */
48: #define IsPowerSurge() (powermac_info.class == POWERMAC_CLASS_POWERSURGE)
49:
50: #define IsPEx() (powermac_info.class == POWERMAC_CLASS_POWEREXPRESS)
51:
52: #define IsPowerBook() (powermac_info.class == POWERMAC_CLASS_POWERBOOK)
53:
54: #define IsGossamer() (powermac_info.class == POWERMAC_CLASS_GOSSAMER)
55:
56: #define IsPowerStar() (powermac_info.class == POWERMAC_CLASS_POWERSTAR)
57:
58: #define IsYosemite() (powermac_info.class == POWERMAC_CLASS_YOSEMITE)
59:
60: // This is not safe until the PMU or Cuda driver have been set up.
61: #define HasPMU() (powermac_info.hasPMU)
62:
63: typedef struct powermac_info {
64: int class; /* Machine type */
65:
66: unsigned int bus_clock_rate_hz; /* Bus frequency */
67: unsigned int dec_clock_period; /* Fixed point number 8.24 */
68:
69: /* to convert from real time ticks to nsec convert by this*/
70: unsigned int proc_clock_to_nsec_numerator;
71: unsigned int proc_clock_to_nsec_denominator;
72:
73: int machine; /* Gestalt value .. */
74: int hasPMU; // Flag for machines with PMU
75: int viaIRQ; // irq number for the via
76: } powermac_info_t;
77:
78: extern powermac_info_t powermac_info;
79:
80: /* This may be merged in struct powermac_info in the future */
81: typedef struct powermac_machine_info {
82: unsigned long dcache_block_size; /* number of bytes */
83: unsigned long dcache_size; /* number of bytes */
84: unsigned long icache_size; /* number of bytes */
85: unsigned long caches_unified; /* boolean_t */
86: unsigned long processor_version; /* contents of PVR */
87: unsigned long cpu_clock_rate_hz;
88: unsigned long dec_clock_rate_hz;
89: unsigned long bus_clock_rate_hz;
90: unsigned long l2_clock_rate_hz;
91: unsigned long bus_clock_rate_hz_num;
92: unsigned long bus_clock_rate_hz_den;
93: unsigned long cpu_pll; /* cpu pll mode * 2 */
94: unsigned long l2_pll; /* l2 pll mode * 2 */
95: unsigned long l2_cache_size;
96: unsigned long l2_cache_type;
97: } powermac_machine_info_t;
98:
99: extern powermac_machine_info_t powermac_machine_info;
100:
101: // Types of L2 Caches
102: #define L2_CACHE_NONE (0)
103: #define L2_CACHE_MB (1)
104: #define L2_CACHE_INLINE (2)
105: #define L2_CACHE_BACKSIDE (3)
106:
107:
108: typedef struct powermac_io_info {
109: int io_size;
110: vm_offset_t io_base_phys; /* IO region */
111: vm_offset_t io_base_virt; /* IO region */
112:
113: vm_offset_t io_base2; // IO region for O'Hare 2
114:
115: vm_offset_t mem_cntlr_base_phys;
116: vm_offset_t int_cntlr_base_phys;
117:
118: vm_offset_t dma_base_phys;
119:
120: /* Remove All this dma stuff later */
121: int dma_buffer_alignment; /* preallocated DMA region */
122: int dma_buffer_size; /* preallocated DMA region */
123: vm_offset_t dma_buffer_phys; /* preallocated DMA region */
124: vm_offset_t dma_buffer_virt; /* preallocated DMA region */
125:
126: vm_offset_t serial_base_phys;
127: vm_offset_t scsi_int_base_phys;
128: vm_offset_t scsi_int_dma_base_phys;
129: vm_offset_t scsi_ext_base_phys;
130: vm_offset_t audio_base_phys;
131: vm_offset_t floppy_base_phys;
132: vm_offset_t ethernet_base_phys;
133: vm_offset_t via_base_phys;
134:
135: vm_offset_t nvram_addr_reg_phys;
136: vm_offset_t nvram_data_reg_phys;
137:
138: vm_offset_t ide0_base_phys;
139: vm_offset_t ide1_base_phys;
140: int nvram_XPRAM_NVPartition;
141: int nvram_NameRegistry_NVPartition;
142: int nvram_OpenFirmware_NVPartition;
143: } powermac_io_info_t;
144:
145: extern powermac_io_info_t powermac_io_info;
146:
147: /* For compatability right now, keep these defines */
148: #define PCI_IO_BASE_PHYS (powermac_io_info.io_base_phys)
149:
150: #define PCI_DMA_BASE_PHYS (powermac_io_info.dma_base_phys)
151:
152: /* SCC registers (serial line) - physical addr is for probe */
153: #define PCI_SCC_BASE_PHYS (powermac_io_info.serial_base_phys)
154:
155: /* ASC registers (external scsi) - physical address for probe */
156: #define PCI_ASC_BASE_PHYS (powermac_io_info.scsi_ext_base_phys)
157:
158: /* MESH (internal scsi) controller */
159: #define PCI_MESH_BASE_PHYS (powermac_io_info.scsi_int_base_phys)
160: #define PCI_MESH_DMA_BASE_PHYS (powermac_io_info.scsi_int_dma_base_phys)
161:
162: /* audio controller */
163: #define PCI_AUDIO_BASE_PHYS (powermac_io_info.audio_base_phys)
164:
165: /* floppy controller */
166: #define PCI_FLOPPY_BASE_PHYS (powermac_io_info.floppy_base_phys)
167:
168: /* Ethernet controller */
169: #define PCI_ETHERNET_BASE_PHYS (powermac_io_info.ethernet_base_phys)
170: #define PCI_ETHERNET_ADDR_PHYS (0xF3019000)
171:
172: /* VIA controls, misc stuff (including CUDA) */
173: #define PCI_VIA_BASE_PHYS (powermac_io_info.via_base_phys)
174:
175: #define PCI_VIA1_AUXCONTROL (POWERMAC_IO(powermac_io_info.via_base_phys + 0x01600))
176: #define PCI_VIA1_T1COUNTERLOW (POWERMAC_IO(powermac_io_info.via_base_phys + 0x00800))
177: #define PCI_VIA1_T1COUNTERHIGH (POWERMAC_IO(powermac_io_info.via_base_phys + 0x00A00))
178: #define PCI_VIA1_T1LATCHLOW (POWERMAC_IO(powermac_io_info.via_base_phys + 0x00C00))
179: #define PCI_VIA1_T1LATCHHIGH (POWERMAC_IO(powermac_io_info.via_base_phys + 0x00E00))
180: #define PCI_VIA1_IER (POWERMAC_IO(powermac_io_info.via_base_phys + 0x01c00))
181: #define PCI_VIA1_IFR (POWERMAC_IO(powermac_io_info.via_base_phys + 0x01a00))
182: #define PCI_VIA1_PCR (POWERMAC_IO(powermac_io_info.via_base_phys + 0x01800))
183:
184: /* NVRAM Addrs and Partitions */
185: #define PCI_NVRAM_ADDR_PHYS (powermac_io_info.nvram_addr_reg_phys)
186: #define PCI_NVRAM_DATA_PHYS (powermac_io_info.nvram_data_reg_phys)
187:
188: #define NVRAM_XPRAM_Offset (powermac_io_info.nvram_XPRAM_NVPartition)
189: #define NVRAM_NameRegistry_Offset (powermac_io_info.nvram_NameRegistry_NVPartition)
190: #define NVRAM_OpenFirmware_Offset (powermac_io_info.nvram_OpenFirmware_NVPartition)
191:
192:
193:
194: /* IDE controller */
195: #define PCI_IDE0_BASE_PHYS (powermac_io_info.ide0_base_phys)
196: #define PCI_IDE1_BASE_PHYS (powermac_io_info.ide1_base_phys)
197:
198:
199: extern void NO_ENTRY(void);
200:
201: typedef struct {
202: void (*configure_machine)(void);
203: void (*machine_initialize_interrupt)(void);
204: void (*machine_initialize_network)(void);
205: void (*machine_initialize_processors)(boot_args *args);
206: int (*machine_initialize_rtclock)(void);
207: powermac_dbdma_channels_t *powermac_dbdma_channels;
208: } powermac_init_t;
209:
210: extern powermac_init_t *powermac_init_p;
211:
212:
213: /* Macro to convert from a physical I/O address into a virtual I/O address */
214: #define POWERMAC_IO(addr) (powermac_io_info.io_base_virt + \
215: (addr - powermac_io_info.io_base_phys))
216:
217: /*
218: * prototypes
219: */
220:
221: /* Used to initialise IO once DMA and IO virtual space has been assigned */
222: extern void powermac_io_init(vm_offset_t powermac_io_base_v);
223:
224: extern void powermac_powerdown(void);
225: extern void powermac_reboot(void);
226:
227: /* Non-cached version of bcopy */
228: extern void bcopy_nc(char *from, char *to, int size);
229:
230: /* Some useful typedefs for accessing control registers */
231:
232: typedef volatile unsigned char v_u_char;
233: typedef volatile unsigned short v_u_short;
234: typedef volatile unsigned int v_u_int;
235: typedef volatile unsigned long v_u_long;
236:
237: /* And some useful defines for reading 'volatile' structures,
238: * don't forget to be be careful about sync()s and eieio()s
239: */
240: #define reg8(reg) (*(v_u_char *)reg)
241: #define reg16(reg) (*(v_u_short *)reg)
242: #define reg32(reg) (*(v_u_int *)reg)
243:
244: /* VIA1_AUXCONTROL values same across several powermacs */
245: #define VIA1_AUX_AUTOT1LATCH 0x40 /* Autoreload of T1 from latches */
246:
247: #endif /* !(__ASSEMBLER__) */
248: #endif /* _POWERMAC_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.