1 /* $NetBSD: promdev.c,v 1.20 2006/07/13 20:03:34 uwe Exp $ */ 2 3 /* 4 * Copyright (c) 1993 Paul Kranenburg 5 * Copyright (c) 1995 Gordon W. Ross 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Paul Kranenburg. 19 * 4. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 /* 35 * Note: the `#ifndef BOOTXX' in here serve to queeze the code size 36 * of the 1st-stage boot program. 37 */ 38 #include <sys/param.h> 39 #include <sys/reboot.h> 40 #include <sys/systm.h> 41 #include <machine/oldmon.h> 42 #include <machine/promlib.h> 43 #include <machine/ctlreg.h> 44 #include <sparc/sparc/asm.h> 45 #include <machine/pte.h> 46 47 #include <lib/libsa/stand.h> 48 #include <lib/libkern/libkern.h> 49 #include <sparc/stand/common/promdev.h> 50 51 #ifndef BOOTXX 52 #include <sys/disklabel.h> 53 #include <dev/sun/disklabel.h> 54 #include <dev/raidframe/raidframevar.h> 55 #endif 56 57 /* OBP V0-3 PROM vector */ 58 #define obpvec ((struct promvec *)romp) 59 60 int obp_close(struct open_file *); 61 int obp_strategy(void *, int, daddr_t, size_t, void *, size_t *); 62 int obp_v0_strategy(void *, int, daddr_t, size_t, void *, size_t *); 63 ssize_t obp_v0_xmit(struct promdata *, void *, size_t); 64 ssize_t obp_v0_recv(struct promdata *, void *, size_t); 65 int obp_v2_strategy(void *, int, daddr_t, size_t, void *, size_t *); 66 ssize_t obp_v2_xmit(struct promdata *, void *, size_t); 67 ssize_t obp_v2_recv(struct promdata *, void *, size_t); 68 int oldmon_close(struct open_file *); 69 int oldmon_strategy(void *, int, daddr_t, size_t, void *, size_t *); 70 void oldmon_iclose(struct saioreq *); 71 int oldmon_iopen(struct promdata *); 72 ssize_t oldmon_xmit(struct promdata *, void *, size_t); 73 ssize_t oldmon_recv(struct promdata *, void *, size_t); 74 75 static char *oldmon_mapin(u_long, int, int); 76 #ifndef BOOTXX 77 static char *mygetpropstring(int, char *); 78 static int getdevtype(int, char *); 79 #endif 80 81 extern struct fs_ops file_system_nfs[]; 82 extern struct fs_ops file_system_ufs[]; 83 84 #define null_devopen (void *)sparc_noop 85 #define null_devioctl (void *)sparc_noop 86 87 #if 0 88 struct devsw devsw[]; 89 int ndevs = (sizeof(devsw)/sizeof(devsw[0])); 90 #endif 91 92 struct devsw oldmon_devsw = 93 { "oldmon", oldmon_strategy, null_devopen, oldmon_close, null_devioctl }; 94 struct devsw obp_v0_devsw = 95 { "obp v0", obp_v0_strategy, null_devopen, obp_close, null_devioctl }; 96 struct devsw obp_v2_devsw = 97 { "obp v2", obp_v2_strategy, null_devopen, obp_close, null_devioctl }; 98 99 100 char prom_bootdevice[MAX_PROM_PATH]; 101 static int saveecho; 102 103 #ifndef BOOTXX 104 static daddr_t doffset = 0; 105 #endif 106 107 108 void 109 putchar(int c) 110 { 111 112 if (c == '\n') 113 prom_putchar('\r'); 114 prom_putchar(c); 115 } 116 117 void 118 _rtt(void) 119 { 120 121 prom_halt(); 122 } 123 124 int 125 devopen(struct open_file *f, const char *fname, char **file) 126 { 127 int error = 0, fd = 0; 128 struct promdata *pd; 129 #ifndef BOOTXX 130 char *partition; 131 int part = 0; 132 char rawpart[MAX_PROM_PATH]; 133 struct promdata *disk_pd; 134 char buf[DEV_BSIZE]; 135 struct disklabel *dlp; 136 size_t read; 137 #endif 138 139 pd = (struct promdata *)alloc(sizeof *pd); 140 f->f_devdata = (void *)pd; 141 142 switch (prom_version()) { 143 case PROM_OLDMON: 144 error = oldmon_iopen(pd); 145 #ifndef BOOTXX 146 pd->xmit = oldmon_xmit; 147 pd->recv = oldmon_recv; 148 #endif 149 f->f_dev = &oldmon_devsw; 150 saveecho = *romVectorPtr->echo; 151 *romVectorPtr->echo = 0; 152 break; 153 154 case PROM_OBP_V0: 155 case PROM_OBP_V2: 156 case PROM_OBP_V3: 157 case PROM_OPENFIRM: 158 if (*prom_bootdevice == '\0') { 159 error = ENXIO; 160 break; 161 } 162 fd = prom_open(prom_bootdevice); 163 if (fd == 0) { 164 error = ENXIO; 165 break; 166 } 167 pd->fd = fd; 168 switch (prom_version()) { 169 case PROM_OBP_V0: 170 #ifndef BOOTXX 171 pd->xmit = obp_v0_xmit; 172 pd->recv = obp_v0_recv; 173 #endif 174 f->f_dev = &obp_v0_devsw; 175 break; 176 case PROM_OBP_V2: 177 case PROM_OBP_V3: 178 case PROM_OPENFIRM: 179 #ifndef BOOTXX 180 pd->xmit = obp_v2_xmit; 181 pd->recv = obp_v2_recv; 182 #endif 183 f->f_dev = &obp_v2_devsw; 184 } 185 } 186 187 if (error) { 188 printf("Can't open device `%s'\n", prom_bootdevice); 189 return (error); 190 } 191 192 #ifdef BOOTXX 193 pd->devtype = DT_BLOCK; 194 #else /* BOOTXX */ 195 pd->devtype = getdevtype(fd, prom_bootdevice); 196 /* Assume type BYTE is a raw device */ 197 if (pd->devtype != DT_BYTE) 198 *file = (char *)fname; 199 200 if (pd->devtype == DT_NET) { 201 bcopy(file_system_nfs, file_system, sizeof(struct fs_ops)); 202 if ((error = net_open(pd)) != 0) { 203 printf("Can't open NFS network connection on `%s'\n", 204 prom_bootdevice); 205 return (error); 206 } 207 } else { 208 bcopy(file_system_ufs, file_system, sizeof(struct fs_ops)); 209 210 #ifdef NOTDEF_DEBUG 211 printf("devopen: Checking disklabel for RAID partition\n"); 212 #endif 213 214 /* 215 * We need to read from the raw partition (i.e. the 216 * beginning of the disk in order to check the NetBSD 217 * disklabel to see if the boot partition is type RAID. 218 * 219 * For machines with prom_version() == PROM_OLDMON, we 220 * only handle boot from RAID for the first disk partition. 221 */ 222 disk_pd = (struct promdata *)alloc(sizeof *disk_pd); 223 memcpy(disk_pd, pd, sizeof(struct promdata)); 224 if (prom_version() != PROM_OLDMON) { 225 strcpy(rawpart, prom_bootdevice); 226 if ((partition = strchr(rawpart, ':')) != '\0' && 227 *++partition >= 'a' && 228 *partition <= 'a' + MAXPARTITIONS) { 229 part = *partition - 'a'; 230 *partition = RAW_PART + 'a'; 231 } else 232 strcat(rawpart, ":c"); 233 if ((disk_pd->fd = prom_open(rawpart)) == 0) 234 return 0; 235 } 236 error = f->f_dev->dv_strategy(disk_pd, F_READ, LABELSECTOR, 237 DEV_BSIZE, &buf, &read); 238 if (prom_version() != PROM_OLDMON) 239 prom_close(disk_pd->fd); 240 if (error || (read != DEV_BSIZE)) 241 return 0; 242 #ifdef NOTDEF_DEBUG 243 { 244 int x = 0; 245 char *p = (char *) buf; 246 247 printf(" Sector %d:\n", LABELSECTOR); 248 printf("00000000 "); 249 while (x < DEV_BSIZE) { 250 if (*p >= 0x00 && *p < 0x10) 251 printf("0%x ", *p & 0xff); 252 else 253 printf("%x ", *p & 0xff); 254 x++; 255 if (x && !(x % 8)) 256 printf(" "); 257 if (x && !(x % 16)) { 258 if(x < 0x100) 259 printf("\n000000%x ", x); 260 else 261 printf("\n00000%x ", x); 262 } 263 p++; 264 } 265 printf("\n"); 266 } 267 #endif 268 /* Check for NetBSD disk label. */ 269 dlp = (struct disklabel *) (buf + LABELOFFSET); 270 if (dlp->d_magic == DISKMAGIC && !dkcksum(dlp) && 271 dlp->d_partitions[part].p_fstype == FS_RAID) { 272 #ifdef NOTDEF_DEBUG 273 printf("devopen: found RAID partition, " 274 "adjusting offset to %d\n", RF_PROTECTED_SECTORS); 275 #endif 276 doffset = RF_PROTECTED_SECTORS; 277 } 278 } 279 #endif /* BOOTXX */ 280 return (0); 281 } 282 283 284 int 285 obp_v0_strategy(void *devdata, int flag, daddr_t dblk, size_t size, 286 void *buf, size_t *rsize) 287 { 288 int n, error = 0; 289 struct promdata *pd = (struct promdata *)devdata; 290 int fd = pd->fd; 291 292 #ifndef BOOTXX 293 dblk += doffset; 294 #endif 295 #ifdef DEBUG_PROM 296 printf("promstrategy: size=%d dblk=%d\n", size, dblk); 297 #endif 298 299 #define prom_bread(fd, nblk, dblk, buf) \ 300 (*obpvec->pv_v0devops.v0_rbdev)(fd, nblk, dblk, buf) 301 #define prom_bwrite(fd, nblk, dblk, buf) \ 302 (*obpvec->pv_v0devops.v0_wbdev)(fd, nblk, dblk, buf) 303 304 #ifndef BOOTXX /* We know it's a block device, so save some space */ 305 if (pd->devtype != DT_BLOCK) { 306 printf("promstrategy: non-block device not supported\n"); 307 error = EINVAL; 308 } 309 #endif 310 311 n = (flag == F_READ) 312 ? prom_bread(fd, btodb(size), dblk, buf) 313 : prom_bwrite(fd, btodb(size), dblk, buf); 314 315 *rsize = dbtob(n); 316 317 #ifdef DEBUG_PROM 318 printf("rsize = %x\n", *rsize); 319 #endif 320 return (error); 321 } 322 323 int 324 obp_v2_strategy(void *devdata, int flag, daddr_t dblk, size_t size, 325 void *buf, size_t *rsize) 326 { 327 int error = 0; 328 struct promdata *pd = (struct promdata *)devdata; 329 int fd = pd->fd; 330 331 #ifndef BOOTXX 332 dblk += doffset; 333 #endif 334 #ifdef DEBUG_PROM 335 printf("promstrategy: size=%d dblk=%d\n", size, dblk); 336 #endif 337 338 #ifndef BOOTXX /* We know it's a block device, so save some space */ 339 if (pd->devtype == DT_BLOCK) 340 #endif 341 prom_seek(fd, dbtob(dblk)); 342 343 *rsize = (flag == F_READ) 344 ? prom_read(fd, buf, size) 345 : prom_write(fd, buf, size); 346 347 #ifdef DEBUG_PROM 348 printf("rsize = %x\n", *rsize); 349 #endif 350 return (error); 351 } 352 353 /* 354 * On old-monitor machines, things work differently. 355 */ 356 int 357 oldmon_strategy(void *devdata, int flag, daddr_t dblk, size_t size, 358 void *buf, size_t *rsize) 359 { 360 struct promdata *pd = devdata; 361 struct saioreq *si; 362 struct om_boottable *ops; 363 char *dmabuf; 364 int si_flag; 365 size_t xcnt; 366 367 si = pd->si; 368 ops = si->si_boottab; 369 370 #ifndef BOOTXX 371 dblk += doffset; 372 #endif 373 #ifdef DEBUG_PROM 374 printf("prom_strategy: size=%d dblk=%d\n", size, dblk); 375 #endif 376 377 dmabuf = dvma_mapin(buf, size); 378 379 si->si_bn = dblk; 380 si->si_ma = dmabuf; 381 si->si_cc = size; 382 383 si_flag = (flag == F_READ) ? SAIO_F_READ : SAIO_F_WRITE; 384 xcnt = (*ops->b_strategy)(si, si_flag); 385 dvma_mapout(dmabuf, size); 386 387 #ifdef DEBUG_PROM 388 printf("disk_strategy: xcnt = %x\n", xcnt); 389 #endif 390 391 if (xcnt <= 0) 392 return (EIO); 393 394 *rsize = xcnt; 395 return (0); 396 } 397 398 int 399 obp_close(struct open_file *f) 400 { 401 struct promdata *pd = f->f_devdata; 402 register int fd = pd->fd; 403 404 #ifndef BOOTXX 405 if (pd->devtype == DT_NET) 406 net_close(pd); 407 #endif 408 prom_close(fd); 409 return 0; 410 } 411 412 int 413 oldmon_close(struct open_file *f) 414 { 415 struct promdata *pd = f->f_devdata; 416 417 #ifndef BOOTXX 418 if (pd->devtype == DT_NET) 419 net_close(pd); 420 #endif 421 oldmon_iclose(pd->si); 422 pd->si = NULL; 423 *romVectorPtr->echo = saveecho; /* Hmm, probably must go somewhere else */ 424 return 0; 425 } 426 427 #ifndef BOOTXX 428 ssize_t 429 obp_v0_xmit(struct promdata *pd, void *buf, size_t len) 430 { 431 432 return ((*obpvec->pv_v0devops.v0_wnet)(pd->fd, len, buf)); 433 } 434 435 ssize_t 436 obp_v2_xmit(struct promdata *pd, void *buf, size_t len) 437 { 438 439 return (prom_write(pd->fd, buf, len)); 440 } 441 442 ssize_t 443 obp_v0_recv(struct promdata *pd, void *buf, size_t len) 444 { 445 446 return ((*obpvec->pv_v0devops.v0_rnet)(pd->fd, len, buf)); 447 } 448 449 ssize_t 450 obp_v2_recv(struct promdata *pd, void *buf, size_t len) 451 { 452 int n; 453 454 n = prom_read(pd->fd, buf, len); 455 456 /* OBP V2 & V3 may return -2 */ 457 return (n == -2 ? 0 : n); 458 } 459 460 ssize_t 461 oldmon_xmit(struct promdata *pd, void *buf, size_t len) 462 { 463 struct saioreq *si; 464 struct saif *sif; 465 char *dmabuf; 466 int rv; 467 468 si = pd->si; 469 sif = si->si_sif; 470 if (sif == NULL) { 471 printf("xmit: not a network device\n"); 472 return (-1); 473 } 474 dmabuf = dvma_mapin(buf, len); 475 rv = sif->sif_xmit(si->si_devdata, dmabuf, len); 476 dvma_mapout(dmabuf, len); 477 478 return (ssize_t)(rv ? -1 : len); 479 } 480 481 ssize_t 482 oldmon_recv(struct promdata *pd, void *buf, size_t len) 483 { 484 struct saioreq *si; 485 struct saif *sif; 486 char *dmabuf; 487 int rv; 488 489 si = pd->si; 490 sif = si->si_sif; 491 dmabuf = dvma_mapin(buf, len); 492 rv = sif->sif_poll(si->si_devdata, dmabuf); 493 dvma_mapout(dmabuf, len); 494 495 return (ssize_t)rv; 496 } 497 498 int 499 getchar(void) 500 { 501 502 return (prom_getchar()); 503 } 504 505 time_t 506 getsecs(void) 507 { 508 509 (void)prom_peekchar(); 510 return (prom_ticks() / 1000); 511 } 512 513 /* 514 * A number of well-known devices on sun4s. 515 */ 516 static struct dtab { 517 char *name; 518 int type; 519 } dtab[] = { 520 { "sd", DT_BLOCK }, 521 { "st", DT_BLOCK }, 522 { "xd", DT_BLOCK }, 523 { "xy", DT_BLOCK }, 524 { "fd", DT_BLOCK }, 525 { "le", DT_NET }, 526 { "ie", DT_NET }, 527 { NULL, 0 } 528 }; 529 530 int 531 getdevtype(int fd, char *name) 532 { 533 struct dtab *dp; 534 int node; 535 char *cp; 536 537 switch (prom_version()) { 538 case PROM_OLDMON: 539 case PROM_OBP_V0: 540 for (dp = dtab; dp->name; dp++) { 541 if (name[0] == dp->name[0] && 542 name[1] == dp->name[1]) 543 return (dp->type); 544 } 545 break; 546 547 case PROM_OBP_V2: 548 case PROM_OBP_V3: 549 case PROM_OPENFIRM: 550 node = prom_instance_to_package(fd); 551 cp = mygetpropstring(node, "device_type"); 552 if (strcmp(cp, "block") == 0) 553 return (DT_BLOCK); 554 else if (strcmp(cp, "network") == 0) 555 return (DT_NET); 556 else if (strcmp(cp, "byte") == 0) 557 return (DT_BYTE); 558 break; 559 } 560 return (0); 561 } 562 563 /* 564 * Return a string property. There is a (small) limit on the length; 565 * the string is fetched into a static buffer which is overwritten on 566 * subsequent calls. 567 */ 568 char * 569 mygetpropstring(int node, char *name) 570 { 571 int len; 572 static char buf[64]; 573 574 len = prom_proplen(node, name); 575 if (len > 0) 576 _prom_getprop(node, name, buf, len); 577 else 578 len = 0; 579 580 buf[len] = '\0'; /* usually unnecessary */ 581 return (buf); 582 } 583 #endif /* BOOTXX */ 584 585 /* 586 * Old monitor routines 587 */ 588 589 struct saioreq prom_si; 590 static int promdev_inuse; 591 592 int 593 oldmon_iopen(struct promdata *pd) 594 { 595 struct om_bootparam *bp; 596 struct om_boottable *ops; 597 struct devinfo *dip; 598 struct saioreq *si; 599 int error; 600 601 if (promdev_inuse) 602 return (EMFILE); 603 604 bp = *romVectorPtr->bootParam; 605 ops = bp->bootTable; 606 dip = ops->b_devinfo; 607 608 #ifdef DEBUG_PROM 609 printf("Boot device type: %s\n", ops->b_desc); 610 printf("d_devbytes=%d\n", dip->d_devbytes); 611 printf("d_dmabytes=%d\n", dip->d_dmabytes); 612 printf("d_localbytes=%d\n", dip->d_localbytes); 613 printf("d_stdcount=%d\n", dip->d_stdcount); 614 printf("d_stdaddrs[%d]=%x\n", bp->ctlrNum, dip->d_stdaddrs[bp->ctlrNum]); 615 printf("d_devtype=%d\n", dip->d_devtype); 616 printf("d_maxiobytes=%d\n", dip->d_maxiobytes); 617 #endif 618 619 dvma_init(); 620 621 si = &prom_si; 622 memset(si, 0, sizeof(*si)); 623 si->si_boottab = ops; 624 si->si_ctlr = bp->ctlrNum; 625 si->si_unit = bp->unitNum; 626 si->si_boff = bp->partNum; 627 628 if (si->si_ctlr > dip->d_stdcount) 629 return (ECTLR); 630 631 if (dip->d_devbytes) { 632 si->si_devaddr = oldmon_mapin(dip->d_stdaddrs[si->si_ctlr], 633 dip->d_devbytes, dip->d_devtype); 634 #ifdef DEBUG_PROM 635 printf("prom_iopen: devaddr=0x%x pte=0x%x\n", 636 si->si_devaddr, 637 getpte4((u_long)si->si_devaddr & ~PGOFSET)); 638 #endif 639 } 640 641 if (dip->d_dmabytes) { 642 si->si_dmaaddr = dvma_alloc(dip->d_dmabytes); 643 #ifdef DEBUG_PROM 644 printf("prom_iopen: dmaaddr=0x%x\n", si->si_dmaaddr); 645 #endif 646 } 647 648 if (dip->d_localbytes) { 649 si->si_devdata = alloc(dip->d_localbytes); 650 #ifdef DEBUG_PROM 651 printf("prom_iopen: devdata=0x%x\n", si->si_devdata); 652 #endif 653 } 654 655 /* OK, call the PROM device open routine. */ 656 error = (*ops->b_open)(si); 657 if (error != 0) { 658 printf("prom_iopen: \"%s\" error=%d\n", ops->b_desc, error); 659 return (ENXIO); 660 } 661 #ifdef DEBUG_PROM 662 printf("prom_iopen: succeeded, error=%d\n", error); 663 #endif 664 665 pd->si = si; 666 promdev_inuse++; 667 return (0); 668 } 669 670 void 671 oldmon_iclose(struct saioreq *si) 672 { 673 struct om_boottable *ops; 674 struct devinfo *dip; 675 676 if (promdev_inuse == 0) 677 return; 678 679 ops = si->si_boottab; 680 dip = ops->b_devinfo; 681 682 (*ops->b_close)(si); 683 684 if (si->si_dmaaddr) { 685 dvma_free(si->si_dmaaddr, dip->d_dmabytes); 686 si->si_dmaaddr = NULL; 687 } 688 689 promdev_inuse = 0; 690 } 691 692 static struct mapinfo { 693 int maptype; 694 int pgtype; 695 int base; 696 } oldmon_mapinfo[] = { 697 #define PG_COMMON (PG_V|PG_W|PG_S|PG_NC) 698 { MAP_MAINMEM, PG_OBMEM | PG_COMMON, 0 }, 699 { MAP_OBIO, PG_OBIO | PG_COMMON, 0 }, 700 { MAP_MBMEM, PG_VME16 | PG_COMMON, 0xFF000000 }, 701 { MAP_MBIO, PG_VME16 | PG_COMMON, 0xFFFF0000 }, 702 { MAP_VME16A16D, PG_VME16 | PG_COMMON, 0xFFFF0000 }, 703 { MAP_VME16A32D, PG_VME32 | PG_COMMON, 0xFFFF0000 }, 704 { MAP_VME24A16D, PG_VME16 | PG_COMMON, 0xFF000000 }, 705 { MAP_VME24A32D, PG_VME32 | PG_COMMON, 0xFF000000 }, 706 { MAP_VME32A16D, PG_VME16 | PG_COMMON, 0 }, 707 { MAP_VME32A32D, PG_VME32 | PG_COMMON, 0 }, 708 }; 709 static int oldmon_mapinfo_cnt = 710 sizeof(oldmon_mapinfo) / sizeof(oldmon_mapinfo[0]); 711 712 /* The virtual address we will use for PROM device mappings. */ 713 static u_long prom_devmap = MONSHORTSEG; 714 715 static char * 716 oldmon_mapin(u_long physaddr, int length, int maptype) 717 { 718 int i, pa, pte, va; 719 720 if (length > (4*NBPG)) 721 panic("oldmon_mapin: length=%d", length); 722 723 for (i = 0; i < oldmon_mapinfo_cnt; i++) 724 if (oldmon_mapinfo[i].maptype == maptype) 725 goto found; 726 panic("oldmon_mapin: invalid maptype %d", maptype); 727 728 found: 729 pte = oldmon_mapinfo[i].pgtype; 730 pa = oldmon_mapinfo[i].base; 731 pa += physaddr; 732 pte |= ((pa >> SUN4_PGSHIFT) & PG_PFNUM); 733 734 va = prom_devmap; 735 do { 736 setpte4(va, pte); 737 va += NBPG; 738 pte += 1; 739 length -= NBPG; 740 } while (length > 0); 741 return ((char*)(prom_devmap | (pa & PGOFSET))); 742 } 743