|
|
1.1.1.3 root 1: /* $Id: sun-mie.c,v 1.4 2010/06/05 13:57:27 fredette Exp $ */
1.1 root 2:
3: /* bus/multibus/sun_mie.c - implementation of the Sun Intel Ethernet Multibus emulation: */
4:
5: /*
6: * Copyright (c) 2003 Matt Fredette
7: * All rights reserved.
8: *
9: * Redistribution and use in source and binary forms, with or without
10: * modification, are permitted provided that the following conditions
11: * are met:
12: * 1. Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: * 2. Redistributions in binary form must reproduce the above copyright
15: * notice, this list of conditions and the following disclaimer in the
16: * documentation and/or other materials provided with the distribution.
17: * 3. All advertising materials mentioning features or use of this software
18: * must display the following acknowledgement:
19: * This product includes software developed by Matt Fredette.
20: * 4. The name of the author may not be used to endorse or promote products
21: * derived from this software without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33: * POSSIBILITY OF SUCH DAMAGE.
34: */
35:
36: #include <tme/common.h>
1.1.1.3 root 37: _TME_RCSID("$Id: sun-mie.c,v 1.4 2010/06/05 13:57:27 fredette Exp $");
1.1 root 38:
39: /* includes: */
40: #include <tme/element.h>
41: #undef TME_BUS_VERSION
42: #define TME_BUS_VERSION TME_X_VERSION(0, 0)
43: #include <tme/generic/bus.h>
44: #undef TME_I825X6_VERSION
45: #define TME_I825X6_VERSION TME_X_VERSION(0, 0)
46: #include <tme/ic/i825x6.h>
47:
48: /* macros: */
49:
50: /* the amount of memory on the board: */
51: #define TME_SUN_MIE_MEMSIZE (256 * 1024)
52:
53: /* the board page size: */
54: #define TME_SUN_MIE_PAGESIZE (1024)
55:
56: /* the number of page map entries: */
57: #define TME_SUN_MIE_PGMAP_COUNT (1024)
58:
59: /* the number of active TLB entries we can have per page map entry: */
60: #define TME_SUN_MIE_PGMAP_TLBS (4)
61:
62: /* register offsets and sizes: */
63: #define TME_SUN_MIE_REG_PGMAP (0)
64: #define TME_SUN_MIE_SIZ_PGMAP (TME_SUN_MIE_PGMAP_COUNT * sizeof(tme_uint16_t))
65: #define TME_SUN_MIE_REG_PROM (TME_SUN_MIE_REG_PGMAP + TME_SUN_MIE_SIZ_PGMAP)
66: #define TME_SUN_MIE_SIZ_PROM (32 * sizeof(tme_uint16_t))
67: #define TME_SUN_MIE_REG_CSR (TME_SUN_MIE_REG_PROM + TME_SUN_MIE_SIZ_PROM)
68: #define TME_SUN_MIE_SIZ_CSR (sizeof(tme_uint16_t))
69: #define TME_SUN_MIE_REG_PCR (TME_SUN_MIE_REG_CSR + TME_SUN_MIE_SIZ_CSR + sizeof(tme_uint16_t))
70: #define TME_SUN_MIE_SIZ_PCR (sizeof(tme_uint16_t))
71: #define TME_SUN_MIE_REG_PE_ALO (TME_SUN_MIE_REG_PCR + TME_SUN_MIE_SIZ_PCR)
72: #define TME_SUN_MIE_SIZ_PE_ALO (sizeof(tme_uint16_t))
73: #define TME_SUN_MIE_SIZ_REGS (TME_SUN_MIE_REG_PE_ALO + TME_SUN_MIE_SIZ_PE_ALO)
74:
75: /* the bits in a pagemap entry: */
76: #define TME_SUN_MIE_PGMAP_SWAB (0x8000)
77: /* 0x4000 unused */
78: #define TME_SUN_MIE_PGMAP_P2MEM (0x2000)
79: /* 0x1000 unused */
80: #define TME_SUN_MIE_PGMAP_PFNUM (0x0fff)
81:
82: /* the bits in the Control/Status Register: */
83: #define TME_SUN_MIE_CSR_RESET (0x8000)
84: #define TME_SUN_MIE_CSR_NOLOOP (0x4000)
85: #define TME_SUN_MIE_CSR_CA (0x2000)
86: #define TME_SUN_MIE_CSR_IE (0x1000)
87: #define TME_SUN_MIE_CSR_PIE (0x0800)
88: /* 0x0400 unused */
89: #define TME_SUN_MIE_CSR_PE (0x0200)
90: #define TME_SUN_MIE_CSR_INTR (0x0100)
91: /* 0x0080 unused */
92: /* 0x0040 unused */
93: #define TME_SUN_MIE_CSR_P2MEM (0x0020)
94: #define TME_SUN_MIE_CSR_BIGRAM (0x0010)
95: #define TME_SUN_MIE_CSR_MPMHI (0x000f)
96: #define TME_SUN_MIE_CSR_READONLY (0x0400 \
97: | TME_SUN_MIE_CSR_PE \
98: | TME_SUN_MIE_CSR_INTR \
99: | 0x0080 \
100: | 0x0040 \
101: | TME_SUN_MIE_CSR_BIGRAM\
102: | TME_SUN_MIE_CSR_MPMHI)
103:
104: /* the bits in the Parity Control Register: */
105: #define TME_SUN_MIE_PCR_PEACK (0x0100)
106: #define TME_SUN_MIE_PCR_PESRC (0x0080)
107: #define TME_SUN_MIE_PCR_PEBYTE (0x0040)
108: /* 0x0020 unused */
109: /* 0x0010 unused */
110: #define TME_SUN_MIE_PCR_PE_AHI (0x000f)
111: #define TME_SUN_MIE_PCR_READONLY (~TME_SUN_MIE_PCR_PEACK)
112:
113: /* the size of the memory port: */
114: #define TME_SUN_MIE_SIZ_MBM (0x10000)
115:
116: /* these get and put the CSR: */
117: #define TME_SUN_MIE_CSR_GET(sun_mie) \
118: tme_betoh_u16(*((tme_uint16_t *) &(sun_mie)->tme_sun_mie_regs[TME_SUN_MIE_REG_CSR]))
119: #define TME_SUN_MIE_CSR_PUT(sun_mie, csr) \
120: (*((tme_uint16_t *) &(sun_mie)->tme_sun_mie_regs[TME_SUN_MIE_REG_CSR]) = tme_htobe_u16(csr))
121:
122: /* these get and put the PCR: */
123: #define TME_SUN_MIE_PCR_GET(sun_mie) \
124: tme_betoh_u16(*((tme_uint16_t *) &(sun_mie)->tme_sun_mie_regs[TME_SUN_MIE_REG_PCR]))
125: #define TME_SUN_MIE_PCR_PUT(sun_mie, pcr) \
126: (*((tme_uint16_t *) &(sun_mie)->tme_sun_mie_regs[TME_SUN_MIE_REG_PCR]) = tme_htobe_u16(pcr))
127:
128: /* the callout flags: */
129: #define TME_SUN_MIE_CALLOUT_CHECK (0)
130: #define TME_SUN_MIE_CALLOUT_RUNNING TME_BIT(0)
131: #define TME_SUN_MIE_CALLOUTS_MASK (-2)
132: #define TME_SUN_MIE_CALLOUT_SIGNALS TME_BIT(1)
133: #define TME_SUN_MIE_CALLOUT_INT TME_BIT(2)
134:
135: /* structures: */
136:
137: /* the card: */
138: struct tme_sun_mie {
139:
140: /* backpointer to our element: */
141: struct tme_element *tme_sun_mie_element;
142:
143: /* the mutex protecting the card: */
144: tme_mutex_t tme_sun_mie_mutex;
145:
146: /* the rwlock protecting the card: */
147: tme_rwlock_t tme_sun_mie_rwlock;
148:
149: /* the bus connection for the card's registers: */
150: struct tme_bus_connection *tme_sun_mie_conn_regs;
151:
152: /* the bus connection for the card's memory: */
153: struct tme_bus_connection *tme_sun_mie_conn_memory;
154:
155: /* the bus connection for the card's i825x6 chip: */
156: struct tme_bus_connection *tme_sun_mie_conn_i825x6;
157:
158: /* the callout flags: */
159: int tme_sun_mie_callout_flags;
160:
1.1.1.4 ! root 161: int tme_sun_mie_ca_callout_delay;
! 162: int tme_sun_mie_ca_callout_pending;
! 163: int tme_sun_mie_pending_deassert_intr;
! 164:
1.1 root 165: /* if our interrupt line is currently asserted: */
166: int tme_sun_mie_int_asserted;
167:
168: /* it's easiest to just model the board registers as a chunk of memory: */
169: tme_uint8_t tme_sun_mie_regs[TME_SUN_MIE_SIZ_REGS];
170:
171: /* the board memory really is a chunk of memory: */
172: tme_uint8_t tme_sun_mie_memory[TME_SUN_MIE_MEMSIZE];
173:
174: /* the active TLB entries for each page map entry on the board: */
1.1.1.3 root 175: struct tme_token *tme_sun_mie_tlb_tokens[TME_SUN_MIE_PGMAP_COUNT * TME_SUN_MIE_PGMAP_TLBS];
1.1 root 176: unsigned int tme_sun_mie_tlb_head[TME_SUN_MIE_PGMAP_COUNT];
177:
178: /* the i825x6 image of the CSR: */
179: tme_uint16_t tme_sun_mie_csr_i825x6;
180:
181: #ifndef TME_NO_LOG
182: tme_uint16_t tme_sun_mie_last_log_csr;
183: #endif /* !TME_NO_LOG */
184: };
185:
186: /* a sun_mie internal bus connection: */
187: struct tme_sun_mie_connection {
188:
189: /* the external bus connection: */
190: struct tme_bus_connection tme_sun_mie_connection;
191:
192: /* this is nonzero if a TME_CONNECTION_BUS_GENERIC chip connection
193: is for the registers: */
194: tme_uint8_t tme_sun_mie_connection_regs;
195:
196: /* if this connection is for the memory port, this is the high
197: nibble (A19..A16) of that port's connection: */
198: tme_uint8_t tme_sun_mie_connection_mpmhi;
199: };
200:
201: /* globals: */
202:
203: /* our bus signals sets: */
204: static const struct tme_bus_signals _tme_sun_mie_bus_signals_generic = TME_BUS_SIGNALS_GENERIC;
205: static const struct tme_bus_signals _tme_sun_mie_bus_signals_i825x6 = TME_BUS_SIGNALS_I825X6;
206:
1.1.1.4 ! root 207: extern int printf(const char *format, ...);
! 208:
1.1 root 209: /* the sun_mie callout function. it must be called with the mutex locked: */
210: static void
211: _tme_sun_mie_callout(struct tme_sun_mie *sun_mie, int new_callouts)
212: {
213: struct tme_bus_connection *conn_i825x6;
214: struct tme_bus_connection *conn_bus;
215: tme_uint16_t csr, csr_diff;
216: unsigned int signal, level;
217: int callouts, later_callouts;
218: int rc;
219: int int_asserted;
220:
221: /* add in any new callouts: */
222: sun_mie->tme_sun_mie_callout_flags |= new_callouts;
223:
224: /* if this function is already running in another thread, simply
225: return now. the other thread will do our work: */
226: if (sun_mie->tme_sun_mie_callout_flags & TME_SUN_MIE_CALLOUT_RUNNING) {
227: return;
228: }
229:
230: /* callouts are now running: */
231: sun_mie->tme_sun_mie_callout_flags |= TME_SUN_MIE_CALLOUT_RUNNING;
232:
233: /* assume that we won't need any later callouts: */
234: later_callouts = 0;
235:
236: /* loop while callouts are needed: */
237: for (; (callouts = sun_mie->tme_sun_mie_callout_flags) & TME_SUN_MIE_CALLOUTS_MASK; ) {
238:
239: /* clear the needed callouts: */
240: sun_mie->tme_sun_mie_callout_flags = callouts & ~TME_SUN_MIE_CALLOUTS_MASK;
241: callouts &= TME_SUN_MIE_CALLOUTS_MASK;
242:
243: /* if we need to call out one or more signals to the i825x6: */
244: if (callouts & TME_SUN_MIE_CALLOUT_SIGNALS) {
245:
246: /* get the current CSR value: */
247: csr = TME_SUN_MIE_CSR_GET(sun_mie);
248:
249: /* get the next signal to call out to the i825x6: */
250: csr_diff = ((csr
251: ^ sun_mie->tme_sun_mie_csr_i825x6)
252: & (TME_SUN_MIE_CSR_RESET
253: | TME_SUN_MIE_CSR_NOLOOP
254: | TME_SUN_MIE_CSR_CA));
255: csr_diff = (csr_diff ^ (csr_diff - 1)) & csr_diff;
256:
257: /* if there is a signal to call out: */
258: if (csr_diff != 0) {
259:
260: /* assume that if the signal's bit is set in the CSR, it will
261: be asserted: */
262: level = csr & csr_diff;
263:
264: /* assume that we're calling out an i825x6 signal: */
265: signal = (_tme_sun_mie_bus_signals_generic.tme_bus_signals_first
266: + TME_BUS_SIGNAL_X(_tme_sun_mie_bus_signals_generic.tme_bus_signals_count));
267:
268: /* dispatch on the CSR bit: */
269: switch (csr_diff) {
270: default:
271: assert (FALSE);
272: case TME_SUN_MIE_CSR_RESET:
273: signal = TME_BUS_SIGNAL_RESET;
274: break;
275: case TME_SUN_MIE_CSR_NOLOOP:
276: signal += TME_I825X6_SIGNAL_LOOP;
277: level = !level;
278: break;
279: case TME_SUN_MIE_CSR_CA:
280: signal += TME_I825X6_SIGNAL_CA;
281: break;
282: }
283:
284: /* create a real signal level value: */
285: level = (level
286: ? TME_BUS_SIGNAL_LEVEL_ASSERTED
287: : TME_BUS_SIGNAL_LEVEL_NEGATED);
288:
289: /* get this card's i825x6 connection: */
290: conn_i825x6 = sun_mie->tme_sun_mie_conn_i825x6;
291:
292: /* unlock the mutex: */
293: tme_mutex_unlock(&sun_mie->tme_sun_mie_mutex);
294:
1.1.1.4 ! root 295: #if 1
! 296: printf("callout conn_i825x6->tme_bus_signal; signal %x, level %x; %x\n",
! 297: (int)signal, (int)level, (int)(signal | level));
! 298: #endif
! 299:
! 300: if (signal)
1.1 root 301: /* do the callout: */
302: rc = (conn_i825x6 != NULL
303: ? ((*conn_i825x6->tme_bus_signal)
304: (conn_i825x6,
305: signal | level))
306: : TME_OK);
307:
308: /* lock the mutex: */
309: tme_mutex_lock(&sun_mie->tme_sun_mie_mutex);
310:
311: /* if the callout was unsuccessful, remember that at some later
312: time this callout should be attempted again: */
313: if (rc != TME_OK) {
314: later_callouts |= TME_SUN_MIE_CALLOUT_SIGNALS;
315: }
316:
317: /* otherwise, the callout was successful: */
318: else {
319:
320: /* update the i825x6 image of the CSR: */
321: sun_mie->tme_sun_mie_csr_i825x6 =
322: ((sun_mie->tme_sun_mie_csr_i825x6 & ~csr_diff)
323: | (csr & csr_diff));
324:
325: /* there may be more signals to call out, so attempt this
326: callout again now: */
327: sun_mie->tme_sun_mie_callout_flags |= TME_SUN_MIE_CALLOUT_SIGNALS;
328: }
329: }
330: }
331:
332: /* if we need to call out a possible change to our interrupt
333: signal: */
334: if (callouts & TME_SUN_MIE_CALLOUT_INT) {
335:
336: /* get the current CSR value: */
337: csr = TME_SUN_MIE_CSR_GET(sun_mie);
338:
339: /* see if the interrupt signal should be asserted or negated: */
340: int_asserted = ((csr & (TME_SUN_MIE_CSR_IE
341: | TME_SUN_MIE_CSR_INTR))
342: == (TME_SUN_MIE_CSR_IE
343: | TME_SUN_MIE_CSR_INTR));
344:
345: /* if the interrupt signal doesn't already have the right state: */
346: if (!int_asserted != !sun_mie->tme_sun_mie_int_asserted) {
347:
348: /* get our bus connection: */
349: conn_bus = sun_mie->tme_sun_mie_conn_regs;
350:
351: /* unlock our mutex: */
352: tme_mutex_unlock(&sun_mie->tme_sun_mie_mutex);
353:
354: /* call out the bus interrupt signal edge: */
355: rc = (conn_bus != NULL
356: ? ((*conn_bus->tme_bus_signal)
357: (conn_bus,
358: TME_BUS_SIGNAL_INT_UNSPEC
359: | (int_asserted
360: ? TME_BUS_SIGNAL_LEVEL_ASSERTED
361: : TME_BUS_SIGNAL_LEVEL_NEGATED)))
362: : TME_OK);
363:
364: /* lock our mutex: */
365: tme_mutex_lock(&sun_mie->tme_sun_mie_mutex);
366:
367: /* if this callout was successful, note the new state of the
368: interrupt signal: */
369: if (rc == TME_OK) {
1.1.1.4 ! root 370: #if 1
! 371: printf("IE assert int %x, csr %x\n", (int)int_asserted, (int)csr);
! 372: #endif
1.1 root 373: sun_mie->tme_sun_mie_int_asserted = int_asserted;
374: }
375:
376: /* otherwise, remember that at some later time this callout
377: should be attempted again: */
378: else {
379: later_callouts |= TME_SUN_MIE_CALLOUT_INT;
380: }
381: }
382: }
383: }
384:
385: /* put in any later callouts, and clear that callouts are running: */
386: sun_mie->tme_sun_mie_callout_flags = later_callouts;
387: }
388:
389: /* the sun_mie bus cycle handler for the board memory: */
390: static int
391: _tme_sun_mie_bus_cycle(void *_sun_mie,
392: struct tme_bus_cycle *cycle_init)
393: {
394: struct tme_sun_mie *sun_mie;
395:
396: /* recover our data structure: */
397: sun_mie = (struct tme_sun_mie *) _sun_mie;
398:
399: /* run the cycle: */
400: tme_bus_cycle_xfer_memory(cycle_init,
401: sun_mie->tme_sun_mie_memory,
402: TME_SUN_MIE_MEMSIZE - 1);
403:
404: /* no faults: */
405: return (TME_OK);
406: }
407:
408: /* the sun_mie bus cycle handler for the board registers: */
409: static int
410: _tme_sun_mie_bus_cycle_regs(void *_sun_mie,
411: struct tme_bus_cycle *cycle_init)
412: {
413: struct tme_sun_mie *sun_mie;
414: unsigned int pgmap_i;
415: unsigned int pgmap_j;
416: unsigned int tlb_i;
417: unsigned int tlb_j;
418: tme_uint16_t csr_old, csr_new, csr_diff;
419: tme_uint16_t pcr_old, pcr_new, pcr_diff;
420: int new_callouts;
421:
1.1.1.4 ! root 422: #if 1
! 423: printf("mie_bus_cycle_regs; type %x, addr %x, size %d, %02x %02x\n",
! 424: (int)cycle_init->tme_bus_cycle_type,
! 425: (int)cycle_init->tme_bus_cycle_address,
! 426: (int)cycle_init->tme_bus_cycle_size,
! 427: (int)cycle_init->tme_bus_cycle_buffer[0],
! 428: (int)cycle_init->tme_bus_cycle_buffer[1]);
! 429: #endif
! 430:
1.1 root 431: /* recover our data structure: */
432: sun_mie = (struct tme_sun_mie *) _sun_mie;
433:
434: /* assume we won't need any new callouts: */
435: new_callouts = 0;
436:
437: /* lock the mutex: */
438: tme_mutex_lock(&sun_mie->tme_sun_mie_mutex);
439:
440: /* if this is a write cycle and the address falls within one or more
441: page map entries, invalidate the TLBs associated with those
442: entries: */
443: if ((cycle_init->tme_bus_cycle_type
444: & TME_BUS_CYCLE_WRITE)
445: && (TME_SUN_MIE_REG_PGMAP
446: <= cycle_init->tme_bus_cycle_address)
447: && (cycle_init->tme_bus_cycle_address
448: < (TME_SUN_MIE_REG_PGMAP
449: + TME_SUN_MIE_SIZ_PGMAP))) {
450:
451: /* get the range of page map entries: */
452: pgmap_i
453: = (cycle_init->tme_bus_cycle_address
454: / sizeof(tme_uint16_t));
455: pgmap_j
456: = ((cycle_init->tme_bus_cycle_address
457: + cycle_init->tme_bus_cycle_size
458: + sizeof(tme_uint16_t)
459: - 1)
460: / sizeof(tme_uint16_t));
461: pgmap_j = TME_MIN(pgmap_j, TME_SUN_MIE_PGMAP_COUNT);
462:
463: /* get the range of TLB handles: */
464: tlb_i = pgmap_i * TME_SUN_MIE_PGMAP_TLBS;
465: tlb_j = pgmap_j * TME_SUN_MIE_PGMAP_TLBS;
466:
467: /* invalidate the TLB entries: */
468: for (; tlb_i < tlb_j; tlb_i++) {
1.1.1.3 root 469: if (sun_mie->tme_sun_mie_tlb_tokens[tlb_i] != NULL) {
470: tme_token_invalidate(sun_mie->tme_sun_mie_tlb_tokens[tlb_i]);
471: sun_mie->tme_sun_mie_tlb_tokens[tlb_i] = NULL;
1.1 root 472: }
473: }
474: }
475:
476: /* get the previous CSR and PCR values: */
477: csr_old = TME_SUN_MIE_CSR_GET(sun_mie);
478: pcr_old = TME_SUN_MIE_PCR_GET(sun_mie);
479:
480: /* unless this address falls within the PROM, run the cycle: */
481: if ((cycle_init->tme_bus_cycle_address
482: < TME_SUN_MIE_REG_PROM)
483: || (cycle_init->tme_bus_cycle_address
484: >= (TME_SUN_MIE_REG_PROM
485: + TME_SUN_MIE_SIZ_PROM))) {
486: tme_bus_cycle_xfer_memory(cycle_init,
487: sun_mie->tme_sun_mie_regs,
488: TME_SUN_MIE_SIZ_REGS - 1);
489: }
490:
491: /* get the current CSR and PCR values, and put back any bits that
492: software can't change: */
493: csr_new = ((TME_SUN_MIE_CSR_GET(sun_mie)
494: & ~TME_SUN_MIE_CSR_READONLY)
495: | (csr_old
496: & TME_SUN_MIE_CSR_READONLY));
1.1.1.4 ! root 497: #if 1
! 498: printf("csr_new %x, csr_old %x, csr %x\n",
! 499: (int)csr_new, (int)csr_old, (int)TME_SUN_MIE_CSR_GET(sun_mie));
! 500: #endif
1.1 root 501: TME_SUN_MIE_CSR_PUT(sun_mie, csr_new);
502: pcr_new = ((TME_SUN_MIE_PCR_GET(sun_mie)
503: & ~TME_SUN_MIE_PCR_READONLY)
504: | (pcr_old
505: & TME_SUN_MIE_PCR_READONLY));
506: TME_SUN_MIE_PCR_PUT(sun_mie, pcr_new);
507:
508: /* get the sets of CSR and PCR bits that have changed: */
509: csr_diff = (csr_old ^ csr_new);
510: pcr_diff = (pcr_old ^ pcr_new);
511:
512: /* if this is a RESET, NOLOOP or CA change, possibly call out the
513: appropriate signal change to the i825x6: */
514: if (csr_diff & (TME_SUN_MIE_CSR_RESET
515: | TME_SUN_MIE_CSR_NOLOOP
516: | TME_SUN_MIE_CSR_CA)) {
517: new_callouts |= TME_SUN_MIE_CALLOUT_SIGNALS;
518: }
519:
520: /* if this is an interrupt mask change, possibly call out an
521: interrupt signal change to the bus: */
522: if (csr_diff & TME_SUN_MIE_CSR_IE) {
523: new_callouts |= TME_SUN_MIE_CALLOUT_INT;
524: }
525:
526: /* abort on any attempt to enable the P2 bus: */
527: if (csr_new & TME_SUN_MIE_CSR_P2MEM) {
528: abort ();
529: }
530:
531: /* if this is acknowledging a parity error: */
532: if (pcr_diff & TME_SUN_MIE_PCR_PEACK) {
533: /* nothing to do */
534: }
535:
1.1.1.4 ! root 536: #if 1
! 537: printf("IE now csr %x, tme_sun_mie_int_asserted %x\n",
! 538: (int)csr_new, (int)sun_mie->tme_sun_mie_int_asserted);
! 539: #endif
! 540:
1.1 root 541: #ifndef TME_NO_LOG
542: if (csr_new != sun_mie->tme_sun_mie_last_log_csr) {
543: sun_mie->tme_sun_mie_last_log_csr = csr_new;
544: tme_log(&sun_mie->tme_sun_mie_element->tme_element_log_handle,
545: 1000, TME_OK,
546: (&sun_mie->tme_sun_mie_element->tme_element_log_handle,
547: "csr now 0x%04x",
548: csr_new));
549: }
550: #endif /* !TME_NO_LOG */
551:
1.1.1.4 ! root 552: #if 1
! 553: if (cycle_init->tme_bus_cycle_type & TME_BUS_CYCLE_WRITE)
! 554: if (sun_mie->tme_sun_mie_pending_deassert_intr) {
! 555: sun_mie->tme_sun_mie_pending_deassert_intr = 0;
! 556: printf("turning off pending intr\n");
! 557: csr_new &= ~TME_SUN_MIE_CSR_INTR;
! 558: TME_SUN_MIE_CSR_PUT(sun_mie, csr_new);
! 559: }
! 560: #endif
! 561:
1.1 root 562: /* make any new callouts: */
563: _tme_sun_mie_callout(sun_mie, new_callouts);
564:
565: /* unlock the mutex: */
566: tme_mutex_unlock(&sun_mie->tme_sun_mie_mutex);
567:
568: /* no faults: */
569: return (TME_OK);
570: }
571:
572: /* the sun_mie bus signal handler: */
573: static int
574: _tme_sun_mie_bus_signal(struct tme_bus_connection *conn_bus,
575: unsigned int signal)
576: {
577: struct tme_sun_mie *sun_mie;
578:
1.1.1.4 ! root 579: #if 1
! 580: printf("_tme_sun_mie_bus_signal() %x, index %d, count %d\n",
! 581: (int)signal,
! 582: (int)TME_BUS_SIGNAL_INDEX(signal),
! 583: (int)_tme_sun_mie_bus_signals_generic.tme_bus_signals_count);
! 584: #endif
! 585:
1.1 root 586: /* return now if this is not a generic bus signal: */
587: if (TME_BUS_SIGNAL_INDEX(signal)
588: > _tme_sun_mie_bus_signals_generic.tme_bus_signals_count) {
589: return (TME_OK);
590: }
591:
592: /* recover our data structures: */
593: sun_mie = conn_bus->tme_bus_connection.tme_connection_element->tme_element_private;
594:
1.1.1.4 ! root 595: #if 1
! 596: printf("_tme_sun_mie_bus_signal() doing it %x\n", (int)signal);
! 597: #endif
! 598:
! 599: #if 1
! 600: if (TME_BUS_SIGNAL_WHICH(signal) == TME_BUS_SIGNAL_INT_UNSPEC)
! 601: {
! 602: tme_uint16_t csr;
! 603: unsigned int level;
! 604: csr = TME_SUN_MIE_CSR_GET(sun_mie);
! 605: level = signal & TME_BUS_SIGNAL_LEVEL_MASK;
! 606:
! 607: if (level == TME_BUS_SIGNAL_LEVEL_ASSERTED) {
! 608: printf("assert csr intr!\n");
! 609: csr |= TME_SUN_MIE_CSR_INTR;
! 610: TME_SUN_MIE_CSR_PUT(sun_mie, csr);
! 611: }
! 612: if (level == TME_BUS_SIGNAL_LEVEL_NEGATED) {
! 613: printf("deassert csr intr!\n");
! 614: // csr &= ~TME_SUN_MIE_CSR_INTR;
! 615: // TME_SUN_MIE_CSR_PUT(sun_mie, csr);
! 616: sun_mie->tme_sun_mie_pending_deassert_intr = 1;
! 617: }
! 618: }
! 619: #endif
! 620:
1.1 root 621: /* since this function is currently only given to the i825x6,
622: just copy its signal through to the Multibus: */
623: conn_bus = sun_mie->tme_sun_mie_conn_regs;
624: return ((*conn_bus->tme_bus_signal)(conn_bus, signal));
625: }
626:
627: /* the sun_mie bus signals adder for the i825x6: */
628: static int
629: _tme_sun_mie_bus_signals_add(struct tme_bus_connection *conn_bus,
630: struct tme_bus_signals *bus_signals_caller)
631: {
632: const struct tme_bus_signals *bus_signals;
633: tme_uint32_t signal_first;
634:
635: /* we only support the generic and i825x6 bus signals: */
636: switch (bus_signals_caller->tme_bus_signals_id) {
637: case TME_BUS_SIGNALS_ID_GENERIC:
638: bus_signals = &_tme_sun_mie_bus_signals_generic;
639: signal_first = _tme_sun_mie_bus_signals_generic.tme_bus_signals_first;
640: break;
641: case TME_BUS_SIGNALS_ID_I825X6:
642: bus_signals = &_tme_sun_mie_bus_signals_i825x6;
643: signal_first = (_tme_sun_mie_bus_signals_generic.tme_bus_signals_first
644: + TME_BUS_SIGNAL_X(_tme_sun_mie_bus_signals_generic.tme_bus_signals_count));
645: break;
646: default:
647: return (ENOENT);
648: }
649:
650: /* XXX we should check versions here: */
651: *bus_signals_caller = *bus_signals;
652: bus_signals_caller->tme_bus_signals_first = signal_first;
653: return (TME_OK);
654: }
655:
1.1.1.3 root 656: /* the sun_mie TLB adder for the i825x6: */
1.1 root 657: static int
1.1.1.3 root 658: _tme_sun_mie_tlb_set_add(struct tme_bus_connection *conn_bus,
659: struct tme_bus_tlb_set_info *tlb_set_info)
1.1 root 660: {
661:
1.1.1.3 root 662: /* if this TLB set provides a bus context register: */
663: if (tlb_set_info->tme_bus_tlb_set_info_bus_context != NULL) {
664:
665: /* this bus only has one context: */
666: (*tlb_set_info->tme_bus_tlb_set_info_bus_context) = 0;
667: tlb_set_info->tme_bus_tlb_set_info_bus_context_max = 0;
1.1 root 668: }
1.1.1.3 root 669:
1.1 root 670: return (TME_OK);
671: }
672:
673: /* the sun_mie TLB filler for the board memory: */
674: static int
675: _tme_sun_mie_tlb_fill(struct tme_bus_connection *conn_bus,
676: struct tme_bus_tlb *tlb,
1.1.1.3 root 677: tme_bus_addr_t address_wider,
1.1 root 678: unsigned int cycles)
679: {
680: struct tme_sun_mie *sun_mie;
1.1.1.3 root 681: tme_bus_addr32_t address;
1.1 root 682: unsigned int pgmap_i;
683: unsigned int tlb_i;
684: tme_uint16_t pgmap;
685:
686: /* recover our data structures: */
687: sun_mie = conn_bus->tme_bus_connection.tme_connection_element->tme_element_private;
688:
1.1.1.3 root 689: /* get the normal-width address: */
690: address = address_wider;
691: assert (address == address_wider);
692:
1.1 root 693: /* the address must be within range: */
694: assert(address <= 0xffffff);
695:
696: /* mask the address with the board page size: */
697: address &= -TME_SUN_MIE_PAGESIZE;
698:
699: /* lock our mutex: */
700: tme_mutex_lock(&sun_mie->tme_sun_mie_mutex);
701:
702: /* get the pagemap entry: */
703: pgmap_i = (address / TME_SUN_MIE_PAGESIZE) & (TME_SUN_MIE_PGMAP_COUNT - 1);
704: pgmap = tme_betoh_u16(((tme_uint16_t *) &sun_mie->tme_sun_mie_regs[TME_SUN_MIE_REG_PGMAP])[pgmap_i]);
705:
706: /* update the head pointer for this page map entry's active TLB
707: entry list: */
708: tlb_i = sun_mie->tme_sun_mie_tlb_head[pgmap_i];
709: if (++tlb_i == TME_SUN_MIE_PGMAP_TLBS) {
710: tlb_i = 0;
711: }
712: sun_mie->tme_sun_mie_tlb_head[pgmap_i] = tlb_i;
713: tlb_i += pgmap_i * TME_SUN_MIE_PGMAP_TLBS;
714:
715: /* if the new head pointer already has a TLB entry, and it doesn't
716: happen to be the same one that we're filling now, invalidate it: */
1.1.1.3 root 717: if (sun_mie->tme_sun_mie_tlb_tokens[tlb_i] != NULL
718: && sun_mie->tme_sun_mie_tlb_tokens[tlb_i] != tlb->tme_bus_tlb_token) {
719: tme_token_invalidate(sun_mie->tme_sun_mie_tlb_tokens[tlb_i]);
1.1 root 720: }
721:
722: /* initialize the TLB entry: */
723: tme_bus_tlb_initialize(tlb);
724:
725: /* this TLB entry covers this range: */
1.1.1.2 root 726: tlb->tme_bus_tlb_addr_first = address;
727: tlb->tme_bus_tlb_addr_last = address | (TME_SUN_MIE_PAGESIZE - 1);
1.1 root 728:
729: /* allow reading and writing: */
730: tlb->tme_bus_tlb_cycles_ok = TME_BUS_CYCLE_READ | TME_BUS_CYCLE_WRITE;
731:
732: /* our bus cycle handler: */
733: tlb->tme_bus_tlb_cycle_private = sun_mie;
734: tlb->tme_bus_tlb_cycle = _tme_sun_mie_bus_cycle;
735:
736: /* this TLB entry allows fast reading and writing: */
737: tlb->tme_bus_tlb_emulator_off_write =
738: (&sun_mie->tme_sun_mie_memory[((pgmap & TME_SUN_MIE_PGMAP_PFNUM)
739: * TME_SUN_MIE_PAGESIZE)]
740: - address);
741: tlb->tme_bus_tlb_emulator_off_read =
742: tlb->tme_bus_tlb_emulator_off_write;
743:
1.1.1.4 ! root 744: #if 1
! 745: printf("_tme_sun_mie_tlb_fill() tlb first %08x, last %08x, off_write %08x\n",
! 746: (int)tlb->tme_bus_tlb_addr_first,
! 747: (int)tlb->tme_bus_tlb_addr_last,
! 748: (int)tlb->tme_bus_tlb_emulator_off_write);
! 749: #endif
! 750:
1.1 root 751: /* add this TLB entry to the active list: */
1.1.1.3 root 752: sun_mie->tme_sun_mie_tlb_tokens[tlb_i] =
753: tlb->tme_bus_tlb_token;
1.1 root 754:
755: /* unlock our mutex: */
756: tme_mutex_unlock(&sun_mie->tme_sun_mie_mutex);
757:
758: return (TME_OK);
759: }
760:
761: /* the sun_mie TLB filler for the board registers: */
762: static int
763: _tme_sun_mie_tlb_fill_regs(struct tme_bus_connection *conn_bus,
764: struct tme_bus_tlb *tlb,
1.1.1.3 root 765: tme_bus_addr_t address_wider,
766: unsigned int cycles)
1.1 root 767: {
768: struct tme_sun_mie *sun_mie;
1.1.1.3 root 769: tme_bus_addr32_t address;
1.1 root 770:
771: /* recover our data structures: */
772: sun_mie = conn_bus->tme_bus_connection.tme_connection_element->tme_element_private;
773:
1.1.1.3 root 774: /* get the normal-width address: */
775: address = address_wider;
776: assert (address == address_wider);
777:
1.1 root 778: /* the address must be within range: */
779: assert(address < TME_SUN_MIE_SIZ_REGS);
780:
781: /* initialize the TLB entry: */
782: tme_bus_tlb_initialize(tlb);
783:
784: /* if the address falls in the page map: */
785: if (TME_SUN_MIE_REG_PGMAP <= address
786: && address < (TME_SUN_MIE_REG_PGMAP
787: + TME_SUN_MIE_SIZ_PGMAP)) {
788:
789: /* this TLB entry covers this range: */
1.1.1.2 root 790: tlb->tme_bus_tlb_addr_first = TME_SUN_MIE_REG_PGMAP;
791: tlb->tme_bus_tlb_addr_last = (TME_SUN_MIE_REG_PGMAP + TME_SUN_MIE_SIZ_PGMAP - 1);
1.1 root 792: }
793:
794: /* if this address falls in the PROM: */
795: else if (TME_SUN_MIE_REG_PROM <= address
796: && address < (TME_SUN_MIE_REG_PROM
797: + TME_SUN_MIE_SIZ_PROM)) {
798:
799:
800: /* this TLB entry covers this range: */
1.1.1.2 root 801: tlb->tme_bus_tlb_addr_first = TME_SUN_MIE_REG_PROM;
802: tlb->tme_bus_tlb_addr_last = TME_SUN_MIE_REG_PROM + TME_SUN_MIE_SIZ_PROM - 1;
1.1 root 803: }
804:
805: /* if this address falls in the CSR: */
806: else if (TME_SUN_MIE_REG_CSR <= address
807: && address < (TME_SUN_MIE_REG_CSR
808: + TME_SUN_MIE_SIZ_CSR)) {
809:
810:
811: /* this TLB entry covers this range: */
1.1.1.2 root 812: tlb->tme_bus_tlb_addr_first = TME_SUN_MIE_REG_CSR;
813: tlb->tme_bus_tlb_addr_last = TME_SUN_MIE_REG_CSR + TME_SUN_MIE_SIZ_CSR - 1;
1.1 root 814: }
815:
816: /* otherwise, this address must fall in the unused hole or in the
817: parity registers: */
818: else {
819: assert (address >= (TME_SUN_MIE_REG_CSR
820: + TME_SUN_MIE_SIZ_CSR));
821:
822: /* this TLB entry covers this range: */
1.1.1.2 root 823: tlb->tme_bus_tlb_addr_first = (TME_SUN_MIE_REG_CSR + TME_SUN_MIE_SIZ_CSR);
824: tlb->tme_bus_tlb_addr_last = (TME_SUN_MIE_REG_PE_ALO + TME_SUN_MIE_SIZ_PE_ALO - 1);
1.1 root 825: }
826:
827: /* all address ranges allow fast reading: */
828: tlb->tme_bus_tlb_emulator_off_read = &sun_mie->tme_sun_mie_regs[0];
829: tlb->tme_bus_tlb_rwlock = &sun_mie->tme_sun_mie_rwlock;
830:
1.1.1.4 ! root 831: #if 0
! 832: /* XXX when debugging, nothing is fast readable or writable: */
! 833: tlb->tme_bus_tlb_emulator_off_read = TME_EMULATOR_OFF_UNDEF;
! 834: tlb->tme_bus_tlb_emulator_off_write = TME_EMULATOR_OFF_UNDEF;
! 835: #endif
! 836:
1.1 root 837: /* allow reading and writing: */
838: tlb->tme_bus_tlb_cycles_ok = TME_BUS_CYCLE_READ | TME_BUS_CYCLE_WRITE;
839:
840: /* our bus cycle handler: */
841: tlb->tme_bus_tlb_cycle_private = sun_mie;
842: tlb->tme_bus_tlb_cycle = _tme_sun_mie_bus_cycle_regs;
843:
844: return (TME_OK);
845: }
846:
847: /* this scores a new connection: */
848: static int
849: _tme_sun_mie_connection_score(struct tme_connection *conn, unsigned int *_score)
850: {
851: struct tme_sun_mie *sun_mie;
852: struct tme_sun_mie_connection *conn_sun_mie;
853:
854: /* both sides must be generic bus connections: */
855: assert(conn->tme_connection_type == TME_CONNECTION_BUS_GENERIC);
856: assert(conn->tme_connection_other->tme_connection_type
857: == conn->tme_connection_type);
858:
859: /* recover our data structures: */
860: sun_mie = conn->tme_connection_element->tme_element_private;
861: conn_sun_mie = (struct tme_sun_mie_connection *)conn;
862:
863: /* this is a generic bus connection, so just score it nonzero and
864: return. note that there's no good way to differentiate a
865: connection to a bus from a connection to just another chip, so we
866: always return a nonzero score here: */
867: *_score = 1;
868: return (TME_OK);
869: }
870:
871: /* this makes a new connection: */
872: static int
873: _tme_sun_mie_connection_make(struct tme_connection *conn, unsigned int state)
874: {
875: struct tme_sun_mie *sun_mie;
876: struct tme_sun_mie_connection *conn_sun_mie;
877: struct tme_bus_connection *conn_bus;
878: tme_uint16_t csr;
879:
880: /* both sides must be generic bus connections: */
881: assert(conn->tme_connection_type == TME_CONNECTION_BUS_GENERIC);
882: assert(conn->tme_connection_other->tme_connection_type
883: == conn->tme_connection_type);
884:
885: /* recover our data structures: */
886: sun_mie = conn->tme_connection_element->tme_element_private;
887: conn_sun_mie = (struct tme_sun_mie_connection *)conn;
888: conn_bus = &conn_sun_mie->tme_sun_mie_connection;
889:
890: /* we're always set up to answer calls across the connection, so we
891: only have to do work when the connection has gone full, namely
892: taking the other side of the connection: */
893: if (state == TME_CONNECTION_FULL) {
894:
895: /* lock our mutex: */
896: tme_mutex_lock(&sun_mie->tme_sun_mie_mutex);
897:
898: /* save our connection: */
899: if (conn_bus->tme_bus_signals_add != NULL) {
900: sun_mie->tme_sun_mie_conn_i825x6 = (struct tme_bus_connection *) conn->tme_connection_other;
901: }
902: else if (conn_sun_mie->tme_sun_mie_connection_regs) {
903: sun_mie->tme_sun_mie_conn_regs = (struct tme_bus_connection *) conn->tme_connection_other;
904: }
905: else {
906: sun_mie->tme_sun_mie_conn_memory = (struct tme_bus_connection *) conn->tme_connection_other;
907: csr = TME_SUN_MIE_CSR_GET(sun_mie);
908: csr &= ~TME_SUN_MIE_CSR_MPMHI;
909: csr |= conn_sun_mie->tme_sun_mie_connection_mpmhi;
910: TME_SUN_MIE_CSR_PUT(sun_mie, csr);
911: }
912:
913: /* unlock our mutex: */
914: tme_mutex_unlock(&sun_mie->tme_sun_mie_mutex);
915: }
916:
917: return (TME_OK);
918: }
919:
920: /* this breaks a connection: */
921: static int
922: _tme_sun_mie_connection_break(struct tme_connection *conn, unsigned int state)
923: {
924: abort();
925: }
926:
927: /* this makes a new connection side for a sun_mie: */
928: static int
929: _tme_sun_mie_connections_new(struct tme_element *element,
930: const char * const *args,
931: struct tme_connection **_conns,
932: char **_output)
933: {
934: struct tme_sun_mie *sun_mie;
935: struct tme_sun_mie_connection *conn_sun_mie;
936: struct tme_bus_connection *conn_bus;
937: struct tme_connection *conn;
938: unsigned int i825x6;
939: tme_uint8_t regs;
940: tme_bus_addr_t mpmhi;
941: int usage;
942: int rc;
943:
944: /* recover our data structure: */
945: sun_mie = (struct tme_sun_mie *) element->tme_element_private;
946:
947: /* we don't bother locking the mutex simply to check if connections
948: already exist: */
949:
950: /* check our arguments: */
951: usage = FALSE;
952: rc = 0;
953: i825x6 = FALSE;
954: regs = FALSE;
955: mpmhi = 0;
956:
957: /* if this connection is for the registers: */
958: if (TME_ARG_IS(args[1], "csr")) {
959:
960: /* if we already have a register connection, complain: */
961: if (sun_mie->tme_sun_mie_conn_regs != NULL) {
962: rc = EEXIST;
963: }
964:
965: /* otherwise, make the new connection: */
966: else {
967: regs = TRUE;
968: }
969: }
970:
971: /* else, if this connection is for the memory: */
972: else if (TME_ARG_IS(args[1], "memory")) {
973:
974: /* if we already have a memory connection, complain: */
975: if (sun_mie->tme_sun_mie_conn_memory != NULL) {
976: rc = EEXIST;
977: }
978:
979: /* otherwise, check the value after "memory". it must be the low
980: 20 bits of the bus address of the board's memory; in our csr we
981: have to report the most significant nibble (A19-A16, as A15..A0
982: are expected to be zero) to software so it can find that
983: memory: */
984: else {
985: mpmhi = tme_bus_addr_parse_any(args[2], &usage);
986: if (!usage
987: && ((mpmhi > 0xfffff)
988: || (mpmhi & (TME_SUN_MIE_SIZ_MBM - 1)))) {
989: tme_output_append_error(_output,
990: "%s %s, ",
991: args[2],
992: _(" is not a 20-bit address with A15..A0 zero"));
993: usage = TRUE;
994: }
995: }
996: }
997:
998: /* else, the connection must be for the i825x6: */
999: else if (args[1] == NULL) {
1000:
1001: /* if we already have an i825x6 connection, complain: */
1002: if (sun_mie->tme_sun_mie_conn_i825x6 != NULL) {
1003: rc = EEXIST;
1004: }
1005:
1006: /* otherwise, make the new conection: */
1007: else {
1008: i825x6 = TRUE;
1009: }
1010: }
1011:
1012: /* otherwise, this is a bad argument: */
1013: else {
1014: tme_output_append_error(_output,
1015: "%s %s, ",
1016: args[1],
1017: _("unexpected"));
1018: usage = TRUE;
1019: }
1020:
1021: if (usage) {
1022: tme_output_append_error(_output,
1023: "%s %s [ csr | memory %s ]",
1024: _("usage:"),
1025: args[0],
1026: _("BUS-ADDRESS"));
1027: rc = EINVAL;
1028: }
1029:
1030: if (rc) {
1031: return (rc);
1032: }
1033:
1034: /* make a new connection: */
1035: conn_sun_mie = tme_new0(struct tme_sun_mie_connection, 1);
1036: conn_bus = &conn_sun_mie->tme_sun_mie_connection;
1037: conn = &conn_bus->tme_bus_connection;
1038:
1039: /* fill in the generic connection: */
1040: conn->tme_connection_next = *_conns;
1041: conn->tme_connection_type = TME_CONNECTION_BUS_GENERIC;
1042: conn->tme_connection_score = _tme_sun_mie_connection_score;
1043: conn->tme_connection_make = _tme_sun_mie_connection_make;
1044: conn->tme_connection_break = _tme_sun_mie_connection_break;
1045:
1046: /* fill in the generic bus connection: */
1047: conn_bus->tme_bus_subregions.tme_bus_subregion_address_first = 0;
1048: conn_bus->tme_bus_subregions.tme_bus_subregion_next = NULL;
1049: if (i825x6) {
1050: conn_bus->tme_bus_subregions.tme_bus_subregion_address_last = 0xffffff;
1051: conn_bus->tme_bus_signals_add = _tme_sun_mie_bus_signals_add;
1052: conn_bus->tme_bus_signal = _tme_sun_mie_bus_signal;
1.1.1.3 root 1053: conn_bus->tme_bus_tlb_set_add = _tme_sun_mie_tlb_set_add;
1.1 root 1054: conn_bus->tme_bus_tlb_fill = _tme_sun_mie_tlb_fill;
1055: }
1056: else if (regs) {
1057: conn_bus->tme_bus_subregions.tme_bus_subregion_address_last = TME_SUN_MIE_SIZ_REGS - 1;
1058: conn_bus->tme_bus_tlb_fill = _tme_sun_mie_tlb_fill_regs;
1059: }
1060: else {
1061: conn_bus->tme_bus_subregions.tme_bus_subregion_address_last = TME_SUN_MIE_SIZ_MBM - 1;
1062: conn_bus->tme_bus_tlb_fill = _tme_sun_mie_tlb_fill;
1063: }
1064:
1065: /* fill in the internal information: */
1066: conn_sun_mie->tme_sun_mie_connection_regs = regs;
1067: conn_sun_mie->tme_sun_mie_connection_mpmhi = (mpmhi >> 16);
1068:
1069: /* return the connection side possibility: */
1070: *_conns = conn;
1071: return (TME_OK);
1072: }
1073:
1074: /* the new sun_mie function: */
1075: TME_ELEMENT_SUB_NEW_DECL(tme_bus_multibus,sun_mie) {
1076: struct tme_sun_mie *sun_mie;
1077: int arg_i;
1078: int usage;
1079:
1080: /* check our arguments: */
1081: usage = 0;
1082: arg_i = 1;
1083: for (;;) {
1084:
1085: if (0) {
1086: }
1087:
1088: /* if we ran out of arguments: */
1089: else if (args[arg_i] == NULL) {
1090:
1091: break;
1092: }
1093:
1094: /* otherwise this is a bad argument: */
1095: else {
1096: tme_output_append_error(_output,
1097: "%s %s, ",
1098: args[arg_i],
1099: _("unexpected"));
1100: usage = TRUE;
1101: break;
1102: }
1103: }
1104:
1105: if (usage) {
1106: tme_output_append_error(_output,
1107: "%s %s",
1108: _("usage:"),
1109: args[0]);
1110: return (EINVAL);
1111: }
1112:
1113: /* start the sun_mie structure: */
1114: sun_mie = tme_new0(struct tme_sun_mie, 1);
1115: sun_mie->tme_sun_mie_element = element;
1116: TME_SUN_MIE_CSR_PUT(sun_mie,
1117: (TME_SUN_MIE_CSR_NOLOOP
1118: | TME_SUN_MIE_CSR_BIGRAM));
1119: tme_mutex_init(&sun_mie->tme_sun_mie_mutex);
1120: tme_rwlock_init(&sun_mie->tme_sun_mie_rwlock);
1121:
1122: /* fill the element: */
1123: element->tme_element_private = sun_mie;
1124: element->tme_element_connections_new = _tme_sun_mie_connections_new;
1125:
1126: return (TME_OK);
1127: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.