console.c (8016:96a3a31ead2a) | console.c (8018:f3975c1b6009) |
---|---|
1/* 2 * Copyright (c) 2003, 2004 3 * The Regents of The University of Michigan 4 * All Rights Reserved 5 * 6 * This code is part of the M5 simulator, developed by Nathan Binkert, 7 * Erik Hallnor, Steve Raasch, and Steve Reinhardt, with contributions 8 * from Ron Dreslinski, Dave Greene, Lisa Hsu, Ali Saidi, and Andrew --- 55 unchanged lines hidden (view full) --- 64#include "cserve.h" 65#include "rpb.h" 66 67#define CONS_INT_TX 0x01 /* interrupt enable / state bits */ 68#define CONS_INT_RX 0x02 69 70#define PAGE_SIZE (8192) 71 | 1/* 2 * Copyright (c) 2003, 2004 3 * The Regents of The University of Michigan 4 * All Rights Reserved 5 * 6 * This code is part of the M5 simulator, developed by Nathan Binkert, 7 * Erik Hallnor, Steve Raasch, and Steve Reinhardt, with contributions 8 * from Ron Dreslinski, Dave Greene, Lisa Hsu, Ali Saidi, and Andrew --- 55 unchanged lines hidden (view full) --- 64#include "cserve.h" 65#include "rpb.h" 66 67#define CONS_INT_TX 0x01 /* interrupt enable / state bits */ 68#define CONS_INT_RX 0x02 69 70#define PAGE_SIZE (8192) 71 |
72#define KSTACK_REGION_VA 0x20040000 73 |
|
72#define KSEG 0xfffffc0000000000 73#define K1BASE 0xfffffc8000000000 74#define KSEG_TO_PHYS(x) (((ulong)x) & ~KSEG) 75 76#define ROUNDUP8(x) ((ulong)(((ulong)x)+7) & ~7) 77#define ROUNDUP128(x) ((ulong)(((ulong)x) + 127) & ~127) 78#define ROUNDUP8K(x) ((ulong)(((ulong)(x)) + 8191) & ~8191) 79 --- 385 unchanged lines hidden (view full) --- 465 466 /* Region 0 */ 467 second[SECOND(0x10000000)] = KPTE(PFN(third_rpb)); 468 469 for (i = 0; i < NUM_KERNEL_THIRD; i++) { 470 /* Region 1 */ 471 second[SECOND(0x20000000) + i] = KPTE(PFN(third_kernel) + i); 472 } | 74#define KSEG 0xfffffc0000000000 75#define K1BASE 0xfffffc8000000000 76#define KSEG_TO_PHYS(x) (((ulong)x) & ~KSEG) 77 78#define ROUNDUP8(x) ((ulong)(((ulong)x)+7) & ~7) 79#define ROUNDUP128(x) ((ulong)(((ulong)x) + 127) & ~127) 80#define ROUNDUP8K(x) ((ulong)(((ulong)(x)) + 8191) & ~8191) 81 --- 385 unchanged lines hidden (view full) --- 467 468 /* Region 0 */ 469 second[SECOND(0x10000000)] = KPTE(PFN(third_rpb)); 470 471 for (i = 0; i < NUM_KERNEL_THIRD; i++) { 472 /* Region 1 */ 473 second[SECOND(0x20000000) + i] = KPTE(PFN(third_kernel) + i); 474 } |
475 |
|
473 /* Region 2 */ 474 second[SECOND(0x40000000)] = KPTE(PFN(second)); 475 476 477 /* For some obscure reason, Dec Unix's database read 478 * from /etc/sysconfigtab is written to this fixed 479 * mapped memory location. Go figure, since it is 480 * not initialized by the console. Maybe it is 481 * to look at the database from the console 482 * after a boot/crash. 483 * 484 * Black magic to estimate the max size. SEGVs on overflow 485 * bugnion 486 */ 487 488#define DATABASE_BASE 0x20000000 489#define DATABASE_END 0x20020000 490 491 ulong *dbPage = (ulong*)unix_boot_alloc(1); | 476 /* Region 2 */ 477 second[SECOND(0x40000000)] = KPTE(PFN(second)); 478 479 480 /* For some obscure reason, Dec Unix's database read 481 * from /etc/sysconfigtab is written to this fixed 482 * mapped memory location. Go figure, since it is 483 * not initialized by the console. Maybe it is 484 * to look at the database from the console 485 * after a boot/crash. 486 * 487 * Black magic to estimate the max size. SEGVs on overflow 488 * bugnion 489 */ 490 491#define DATABASE_BASE 0x20000000 492#define DATABASE_END 0x20020000 493 494 ulong *dbPage = (ulong*)unix_boot_alloc(1); |
495 bzero(dbPage, PAGE_SIZE); |
|
492 second[SECOND(DATABASE_BASE)] = KPTE(PFN(dbPage)); | 496 second[SECOND(DATABASE_BASE)] = KPTE(PFN(dbPage)); |
493 for (i = DATABASE_BASE; i < DATABASE_END ; i += 8096) { | 497 for (i = DATABASE_BASE; i < DATABASE_END ; i += PAGE_SIZE) { |
494 ulong *db = (ulong*)unix_boot_alloc(1); 495 dbPage[THIRD(i)] = KPTE(PFN(db)); 496 } 497 498 /* Region 0 */ 499 /* Map the HWRPB */ 500 for (i = 0; i < HWRPB_PAGES; i++) 501 third_rpb[i] = KPTE(PFN(rpb) + i); --- 4 unchanged lines hidden (view full) --- 506 } 507 508 /* Protect the PAL pages */ 509 for (i = 1; i < PFN(first); i++) 510 third_rpb[HWRPB_PAGES + MDT_BITMAP_PAGES + i] = KPTE(i); 511 512 /* Set up third_kernel after it's loaded, when we know where it is */ 513 kern_first_page = (KSEG_TO_PHYS(m5Conf.kernStart)/PAGE_SIZE); | 498 ulong *db = (ulong*)unix_boot_alloc(1); 499 dbPage[THIRD(i)] = KPTE(PFN(db)); 500 } 501 502 /* Region 0 */ 503 /* Map the HWRPB */ 504 for (i = 0; i < HWRPB_PAGES; i++) 505 third_rpb[i] = KPTE(PFN(rpb) + i); --- 4 unchanged lines hidden (view full) --- 510 } 511 512 /* Protect the PAL pages */ 513 for (i = 1; i < PFN(first); i++) 514 third_rpb[HWRPB_PAGES + MDT_BITMAP_PAGES + i] = KPTE(i); 515 516 /* Set up third_kernel after it's loaded, when we know where it is */ 517 kern_first_page = (KSEG_TO_PHYS(m5Conf.kernStart)/PAGE_SIZE); |
514 kernel_end = ksp_top = ROUNDUP8K(m5Conf.kernEnd); | 518 kernel_end = ROUNDUP8K(m5Conf.kernEnd); |
515 bootadr = m5Conf.entryPoint; 516 517 printf_lock("HWRPB 0x%x l1pt 0x%x l2pt 0x%x l3pt_rpb 0x%x l3pt_kernel 0x%x" 518 " l2reserv 0x%x\n", 519 rpb, first, second, third_rpb, third_kernel, reservedFixup); 520 if (kernel_end - m5Conf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { 521 printf_lock("Kernel is more than 8MB 0x%x - 0x%x = 0x%x\n", 522 kernel_end, m5Conf.kernStart, 523 kernel_end - m5Conf.kernStart ); 524 panic("kernel too big\n"); 525 } | 519 bootadr = m5Conf.entryPoint; 520 521 printf_lock("HWRPB 0x%x l1pt 0x%x l2pt 0x%x l3pt_rpb 0x%x l3pt_kernel 0x%x" 522 " l2reserv 0x%x\n", 523 rpb, first, second, third_rpb, third_kernel, reservedFixup); 524 if (kernel_end - m5Conf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { 525 printf_lock("Kernel is more than 8MB 0x%x - 0x%x = 0x%x\n", 526 kernel_end, m5Conf.kernStart, 527 kernel_end - m5Conf.kernStart ); 528 panic("kernel too big\n"); 529 } |
530 printf_lock("kstart = 0x%x, kend = 0x%x, kentry = 0x%x, numCPUs = 0x%x\n", m5Conf.kernStart, m5Conf.kernEnd, m5Conf.entryPoint, m5Conf.numCPUs); |
|
526 | 531 |
527 /* Map the kernel's pages into the third level of region 2 */ 528 for (ptr = m5Conf.kernStart; ptr < kernel_end; ptr += PAGE_SIZE) { 529 third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); 530 } | 532 ksp_bottom = (ulong)unix_boot_alloc(1); 533 ksp_top = ksp_bottom + PAGE_SIZE; |
531 | 534 |
532 /* blow 2 pages of phys mem for guards since it maintains 1-to-1 mapping */ 533 ksp = ksp_top + (3 * PAGE_SIZE); 534 if (ksp - m5Conf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { 535 printf_lock("Kernel stack pushd us over 8MB\n"); 536 panic("ksp too big\n"); 537 } 538 if (THIRD_XXX((ulong)ksp_top) > NUM_KERNEL_THIRD * 1024) { 539 panic("increase NUM_KERNEL_THIRD, and change THIRD_XXX\n"); 540 } 541 ptr = (ulong) ksp_top; 542 bzero((char *)ptr, PAGE_SIZE * 2); 543 third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ 544 ptr += PAGE_SIZE; 545 third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); /* Kernel Stack Pages */ 546 ptr += PAGE_SIZE; 547 third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); 548 ptr += PAGE_SIZE; 549 third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ | 535 ptr = (ulong) ksp_bottom; 536 bzero((char *)ptr, PAGE_SIZE); 537 dbPage[THIRD(KSTACK_REGION_VA)] = 0; /* Stack Guard Page */ 538 dbPage[THIRD(KSTACK_REGION_VA + PAGE_SIZE)] = KPTE(PFN(ptr)); /* Kernel Stack Page */ 539 dbPage[THIRD(KSTACK_REGION_VA + 2*PAGE_SIZE)] = 0; /* Stack Guard Page */ |
550 551 /* put argv into the bottom of the stack - argv starts at 1 because 552 * the command thatr got us here (i.e. "unixboot) is in argv[0]. 553 */ | 540 541 /* put argv into the bottom of the stack - argv starts at 1 because 542 * the command thatr got us here (i.e. "unixboot) is in argv[0]. 543 */ |
554 ksp -= 8; /* Back up one longword */ | 544 ksp = ksp_top - 8; /* Back up one longword */ |
555 ksp -= argc * sizeof(char *); /* Make room for argv */ 556 kargv = (char **) ksp; 557 for (i = 1; i < argc; i++) { /* Copy arguments to stack */ 558 ksp -= ((strlen(argv[i]) + 1) + 7) & ~0x7; 559 kargv[i-1] = (char *) ksp; 560 strcpy(kargv[i - 1], argv[i]); 561 } 562 kargc = i - 1; 563 kargv[kargc] = NULL; /* just to be sure; doesn't seem to be used */ 564 ksp -= sizeof(char *); /* point above last arg for no real reason */ 565 | 545 ksp -= argc * sizeof(char *); /* Make room for argv */ 546 kargv = (char **) ksp; 547 for (i = 1; i < argc; i++) { /* Copy arguments to stack */ 548 ksp -= ((strlen(argv[i]) + 1) + 7) & ~0x7; 549 kargv[i-1] = (char *) ksp; 550 strcpy(kargv[i - 1], argv[i]); 551 } 552 kargc = i - 1; 553 kargv[kargc] = NULL; /* just to be sure; doesn't seem to be used */ 554 ksp -= sizeof(char *); /* point above last arg for no real reason */ 555 |
566 free_pfn = PFN(ptr); | 556 free_pfn = PFN(kernel_end); |
567 568 bcopy((char *)&m5_rpb, (char *)rpb, sizeof(struct rpb)); 569 570 rpb->rpb_selfref = (struct rpb *) KSEG_TO_PHYS(rpb); 571 rpb->rpb_string = 0x0000004250525748; 572 573 tbb = (ulong *) (((char *) rpb) + ROUNDUP8(sizeof(struct rpb))); 574 rpb->rpb_trans_off = (ulong)tbb - (ulong)rpb; --- 30 unchanged lines hidden (view full) --- 605 for (i = 0; i < m5Conf.numCPUs; i++) { 606 struct rpb_percpu *thisCPU = (struct rpb_percpu*) 607 ((ulong)rpb_percpu + percpu_size * i); 608 609 bzero((char *)thisCPU, percpu_size); 610 bcopy((char *)&m5_rpb_percpu, (char *)thisCPU, 611 sizeof(struct rpb_percpu)); 612 | 557 558 bcopy((char *)&m5_rpb, (char *)rpb, sizeof(struct rpb)); 559 560 rpb->rpb_selfref = (struct rpb *) KSEG_TO_PHYS(rpb); 561 rpb->rpb_string = 0x0000004250525748; 562 563 tbb = (ulong *) (((char *) rpb) + ROUNDUP8(sizeof(struct rpb))); 564 rpb->rpb_trans_off = (ulong)tbb - (ulong)rpb; --- 30 unchanged lines hidden (view full) --- 595 for (i = 0; i < m5Conf.numCPUs; i++) { 596 struct rpb_percpu *thisCPU = (struct rpb_percpu*) 597 ((ulong)rpb_percpu + percpu_size * i); 598 599 bzero((char *)thisCPU, percpu_size); 600 bcopy((char *)&m5_rpb_percpu, (char *)thisCPU, 601 sizeof(struct rpb_percpu)); 602 |
613 thisCPU->rpb_pcb.rpb_ksp = ksp; | 603 thisCPU->rpb_pcb.rpb_ksp = (KSTACK_REGION_VA + 2*PAGE_SIZE - (ksp_top - ksp)); |
614 thisCPU->rpb_pcb.rpb_ptbr = PFN(first); 615 616 thisCPU->rpb_logout = KSEG_TO_PHYS(percpu_logout); 617 thisCPU->rpb_logout_len = PAGE_SIZE; 618 619 printf_lock("KSP: 0x%x PTBR 0x%x\n", 620 thisCPU->rpb_pcb.rpb_ksp, thisCPU->rpb_pcb.rpb_ptbr); 621 } --- 15 unchanged lines hidden (view full) --- 637 rpb_ctb->rpb_length = sizeof(ctb_tt) - sizeof(rpb_ctb); 638 639 /* 640 * uart initizliation 641 */ 642 ctb_tt->ctb_csr = 0; 643 ctb_tt->ctb_tivec = 0x6c0; /* matches tlaser pal code */ 644 ctb_tt->ctb_rivec = 0x680; /* matches tlaser pal code */ | 604 thisCPU->rpb_pcb.rpb_ptbr = PFN(first); 605 606 thisCPU->rpb_logout = KSEG_TO_PHYS(percpu_logout); 607 thisCPU->rpb_logout_len = PAGE_SIZE; 608 609 printf_lock("KSP: 0x%x PTBR 0x%x\n", 610 thisCPU->rpb_pcb.rpb_ksp, thisCPU->rpb_pcb.rpb_ptbr); 611 } --- 15 unchanged lines hidden (view full) --- 627 rpb_ctb->rpb_length = sizeof(ctb_tt) - sizeof(rpb_ctb); 628 629 /* 630 * uart initizliation 631 */ 632 ctb_tt->ctb_csr = 0; 633 ctb_tt->ctb_tivec = 0x6c0; /* matches tlaser pal code */ 634 ctb_tt->ctb_rivec = 0x680; /* matches tlaser pal code */ |
645 ctb_tt->ctb_baud = 9600; | 635 ctb_tt->ctb_term_type = 2; |
646 ctb_tt->ctb_put_sts = 0; 647 ctb_tt->ctb_get_sts = 0; 648 649 rpb_crb = (struct rpb_crb *) (((ulong)rpb_ctb) + sizeof(struct ctb_tt)); 650 rpb->rpb_crb_off = ((ulong)rpb_crb) - (ulong)rpb; 651 652 bzero((char *)rpb_crb, sizeof(struct rpb_crb)); 653 --- 463 unchanged lines hidden --- | 636 ctb_tt->ctb_put_sts = 0; 637 ctb_tt->ctb_get_sts = 0; 638 639 rpb_crb = (struct rpb_crb *) (((ulong)rpb_ctb) + sizeof(struct ctb_tt)); 640 rpb->rpb_crb_off = ((ulong)rpb_crb) - (ulong)rpb; 641 642 bzero((char *)rpb_crb, sizeof(struct rpb_crb)); 643 --- 463 unchanged lines hidden --- |