1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
|
/* $OpenBSD: xbow.c,v 1.26 2009/11/25 11:23:30 miod Exp $ */
/*
* Copyright (c) 2008, 2009 Miodrag Vallat.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Copyright (c) 2004 Opsycon AB (www.opsycon.se)
*
* 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.
*
* 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.
*
*/
/*
* XBOW is the mux between two nodes and XIO.
*
* A Crossbow (XBOW) connects two nodeboards via their respecive
* HUB to up to six different I/O controllers in XIO slots. In a
* multiprocessor system all processors have access to the XIO
* slots but may need to pass traffic via the routers.
*
* To each XIO port on the XBOW a XIO interface is attached. Such
* interfaces can be for example PCI bridges wich then add another
* level to the hierarchy.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <mips64/archtype.h>
#include <machine/atomic.h>
#include <machine/autoconf.h>
#include <machine/intr.h>
#include <machine/mnode.h>
#include <sgi/xbow/hub.h>
#include <sgi/xbow/widget.h>
#include <sgi/xbow/xbow.h>
#include <sgi/xbow/xbowdevs.h>
#include <sgi/xbow/xbowdevs_data.h>
int xbowmatch(struct device *, void *, void *);
void xbowattach(struct device *, struct device *, void *);
int xbowprint(void *, const char *);
int xbowsubmatch(struct device *, void *, void *);
int xbow_attach_widget(struct device *, int16_t, int,
int (*)(struct device *, void *, void *), cfprint_t);
int xbow_kl_search_brd(lboard_t *, void *);
int xbow_kl_search_mplane(klinfo_t *, void *);
uint32_t xbow_read_4(bus_space_tag_t, bus_space_handle_t, bus_size_t);
uint64_t xbow_read_8(bus_space_tag_t, bus_space_handle_t, bus_size_t);
void xbow_write_4(bus_space_tag_t, bus_space_handle_t, bus_size_t, uint32_t);
void xbow_write_8(bus_space_tag_t, bus_space_handle_t, bus_size_t, uint64_t);
void xbow_read_raw_4(bus_space_tag_t, bus_space_handle_t, bus_addr_t,
uint8_t *, bus_size_t);
void xbow_write_raw_4(bus_space_tag_t, bus_space_handle_t, bus_addr_t,
const uint8_t *, bus_size_t);
void xbow_read_raw_8(bus_space_tag_t, bus_space_handle_t, bus_addr_t,
uint8_t *, bus_size_t);
void xbow_write_raw_8(bus_space_tag_t, bus_space_handle_t, bus_addr_t,
const uint8_t *, bus_size_t);
void xbow_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
int xbow_space_region(bus_space_tag_t, bus_space_handle_t, bus_size_t,
bus_size_t, bus_space_handle_t *);
void *xbow_space_vaddr(bus_space_tag_t, bus_space_handle_t);
const struct xbow_product *xbow_identify(uint32_t, uint32_t);
struct xbow_softc {
struct device sc_dev;
int16_t sc_nasid;
};
const struct cfattach xbow_ca = {
sizeof(struct xbow_softc), xbowmatch, xbowattach
};
struct cfdriver xbow_cd = {
NULL, "xbow", DV_DULL
};
static const bus_space_t xbowbus_tag = {
(bus_addr_t)0, /* will be modified in widgets bus_space_t */
NULL,
xbow_read_1,
xbow_write_1,
xbow_read_2,
xbow_write_2,
xbow_read_4,
xbow_write_4,
xbow_read_8,
xbow_write_8,
xbow_read_raw_2,
xbow_write_raw_2,
xbow_read_raw_4,
xbow_write_raw_4,
xbow_read_raw_8,
xbow_write_raw_8,
xbow_space_map,
xbow_space_unmap,
xbow_space_region
};
/*
* Function pointers to hide widget discovery and mapping differences accross
* systems.
*/
paddr_t (*xbow_widget_base)(int16_t, u_int);
paddr_t (*xbow_widget_map)(int16_t, u_int, bus_addr_t *, bus_size_t *);
int (*xbow_widget_id)(int16_t, u_int, uint32_t *);
/*
* Attachment glue.
*/
int
xbowmatch(struct device *parent, void *match, void *aux)
{
struct mainbus_attach_args *maa = aux;
if (strcmp(maa->maa_name, xbow_cd.cd_name) != 0)
return (0);
switch (sys_config.system_type) {
case SGI_IP27:
case SGI_IP35:
case SGI_OCTANE:
return (1);
default:
return (0);
}
}
const struct xbow_product *
xbow_identify(uint32_t vendor, uint32_t product)
{
const struct xbow_product *p;
for (p = xbow_products; p->productname != NULL; p++)
if (p->vendor == vendor && p->product == product)
return p;
return NULL;
}
int
xbowprint(void *aux, const char *pnp)
{
struct xbow_attach_args *xaa = aux;
const struct xbow_product *p;
p = xbow_identify(xaa->xaa_vendor, xaa->xaa_product);
if (pnp != NULL) {
if (p != NULL)
printf("\"%s\"", p->productname);
else
printf("vendor %x product %x",
xaa->xaa_vendor, xaa->xaa_product);
printf(" revision %d at %s",
xaa->xaa_revision, pnp);
}
printf(" widget %d", xaa->xaa_widget);
if (pnp == NULL) {
if (p != NULL)
printf(": %s", p->productname);
}
return (UNCONF);
}
int
xbowsubmatch(struct device *parent, void *vcf, void *aux)
{
struct xbow_attach_args *xaa = aux;
struct cfdata *cf = vcf;
if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != xaa->xaa_widget)
return 0;
if (cf->cf_loc[1] != -1 && cf->cf_loc[1] != xaa->xaa_vendor)
return 0;
if (cf->cf_loc[2] != -1 && cf->cf_loc[2] != xaa->xaa_product)
return 0;
return (*cf->cf_attach->ca_match)(parent, vcf, aux);
}
/*
* Widget probe order for various components
*/
/* Octane: probe Heart first, then onboard devices, then other slots */
const uint8_t xbow_probe_octane[] =
{ 0x08, 0x0f, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0 };
/* Origin 200: probe onboard devices, and there is nothing more */
const uint8_t xbow_probe_singlebridge[] =
{ 0x08, 0 };
/* Base I/O board: probe in ascending order */
const uint8_t xbow_probe_baseio[] =
{ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0 };
/* I-Brick: probe PCI buses first (starting with the onboard devices) */
const uint8_t xbow_probe_ibrick[] =
{ 0x0f, 0x0e, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0 };
/* P-Brick: all widgets are PCI buses, probe in recommended order */
const uint8_t xbow_probe_pbrick[] =
{ 0x09, 0x08, 0x0f, 0x0e, 0x0d, 0x0c, 0x0a, 0x0b, 0 };
/* X-Brick: all widgets are XIO devices, probe in recommended order */
const uint8_t xbow_probe_xbrick[] =
{ 0x08, 0x09, 0x0c, 0x0d, 0x0a, 0x0b, 0x0e, 0x0f, 0 };
/*
* Structures used to carry information between KL and attachment code.
*/
struct xbow_config {
int valid;
int master;
int widgets[WIDGET_MAX + 1 - WIDGET_MIN];
};
struct xbow_kl_config {
const uint8_t *probe_order;
struct xbow_config *cfg;
};
void
xbowattach(struct device *parent, struct device *self, void *aux)
{
struct xbow_softc *sc = (struct xbow_softc *)self;
struct mainbus_attach_args *maa = aux;
int16_t nasid = maa->maa_nasid;
uint32_t wid, vendor, product;
const struct xbow_product *p;
struct xbow_config cfg;
struct xbow_kl_config klcfg;
uint widget;
sc->sc_nasid = nasid;
/*
* This assumes widget 0 is the XBow itself (or an XXBow).
* If it isn't - feel free to haunt my bedroom at night.
*/
if (xbow_widget_id(nasid, 0, &wid) != 0)
panic("no xbow");
vendor = (wid & WIDGET_ID_VENDOR_MASK) >> WIDGET_ID_VENDOR_SHIFT;
product = (wid & WIDGET_ID_PRODUCT_MASK) >> WIDGET_ID_PRODUCT_SHIFT;
p = xbow_identify(vendor, product);
if (p == NULL)
printf(": unknown xbow (vendor %x product %x)",
vendor, product);
else
printf(": %s", p->productname);
printf(" revision %d\n",
(wid & WIDGET_ID_REV_MASK) >> WIDGET_ID_REV_SHIFT);
memset(&cfg, 0, sizeof cfg);
switch (sys_config.system_type) {
case SGI_OCTANE:
klcfg.probe_order = xbow_probe_octane;
break;
#ifdef TGT_ORIGIN
default:
/*
* Default value for the interrupt register.
*/
if (xbow_intr_widget_register == 0)
xbow_intr_widget_register =
(1UL << 47) /* XIO I/O space */ |
(nasid <<
(sys_config.system_type == SGI_IP35 ? 39 : 38)) |
((paddr_t)IP27_RHUB_ADDR(0, HUBPI_IR_CHANGE) -
IP27_NODE_IO_BASE(0)) /* HUB register offset */;
klcfg.cfg = &cfg;
klcfg.probe_order = NULL;
/*
* If widget 0 reports itself as a bridge, this is not a
* complete XBow, but only a limited topology. This is
* found on at least the Origin 200.
*/
if (vendor == XBOW_VENDOR_SGI4 &&
product == XBOW_PRODUCT_SGI4_BRIDGE) {
/*
* Interrupt widget is hardwired to #a (this is another
* facet of this bridge).
*/
if (xbow_intr_widget == 0)
xbow_intr_widget = 0x0a;
klcfg.probe_order = xbow_probe_singlebridge;
} else {
/*
* Get crossbow information from the KL configuration.
*/
kl_scan_node(nasid, KLBRD_ANY, xbow_kl_search_brd,
&klcfg);
if (cfg.valid == 0)
panic("no hub");
/*
* This widget number is actually the Hub part of the
* crossbow, and is where memory and interrupt logic
* resources are connected to.
*/
if (xbow_intr_widget == 0)
xbow_intr_widget = cfg.master;
}
break;
#endif
}
if (klcfg.probe_order == NULL)
klcfg.probe_order = xbow_probe_baseio;
for (; *klcfg.probe_order != 0; klcfg.probe_order++) {
widget = *klcfg.probe_order;
if (cfg.valid != 0 &&
!ISSET(cfg.widgets[widget - WIDGET_MIN], XBOW_PORT_ENABLE))
continue;
(void)xbow_attach_widget(self, nasid, widget, xbowsubmatch,
xbowprint);
}
}
int
xbow_attach_widget(struct device *self, int16_t nasid, int widget,
int (*sm)(struct device *, void *, void *), cfprint_t print)
{
struct xbow_attach_args xaa;
uint32_t wid;
struct mips_bus_space bs;
int rc;
if ((rc = xbow_widget_id(nasid, widget, &wid)) != 0)
return rc;
/*
* Build a bus_space_t suitable for this widget.
*/
xbow_build_bus_space(&bs, nasid, widget);
xaa.xaa_nasid = nasid;
xaa.xaa_widget = widget;
xaa.xaa_vendor = (wid & WIDGET_ID_VENDOR_MASK) >>
WIDGET_ID_VENDOR_SHIFT;
xaa.xaa_product = (wid & WIDGET_ID_PRODUCT_MASK) >>
WIDGET_ID_PRODUCT_SHIFT;
xaa.xaa_revision = (wid & WIDGET_ID_REV_MASK) >> WIDGET_ID_REV_SHIFT;
xaa.xaa_iot = &bs;
if (config_found_sm(self, &xaa, print, sm) == NULL)
return ENOENT;
return 0;
}
#ifdef TGT_ORIGIN
/*
* These two functions try to figure out the configuration of the XBow
* on this node.
*
* We are looking for two pieces of information:
* - the Hub widget, to which memory is attached and interrupts are routed.
* - what kind of Brick we are.
*
* The first information can be obtained easily by looking for a MPLANE type
* board. However there is no easy way to figure the second part, except for
* checking what kind of boards are reported.
*
* A BaseIO board will report itself once, as a single widget. Bricks, on the
* other hand, appear for each of the widgets they provide.
*/
int
xbow_kl_search_brd(lboard_t *brd, void *arg)
{
struct xbow_kl_config *cfg = arg;
switch (brd->brd_type & IP27_BC_MASK) {
case IP27_BC_MPLANE:
if (cfg->cfg->valid == 0)
kl_scan_board(brd, KLSTRUCT_XBOW, xbow_kl_search_mplane,
cfg->cfg);
break;
case IP27_BC_IO:
if (cfg->probe_order == NULL)
cfg->probe_order = xbow_probe_baseio;
break;
case IP27_BC_BRICK:
if (cfg->probe_order == NULL)
switch (brd->brd_type) {
case IP27_BRD_IBRICK:
case IP27_BRD_IXBRICK:
cfg->probe_order = xbow_probe_ibrick;
break;
case IP27_BRD_PBRICK:
case IP27_BRD_PXBRICK:
cfg->probe_order = xbow_probe_pbrick;
break;
case IP27_BRD_XBRICK:
cfg->probe_order = xbow_probe_xbrick;
break;
default:
/* other brick */
break;
}
break;
}
if (cfg->cfg->valid != 0 && cfg->probe_order != NULL)
return 1; /* stop enumeration */
return 0;
}
int
xbow_kl_search_mplane(klinfo_t *c, void *arg)
{
klxbow_t *xbow = (klxbow_t *)c;
struct xbow_config *cfg = arg;
uint w;
cfg->valid = 1;
cfg->master = xbow->xbow_hub_master_link;
for (w = WIDGET_MIN; w <= WIDGET_MAX; w++)
cfg->widgets[w - WIDGET_MIN] =
xbow->xbow_port_info[w - WIDGET_MIN].port_flag;
return 1;
}
#endif
/*
* Bus access primitives.
*/
void
xbow_build_bus_space(struct mips_bus_space *bs, int nasid, int widget)
{
bcopy(&xbowbus_tag, bs, sizeof (*bs));
bs->bus_base = (*xbow_widget_base)(nasid, widget);
}
uint8_t
xbow_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
{
return *(volatile uint8_t *)(h + o);
}
uint16_t
xbow_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
{
return *(volatile uint16_t *)(h + o);
}
uint32_t
xbow_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
{
return *(volatile uint32_t *)(h + o);
}
uint64_t
xbow_read_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
{
return *(volatile uint64_t *)(h + o);
}
void
xbow_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, uint8_t v)
{
*(volatile uint8_t *)(h + o) = v;
}
void
xbow_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, uint16_t v)
{
*(volatile uint16_t *)(h + o) = v;
}
void
xbow_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, uint32_t v)
{
*(volatile uint32_t *)(h + o) = v;
}
void
xbow_write_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, uint64_t v)
{
*(volatile uint64_t *)(h + o) = v;
}
void
xbow_read_raw_2(bus_space_tag_t t, bus_space_handle_t h, bus_addr_t o,
uint8_t *buf, bus_size_t len)
{
volatile uint16_t *addr = (volatile uint16_t *)(h + o);
len >>= 1;
while (len-- != 0) {
*(uint16_t *)buf = *addr;
buf += 2;
}
}
void
xbow_write_raw_2(bus_space_tag_t t, bus_space_handle_t h, bus_addr_t o,
const uint8_t *buf, bus_size_t len)
{
volatile uint16_t *addr = (volatile uint16_t *)(h + o);
len >>= 1;
while (len-- != 0) {
*addr = *(uint16_t *)buf;
buf += 2;
}
}
void
xbow_read_raw_4(bus_space_tag_t t, bus_space_handle_t h, bus_addr_t o,
uint8_t *buf, bus_size_t len)
{
volatile uint32_t *addr = (volatile uint32_t *)(h + o);
len >>= 2;
while (len-- != 0) {
*(uint32_t *)buf = *addr;
buf += 4;
}
}
void
xbow_write_raw_4(bus_space_tag_t t, bus_space_handle_t h, bus_addr_t o,
const uint8_t *buf, bus_size_t len)
{
volatile uint32_t *addr = (volatile uint32_t *)(h + o);
len >>= 2;
while (len-- != 0) {
*addr = *(uint32_t *)buf;
buf += 4;
}
}
void
xbow_read_raw_8(bus_space_tag_t t, bus_space_handle_t h, bus_addr_t o,
uint8_t *buf, bus_size_t len)
{
volatile uint64_t *addr = (volatile uint64_t *)(h + o);
len >>= 3;
while (len-- != 0) {
*(uint64_t *)buf = *addr;
buf += 8;
}
}
void
xbow_write_raw_8(bus_space_tag_t t, bus_space_handle_t h, bus_addr_t o,
const uint8_t *buf, bus_size_t len)
{
volatile uint64_t *addr = (volatile uint64_t *)(h + o);
len >>= 3;
while (len-- != 0) {
*addr = *(uint64_t *)buf;
buf += 8;
}
}
int
xbow_space_map(bus_space_tag_t t, bus_addr_t offs, bus_size_t size,
int flags, bus_space_handle_t *bshp)
{
bus_addr_t bpa;
bpa = t->bus_base + offs;
#ifdef DIAGNOSTIC
/* check that this does not overflow the window */
if (((bpa + size - 1) >> 24) != (t->bus_base >> 24))
return (EINVAL);
#endif
*bshp = bpa;
return 0;
}
void
xbow_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
{
}
int
xbow_space_region(bus_space_tag_t t, bus_space_handle_t bsh,
bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp)
{
#ifdef DIAGNOSTIC
bus_addr_t bpa;
bpa = (bus_addr_t)bsh - t->bus_base;
/* check that this does not overflow the window */
if (((bpa + offset) >> 24) != (t->bus_base >> 24))
return (EINVAL);
#endif
*nbshp = bsh + offset;
return 0;
}
void *
xbow_space_vaddr(bus_space_tag_t t, bus_space_handle_t h)
{
return (void *)h;
}
/*
* Interrupt handling code.
*
* Interrupt handling should be done at the Heart/Hub driver level, we only
* act as a proxy here.
*
* Note that, for the time being, interrupt handling is implicitly done at
* the master nasid; other nodes do not handle interrupts.
*/
int xbow_intr_widget = 0;
paddr_t xbow_intr_widget_register;
int (*xbow_intr_widget_intr_register)(int, int, int *) = NULL;
int (*xbow_intr_widget_intr_establish)(int (*)(void *), void *, int, int,
const char *, struct intrhand *) = NULL;
void (*xbow_intr_widget_intr_disestablish)(int) = NULL;
void (*xbow_intr_widget_intr_set)(int) = NULL;
void (*xbow_intr_widget_intr_clear)(int) = NULL;
int
xbow_intr_register(int widget, int level, int *intrbit)
{
if (xbow_intr_widget_intr_register == NULL)
return EINVAL;
return (*xbow_intr_widget_intr_register)(widget, level, intrbit);
}
int
xbow_intr_establish(int (*func)(void *), void *arg, int intrbit, int level,
const char *name, struct intrhand *ihstore)
{
if (xbow_intr_widget_intr_establish == NULL)
return EINVAL;
return (*xbow_intr_widget_intr_establish)(func, arg, intrbit, level,
name, ihstore);
}
void
xbow_intr_disestablish(int intrbit)
{
if (xbow_intr_widget_intr_disestablish == NULL)
return;
(*xbow_intr_widget_intr_disestablish)(intrbit);
}
void
xbow_intr_clear(int intrbit)
{
if (xbow_intr_widget_intr_clear == NULL)
return;
(*xbow_intr_widget_intr_clear)(intrbit);
}
void
xbow_intr_set(int intrbit)
{
if (xbow_intr_widget_intr_set == NULL)
return;
(*xbow_intr_widget_intr_set)(intrbit);
}
/*
* Widget mapping code.
*/
paddr_t
xbow_widget_map_space(struct device *dev, u_int widget, bus_addr_t *offs,
bus_size_t *len)
{
struct xbow_softc *sc = (struct xbow_softc *)dev;
if (xbow_widget_map == NULL)
return 0UL;
return (*xbow_widget_map)(sc->sc_nasid, widget, offs, len);
}
|