From b8612cbda3625e27f109469a1f5416237c97fb41 Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Fri, 14 Nov 2003 10:52:42 -0500 Subject: Import changeset --- system/alpha/console/console.c | 1126 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1126 insertions(+) create mode 100644 system/alpha/console/console.c (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c new file mode 100644 index 000000000..c6a61a10e --- /dev/null +++ b/system/alpha/console/console.c @@ -0,0 +1,1126 @@ + + +/* ****************************************** + * SimOS SRM Console + * + * Derived from Lance Berc's SRM console + * for the SRC XXM Machine + * ******************************************/ + + +/* from simos */ +typedef unsigned long long uint64; +#include "machine_defs.h" +#include "new_aouthdr.h" +#include "alpha_access.h" +#if 0 +#include "srcmax.h" +#endif + +/* from ../h */ +#include "lib.h" +#include "rpb.h" +#include "cserve.h" + + +#define CONS_INT_TX 0x01 /* interrupt enable / state bits */ +#define CONS_INT_RX 0x02 + +#define KSEG 0xfffffc0000000000 +#define K1BASE 0xfffffc8000000000 +#define KSEG_TO_PHYS(x)(((ul)x) & ~KSEG) + +#define CDR ((volatile DevConsoleRegisters *) \ + (__MAGIC_ZONE(0, 0, MAGIC_ZONE_BDOOR_DEV) + __MAGIC_BDOOR_CNSLE_OFFS)) + + +#define PHYS_TO_K1(_x) (K1BASE|(_x)) + +#define AOUT_LOAD_ADDR (KSEG|0xf000) + +#define ROUNDUP8(x) ((ul)(((ul)x)+7) & ~7) +#define ROUNDUP128(x) ((ul)(((ul)x)+127) & ~127) +#define ROUNDUP8K(x) ((ul)(((ul)(x))+8191) & ~8191) + +#define FIRST(x) ((((ul)(x)) >> 33) & 0x3ff) +#define SECOND(x) ((((ul)(x)) >> 23) & 0x3ff) +#define THIRD(x) ((((ul)(x)) >> 13) & 0x3ff) +#define THIRD_XXX(x) ((((ul)(x)) >> 13) & 0xfff) +#define PFN(x) ((((ul)(x) & ~KSEG) >> 13)) + +/* Kernel write | kernel read | valid */ +#define KPTE(x) ((ul)((((ul)(x)) << 32) | 0x1101)) + +#define HWRPB_PAGES 4 +#define MDT_BITMAP_PAGES 4 + +#define CSERVE_K_JTOKERN 0x18 + +#define NUM_KERNEL_THIRD (4) + + +static unixBoot(int go, int argc, char **argv); +void jToPal(ul bootadr); +void SlaveLoop(int cpu); + + +AlphaAccess simosConf; + +/* ************************************************************** + * Console callbacks use VMS calling conventions + * read AXP manual, 2-64. + * ***************************************************************/ +typedef struct OpenVMSFunc { + long dummy; + long func; +}OpenVMSFunc; + +OpenVMSFunc callbackFunc, fixupFunc; + + + + +ul theLock; + + +extern void SpinLock(ul *lock); +#define SpinUnlock(_x) *(_x) = 0; + +struct _kernel_params { + char *bootadr; + ul rpb_percpu; + ul free_pfn; + ul argc; + ul argv; + ul envp; /* NULL */ +}; + + +extern consoleCallback[]; +extern consoleFixup[]; +long CallBackDispatcher(); +long CallBackFixup(); + +/* + * simos console output + */ + +void InitConsole(void) +{ +#if 0 + CDR->intr_status =(DevRegister)(DEV_CNSLE_RX_INTR |DEV_CNSLE_TX_INTR); +#endif +} + +void PutChar(char c) +{ +#if 0 + CDR->data = c; +#endif +#if 0 + *(int*) PHYS_TO_K1(SLOT_D_COM1<<5) = c; +#endif + AlphaAccess *k1Conf = (AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); + k1Conf->outputChar = c; + +} + + +int passArgs(int argc) +{ + ; +} + + +main(int argc, char **argv) +{ + int x,i; + AlphaAccess *k1Conf = (AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); + ui *k1ptr,*ksegptr; + + + InitConsole(); + printf("SimOS console \n"); + /* + * get configuration from backdoor + */ + simosConf.last_offset = k1Conf->last_offset; + printf(" Got simosConfiguration %d \n",simosConf.last_offset); + + for (i=1;i<=simosConf.last_offset/4;i++) { + ui *k1ptr = (ui*)k1Conf + i; + ui *ksegptr = (ui*)(&simosConf.last_offset)+i; + *ksegptr = *k1ptr; + + } + + if (simosConf.version != ALPHA_ACCESS_VERSION) { + panic("Console version mismatch. Console expects %d. SimOS has %d \n", + ALPHA_ACCESS_VERSION,simosConf.version); + } + + + /* + * setup arguments to kernel + */ + unixBoot(1,argc,argv); + + x = *(volatile int *)(K1BASE-4); + while(1) continue; + return x; +} + +/* + * BOOTING + */ +struct rpb xxm_rpb = { + NULL, /* 000: physical self-reference */ + 'H'|('W'<<8)|('R'<<16)|('P'<<24)|('B'<<32), /* 008: contains string "HWRPB" */ + 6, /* 010: HWRPB version number */ + /* the byte count is wrong, but who needs it? - lance */ + 0, /* 018: bytes in RPB perCPU CTB CRB MEDSC */ + 0, /* 020: primary cpu id */ + 8192, /* 028: page size in bytes */ + 43, /* 030: number of phys addr bits */ + 127, /* 038: max valid ASN */ + {'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'}, /* 040: system serial num: 10 ascii chars */ +#ifdef undef +/* To be legitimate, the following system type and variation are correct for the XXM. + But there are too many #ifdefs etc to deal with in Unix, so we tell the kernel + that we're an Avanti, which is similar enough. + */ + 31, /* 050: system type - XXM is now in the Alpha SRM */ + (1 << 10) | (2<<1),/* 058: system variation - XXM w/EV5 & embeded console */ +#endif +#if 0 + 0x12, /* 050: system type - masquarade as some random 21064 */ +#endif + 12, /* masquerade a DEC_3000_500 (bugnion) */ + (2<<1), /* 058: system variation */ + 'c'|('o'<<8)|('o'<<16)|('l'<< 24), /* 060: system revision */ + 1024*4096, /* 068: scaled interval clock intr freq OVERRIDEN*/ + 0, /* 070: cycle counter frequency */ + 0x200000000, /* 078: virtual page table base */ + 0, /* 080: reserved */ + 0, /* 088: offset to translation buffer hint */ + 1, /* 090: number of processor slots OVERRIDDEN*/ + sizeof(struct rpb_percpu), /* 098: per-cpu slot size. OVERRIDDEN */ + 0, /* 0A0: offset to per_cpu slots */ + 1, /* 0A8: number of CTBs */ +#ifdef bugnion_gone + sizeof(struct rpb_ctb), /* 0B0: bytes in largest CTB */ +#else + sizeof(struct ctb_tt), +#endif + 0, /* 0B8: offset to CTB (cons term block) */ + 0, /* 0C0: offset to CRB (cons routine block) */ + 0, /* 0C8: offset to memory descriptor table */ + 0, /* 0D0: offset to config data block */ + 0, /* 0D8: offset to FRU table */ + 0, /* 0E0: virt addr of save term routine */ + 0, /* 0E8: proc value for save term routine */ + 0, /* 0F0: virt addr of restore term routine */ + 0, /* 0F8: proc value for restore term routine */ + 0, /* 100: virt addr of CPU restart routine */ + 0, /* 108: proc value for CPU restart routine */ + 0, /* 110: used to determine presence of kdebug */ + 0, /* 118: reserved for hardware */ +/* the checksum is wrong, but who needs it? - lance */ + 0, /* 120: checksum of prior entries in rpb */ + 0, /* 128: receive ready bitmask */ + 0, /* 130: transmit ready bitmask */ + 0, /* 138: Dynamic System Recog. offset */ +}; + +ul xxm_tbb[] = { 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, + 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e}; + +struct rpb_percpu xxm_rpb_percpu = { + {0,0,0,0,0,0,0,{0,0},{0,0,0,0,0,0,0,0}}, /* 000: boot/restart HWPCB */ + (STATE_PA | STATE_PP | STATE_CV | STATE_PV | STATE_PMV | STATE_PL), /* 080: per-cpu state bits */ + 0xc000, /* 088: palcode memory length */ + 0x2000, /* 090: palcode scratch length */ + 0x4000, /* 098: phys addr of palcode mem space */ + 0x2000, /* 0A0: phys addr of palcode scratch space */ + (2 << 16) | (5 << 8) | 1, /* 0A8: PALcode rev required */ + 5|(2<<32), /* 0B0: processor type */ + 7, /* 0B8: processor variation */ + 'D'|('a'<<8)|('v'<<16)|('e'<<24), /* 0C0: processor revision */ + {'D','a','v','e','C','o','n','r','o','y',0,0,0,0,0,0}, /* 0C8: proc serial num: 10 ascii chars */ + 0, /* 0D8: phys addr of logout area */ + 0, /* 0E0: length in bytes of logout area */ + 0, /* 0E8: halt pcb base */ + 0, /* 0F0: halt pc */ + 0, /* 0F8: halt ps */ + 0, /* 100: halt arg list (R25) */ + 0, /* 108: halt return address (R26) */ + 0, /* 110: halt procedure value (R27) */ + 0, /* 118: reason for halt */ + 0, /* 120: for software */ + {0}, /* 128: inter-console communications buffer */ + {1,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0}, /* 1D0: PALcode revs available */ + 0 /* 250: reserved for arch use */ +/* the dump stack grows from the end of the rpb page not to reach here */ +}; + +struct _xxm_rpb_mdt { + long rpb_checksum; /* 000: checksum of entire mem desc table */ + long rpb_impaddr; /* 008: PA of implementation dep info */ + long rpb_numcl; /* 010: number of clusters */ + struct rpb_cluster rpb_cluster[3]; /* first instance of a cluster */ +}; + +struct _xxm_rpb_mdt xxm_rpb_mdt = { + 0, /* 000: checksum of entire mem desc table */ + 0, /* 008: PA of implementation dep info */ + 0, /* 010: number of clusters */ + {{ 0, /* 000: starting PFN of this cluster */ + 0, /* 008: count of PFNs in this cluster */ + 0, /* 010: count of tested PFNs in cluster */ + 0, /* 018: va of bitmap */ + 0, /* 020: pa of bitmap */ + 0, /* 028: checksum of bitmap */ + 1 /* 030: usage of cluster */ + }, + { 0, /* 000: starting PFN of this cluster */ + 0, /* 008: count of PFNs in this cluster */ + 0, /* 010: count of tested PFNs in cluster */ + 0, /* 018: va of bitmap */ + 0, /* 020: pa of bitmap */ + 0, /* 028: checksum of bitmap */ + 0 /* 030: usage of cluster */ + }, + { 0, /* 000: starting PFN of this cluster */ + 0, /* 008: count of PFNs in this cluster */ + 0, /* 010: count of tested PFNs in cluster */ + 0, /* 018: va of bitmap */ + 0, /* 020: pa of bitmap */ + 0, /* 028: checksum of bitmap */ + 0 /* 030: usage of cluster */ + }} +}; + +/* constants for slotinfo bus_type subfield */ +#define SLOTINFO_TC 0 +#define SLOTINFO_ISA 1 +#define SLOTINFO_EISA 2 +#define SLOTINFO_PCI 3 + +struct rpb_ctb xxm_rpb_ctb = { + CONS_DZ, /* 000: console type */ + 0, /* 008: console unit */ + 0, /* 010: reserved */ + 0 /* 018: byte length of device dep portion */ +}; + +/* we don't do any fixup (aka relocate the console) - we hope */ +struct rpb_crb xxm_rpb_crb = { + 0, /* va of call-back dispatch rtn */ + 0, /* pa of call-back dispatch rtn */ + 0, /* va of call-back fixup rtn */ + 0, /* pa of call-back fixup rtn */ + 0, /* number of entries in phys/virt map */ + 0 /* Number of pages to be mapped */ +}; + +struct _rpb_name { + unsigned long length; + char name[16]; +}; + +extern struct _rpb_name xxm_name; + +struct rpb_dsr xxm_rpb_dsr = { + 0, + 0, + 0, +}; + +struct _rpb_name xxm_name = { + 16, + {'D','E','C',' ','S','R','C',' ','X','X','M',' ','D','G','C',0}, +}; + +/* XXM has one LURT entry - 1050 is for workstations, 1100 is servers (and is needed for CXX) */ +long xxm_lurt[10] = { 9, 12, -1, -1, -1, -1, -1, -1, 1100, 1100 }; + +ul unix_boot_mem; +unsigned long bootadr; +#if 0 +unsigned long aout_bss_addr, aout_bss_size, aout_entry, aout_text_start, aout_data_addr; +#endif +char **kargv; +int kargc; +ul free_pfn; +struct rpb_percpu *rpb_percpu; + + +#define MAX_CPUS 32 + +ul bootStrapImpure[MAX_CPUS]; + + +char *unix_boot_alloc(int pages) +{ + char *ret = (char *) unix_boot_mem; + unix_boot_mem += (pages * 8192); + return ret; +} + +ul *first = 0; +ul *third_rpb = 0; +ul *reservedFixup = 0; + +struct rpb *rpb; + +unixBoot(int go, int argc, char **argv) +{ + ul *second, *third_kernel, ptr, *tbb, size, *percpu_logout; + unsigned char *mdt_bitmap; + long *lp1, *lp2, sum; + int i, cl; + int kern_first_page; + int mem_size = simosConf.mem_size; + + int mem_pages = mem_size / 8192, cons_pages; + ul kernel_bytes, ksp, kernel_end, *unix_kernel_stack, bss, ksp_bottom, ksp_top; + struct rpb_ctb *rpb_ctb; + struct ctb_tt *ctb_tt; + struct rpb_dsr *rpb_dsr; + struct rpb_crb *rpb_crb; + struct _xxm_rpb_mdt *rpb_mdt; + int *rpb_lurt; + char *rpb_name; + ul nextPtr; + + printf( "memsize %x pages %x \n",mem_size,mem_pages); + + + +#ifdef notnow + if (unixArgs()) return; +#endif + + /* Allocate: + * two pages for the HWRPB + * five page table pages: + * 1: First level page table + * 1: Second level page table + * 1: Third level page table for HWRPB + * 2: Third level page table for kernel (for up to 16MB) + * set up the page tables + * load the kernel at the physical address 0x230000 + * build the HWRPB + * set up memory descriptor table to give up the + * physical memory between the end of the page + * tables and the start of the kernel + * enable kseg addressing + * jump to the kernel + */ + + unix_boot_mem = ROUNDUP8K(&_end); + + printf("First free page after ROM 0x%x\n", unix_boot_mem); + + rpb = (struct rpb *) unix_boot_alloc( HWRPB_PAGES); + + mdt_bitmap = (unsigned char *) unix_boot_alloc(MDT_BITMAP_PAGES); + first = (ul *)unix_boot_alloc(1); + second = (ul *)unix_boot_alloc(1); + third_rpb = (ul *)unix_boot_alloc(1); + reservedFixup = (ul*) unix_boot_alloc(1); + third_kernel = (ul *)unix_boot_alloc(NUM_KERNEL_THIRD); + percpu_logout = (ul*)unix_boot_alloc(1); + + + cons_pages = KSEG_TO_PHYS(unix_boot_mem) / 8192; + + /* Set up the page tables */ + bzero((char *)first, 8192); + bzero((char *)second, 8192); + bzero((char *)reservedFixup,8192); + bzero((char *)third_rpb, HWRPB_PAGES * 8192); + bzero((char *)third_kernel, 8192 * NUM_KERNEL_THIRD); + + first[0] = KPTE(PFN(second)); + first[1] = KPTE(PFN(first)); /* Region 3 */ + + second[SECOND(0x10000000)] = KPTE(PFN(third_rpb)); /* Region 0 */ + for (i=0;i (0x800000*NUM_KERNEL_THIRD)) { + printf("Kernel is more than 8MB 0x%x - 0x%x = 0x%x\n", + kernel_end, simosConf.kernStart, + kernel_end -simosConf.kernStart ); + panic("kernel too big\n"); + + } + /* Map the kernel's pages into the third level of region 2 */ + + for (ptr = simosConf.kernStart; ptr < kernel_end; ptr += 8192) { + + third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); + } + /* blow 2 pages of phys mem for guards since it maintains 1-to-1 mapping */ + ksp = ksp_top + (3 * 8192); + if (ksp - simosConf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { + printf("Kernel stack pushd us over 8MB\n"); + panic("ksp too big\n"); + } + if (THIRD_XXX((ul)ksp_top) > NUM_KERNEL_THIRD * 1024) { + panic("increase NUM_KERNEL_THIRD, and change THIRD_XXX\n"); + } + ptr = (ul) ksp_top; + bzero((char *)ptr, 8192 * 2); + third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ + ptr += 8192; + third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); /* Kernel Stack Pages */ + ptr += 8192; + third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); + ptr += 8192; + third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ + + /* put argv into the bottom of the stack - argv starts at 1 because + * the command thatr got us here (i.e. "unixboot) is in argv[0]. + */ + ksp -= 8; /* Back up one longword */ + ksp -= argc * sizeof(char *); /* Make room for argv */ + kargv = (char **) ksp; + for (i = 1; i < argc; i++) { /* Copy arguments to stack */ + ksp -= ((strlen(argv[i]) + 1) + 7) & ~0x7; + kargv[i-1] = (char *) ksp; + strcpy(kargv[i-1], argv[i]); + } + kargc = i - 1; + kargv[kargc] = NULL; /* just to be sure; doesn't seem to be used */ + ksp -= sizeof(char *); /* point above last arg for no real reason */ + + free_pfn = PFN(ptr); + + bcopy((char *)&xxm_rpb, (char *)rpb, sizeof(struct rpb)); + + rpb->rpb_selfref = (struct rpb *) KSEG_TO_PHYS(rpb); + rpb->rpb_string = 0x0000004250525748; + + tbb = (ul *) (((char *) rpb) + ROUNDUP8(sizeof(struct rpb))); + rpb->rpb_trans_off = (ul)tbb - (ul)rpb; + bcopy((char *)xxm_tbb, (char *)tbb, sizeof(xxm_tbb)); + + + /* + * rpb_counter. Use to determine timeouts in OS. + * XXX must be patched after a checkpoint restore (I guess) + */ + + printf("CPU Clock at %d MHz IntrClockFrequency=%d \n", simosConf.cpuClock,simosConf.intrClockFrequency); + rpb->rpb_counter = simosConf.cpuClock * 1000 * 1000; + + /* + * By definition, the rpb_clock is scaled by 4096 (in hz) + */ + rpb->rpb_clock = simosConf.intrClockFrequency * 4096; + + + + /* + * Per CPU Slots. Multiprocessor support. + */ + { + int i; + int size = ROUNDUP128(sizeof(struct rpb_percpu)); + + printf("Booting with %d processor(s) \n",simosConf.numCPUs); + + rpb->rpb_numprocs = simosConf.numCPUs; + rpb->rpb_slotsize = size; + rpb_percpu = (struct rpb_percpu *) + ROUNDUP128(((ul) tbb) +(sizeof(xxm_tbb))); + + rpb->rpb_percpu_off = (ul)rpb_percpu - (ul)rpb; + + for (i=0;irpb_pcb.rpb_ksp = ksp; + thisCPU->rpb_pcb.rpb_ptbr = PFN(first); + + thisCPU->rpb_logout = KSEG_TO_PHYS(percpu_logout); + thisCPU->rpb_logout_len = 8192; + +/* thisCPU->rpb_pcb.rpb_ptbr = PFN(second);*/ + + printf("KSP: 0x%x PTBR 0x%x\n", thisCPU->rpb_pcb.rpb_ksp, thisCPU->rpb_pcb.rpb_ptbr); + + if (i) { + bootStrapImpure[i] = (ul)unix_boot_alloc(1); + } + + } + + nextPtr = (ul)rpb_percpu + size*simosConf.numCPUs; + } + + /* + * Console Terminal Block + */ + + + rpb_ctb = (struct rpb_ctb *) nextPtr; + ctb_tt = (struct ctb_tt*) rpb_ctb; + + rpb->rpb_ctb_off = ((ul)rpb_ctb) - (ul)rpb; + rpb->rpb_ctb_size = sizeof(struct rpb_ctb); + + bzero((char *)rpb_ctb, sizeof(struct ctb_tt)); + +#ifdef original_xxm + if (tga_slot == -1) + rpb_ctb->rpb_type = CONS_DZ; + else { + rpb_ctb->rpb_type = CONS_GRPH; + rpb_ctb->rpb_unit = (SLOTINFO_PCI << 16) | (0 << 8) | tga_slot; + } +#else + rpb_ctb->rpb_type = CONS_DZ; +#endif + + rpb_ctb->rpb_length = sizeof(ctb_tt)-sizeof(rpb_ctb); + + /* + * uart initizliation + */ + ctb_tt->ctb_csr = 0; + ctb_tt->ctb_tivec = 0x6c0; /* matches tlaser pal code */ + ctb_tt->ctb_rivec = 0x680; /* matches tlaser pal code */ + ctb_tt->ctb_baud = 9600; + ctb_tt->ctb_put_sts = 0; + ctb_tt->ctb_get_sts = 0; + + + rpb_crb = (struct rpb_crb *) (((ul)rpb_ctb) + sizeof(struct ctb_tt)); + rpb->rpb_crb_off = ((ul)rpb_crb) - (ul)rpb; + + bzero((char *)rpb_crb, sizeof(struct rpb_crb)); + /* + * console callback stuff (simos) + */ + + rpb_crb->rpb_num = 1; + rpb_crb->rpb_mapped_pages = HWRPB_PAGES; + rpb_crb->rpb_map[0].rpb_virt = 0x10000000; + rpb_crb->rpb_map[0].rpb_phys = ((ul)rpb) & ~0x1fff; + rpb_crb->rpb_map[0].rpb_pgcount = HWRPB_PAGES; + + + printf("Console Callback at 0x%x, fixup at 0x%x \n", + rpb_crb->rpb_va_disp, + rpb_crb->rpb_va_fixup ); + + rpb_mdt = (struct _xxm_rpb_mdt *) (((ul)rpb_crb) + sizeof(struct rpb_crb)); + rpb->rpb_mdt_off = (ul)rpb_mdt - (ul)rpb; + bcopy((char *)&xxm_rpb_mdt, (char *)rpb_mdt, sizeof(struct _xxm_rpb_mdt)); + + + cl = 0; +#ifdef undef + /* Until Digital Unix can handle it, account all pages below the kernel + * as "console" memory. */ + rpb_mdt->rpb_cluster[cl].rpb_pfncount = cons_pages; +#endif + rpb_mdt->rpb_cluster[cl].rpb_pfncount = kern_first_page; + cl++; + + rpb_mdt->rpb_cluster[cl].rpb_pfn = kern_first_page; + rpb_mdt->rpb_cluster[cl].rpb_pfncount = mem_pages - kern_first_page; + rpb_mdt->rpb_cluster[cl].rpb_pfntested=rpb_mdt->rpb_cluster[cl].rpb_pfncount; + rpb_mdt->rpb_cluster[cl].rpb_pa = KSEG_TO_PHYS(mdt_bitmap); + rpb_mdt->rpb_cluster[cl].rpb_va = 0x10000000 + HWRPB_PAGES * 8192; + cl++; + +#ifdef undef + /* The stupid Unix kernel needs to have all mdt clusters in ascending + * order, and the last cluster is used to compute the top of memory. + * It can't make use of memory between the console and the kernel. + */ + rpb_mdt->rpb_cluster[cl].rpb_pfn = cons_pages; + rpb_mdt->rpb_cluster[cl].rpb_pfncount = kern_first_page - cons_pages; + rpb_mdt->rpb_cluster[cl].rpb_pfntested=rpb_mdt->rpb_cluster[cl].rpb_pfncount; + rpb_mdt->rpb_cluster[cl].rpb_pa = KSEG_TO_PHYS(mdt_bitmap); + rpb_mdt->rpb_cluster[cl].rpb_va = 0x10000000 + HWRPB_PAGES * 8192; + cl++; +#endif + + rpb_mdt->rpb_numcl = cl; + + for (i = 0; i < cl; i++) + printf("Memory cluster %d [%d - %d]\n", i, rpb_mdt->rpb_cluster[i].rpb_pfn, rpb_mdt->rpb_cluster[i].rpb_pfncount); + + + + /* Checksum the rpb for good luck */ + sum = 0; + lp1 = (long *)&rpb_mdt->rpb_impaddr; + lp2 = (long *)&rpb_mdt->rpb_cluster[cl]; + while (lp1 < lp2) sum += *lp1++; + rpb_mdt->rpb_checksum = sum; + + /* XXX should checksum the cluster descriptors */ + + bzero((char *)mdt_bitmap, MDT_BITMAP_PAGES * 8192); + for (i = 0; i < mem_pages/8; i++) ((unsigned char *)mdt_bitmap)[i] = 0xff; + + printf("Initalizing mdt_bitmap addr 0x%x mem_pages %x \n", + (long)mdt_bitmap,(long)mem_pages); + + xxm_rpb.rpb_config_off = 0; + xxm_rpb.rpb_fru_off = 0; + + rpb_dsr = (struct rpb_dsr *) (((ul)rpb_mdt) + sizeof(struct _xxm_rpb_mdt)); + rpb->rpb_dsr_off = ((ul)rpb_dsr) - (ul)rpb; + bzero((char *)rpb_dsr, sizeof(struct rpb_dsr)); + rpb_dsr->rpb_smm = 1578; /* Official XXM SMM number as per SRM */ + rpb_dsr->rpb_smm = 1089; /* Official Alcor SMM number as per SRM */ + + rpb_lurt = (int *) ROUNDUP8(((ul)rpb_dsr) + sizeof(struct rpb_dsr)); + rpb_dsr->rpb_lurt_off = ((ul) rpb_lurt) - (ul) rpb_dsr; + bcopy((char *)xxm_lurt, (char *)rpb_lurt, sizeof(xxm_lurt)); + + rpb_name = (char *) ROUNDUP8(((ul)rpb_lurt) + sizeof(xxm_lurt)); + rpb_dsr->rpb_sysname_off = ((ul) rpb_name) - (ul) rpb_dsr; +#define THENAME " SimOS ALPHA/EV5" + sum = sizeof(THENAME); + bcopy(THENAME, rpb_name, sum); + *(ul *)rpb_name = sizeof(THENAME); /* put in length field */ + + /* calculate size of rpb */ + rpb->rpb_size = ((ul) &rpb_name[sum]) - (ul)rpb; + + if (rpb->rpb_size > 8192*HWRPB_PAGES) { + panic("HWRPB_PAGES=%d too small for HWRPB !!! \n"); + } + + + { + ul *ptr = (ul*)((char*)rpb_dsr + sizeof(struct rpb_dsr )); + rpb_crb->rpb_pa_disp = KSEG_TO_PHYS(ptr); + rpb_crb->rpb_va_disp = 0x10000000 + ((ul)ptr&(0x2000*HWRPB_PAGES-1)); + printf("ConsoleDispatch at virt %x phys %x val %x\n", + rpb_crb->rpb_va_disp, + rpb_crb->rpb_pa_disp, + consoleCallback); + *ptr++ = 0; + *ptr++ = (ul) consoleCallback; + rpb_crb->rpb_pa_fixup = KSEG_TO_PHYS(ptr); + rpb_crb->rpb_va_fixup = 0x10000000 + ((ul)ptr& (0x2000*HWRPB_PAGES-1)); + *ptr++ = 0; + *ptr++ = (ul) consoleFixup; + } + + + /* Checksum the rpb for good luck */ + sum = 0; + lp1 = (long *)rpb; + lp2 = &rpb->rpb_checksum; + while (lp1 < lp2) + sum += *lp1++; + *lp2 = sum; + + + /* + * MP bootstrap + */ + + { + int i; + for (i=1;ibootStrapImpure = bootStrapImpure[i]; + k1Conf->bootStrapCPU = i; + } + } + + /* + * Make sure that we are not stepping on the kernel + */ + if ((ul)unix_boot_mem >= (ul)simosConf.kernStart) { + panic("CONSOLE: too much memory. Smashing kernel \n"); + } else { + SpinLock(&theLock); + printf("unix_boot_mem ends at %x \n",unix_boot_mem); + SpinUnlock(&theLock); + } + + +#ifdef undef +#define CSERVE_K_JTOKERN 0x18 + cServe(bootadr, (ul) rpb_percpu, CSERVE_K_JTOKERN, free_pfn); +#endif + + if (go) JToKern(bootadr, rpb_percpu, free_pfn, kargc, kargv, NULL); +} + + +#if 0 +aoutfixup(char *p) +{ + int i; + unsigned long rem, len, off, dst; + + + struct new_aouthdr *ao = (struct new_aouthdr *) &p[NEW_FILHSZ]; +#if 0 + struct scnhdr *s = (struct scnhdr *) &p[FILHSZ + AOUTHSZ]; + struct scnhdr *t, *d, *b; + printf("aoutfixup: %d sections \n",fh->f_nscns); +#endif + + + aout_text_start = ((ul)ao->text_start_hi<<32) + ao->text_start; + aout_data_addr = ((ul)ao->data_start_hi<<32) + ao->data_start; + aout_bss_addr = ((ul)ao->bss_start_hi<<32) + ao->bss_start; + aout_bss_size = ((ul)ao->bsize_hi<<32) + ao->bsize; + aout_entry = ((ul)ao->entry_hi<<32) + ao->entry; + + printf("_text 0x%16x %8d @ %08d\n", aout_text_start, ao->tsize,0 /* t->s_scnptr*/); + printf("_data 0x%16x %8d @ %08d\n", aout_data_addr, ao->dsize,0/* d->s_scnptr*/); + printf("_bss 0x%16x %8d\n", aout_bss_addr, ao->bsize); + printf("entry 0x%16x\n", aout_entry); +#if 0 + for (i = 0; i < fh->f_nscns; i++) { + printf("section %d %s \n",i,s[i].s_name); + if (!strcmp(s[i].s_name, ".text")) t = &s[i]; + else if (!strcmp(s[i].s_name, ".data")) d = &s[i]; + else if (!strcmp(s[i].s_name, ".bss")) b = &s[i]; + } + bcopy(&p[t->s_scnptr], (char *)ao->text_start, ao->tsize); + bcopy(&p[d->s_scnptr], (char *)ao->data_start, ao->dsize); +#endif +} +#endif + +extern ui palJToKern[]; + +JToKern(bootadr, rpb_percpu, free_pfn, k_argc, k_argv, envp) +char * bootadr; +ul rpb_percpu; +ul free_pfn; +ul k_argc; +char **k_argv; +char **envp; +{ + struct _kernel_params *kernel_params = (struct _kernel_params *) KSEG; + int i; + + printf("k_argc = %d ", k_argc); + for (i = 0; i < k_argc; i++) { + printf("'%s' ", k_argv[i]); + } + printf("\n"); + +/* rpb_percpu |= 0xfffffc0000000000;*/ + kernel_params->bootadr = bootadr; + kernel_params->rpb_percpu = KSEG_TO_PHYS(rpb_percpu); + kernel_params->free_pfn = free_pfn; + kernel_params->argc = k_argc; + kernel_params->argv = (ul)k_argv; + kernel_params->envp = (ul)envp; + printf("jumping to kernel at 0x%x, (PCBB 0x%x pfn %d)\n", bootadr, rpb_percpu, free_pfn); + jToPal(KSEG_TO_PHYS((ul)palJToKern)); + printf("returned from jToPal. Looping\n"); + while(1) continue; +} + + +void jToPal(ul bootadr) +{ + cServe(bootadr, 0, CSERVE_K_JTOPAL); + +/* + * Make sure that floating point is enabled incase + * it was disabled by the user program. + */ + wrfen(1); +} + + +int strcpy(char *dst, char *src) +{ + int i=0; + while(*src) { + *dst++ = *src++; + i++; + } + return i; +} + + + + +/* ***************************************** + * Console I/O + * ******************************************/ + +int numOpenDevices = 11; +struct { + char name[128]; +} deviceState[32]; + +#define BOOTDEVICE_NAME "SCSI 1 0 0 1 100" + +void DeviceOperation(long op,long channel, long count, long address, long block) +{ + AlphaAccess *k1Conf = (AlphaAccess *) + (__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); + + long pAddr; + +#if 0 + printf("Console::DeviceRead count=0x%x address=0x%x block=0x%x\n", + count,address,block); +#endif + + if (strcmp(deviceState[channel].name, BOOTDEVICE_NAME )) { + panic("DeviceRead: only implemented for root disk \n"); + } + pAddr = KSEG_TO_PHYS(address); + if (pAddr + count > simosConf.mem_size) { + panic("DeviceRead: request out of range \n"); + } + + k1Conf->diskCount = count; + k1Conf->diskPAddr = pAddr; + k1Conf->diskBlock = block; + k1Conf->diskOperation = op; /* launch */ +} + + + +/* ************************************************************************* + * SimoS Console callbacks + * **************************************************/ + +/* AXP manual 2-31 */ +#define CONSCB_GETC 0x1 +#define CONSCB_PUTS 0x2 +#define CONSCB_RESET_TERM 0x3 +#define CONSCB_SET_TERM_INT 0x4 +#define CONSCB_SET_TERM_CTL 0x5 +#define CONSCB_PROCESS_KEY 0x6 + +#define CONSCB_OPEN 0x10 +#define CONSCB_CLOSE 0x11 +#define CONSCB_READ 0x13 + +#define CONSCB_GETENV 0x22 + +/* AXP manual 2-26 */ + +#define ENV_BOOTED_DEV 0x4 +#define ENV_BOOTED_OSFLAGS 0x8 + +long CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) +{ + int i; + switch (a0) { + case CONSCB_PUTS: + for(i=0;i a3) { + panic("CONSCB_GETENV overwrote buffer \n"); + } + return i; + case CONSCB_OPEN: + bcopy((char*)a1,deviceState[numOpenDevices].name,a2); + deviceState[numOpenDevices].name[a2] = '\0'; + printf("CONSOLE OPEN : %s --> success \n", + deviceState[numOpenDevices].name); + return numOpenDevices++; + + case CONSCB_READ: + DeviceOperation(a0,a1,a2,a3,a4); + break; + case CONSCB_CLOSE: + break; + default: + panic("cher (%x,%x,%x,%x) \n", + a0,a1,a2,a3); + } + return 0; +} + +long CallBackFixup(int a0, int a1, int a2) +{ + printf("CallbackFixup %x %x \n",a0,a1); + +#if 0 + if (first[FIRST(a1)]==0) { + first[FIRST(a1)] = KPTE(PFN(reservedFixup)); + } else { + panic("CallBakcfixup\n"); + } + second[SECOND(a1)] = KPTE(PFN(third_rpb)); /* Region 0 */ + printf("Fixup: FISRT(a1)=0x%x SECOND(a1)=0x%x THIRD(a1)=0x%x\n", + FIRST(a1),SECOND(a1),THIRD(a1)); + +#endif + return 0; +} + + + + + +void SlaveCmd(int cpu, struct rpb_percpu *my_rpb) +{ +/* extern void palJToSlave[]; */ + extern unsigned int palJToSlave[]; + + + my_rpb->rpb_state |= STATE_BIP; + my_rpb->rpb_state &= ~STATE_RC; + + SpinLock(&theLock); + printf("SlaveCmd: restart %x %x vptb %x my_rpb %x my_rpb_phys %x\n", + rpb->rpb_restart, + rpb->rpb_restart_pv, + rpb->rpb_vptb, my_rpb, + KSEG_TO_PHYS(my_rpb)); + SpinUnlock(&theLock); + + cServe(KSEG_TO_PHYS((ul)palJToSlave), + (ul)rpb->rpb_restart, + CSERVE_K_JTOPAL, + rpb->rpb_restart_pv, + rpb->rpb_vptb, + KSEG_TO_PHYS(my_rpb)); +} + +void SlaveLoop( int cpu) +{ + int size = ROUNDUP128(sizeof(struct rpb_percpu)); + struct rpb_percpu *my_rpb = (struct rpb_percpu*) + ((ul)rpb_percpu + size*cpu); + + + SpinLock(&theLock); + if (cpu==0) { + panic("CPU 0 entering slaveLoop. Reenetering the console. HOSED \n"); + } else { + printf("Entering slaveloop for cpu %d my_rpb=%x \n",cpu,my_rpb); + } + SpinUnlock(&theLock); + while(1) { + int i; + for (i=0; i < 1000000 ; i++) { + if (my_rpb->rpb_iccb.iccb_rxlen) { + SpinLock(&theLock); + printf("Slave CPU %d console command %s", + cpu,my_rpb->rpb_iccb.iccb_rxbuf); + SpinUnlock(&theLock); + SlaveCmd(cpu,my_rpb); + panic("SlaveCmd returned \n"); + } + } + printf("*"); + } +} + -- cgit v1.2.3 From 492fa2ae5ee7ef9c3f3601ac611ebc9a43ff83eb Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 14 Nov 2003 12:32:52 -0500 Subject: Get the console code to compile correctly Add support for some thigns that M5 needs Make this better support Tru64 v5.1 console/Makefile: I couldn't figure out the old build system since I was missing a bunch of tools at the time, so I kinda rewrote it. console/console.c: Get the includes right, and make things compile little bit of cleanup along the way console/paljtokern.s: formatting junk console/printf.c: Formatting get const right h/lib.h: fiddle with the includes that we need console/console.c: Get the BOOTDEVICE_NAME right Add a bit of support for grabbing console environment variables --- system/alpha/console/console.c | 187 ++++++++++++++++++++++++++++++++++------- 1 file changed, 155 insertions(+), 32 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index c6a61a10e..6763a332f 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -10,10 +10,14 @@ /* from simos */ typedef unsigned long long uint64; -#include "machine_defs.h" -#include "new_aouthdr.h" +typedef unsigned int uint32; + +#define CONSOLE #include "alpha_access.h" +#include "machine_defs.h" + #if 0 +#include "new_aouthdr.h" #include "srcmax.h" #endif @@ -64,7 +68,7 @@ void jToPal(ul bootadr); void SlaveLoop(int cpu); -AlphaAccess simosConf; +struct AlphaAccess simosConf; /* ************************************************************** * Console callbacks use VMS calling conventions @@ -112,6 +116,12 @@ void InitConsole(void) #endif } +char GetChar() +{ + struct AlphaAccess *k1Conf = (struct AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); + return 0; +} + void PutChar(char c) { #if 0 @@ -120,22 +130,21 @@ void PutChar(char c) #if 0 *(int*) PHYS_TO_K1(SLOT_D_COM1<<5) = c; #endif - AlphaAccess *k1Conf = (AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); + struct AlphaAccess *k1Conf = (struct AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); k1Conf->outputChar = c; } -int passArgs(int argc) -{ - ; -} - +int +passArgs(int argc) +{ return 0; } +int main(int argc, char **argv) { int x,i; - AlphaAccess *k1Conf = (AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); + struct AlphaAccess *k1Conf = (struct AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); ui *k1ptr,*ksegptr; @@ -175,7 +184,8 @@ main(int argc, char **argv) */ struct rpb xxm_rpb = { NULL, /* 000: physical self-reference */ - 'H'|('W'<<8)|('R'<<16)|('P'<<24)|('B'<<32), /* 008: contains string "HWRPB" */ + ((long)'H') | (((long)'W') << 8) | (((long)'R') << 16) | + ((long)'P' << 24) | (((long)'B') << 32), /* 008: contains string "HWRPB" */ 6, /* 010: HWRPB version number */ /* the byte count is wrong, but who needs it? - lance */ 0, /* 018: bytes in RPB perCPU CTB CRB MEDSC */ @@ -243,7 +253,7 @@ struct rpb_percpu xxm_rpb_percpu = { 0x4000, /* 098: phys addr of palcode mem space */ 0x2000, /* 0A0: phys addr of palcode scratch space */ (2 << 16) | (5 << 8) | 1, /* 0A8: PALcode rev required */ - 5|(2<<32), /* 0B0: processor type */ + 5 | (2L << 32), /* 0B0: processor type */ 7, /* 0B8: processor variation */ 'D'|('a'<<8)|('v'<<16)|('e'<<24), /* 0C0: processor revision */ {'D','a','v','e','C','o','n','r','o','y',0,0,0,0,0,0}, /* 0C8: proc serial num: 10 ascii chars */ @@ -371,6 +381,8 @@ ul *first = 0; ul *third_rpb = 0; ul *reservedFixup = 0; +int strcpy(char *dst, char *src); + struct rpb *rpb; unixBoot(int go, int argc, char **argv) @@ -777,7 +789,11 @@ unixBoot(int go, int argc, char **argv) { ul *ptr = (ul*)((char*)rpb_dsr + sizeof(struct rpb_dsr )); rpb_crb->rpb_pa_disp = KSEG_TO_PHYS(ptr); +#if 0 rpb_crb->rpb_va_disp = 0x10000000 + ((ul)ptr&(0x2000*HWRPB_PAGES-1)); +#else + rpb_crb->rpb_va_disp = 0x10000000 + ((ul)ptr & 0x1fff); +#endif printf("ConsoleDispatch at virt %x phys %x val %x\n", rpb_crb->rpb_va_disp, rpb_crb->rpb_pa_disp, @@ -785,7 +801,11 @@ unixBoot(int go, int argc, char **argv) *ptr++ = 0; *ptr++ = (ul) consoleCallback; rpb_crb->rpb_pa_fixup = KSEG_TO_PHYS(ptr); +#if 0 rpb_crb->rpb_va_fixup = 0x10000000 + ((ul)ptr& (0x2000*HWRPB_PAGES-1)); +#else + rpb_crb->rpb_va_fixup = 0x10000000 + ((ul)ptr & 0x1fff); +#endif *ptr++ = 0; *ptr++ = (ul) consoleFixup; } @@ -807,7 +827,7 @@ unixBoot(int go, int argc, char **argv) { int i; for (i=1;i= 0 && a1 < 100) + printf ("GETENV unsupported option %d\n", a1); + else + printf ("GETENV unsupported option %s\n", a1); break; } if (i > a3) { -- cgit v1.2.3 From f6bfca014bc97f9cfa2c9ebc85bfcb091b709550 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 17 Dec 2003 21:39:42 -0500 Subject: Implement support for more console environment variables. There are some default values here, but they can be changed from the simulator itself. (Search in m5 for boot_osflags) --- system/alpha/console/console.c | 136 +++++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 67 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 6763a332f..e8bc9bd26 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -1046,27 +1046,24 @@ DeviceOperation(long op, long channel, long count, long address, long block) #define MAX_ENVLEN 32 -char env_booted_dev[MAX_ENVLEN] = BOOTDEVICE_NAME; -char env_booted_osflags[MAX_ENVLEN] = ""; -char env_com1_baud[MAX_ENVLEN] = ""; -char env_secure[MAX_ENVLEN] = ""; - -#if 0 -char env_auto_action[MAX_ENVLEN] = ""; +char env_auto_action[MAX_ENVLEN] = "BOOT"; char env_boot_dev[MAX_ENVLEN] = ""; char env_bootdef_dev[MAX_ENVLEN] = ""; +char env_booted_dev[MAX_ENVLEN] = BOOTDEVICE_NAME; char env_boot_file[MAX_ENVLEN] = ""; char env_booted_file[MAX_ENVLEN] = ""; char env_boot_osflags[MAX_ENVLEN] = ""; +char env_booted_osflags[MAX_ENVLEN] = ""; char env_boot_reset[MAX_ENVLEN] = ""; char env_dump_dev[MAX_ENVLEN] = ""; char env_enable_audit[MAX_ENVLEN] = ""; char env_license[MAX_ENVLEN] = ""; char env_char_set[MAX_ENVLEN] = ""; -int env_language = 0; -char env_tty_dev[MAX_ENVLEN] = ""; +char env_language[MAX_ENVLEN] = ""; +char env_tty_dev[MAX_ENVLEN] = "0"; char env_scsiid[MAX_ENVLEN] = ""; char env_scsifast[MAX_ENVLEN] = ""; +char env_com1_baud[MAX_ENVLEN] = ""; char env_com1_modem[MAX_ENVLEN] = ""; char env_com1_flow[MAX_ENVLEN] = ""; char env_com1_misc[MAX_ENVLEN] = ""; @@ -1075,9 +1072,54 @@ char env_com2_modem[MAX_ENVLEN] = ""; char env_com2_flow[MAX_ENVLEN] = ""; char env_com2_misc[MAX_ENVLEN] = ""; char env_password[MAX_ENVLEN] = ""; +char env_secure[MAX_ENVLEN] = ""; char env_logfail[MAX_ENVLEN] = ""; char env_srm2dev_id[MAX_ENVLEN] = ""; -#endif + +#define MAX_ENV_INDEX 100 +char *env_ptr[MAX_ENV_INDEX] = +{ + 0, /* 0x00 */ + env_auto_action, /* 0x01 */ + env_boot_dev, /* 0x02 */ + env_bootdef_dev, /* 0x03 */ + env_booted_dev, /* 0x04 */ + env_boot_file, /* 0x05 */ + env_booted_file, /* 0x06 */ + env_boot_osflags, /* 0x07 */ + env_booted_osflags, /* 0x08 */ + env_boot_reset, /* 0x09 */ + env_dump_dev, /* 0x0A */ + env_enable_audit, /* 0x0B */ + env_license, /* 0x0C */ + env_char_set, /* 0x0D */ + (char *)&env_language, /* 0x0E */ + env_tty_dev, /* 0x0F */ + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* 0x10 - 0x1F */ + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* 0x20 - 0x2F */ + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* 0x30 - 0x3F */ + 0, /* 0x40 */ + 0, /* 0x41 */ + env_scsiid, /* 0x42 */ + env_scsifast, /* 0x43 */ + env_com1_baud, /* 0x44 */ + env_com1_modem, /* 0x45 */ + env_com1_flow, /* 0x46 */ + env_com1_misc, /* 0x47 */ + env_com2_baud, /* 0x48 */ + env_com2_modem, /* 0x49 */ + env_com2_flow, /* 0x4A */ + env_com2_misc, /* 0x4B */ + env_password, /* 0x4C */ + env_secure, /* 0x4D */ + env_logfail, /* 0x4E */ + env_srm2dev_id, /* 0x4F */ + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* 0x50 - 0x5F */ + 0, /* 0x60 */ + 0, /* 0x61 */ + 0, /* 0x62 */ + 0, /* 0x63 */ +}; long CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) @@ -1094,63 +1136,21 @@ CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) return a3; case CONSCB_GETENV: - switch (a1) { - case ENV_BOOTED_DEV: - i = strcpy((char*)a2, env_booted_dev); - break; - - case ENV_BOOTED_OSFLAGS: - i = strcpy((char*)a2, env_booted_osflags); - break; - - case ENV_COM1_BAUD: - i = strcpy((char*)a2, env_com1_baud); - break; - - case ENV_SECURE: - i = strcpy((char *)a2, env_secure); - break; - -#if 0 - case ENV_AUTO_ACTION: - case ENV_BOOT_DEV: - case ENV_BOOTDEF_DEV: - case ENV_BOOT_FILE: - case ENV_BOOTED_FILE: - case ENV_BOOT_OSFLAGS: - case ENV_BOOT_RESET: - case ENV_DUMP_DEV: - case ENV_ENABLE_AUDIT: - case ENV_LICENSE: - case ENV_CHAR_SET: - case ENV_LANGUAGE: - case ENV_TTY_DEV: - case ENV_SCSIID: - case ENV_SCSIFAST: - case ENV_COM1_MODEM: - case ENV_COM1_FLOW: - case ENV_COM1_MISC: - case ENV_COM2_BAUD: - case ENV_COM2_MODEM: - case ENV_COM2_FLOW: - case ENV_COM2_MISC: - case ENV_PASSWORD: - case ENV_LOGFAIL: - case ENV_SRM2DEV_ID: -#endif - default: - strcpy((char*)a2,""); + if (a1 >= 0 && a1 < MAX_ENV_INDEX && env_ptr[a1] != 0 && *env_ptr[a1]) { + i = strcpy((char*)a2, env_ptr[a1]); + } else { + strcpy((char*)a2, ""); i = (long)0xc000000000000000; - if (a1 >= 0 && a1 < 100) - printf ("GETENV unsupported option %d\n", a1); + if (a1 >= 0 && a1 < MAX_ENV_INDEX) + printf ("GETENV unsupported option %d (0x%x)\n", a1, a1); else - printf ("GETENV unsupported option %s\n", a1); - break; - } - if (i > a3) { - panic("CONSCB_GETENV overwrote buffer \n"); - } - return i; + printf ("GETENV unsupported option %s\n", a1); + } + + if (i > a3) + panic("CONSCB_GETENV overwrote buffer\n"); + return i; + case CONSCB_OPEN: bcopy((char*)a1,deviceState[numOpenDevices].name,a2); deviceState[numOpenDevices].name[a2] = '\0'; @@ -1161,12 +1161,14 @@ CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) case CONSCB_READ: DeviceOperation(a0,a1,a2,a3,a4); break; + case CONSCB_CLOSE: break; + default: - panic("cher (%x,%x,%x,%x) \n", - a0,a1,a2,a3); + panic("cher (%x,%x,%x,%x)\n", a0, a1, a2, a3); } + return 0; } -- cgit v1.2.3 From fbe8ff04da3c33549ffde08258c5b2b0f586e94a Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Mon, 22 Dec 2003 13:04:23 -0500 Subject: Implement GetChar() console/Makefile: Quick install target to copy the binary to zizzer --- system/alpha/console/console.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index e8bc9bd26..d62dfdb70 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -8,8 +8,9 @@ * ******************************************/ -/* from simos */ +typedef unsigned long long uint64_t; typedef unsigned long long uint64; +typedef unsigned int uint32_t; typedef unsigned int uint32; #define CONSOLE @@ -119,7 +120,7 @@ void InitConsole(void) char GetChar() { struct AlphaAccess *k1Conf = (struct AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); - return 0; + return k1Conf->inputChar; } void PutChar(char c) @@ -1127,12 +1128,11 @@ CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) long i; switch (a0) { case CONSCB_GETC: - break; + return GetChar(); case CONSCB_PUTS: - for(i = 0; i < a3; i++) { + for(i = 0; i < a3; i++) PutChar(*(char *)a2+i); - } return a3; case CONSCB_GETENV: -- cgit v1.2.3 From d23ad6c0c4112177c546fd615ca6f679b179e5f5 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Wed, 14 Jan 2004 04:06:44 -0500 Subject: Added support for OPEN_CONSOLE and CLOSE_CONSOLE; fixed PUTS bug --- system/alpha/console/console.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index e8bc9bd26..3ae97425b 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -1006,6 +1006,8 @@ DeviceOperation(long op, long channel, long count, long address, long block) #define CONSCB_SET_TERM_INT 0x4 #define CONSCB_SET_TERM_CTL 0x5 #define CONSCB_PROCESS_KEY 0x6 +#define CONSCB_OPEN_CONSOLE 0x7 +#define CONSCB_CLOSE_CONSOLE 0x8 #define CONSCB_OPEN 0x10 #define CONSCB_CLOSE 0x11 @@ -1131,7 +1133,7 @@ CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) case CONSCB_PUTS: for(i = 0; i < a3; i++) { - PutChar(*(char *)a2+i); + PutChar(*((char *)a2+i)); } return a3; @@ -1164,6 +1166,14 @@ CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) case CONSCB_CLOSE: break; + case CONSCB_OPEN_CONSOLE: + printf("CONSOLE OPEN\n"); + return 0; /* success */ + break; /* not rearched */ + case CONSCB_CLOSE_CONSOLE: + printf("CONSOLE CLOSE\n"); + return 0; /* success */ + break; /* not reached */ default: panic("cher (%x,%x,%x,%x)\n", a0, a1, a2, a3); -- cgit v1.2.3 From 5d3149b69d42b28fef51d9137528937ba2c49141 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Mon, 2 Feb 2004 17:40:11 -0500 Subject: Added platfrom_m5 - Our hacked up tsunami palcode and modified palcode makefile to that end. Additionally made a change in console to preserve t7 on call back because linux uses it for the "current" pointer. console/Makefile: Changed makefile back to using gcc and gas rather then trying to cross-compile for now console/console.c: Put code in to save t7 on CallBackFixup() call and changed the system type to Tsunami palcode/Makefile: updated palcode makefile to have targets for tlaser and tsunami --- system/alpha/console/console.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 0697be63a..844cb4ddc 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -27,7 +27,6 @@ typedef unsigned int uint32; #include "rpb.h" #include "cserve.h" - #define CONS_INT_TX 0x01 /* interrupt enable / state bits */ #define CONS_INT_RX 0x02 @@ -206,8 +205,8 @@ struct rpb xxm_rpb = { #if 0 0x12, /* 050: system type - masquarade as some random 21064 */ #endif - 12, /* masquerade a DEC_3000_500 (bugnion) */ - (2<<1), /* 058: system variation */ + 34, /* masquerade a Tsunami RGD */ + (1<<10), /* 058: system variation */ 'c'|('o'<<8)|('o'<<16)|('l'<< 24), /* 060: system revision */ 1024*4096, /* 068: scaled interval clock intr freq OVERRIDEN*/ 0, /* 070: cycle counter frequency */ @@ -1184,7 +1183,23 @@ CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) long CallBackFixup(int a0, int a1, int a2) { - printf("CallbackFixup %x %x \n",a0,a1); + long temp; + /* Linux uses r8 for the current pointer (pointer to data structure + contating info about currently running process). It is set when the + kernel starts and is expected to remain there... Problem is that the + unlike the kernel, the console does not prevent the assembler from + using r8. So here is a work around. So far this has only been a problem + in CallBackFixup() but any other call back functions could cause a problem + at some point */ + + /* save off the current pointer to a temp variable */ + asm("bis $8, $31, %0" : "=r" (temp)); + + /* call original code */ + printf("CallbackFixup %x %x, t7=%x\n",a0,a1,temp); + + /* restore the current pointer */ + asm("bis %0, $31, $8" : : "r" (temp) : "$8"); #if 0 if (first[FIRST(a1)]==0) { -- cgit v1.2.3 From ce9b1a1e373cf965e18ef379a121b95119ff1f46 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Tue, 11 May 2004 17:31:28 -0400 Subject: added some comments to palcode and zeroed system type in HWPRB (m5 will fill in) console/console.c: 0 the system type, let m5 overwrite palcode/platform_m5.s: add some comments and make the timer interrupt actually care what CPU it happened on --- system/alpha/console/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 844cb4ddc..5e9e49ce1 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -205,7 +205,7 @@ struct rpb xxm_rpb = { #if 0 0x12, /* 050: system type - masquarade as some random 21064 */ #endif - 34, /* masquerade a Tsunami RGD */ + 0, /* masquerade a Tsunami RGD */ (1<<10), /* 058: system variation */ 'c'|('o'<<8)|('o'<<16)|('l'<< 24), /* 060: system revision */ 1024*4096, /* 068: scaled interval clock intr freq OVERRIDEN*/ -- cgit v1.2.3 From 120825c1e2c0d1fac57f3692ae7fe3194fbd0b3c Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Tue, 18 May 2004 20:11:58 -0400 Subject: Added ALPHA_ACCESS_BASE to get rid of machine_defs.h --- system/alpha/console/console.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 5e9e49ce1..afdf00362 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -15,7 +15,6 @@ typedef unsigned int uint32; #define CONSOLE #include "alpha_access.h" -#include "machine_defs.h" #if 0 #include "new_aouthdr.h" @@ -34,8 +33,7 @@ typedef unsigned int uint32; #define K1BASE 0xfffffc8000000000 #define KSEG_TO_PHYS(x)(((ul)x) & ~KSEG) -#define CDR ((volatile DevConsoleRegisters *) \ - (__MAGIC_ZONE(0, 0, MAGIC_ZONE_BDOOR_DEV) + __MAGIC_BDOOR_CNSLE_OFFS)) +#define ALPHA_ACCESS_BASE 0xfffffc8000a00000 #define PHYS_TO_K1(_x) (K1BASE|(_x)) @@ -118,7 +116,7 @@ void InitConsole(void) char GetChar() { - struct AlphaAccess *k1Conf = (struct AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); + struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); return k1Conf->inputChar; } @@ -130,7 +128,7 @@ void PutChar(char c) #if 0 *(int*) PHYS_TO_K1(SLOT_D_COM1<<5) = c; #endif - struct AlphaAccess *k1Conf = (struct AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); + struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); k1Conf->outputChar = c; } @@ -144,7 +142,7 @@ int main(int argc, char **argv) { int x,i; - struct AlphaAccess *k1Conf = (struct AlphaAccess *)(__MAGIC_ZONE(0, 0, MAGIC_ZONE_EV5_ALIAS)); + struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); ui *k1ptr,*ksegptr; @@ -828,7 +826,7 @@ unixBoot(int go, int argc, char **argv) int i; for (i=1;i Date: Wed, 23 Jun 2004 15:12:15 -0400 Subject: Copy variables over one at a time rather than copying 4 bytes at a time. Easiest way to deal with the endian issue. --- system/alpha/console/console.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index afdf00362..61e765411 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -154,12 +154,31 @@ main(int argc, char **argv) simosConf.last_offset = k1Conf->last_offset; printf(" Got simosConfiguration %d \n",simosConf.last_offset); - for (i=1;i<=simosConf.last_offset/4;i++) { +/* for (i=1;i<=simosConf.last_offset/4;i++) { ui *k1ptr = (ui*)k1Conf + i; ui *ksegptr = (ui*)(&simosConf.last_offset)+i; *ksegptr = *k1ptr; - } + }*/ + + simosConf.last_offset = k1Conf->last_offset; + simosConf.version = k1Conf->version; + simosConf.numCPUs = k1Conf->numCPUs; + simosConf.intrClockFrequency = k1Conf->intrClockFrequency; + simosConf.cpuClock = k1Conf->cpuClock; + simosConf.mem_size = k1Conf->mem_size; + simosConf.kernStart = k1Conf->kernStart; + simosConf.kernEnd = k1Conf->kernEnd; + simosConf.entryPoint = k1Conf->entryPoint; + simosConf.diskUnit = k1Conf->diskUnit; + simosConf.diskCount = k1Conf->diskCount; + simosConf.diskPAddr = k1Conf->diskPAddr; + simosConf.diskBlock = k1Conf->diskBlock; + simosConf.diskOperation = k1Conf->diskOperation; + simosConf.outputChar = k1Conf->outputChar; + simosConf.inputChar = k1Conf->inputChar; + simosConf.bootStrapImpure = k1Conf->bootStrapImpure; + simosConf.bootStrapCPU = k1Conf->bootStrapCPU; if (simosConf.version != ALPHA_ACCESS_VERSION) { panic("Console version mismatch. Console expects %d. SimOS has %d \n", -- cgit v1.2.3 From 29c5218e4faf2b059a00b0864e6763ee18143d56 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Sun, 1 Aug 2004 00:50:26 -0400 Subject: changed to generate tlaser and tsunami console code at different addresses so the uncachable bit is set for tsunami. console/Makefile: console/console.c: changed to generate tlaser and tsunami console code at different addresses --- system/alpha/console/console.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 61e765411..12db3d9f5 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -33,8 +33,13 @@ typedef unsigned int uint32; #define K1BASE 0xfffffc8000000000 #define KSEG_TO_PHYS(x)(((ul)x) & ~KSEG) +#ifdef TSUNAMI +#define ALPHA_ACCESS_BASE 0xfffffd0200000000 +#elif TLASER #define ALPHA_ACCESS_BASE 0xfffffc8000a00000 - +#else +#error TSUNAMI/TLASER not defined. +#endif #define PHYS_TO_K1(_x) (K1BASE|(_x)) -- cgit v1.2.3 From 1940fcdd2915697a7d213043dcd45260bf5b2eda Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Wed, 1 Sep 2004 00:23:00 -0400 Subject: changes to make smp work in linux console/console.c: Remove Printed SimOS references and replace with M5 Rework the SMP stuff, so we don't trash any stacks, or what we thought were stacks, but are actually other ppls memory. console/dbmentry.s: add a carefully crafted piece of assembly that doesn't use the stack, so we don't clobber anthing in the time between when we are spinning and when the OS tells us to go. palcode/platform_m5.s: add/fix code for IPI, multiprocessor interrupts (DIR), and initial bootstrapping of the cpu --- system/alpha/console/console.c | 54 ++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 33 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 12db3d9f5..a82e695e1 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -152,19 +152,12 @@ main(int argc, char **argv) InitConsole(); - printf("SimOS console \n"); + printf("M5 console\n"); /* * get configuration from backdoor */ simosConf.last_offset = k1Conf->last_offset; - printf(" Got simosConfiguration %d \n",simosConf.last_offset); - -/* for (i=1;i<=simosConf.last_offset/4;i++) { - ui *k1ptr = (ui*)k1Conf + i; - ui *ksegptr = (ui*)(&simosConf.last_offset)+i; - *ksegptr = *k1ptr; - - }*/ + printf("Got Configuration %d \n",simosConf.last_offset); simosConf.last_offset = k1Conf->last_offset; simosConf.version = k1Conf->version; @@ -186,7 +179,7 @@ main(int argc, char **argv) simosConf.bootStrapCPU = k1Conf->bootStrapCPU; if (simosConf.version != ALPHA_ACCESS_VERSION) { - panic("Console version mismatch. Console expects %d. SimOS has %d \n", + panic("Console version mismatch. Console expects %d. has %d \n", ALPHA_ACCESS_VERSION,simosConf.version); } @@ -227,8 +220,8 @@ struct rpb xxm_rpb = { #if 0 0x12, /* 050: system type - masquarade as some random 21064 */ #endif - 0, /* masquerade a Tsunami RGD */ - (1<<10), /* 058: system variation */ + 0, /* OVERRIDDEN */ + (1<<10), /* 058: system variation OVERRIDDEN */ 'c'|('o'<<8)|('o'<<16)|('l'<< 24), /* 060: system revision */ 1024*4096, /* 068: scaled interval clock intr freq OVERRIDEN*/ 0, /* 070: cycle counter frequency */ @@ -268,17 +261,17 @@ ul xxm_tbb[] = { 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e}; struct rpb_percpu xxm_rpb_percpu = { - {0,0,0,0,0,0,0,{0,0},{0,0,0,0,0,0,0,0}}, /* 000: boot/restart HWPCB */ + {0,0,0,0,0,0,1,{0,0},{0,0,0,0,0,0,0,0}}, /* 000: boot/restart HWPCB */ (STATE_PA | STATE_PP | STATE_CV | STATE_PV | STATE_PMV | STATE_PL), /* 080: per-cpu state bits */ 0xc000, /* 088: palcode memory length */ 0x2000, /* 090: palcode scratch length */ 0x4000, /* 098: phys addr of palcode mem space */ 0x2000, /* 0A0: phys addr of palcode scratch space */ (2 << 16) | (5 << 8) | 1, /* 0A8: PALcode rev required */ - 5 | (2L << 32), /* 0B0: processor type */ + 11 | (2L << 32), /* 0B0: processor type */ 7, /* 0B8: processor variation */ - 'D'|('a'<<8)|('v'<<16)|('e'<<24), /* 0C0: processor revision */ - {'D','a','v','e','C','o','n','r','o','y',0,0,0,0,0,0}, /* 0C8: proc serial num: 10 ascii chars */ + 'M'|('5'<<8)|('A'<<16)|('0'<<24), /* 0C0: processor revision */ + {'M','5','/','A','l','p','h','a','0','0','0','0','0','0','0','0'}, /* 0C8: proc serial num: 10 ascii chars */ 0, /* 0D8: phys addr of logout area */ 0, /* 0E0: length in bytes of logout area */ 0, /* 0E8: halt pcb base */ @@ -795,7 +788,7 @@ unixBoot(int go, int argc, char **argv) rpb_name = (char *) ROUNDUP8(((ul)rpb_lurt) + sizeof(xxm_lurt)); rpb_dsr->rpb_sysname_off = ((ul) rpb_name) - (ul) rpb_dsr; -#define THENAME " SimOS ALPHA/EV5" +#define THENAME " M5/Alpha " sum = sizeof(THENAME); bcopy(THENAME, rpb_name, sum); *(ul *)rpb_name = sizeof(THENAME); /* put in length field */ @@ -1246,6 +1239,9 @@ void SlaveCmd(int cpu, struct rpb_percpu *my_rpb) /* extern void palJToSlave[]; */ extern unsigned int palJToSlave[]; + SpinLock(&theLock); + printf("Slave CPU %d console command %s", cpu,my_rpb->rpb_iccb.iccb_rxbuf); + SpinUnlock(&theLock); my_rpb->rpb_state |= STATE_BIP; my_rpb->rpb_state &= ~STATE_RC; @@ -1264,6 +1260,8 @@ void SlaveCmd(int cpu, struct rpb_percpu *my_rpb) rpb->rpb_restart_pv, rpb->rpb_vptb, KSEG_TO_PHYS(my_rpb)); + + panic("SlaveCmd returned \n"); } void SlaveLoop( int cpu) @@ -1272,7 +1270,6 @@ void SlaveLoop( int cpu) struct rpb_percpu *my_rpb = (struct rpb_percpu*) ((ul)rpb_percpu + size*cpu); - SpinLock(&theLock); if (cpu==0) { panic("CPU 0 entering slaveLoop. Reenetering the console. HOSED \n"); @@ -1280,19 +1277,10 @@ void SlaveLoop( int cpu) printf("Entering slaveloop for cpu %d my_rpb=%x \n",cpu,my_rpb); } SpinUnlock(&theLock); - while(1) { - int i; - for (i=0; i < 1000000 ; i++) { - if (my_rpb->rpb_iccb.iccb_rxlen) { - SpinLock(&theLock); - printf("Slave CPU %d console command %s", - cpu,my_rpb->rpb_iccb.iccb_rxbuf); - SpinUnlock(&theLock); - SlaveCmd(cpu,my_rpb); - panic("SlaveCmd returned \n"); - } - } - printf("*"); - } -} + // swap the processors context to the one in the + // rpb_percpu struct very carefully (i.e. no stack usage) + // so that linux knows which processor ends up in __smp_callin + // and we don't trash any data is the process + SlaveSpin(cpu,my_rpb,&my_rpb->rpb_iccb.iccb_rxlen); +} -- cgit v1.2.3 From 8b1db1cf98c79a9a22ac241309fc480dbb5b4f20 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Wed, 6 Oct 2004 11:27:46 -0400 Subject: Fix from Adam: Strip the kseg off the physical address in the RPB structure. --- system/alpha/console/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index a82e695e1..e7cf36ba5 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -709,7 +709,7 @@ unixBoot(int go, int argc, char **argv) rpb_crb->rpb_num = 1; rpb_crb->rpb_mapped_pages = HWRPB_PAGES; rpb_crb->rpb_map[0].rpb_virt = 0x10000000; - rpb_crb->rpb_map[0].rpb_phys = ((ul)rpb) & ~0x1fff; + rpb_crb->rpb_map[0].rpb_phys = KSEG_TO_PHYS(((ul)rpb) & ~0x1fff); rpb_crb->rpb_map[0].rpb_pgcount = HWRPB_PAGES; -- cgit v1.2.3 From 99a522fb8b04a30d2114a19642be9a7acd78b425 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Tue, 23 Nov 2004 04:04:13 -0500 Subject: do a better job of always locking printf. We used to only lock on secondary cpus, this also locks on the primary cpu. Now the initial print out doesn't get garbled with more than 1 cpu. --- system/alpha/console/console.c | 77 ++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 40 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index e7cf36ba5..b4afcaae1 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -65,6 +65,13 @@ typedef unsigned int uint32; #define NUM_KERNEL_THIRD (4) +#define printf_lock(args...) \ + do { \ + SpinLock(&theLock); \ + printf(args); \ + SpinUnlock(&theLock); \ + } while (0) + static unixBoot(int go, int argc, char **argv); void jToPal(ul bootadr); @@ -152,12 +159,12 @@ main(int argc, char **argv) InitConsole(); - printf("M5 console\n"); + printf_lock("M5 console\n"); /* * get configuration from backdoor */ simosConf.last_offset = k1Conf->last_offset; - printf("Got Configuration %d \n",simosConf.last_offset); + printf_lock("Got Configuration %d \n",simosConf.last_offset); simosConf.last_offset = k1Conf->last_offset; simosConf.version = k1Conf->version; @@ -420,7 +427,7 @@ unixBoot(int go, int argc, char **argv) char *rpb_name; ul nextPtr; - printf( "memsize %x pages %x \n",mem_size,mem_pages); + printf_lock( "memsize %x pages %x \n",mem_size,mem_pages); @@ -447,7 +454,7 @@ unixBoot(int go, int argc, char **argv) unix_boot_mem = ROUNDUP8K(&_end); - printf("First free page after ROM 0x%x\n", unix_boot_mem); + printf_lock("First free page after ROM 0x%x\n", unix_boot_mem); rpb = (struct rpb *) unix_boot_alloc( HWRPB_PAGES); @@ -541,10 +548,10 @@ unixBoot(int go, int argc, char **argv) bootadr = simosConf.entryPoint; - printf("HWRPB 0x%x l1pt 0x%x l2pt 0x%x l3pt_rpb 0x%x l3pt_kernel 0x%x l2reserv 0x%x\n", + printf_lock("HWRPB 0x%x l1pt 0x%x l2pt 0x%x l3pt_rpb 0x%x l3pt_kernel 0x%x l2reserv 0x%x\n", rpb, first, second, third_rpb, third_kernel,reservedFixup); if (kernel_end - simosConf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { - printf("Kernel is more than 8MB 0x%x - 0x%x = 0x%x\n", + printf_lock("Kernel is more than 8MB 0x%x - 0x%x = 0x%x\n", kernel_end, simosConf.kernStart, kernel_end -simosConf.kernStart ); panic("kernel too big\n"); @@ -559,7 +566,7 @@ unixBoot(int go, int argc, char **argv) /* blow 2 pages of phys mem for guards since it maintains 1-to-1 mapping */ ksp = ksp_top + (3 * 8192); if (ksp - simosConf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { - printf("Kernel stack pushd us over 8MB\n"); + printf_lock("Kernel stack pushd us over 8MB\n"); panic("ksp too big\n"); } if (THIRD_XXX((ul)ksp_top) > NUM_KERNEL_THIRD * 1024) { @@ -607,7 +614,7 @@ unixBoot(int go, int argc, char **argv) * XXX must be patched after a checkpoint restore (I guess) */ - printf("CPU Clock at %d MHz IntrClockFrequency=%d \n", simosConf.cpuClock,simosConf.intrClockFrequency); + printf_lock("CPU Clock at %d MHz IntrClockFrequency=%d \n", simosConf.cpuClock,simosConf.intrClockFrequency); rpb->rpb_counter = simosConf.cpuClock * 1000 * 1000; /* @@ -624,7 +631,7 @@ unixBoot(int go, int argc, char **argv) int i; int size = ROUNDUP128(sizeof(struct rpb_percpu)); - printf("Booting with %d processor(s) \n",simosConf.numCPUs); + printf_lock("Booting with %d processor(s) \n",simosConf.numCPUs); rpb->rpb_numprocs = simosConf.numCPUs; rpb->rpb_slotsize = size; @@ -650,7 +657,7 @@ unixBoot(int go, int argc, char **argv) /* thisCPU->rpb_pcb.rpb_ptbr = PFN(second);*/ - printf("KSP: 0x%x PTBR 0x%x\n", thisCPU->rpb_pcb.rpb_ksp, thisCPU->rpb_pcb.rpb_ptbr); + printf_lock("KSP: 0x%x PTBR 0x%x\n", thisCPU->rpb_pcb.rpb_ksp, thisCPU->rpb_pcb.rpb_ptbr); if (i) { bootStrapImpure[i] = (ul)unix_boot_alloc(1); @@ -713,7 +720,7 @@ unixBoot(int go, int argc, char **argv) rpb_crb->rpb_map[0].rpb_pgcount = HWRPB_PAGES; - printf("Console Callback at 0x%x, fixup at 0x%x \n", + printf_lock("Console Callback at 0x%x, fixup at 0x%x \n", rpb_crb->rpb_va_disp, rpb_crb->rpb_va_fixup ); @@ -754,7 +761,7 @@ unixBoot(int go, int argc, char **argv) rpb_mdt->rpb_numcl = cl; for (i = 0; i < cl; i++) - printf("Memory cluster %d [%d - %d]\n", i, rpb_mdt->rpb_cluster[i].rpb_pfn, rpb_mdt->rpb_cluster[i].rpb_pfncount); + printf_lock("Memory cluster %d [%d - %d]\n", i, rpb_mdt->rpb_cluster[i].rpb_pfn, rpb_mdt->rpb_cluster[i].rpb_pfncount); @@ -770,7 +777,7 @@ unixBoot(int go, int argc, char **argv) bzero((char *)mdt_bitmap, MDT_BITMAP_PAGES * 8192); for (i = 0; i < mem_pages/8; i++) ((unsigned char *)mdt_bitmap)[i] = 0xff; - printf("Initalizing mdt_bitmap addr 0x%x mem_pages %x \n", + printf_lock("Initalizing mdt_bitmap addr 0x%x mem_pages %x \n", (long)mdt_bitmap,(long)mem_pages); xxm_rpb.rpb_config_off = 0; @@ -809,7 +816,7 @@ unixBoot(int go, int argc, char **argv) #else rpb_crb->rpb_va_disp = 0x10000000 + ((ul)ptr & 0x1fff); #endif - printf("ConsoleDispatch at virt %x phys %x val %x\n", + printf_lock("ConsoleDispatch at virt %x phys %x val %x\n", rpb_crb->rpb_va_disp, rpb_crb->rpb_pa_disp, consoleCallback); @@ -844,10 +851,8 @@ unixBoot(int go, int argc, char **argv) for (i=1;ibootStrapImpure = bootStrapImpure[i]; k1Conf->bootStrapCPU = i; } @@ -859,9 +864,7 @@ unixBoot(int go, int argc, char **argv) if ((ul)unix_boot_mem >= (ul)simosConf.kernStart) { panic("CONSOLE: too much memory. Smashing kernel \n"); } else { - SpinLock(&theLock); - printf("unix_boot_mem ends at %x \n",unix_boot_mem); - SpinUnlock(&theLock); + printf_lock("unix_boot_mem ends at %x \n",unix_boot_mem); } @@ -925,11 +928,11 @@ char **envp; struct _kernel_params *kernel_params = (struct _kernel_params *) KSEG; int i; - printf("k_argc = %d ", k_argc); + printf_lock("k_argc = %d ", k_argc); for (i = 0; i < k_argc; i++) { - printf("'%s' ", k_argv[i]); + printf_lock("'%s' ", k_argv[i]); } - printf("\n"); + printf_lock("\n"); /* rpb_percpu |= 0xfffffc0000000000;*/ kernel_params->bootadr = bootadr; @@ -938,9 +941,9 @@ char **envp; kernel_params->argc = k_argc; kernel_params->argv = (ul)k_argv; kernel_params->envp = (ul)envp; - printf("jumping to kernel at 0x%x, (PCBB 0x%x pfn %d)\n", bootadr, rpb_percpu, free_pfn); + printf_lock("jumping to kernel at 0x%x, (PCBB 0x%x pfn %d)\n", bootadr, rpb_percpu, free_pfn); jToPal(KSEG_TO_PHYS((ul)palJToKern)); - printf("returned from jToPal. Looping\n"); + printf_lock("returned from jToPal. Looping\n"); while(1) continue; } @@ -1158,9 +1161,9 @@ CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) strcpy((char*)a2, ""); i = (long)0xc000000000000000; if (a1 >= 0 && a1 < MAX_ENV_INDEX) - printf ("GETENV unsupported option %d (0x%x)\n", a1, a1); + printf_lock("GETENV unsupported option %d (0x%x)\n", a1, a1); else - printf ("GETENV unsupported option %s\n", a1); + printf_lock("GETENV unsupported option %s\n", a1); } if (i > a3) @@ -1170,7 +1173,7 @@ CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) case CONSCB_OPEN: bcopy((char*)a1,deviceState[numOpenDevices].name,a2); deviceState[numOpenDevices].name[a2] = '\0'; - printf("CONSOLE OPEN : %s --> success \n", + printf_lock("CONSOLE OPEN : %s --> success \n", deviceState[numOpenDevices].name); return numOpenDevices++; @@ -1181,11 +1184,11 @@ CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) case CONSCB_CLOSE: break; case CONSCB_OPEN_CONSOLE: - printf("CONSOLE OPEN\n"); + printf_lock("CONSOLE OPEN\n"); return 0; /* success */ break; /* not rearched */ case CONSCB_CLOSE_CONSOLE: - printf("CONSOLE CLOSE\n"); + printf_lock("CONSOLE CLOSE\n"); return 0; /* success */ break; /* not reached */ @@ -1211,7 +1214,7 @@ long CallBackFixup(int a0, int a1, int a2) asm("bis $8, $31, %0" : "=r" (temp)); /* call original code */ - printf("CallbackFixup %x %x, t7=%x\n",a0,a1,temp); + printf_lock("CallbackFixup %x %x, t7=%x\n",a0,a1,temp); /* restore the current pointer */ asm("bis %0, $31, $8" : : "r" (temp) : "$8"); @@ -1239,20 +1242,16 @@ void SlaveCmd(int cpu, struct rpb_percpu *my_rpb) /* extern void palJToSlave[]; */ extern unsigned int palJToSlave[]; - SpinLock(&theLock); - printf("Slave CPU %d console command %s", cpu,my_rpb->rpb_iccb.iccb_rxbuf); - SpinUnlock(&theLock); + printf_lock("Slave CPU %d console command %s", cpu,my_rpb->rpb_iccb.iccb_rxbuf); my_rpb->rpb_state |= STATE_BIP; my_rpb->rpb_state &= ~STATE_RC; - SpinLock(&theLock); - printf("SlaveCmd: restart %x %x vptb %x my_rpb %x my_rpb_phys %x\n", + printf_lock("SlaveCmd: restart %x %x vptb %x my_rpb %x my_rpb_phys %x\n", rpb->rpb_restart, rpb->rpb_restart_pv, rpb->rpb_vptb, my_rpb, KSEG_TO_PHYS(my_rpb)); - SpinUnlock(&theLock); cServe(KSEG_TO_PHYS((ul)palJToSlave), (ul)rpb->rpb_restart, @@ -1270,13 +1269,11 @@ void SlaveLoop( int cpu) struct rpb_percpu *my_rpb = (struct rpb_percpu*) ((ul)rpb_percpu + size*cpu); - SpinLock(&theLock); if (cpu==0) { panic("CPU 0 entering slaveLoop. Reenetering the console. HOSED \n"); } else { - printf("Entering slaveloop for cpu %d my_rpb=%x \n",cpu,my_rpb); + printf_lock("Entering slaveloop for cpu %d my_rpb=%x \n",cpu,my_rpb); } - SpinUnlock(&theLock); // swap the processors context to the one in the // rpb_percpu struct very carefully (i.e. no stack usage) -- cgit v1.2.3 From 5821f37cb6f1875f5912adc37a01139a159e697c Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Mon, 6 Dec 2004 11:44:22 -0500 Subject: Add support for tsunami with 64 processors and fix some console bugs I steped on while doing it console/console.c: Allocate more HWRPB pages so we have room for 64 percpu_rpbs Fix writing of Console Relocation Block virtual addresses so that if they are outside of the first page, which they will be with more than 8 processors, the correct adress is written palcode/Makefile: Update makefile for tsunami with 64 processors palcode/platform_m5.S: Add support for tsunami with 64 processors --- system/alpha/console/console.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index b4afcaae1..2ab4c6ec8 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -58,7 +58,7 @@ typedef unsigned int uint32; /* Kernel write | kernel read | valid */ #define KPTE(x) ((ul)((((ul)(x)) << 32) | 0x1101)) -#define HWRPB_PAGES 4 +#define HWRPB_PAGES 16 #define MDT_BITMAP_PAGES 4 #define CSERVE_K_JTOKERN 0x18 @@ -480,6 +480,7 @@ unixBoot(int go, int argc, char **argv) first[1] = KPTE(PFN(first)); /* Region 3 */ second[SECOND(0x10000000)] = KPTE(PFN(third_rpb)); /* Region 0 */ + for (i=0;irpb_map[0].rpb_pgcount = HWRPB_PAGES; - printf_lock("Console Callback at 0x%x, fixup at 0x%x \n", + printf_lock("Console Callback at 0x%x, fixup at 0x%x, crb offset: 0x%x\n", rpb_crb->rpb_va_disp, - rpb_crb->rpb_va_fixup ); + rpb_crb->rpb_va_fixup, + rpb->rpb_crb_off); rpb_mdt = (struct _xxm_rpb_mdt *) (((ul)rpb_crb) + sizeof(struct rpb_crb)); rpb->rpb_mdt_off = (ul)rpb_mdt - (ul)rpb; @@ -811,11 +813,7 @@ unixBoot(int go, int argc, char **argv) { ul *ptr = (ul*)((char*)rpb_dsr + sizeof(struct rpb_dsr )); rpb_crb->rpb_pa_disp = KSEG_TO_PHYS(ptr); -#if 0 - rpb_crb->rpb_va_disp = 0x10000000 + ((ul)ptr&(0x2000*HWRPB_PAGES-1)); -#else - rpb_crb->rpb_va_disp = 0x10000000 + ((ul)ptr & 0x1fff); -#endif + rpb_crb->rpb_va_disp = 0x10000000 + (((ul)ptr - (ul)rpb) & (0x2000*HWRPB_PAGES-1)); printf_lock("ConsoleDispatch at virt %x phys %x val %x\n", rpb_crb->rpb_va_disp, rpb_crb->rpb_pa_disp, @@ -823,12 +821,9 @@ unixBoot(int go, int argc, char **argv) *ptr++ = 0; *ptr++ = (ul) consoleCallback; rpb_crb->rpb_pa_fixup = KSEG_TO_PHYS(ptr); -#if 0 - rpb_crb->rpb_va_fixup = 0x10000000 + ((ul)ptr& (0x2000*HWRPB_PAGES-1)); -#else - rpb_crb->rpb_va_fixup = 0x10000000 + ((ul)ptr & 0x1fff); -#endif + rpb_crb->rpb_va_fixup = 0x10000000 + (((ul)ptr - (ul)rpb) & (0x2000*HWRPB_PAGES-1)); *ptr++ = 0; + *ptr++ = (ul) consoleFixup; } -- cgit v1.2.3 From 8cefbc93cfa1ed52836b3b5e28e4c74581e06c9b Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Sat, 4 Jun 2005 18:59:06 -0400 Subject: HP copyrights console/Makefile: Added copyright added CROSS_COMPILE variable removed install target console/console.c: console/dbmentry.S: console/paljtokern.S: console/paljtoslave.S: console/printf.c: h/cia.h: h/cserve.h: h/dc21164FromGasSources.h: h/eb164.h: h/ev5_alpha_defs.h: h/ev5_defs.h: h/ev5_impure.h: h/ev5_osfalpha_defs.h: h/ev5_paldef.h: h/fromHudsonMacros.h: h/fromHudsonOsf.h: h/lib.h: h/platform.h: h/regdefs.h: h/rpb.h: palcode/Makefile: palcode/osfpal.S: palcode/osfpal_cache_copy.S: palcode/osfpal_cache_copy_unaligned.S: palcode/platform_m5.S: palcode/platform_tlaser.S: added hp and our copyright --- system/alpha/console/console.c | 52 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 2ab4c6ec8..f51d958c0 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -1,5 +1,53 @@ - - +/* +Copyright (c) 2003, 2004 +The Regents of The University of Michigan +All Rights Reserved + +This code is part of the M5 simulator, developed by Nathan Binkert, +Erik Hallnor, Steve Raasch, and Steve Reinhardt, with contributions +from Ron Dreslinski, Dave Greene, Lisa Hsu, Ali Saidi, and Andrew +Schultz. + +Permission is granted to use, copy, create derivative works and +redistribute this software and such derivative works for any purpose, +so long as the copyright notice above, this grant of permission, and +the disclaimer below appear in all copies made; and so long as the +name of The University of Michigan is not used in any advertising or +publicity pertaining to the use or distribution of this software +without specific, written prior authorization. + +THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE +UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND WITHOUT +WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER EXPRESS OR +IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE REGENTS OF +THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE FOR ANY DAMAGES, +INCLUDING DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WITH RESPECT TO ANY CLAIM ARISING OUT OF OR IN CONNECTION +WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS BEEN OR IS HEREAFTER +ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +*/ +/* +Copyright 1993 Hewlett-Packard Development Company, L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ /* ****************************************** * SimOS SRM Console * -- cgit v1.2.3 From 55e3b9f74391282bda18d90e05df78c331b59392 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Mon, 27 Jun 2005 17:25:54 -0400 Subject: Major system code cleanup and formatting remove unused code console/Makefile: cleanup Makefile. Remove unneeded -D options console/console.c: Major cleanup and formatting remove unused #ifdef code remove unused #includes rename xxm -> m5 rename simos -> m5 console/dbmentry.S: console/paljtokern.S: console/paljtoslave.S: console/printf.c: Major cleanup and formatting remove unused #ifdef code remove unused #includes rename __start -> _start to get rid of warning. h/cserve.h: h/dc21164FromGasSources.h: h/ev5_alpha_defs.h: h/ev5_defs.h: h/ev5_osfalpha_defs.h: h/ev5_paldef.h: h/fromHudsonMacros.h: h/fromHudsonOsf.h: h/rpb.h: Major cleanup and formatting h/ev5_impure.h: Major cleanup and formatting remove unused #ifdef code palcode/Makefile: cleanup Makefile remove unused -D options unify platform_tlaser.S and platform_tsunami.S into platform.S and generate multiple .o files using various #defines unify osfpal.S osfpal_cache_copy.S and osfpal_cache_copy_unaligned.S into osfpal.S and generate multiple .o files using various #defines palcode/osfpal.S: Major cleanup and formatting remove unused #defines remove unused #if code merge copy code into this file. palcode/platform.S: Major cleanup and formatting remove unused #defines remove unused #if code merge platform code into this file. --- system/alpha/console/console.c | 1901 ++++++++++++++++++---------------------- 1 file changed, 858 insertions(+), 1043 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index f51d958c0..1cd5f1a6c 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -1,85 +1,77 @@ /* -Copyright (c) 2003, 2004 -The Regents of The University of Michigan -All Rights Reserved - -This code is part of the M5 simulator, developed by Nathan Binkert, -Erik Hallnor, Steve Raasch, and Steve Reinhardt, with contributions -from Ron Dreslinski, Dave Greene, Lisa Hsu, Ali Saidi, and Andrew -Schultz. - -Permission is granted to use, copy, create derivative works and -redistribute this software and such derivative works for any purpose, -so long as the copyright notice above, this grant of permission, and -the disclaimer below appear in all copies made; and so long as the -name of The University of Michigan is not used in any advertising or -publicity pertaining to the use or distribution of this software -without specific, written prior authorization. - -THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE -UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND WITHOUT -WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER EXPRESS OR -IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE REGENTS OF -THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE FOR ANY DAMAGES, -INCLUDING DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WITH RESPECT TO ANY CLAIM ARISING OUT OF OR IN CONNECTION -WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS BEEN OR IS HEREAFTER -ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -*/ + * Copyright (c) 2003, 2004 + * The Regents of The University of Michigan + * All Rights Reserved + * + * This code is part of the M5 simulator, developed by Nathan Binkert, + * Erik Hallnor, Steve Raasch, and Steve Reinhardt, with contributions + * from Ron Dreslinski, Dave Greene, Lisa Hsu, Ali Saidi, and Andrew + * Schultz. + * + * Permission is granted to use, copy, create derivative works and + * redistribute this software and such derivative works for any purpose, + * so long as the copyright notice above, this grant of permission, and + * the disclaimer below appear in all copies made; and so long as the + * name of The University of Michigan is not used in any advertising or + * publicity pertaining to the use or distribution of this software + * without specific, written prior authorization. + * + * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE + * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND WITHOUT + * WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE REGENTS OF + * THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE FOR ANY DAMAGES, + * INCLUDING DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL + * DAMAGES, WITH RESPECT TO ANY CLAIM ARISING OUT OF OR IN CONNECTION + * WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS BEEN OR IS HEREAFTER + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + /* -Copyright 1993 Hewlett-Packard Development Company, L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ -/* ****************************************** - * SimOS SRM Console + * Copyright 1993 Hewlett-Packard Development Company, L.P. * - * Derived from Lance Berc's SRM console - * for the SRC XXM Machine - * ******************************************/ + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +/* ****************************************** + * M5 Console + * ******************************************/ -typedef unsigned long long uint64_t; -typedef unsigned long long uint64; -typedef unsigned int uint32_t; -typedef unsigned int uint32; +#include +#include #define CONSOLE #include "alpha_access.h" - -#if 0 -#include "new_aouthdr.h" -#include "srcmax.h" -#endif - -/* from ../h */ -#include "lib.h" -#include "rpb.h" #include "cserve.h" +#include "rpb.h" #define CONS_INT_TX 0x01 /* interrupt enable / state bits */ #define CONS_INT_RX 0x02 +#define PAGE_SIZE (8192) + #define KSEG 0xfffffc0000000000 #define K1BASE 0xfffffc8000000000 -#define KSEG_TO_PHYS(x)(((ul)x) & ~KSEG) +#define KSEG_TO_PHYS(x) (((ulong)x) & ~KSEG) #ifdef TSUNAMI #define ALPHA_ACCESS_BASE 0xfffffd0200000000 @@ -89,295 +81,258 @@ typedef unsigned int uint32; #error TSUNAMI/TLASER not defined. #endif -#define PHYS_TO_K1(_x) (K1BASE|(_x)) +#define ROUNDUP8(x) ((ulong)(((ulong)x)+7) & ~7) +#define ROUNDUP128(x) ((ulong)(((ulong)x) + 127) & ~127) +#define ROUNDUP8K(x) ((ulong)(((ulong)(x)) + 8191) & ~8191) -#define AOUT_LOAD_ADDR (KSEG|0xf000) - -#define ROUNDUP8(x) ((ul)(((ul)x)+7) & ~7) -#define ROUNDUP128(x) ((ul)(((ul)x)+127) & ~127) -#define ROUNDUP8K(x) ((ul)(((ul)(x))+8191) & ~8191) - -#define FIRST(x) ((((ul)(x)) >> 33) & 0x3ff) -#define SECOND(x) ((((ul)(x)) >> 23) & 0x3ff) -#define THIRD(x) ((((ul)(x)) >> 13) & 0x3ff) -#define THIRD_XXX(x) ((((ul)(x)) >> 13) & 0xfff) -#define PFN(x) ((((ul)(x) & ~KSEG) >> 13)) +#define FIRST(x) ((((ulong)(x)) >> 33) & 0x3ff) +#define SECOND(x) ((((ulong)(x)) >> 23) & 0x3ff) +#define THIRD(x) ((((ulong)(x)) >> 13) & 0x3ff) +#define THIRD_XXX(x) ((((ulong)(x)) >> 13) & 0xfff) +#define PFN(x) ((((ulong)(x) & ~KSEG) >> 13)) /* Kernel write | kernel read | valid */ -#define KPTE(x) ((ul)((((ul)(x)) << 32) | 0x1101)) +#define KPTE(x) ((ulong)((((ulong)(x)) << 32) | 0x1101)) #define HWRPB_PAGES 16 #define MDT_BITMAP_PAGES 4 -#define CSERVE_K_JTOKERN 0x18 - #define NUM_KERNEL_THIRD (4) -#define printf_lock(args...) \ - do { \ - SpinLock(&theLock); \ - printf(args); \ - SpinUnlock(&theLock); \ +#define printf_lock(args...) \ + do { \ + SpinLock(&theLock); \ + printf(args); \ + SpinUnlock(&theLock); \ } while (0) -static unixBoot(int go, int argc, char **argv); -void jToPal(ul bootadr); +void unixBoot(int go, int argc, char **argv); +void JToKern(char *bootadr, ulong rpb_percpu, ulong free_pfn, ulong k_argc, + char **k_argv, char **envp); +void JToPal(ulong bootadr); void SlaveLoop(int cpu); +struct AlphaAccess m5Conf; -struct AlphaAccess simosConf; - -/* ************************************************************** - * Console callbacks use VMS calling conventions - * read AXP manual, 2-64. - * ***************************************************************/ -typedef struct OpenVMSFunc { - long dummy; - long func; -}OpenVMSFunc; - -OpenVMSFunc callbackFunc, fixupFunc; +ulong theLock; - - - -ul theLock; - - -extern void SpinLock(ul *lock); +extern void SpinLock(ulong *lock); #define SpinUnlock(_x) *(_x) = 0; struct _kernel_params { - char *bootadr; - ul rpb_percpu; - ul free_pfn; - ul argc; - ul argv; - ul envp; /* NULL */ + char *bootadr; + ulong rpb_percpu; + ulong free_pfn; + ulong argc; + ulong argv; + ulong envp; /* NULL */ }; - extern consoleCallback[]; extern consoleFixup[]; long CallBackDispatcher(); long CallBackFixup(); /* - * simos console output + * m5 console output */ -void InitConsole(void) +void +InitConsole() { -#if 0 - CDR->intr_status =(DevRegister)(DEV_CNSLE_RX_INTR |DEV_CNSLE_TX_INTR); -#endif } -char GetChar() +char +GetChar() { - struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); - return k1Conf->inputChar; + struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); + return k1Conf->inputChar; } -void PutChar(char c) +void +PutChar(char c) { -#if 0 - CDR->data = c; -#endif -#if 0 - *(int*) PHYS_TO_K1(SLOT_D_COM1<<5) = c; -#endif - struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); - k1Conf->outputChar = c; - + struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); + k1Conf->outputChar = c; } - int passArgs(int argc) -{ return 0; } +{ + return 0; +} int main(int argc, char **argv) { - int x,i; - struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); - ui *k1ptr,*ksegptr; - - - InitConsole(); - printf_lock("M5 console\n"); - /* - * get configuration from backdoor - */ - simosConf.last_offset = k1Conf->last_offset; - printf_lock("Got Configuration %d \n",simosConf.last_offset); - - simosConf.last_offset = k1Conf->last_offset; - simosConf.version = k1Conf->version; - simosConf.numCPUs = k1Conf->numCPUs; - simosConf.intrClockFrequency = k1Conf->intrClockFrequency; - simosConf.cpuClock = k1Conf->cpuClock; - simosConf.mem_size = k1Conf->mem_size; - simosConf.kernStart = k1Conf->kernStart; - simosConf.kernEnd = k1Conf->kernEnd; - simosConf.entryPoint = k1Conf->entryPoint; - simosConf.diskUnit = k1Conf->diskUnit; - simosConf.diskCount = k1Conf->diskCount; - simosConf.diskPAddr = k1Conf->diskPAddr; - simosConf.diskBlock = k1Conf->diskBlock; - simosConf.diskOperation = k1Conf->diskOperation; - simosConf.outputChar = k1Conf->outputChar; - simosConf.inputChar = k1Conf->inputChar; - simosConf.bootStrapImpure = k1Conf->bootStrapImpure; - simosConf.bootStrapCPU = k1Conf->bootStrapCPU; - - if (simosConf.version != ALPHA_ACCESS_VERSION) { - panic("Console version mismatch. Console expects %d. has %d \n", - ALPHA_ACCESS_VERSION,simosConf.version); - } - - - /* - * setup arguments to kernel - */ - unixBoot(1,argc,argv); - - x = *(volatile int *)(K1BASE-4); - while(1) continue; - return x; + int x, i; + struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); + uint *k1ptr, *ksegptr; + + InitConsole(); + printf_lock("M5 console\n"); + + /* + * get configuration from backdoor + */ + m5Conf.last_offset = k1Conf->last_offset; + printf_lock("Got Configuration %d\n", m5Conf.last_offset); + + m5Conf.last_offset = k1Conf->last_offset; + m5Conf.version = k1Conf->version; + m5Conf.numCPUs = k1Conf->numCPUs; + m5Conf.intrClockFrequency = k1Conf->intrClockFrequency; + m5Conf.cpuClock = k1Conf->cpuClock; + m5Conf.mem_size = k1Conf->mem_size; + m5Conf.kernStart = k1Conf->kernStart; + m5Conf.kernEnd = k1Conf->kernEnd; + m5Conf.entryPoint = k1Conf->entryPoint; + m5Conf.diskUnit = k1Conf->diskUnit; + m5Conf.diskCount = k1Conf->diskCount; + m5Conf.diskPAddr = k1Conf->diskPAddr; + m5Conf.diskBlock = k1Conf->diskBlock; + m5Conf.diskOperation = k1Conf->diskOperation; + m5Conf.outputChar = k1Conf->outputChar; + m5Conf.inputChar = k1Conf->inputChar; + m5Conf.bootStrapImpure = k1Conf->bootStrapImpure; + m5Conf.bootStrapCPU = k1Conf->bootStrapCPU; + + if (m5Conf.version != ALPHA_ACCESS_VERSION) { + panic("Console version mismatch. Console expects %d. has %d \n", + ALPHA_ACCESS_VERSION, m5Conf.version); + } + + /* + * setup arguments to kernel + */ + unixBoot(1, argc, argv); + + x = *(volatile int *)(K1BASE-4); + while (1) + continue; + return x; } /* * BOOTING */ -struct rpb xxm_rpb = { - NULL, /* 000: physical self-reference */ - ((long)'H') | (((long)'W') << 8) | (((long)'R') << 16) | - ((long)'P' << 24) | (((long)'B') << 32), /* 008: contains string "HWRPB" */ - 6, /* 010: HWRPB version number */ - /* the byte count is wrong, but who needs it? - lance */ - 0, /* 018: bytes in RPB perCPU CTB CRB MEDSC */ - 0, /* 020: primary cpu id */ - 8192, /* 028: page size in bytes */ - 43, /* 030: number of phys addr bits */ - 127, /* 038: max valid ASN */ - {'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'}, /* 040: system serial num: 10 ascii chars */ -#ifdef undef -/* To be legitimate, the following system type and variation are correct for the XXM. - But there are too many #ifdefs etc to deal with in Unix, so we tell the kernel - that we're an Avanti, which is similar enough. - */ - 31, /* 050: system type - XXM is now in the Alpha SRM */ - (1 << 10) | (2<<1),/* 058: system variation - XXM w/EV5 & embeded console */ -#endif -#if 0 - 0x12, /* 050: system type - masquarade as some random 21064 */ -#endif - 0, /* OVERRIDDEN */ - (1<<10), /* 058: system variation OVERRIDDEN */ - 'c'|('o'<<8)|('o'<<16)|('l'<< 24), /* 060: system revision */ - 1024*4096, /* 068: scaled interval clock intr freq OVERRIDEN*/ - 0, /* 070: cycle counter frequency */ - 0x200000000, /* 078: virtual page table base */ - 0, /* 080: reserved */ - 0, /* 088: offset to translation buffer hint */ - 1, /* 090: number of processor slots OVERRIDDEN*/ - sizeof(struct rpb_percpu), /* 098: per-cpu slot size. OVERRIDDEN */ - 0, /* 0A0: offset to per_cpu slots */ - 1, /* 0A8: number of CTBs */ -#ifdef bugnion_gone - sizeof(struct rpb_ctb), /* 0B0: bytes in largest CTB */ -#else - sizeof(struct ctb_tt), -#endif - 0, /* 0B8: offset to CTB (cons term block) */ - 0, /* 0C0: offset to CRB (cons routine block) */ - 0, /* 0C8: offset to memory descriptor table */ - 0, /* 0D0: offset to config data block */ - 0, /* 0D8: offset to FRU table */ - 0, /* 0E0: virt addr of save term routine */ - 0, /* 0E8: proc value for save term routine */ - 0, /* 0F0: virt addr of restore term routine */ - 0, /* 0F8: proc value for restore term routine */ - 0, /* 100: virt addr of CPU restart routine */ - 0, /* 108: proc value for CPU restart routine */ - 0, /* 110: used to determine presence of kdebug */ - 0, /* 118: reserved for hardware */ +struct rpb m5_rpb = { + NULL, /* 000: physical self-reference */ + ((long)'H') | (((long)'W') << 8) | (((long)'R') << 16) | + ((long)'P' << 24) | (((long)'B') << 32), /* 008: contains "HWRPB" */ + 6, /* 010: HWRPB version number */ + /* the byte count is wrong, but who needs it? - lance */ + 0, /* 018: bytes in RPB perCPU CTB CRB MEDSC */ + 0, /* 020: primary cpu id */ + PAGE_SIZE, /* 028: page size in bytes */ + 43, /* 030: number of phys addr bits */ + 127, /* 038: max valid ASN */ + {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1'}, + /* 040: system serial num: 10 ascii chars */ + 0, /* OVERRIDDEN */ + (1<<10), /* 058: system variation */ + 'c'|('o'<<8)|('o'<<16)|('l'<< 24), /* 060: system revision */ + 1024*4096, /* 068: scaled interval clock intr freq */ + 0, /* 070: cycle counter frequency */ + 0x200000000, /* 078: virtual page table base */ + 0, /* 080: reserved */ + 0, /* 088: offset to translation buffer hint */ + 1, /* 090: number of processor slots OVERRIDDEN*/ + sizeof(struct rpb_percpu), /* 098: per-cpu slot size. OVERRIDDEN */ + 0, /* 0A0: offset to per_cpu slots */ + 1, /* 0A8: number of CTBs */ + sizeof(struct ctb_tt), + 0, /* 0B8: offset to CTB (cons term block) */ + 0, /* 0C0: offset to CRB (cons routine block) */ + 0, /* 0C8: offset to memory descriptor table */ + 0, /* 0D0: offset to config data block */ + 0, /* 0D8: offset to FRU table */ + 0, /* 0E0: virt addr of save term routine */ + 0, /* 0E8: proc value for save term routine */ + 0, /* 0F0: virt addr of restore term routine */ + 0, /* 0F8: proc value for restore term routine */ + 0, /* 100: virt addr of CPU restart routine */ + 0, /* 108: proc value for CPU restart routine */ + 0, /* 110: used to determine presence of kdebug */ + 0, /* 118: reserved for hardware */ /* the checksum is wrong, but who needs it? - lance */ - 0, /* 120: checksum of prior entries in rpb */ - 0, /* 128: receive ready bitmask */ - 0, /* 130: transmit ready bitmask */ - 0, /* 138: Dynamic System Recog. offset */ + 0, /* 120: checksum of prior entries in rpb */ + 0, /* 128: receive ready bitmask */ + 0, /* 130: transmit ready bitmask */ + 0, /* 138: Dynamic System Recog. offset */ }; -ul xxm_tbb[] = { 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, - 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e}; - -struct rpb_percpu xxm_rpb_percpu = { - {0,0,0,0,0,0,1,{0,0},{0,0,0,0,0,0,0,0}}, /* 000: boot/restart HWPCB */ - (STATE_PA | STATE_PP | STATE_CV | STATE_PV | STATE_PMV | STATE_PL), /* 080: per-cpu state bits */ - 0xc000, /* 088: palcode memory length */ - 0x2000, /* 090: palcode scratch length */ - 0x4000, /* 098: phys addr of palcode mem space */ - 0x2000, /* 0A0: phys addr of palcode scratch space */ - (2 << 16) | (5 << 8) | 1, /* 0A8: PALcode rev required */ - 11 | (2L << 32), /* 0B0: processor type */ - 7, /* 0B8: processor variation */ - 'M'|('5'<<8)|('A'<<16)|('0'<<24), /* 0C0: processor revision */ - {'M','5','/','A','l','p','h','a','0','0','0','0','0','0','0','0'}, /* 0C8: proc serial num: 10 ascii chars */ - 0, /* 0D8: phys addr of logout area */ - 0, /* 0E0: length in bytes of logout area */ - 0, /* 0E8: halt pcb base */ - 0, /* 0F0: halt pc */ - 0, /* 0F8: halt ps */ - 0, /* 100: halt arg list (R25) */ - 0, /* 108: halt return address (R26) */ - 0, /* 110: halt procedure value (R27) */ - 0, /* 118: reason for halt */ - 0, /* 120: for software */ - {0}, /* 128: inter-console communications buffer */ - {1,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0}, /* 1D0: PALcode revs available */ - 0 /* 250: reserved for arch use */ +ulong m5_tbb[] = { 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, + 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, + 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e, + 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e }; + +struct rpb_percpu m5_rpb_percpu = { + {0,0,0,0,0,0,1,{0,0},{0,0,0,0,0,0,0,0}}, /* 000: boot/restart HWPCB */ + (STATE_PA | STATE_PP | STATE_CV | + STATE_PV | STATE_PMV | STATE_PL), /* 080: per-cpu state bits */ + 0xc000, /* 088: palcode memory length */ + 0x2000, /* 090: palcode scratch length */ + 0x4000, /* 098: paddr of pal mem space */ + 0x2000, /* 0A0: paddr of pal scratch space */ + (2 << 16) | (5 << 8) | 1, /* 0A8: PALcode rev required */ + 11 | (2L << 32), /* 0B0: processor type */ + 7, /* 0B8: processor variation */ + 'M'|('5'<<8)|('A'<<16)|('0'<<24), /* 0C0: processor revision */ + {'M','5','/','A','l','p','h','a','0','0','0','0','0','0','0','0'}, + /* 0C8: proc serial num: 10 chars */ + 0, /* 0D8: phys addr of logout area */ + 0, /* 0E0: len in bytes of logout area */ + 0, /* 0E8: halt pcb base */ + 0, /* 0F0: halt pc */ + 0, /* 0F8: halt ps */ + 0, /* 100: halt arg list (R25) */ + 0, /* 108: halt return address (R26) */ + 0, /* 110: halt procedure value (R27) */ + 0, /* 118: reason for halt */ + 0, /* 120: for software */ + {0}, /* 128: inter-console comm buffer */ + {1,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0}, /* 1D0: PALcode revs available */ + 0 /* 250: reserved for arch use */ /* the dump stack grows from the end of the rpb page not to reach here */ }; -struct _xxm_rpb_mdt { - long rpb_checksum; /* 000: checksum of entire mem desc table */ - long rpb_impaddr; /* 008: PA of implementation dep info */ - long rpb_numcl; /* 010: number of clusters */ - struct rpb_cluster rpb_cluster[3]; /* first instance of a cluster */ +struct _m5_rpb_mdt { + long rpb_checksum; /* 000: checksum of entire mem desc table */ + long rpb_impaddr; /* 008: PA of implementation dep info */ + long rpb_numcl; /* 010: number of clusters */ + struct rpb_cluster rpb_cluster[3]; /* first instance of a cluster */ }; -struct _xxm_rpb_mdt xxm_rpb_mdt = { - 0, /* 000: checksum of entire mem desc table */ - 0, /* 008: PA of implementation dep info */ - 0, /* 010: number of clusters */ - {{ 0, /* 000: starting PFN of this cluster */ +struct _m5_rpb_mdt m5_rpb_mdt = { + 0, /* 000: checksum of entire mem desc table */ + 0, /* 008: PA of implementation dep info */ + 0, /* 010: number of clusters */ + {{ 0, /* 000: starting PFN of this cluster */ 0, /* 008: count of PFNs in this cluster */ 0, /* 010: count of tested PFNs in cluster */ 0, /* 018: va of bitmap */ 0, /* 020: pa of bitmap */ 0, /* 028: checksum of bitmap */ 1 /* 030: usage of cluster */ - }, - { 0, /* 000: starting PFN of this cluster */ - 0, /* 008: count of PFNs in this cluster */ - 0, /* 010: count of tested PFNs in cluster */ - 0, /* 018: va of bitmap */ - 0, /* 020: pa of bitmap */ - 0, /* 028: checksum of bitmap */ - 0 /* 030: usage of cluster */ - }, - { 0, /* 000: starting PFN of this cluster */ - 0, /* 008: count of PFNs in this cluster */ - 0, /* 010: count of tested PFNs in cluster */ - 0, /* 018: va of bitmap */ - 0, /* 020: pa of bitmap */ - 0, /* 028: checksum of bitmap */ - 0 /* 030: usage of cluster */ - }} + }, + { 0, /* 000: starting PFN of this cluster */ + 0, /* 008: count of PFNs in this cluster */ + 0, /* 010: count of tested PFNs in cluster */ + 0, /* 018: va of bitmap */ + 0, /* 020: pa of bitmap */ + 0, /* 028: checksum of bitmap */ + 0 /* 030: usage of cluster */ + }, + { 0, /* 000: starting PFN of this cluster */ + 0, /* 008: count of PFNs in this cluster */ + 0, /* 010: count of tested PFNs in cluster */ + 0, /* 018: va of bitmap */ + 0, /* 020: pa of bitmap */ + 0, /* 028: checksum of bitmap */ + 0 /* 030: usage of cluster */ + }} }; /* constants for slotinfo bus_type subfield */ @@ -386,643 +341,524 @@ struct _xxm_rpb_mdt xxm_rpb_mdt = { #define SLOTINFO_EISA 2 #define SLOTINFO_PCI 3 -struct rpb_ctb xxm_rpb_ctb = { - CONS_DZ, /* 000: console type */ - 0, /* 008: console unit */ - 0, /* 010: reserved */ - 0 /* 018: byte length of device dep portion */ +struct rpb_ctb m5_rpb_ctb = { + CONS_DZ, /* 000: console type */ + 0, /* 008: console unit */ + 0, /* 010: reserved */ + 0 /* 018: byte length of device dep portion */ }; /* we don't do any fixup (aka relocate the console) - we hope */ -struct rpb_crb xxm_rpb_crb = { - 0, /* va of call-back dispatch rtn */ - 0, /* pa of call-back dispatch rtn */ - 0, /* va of call-back fixup rtn */ - 0, /* pa of call-back fixup rtn */ - 0, /* number of entries in phys/virt map */ - 0 /* Number of pages to be mapped */ +struct rpb_crb m5_rpb_crb = { + 0, /* va of call-back dispatch rtn */ + 0, /* pa of call-back dispatch rtn */ + 0, /* va of call-back fixup rtn */ + 0, /* pa of call-back fixup rtn */ + 0, /* number of entries in phys/virt map */ + 0 /* Number of pages to be mapped */ }; struct _rpb_name { - unsigned long length; - char name[16]; + ulong length; + char name[16]; }; -extern struct _rpb_name xxm_name; +extern struct _rpb_name m5_name; -struct rpb_dsr xxm_rpb_dsr = { - 0, - 0, - 0, +struct rpb_dsr m5_rpb_dsr = { + 0, + 0, + 0, }; -struct _rpb_name xxm_name = { - 16, - {'D','E','C',' ','S','R','C',' ','X','X','M',' ','D','G','C',0}, +struct _rpb_name m5_name = { + 16, + {'U','M','I','C','H',' ','M','5','/','A','L','P','H','A',' ',0}, }; -/* XXM has one LURT entry - 1050 is for workstations, 1100 is servers (and is needed for CXX) */ -long xxm_lurt[10] = { 9, 12, -1, -1, -1, -1, -1, -1, 1100, 1100 }; +/* + * M5 has one LURT entry: + * 1050 is for workstations + * 1100 is servers (and is needed for CXX) + */ +long m5_lurt[10] = { 9, 12, -1, -1, -1, -1, -1, -1, 1100, 1100 }; + +ulong unix_boot_mem; +ulong bootadr; -ul unix_boot_mem; -unsigned long bootadr; -#if 0 -unsigned long aout_bss_addr, aout_bss_size, aout_entry, aout_text_start, aout_data_addr; -#endif char **kargv; int kargc; -ul free_pfn; +ulong free_pfn; struct rpb_percpu *rpb_percpu; - #define MAX_CPUS 32 -ul bootStrapImpure[MAX_CPUS]; +ulong bootStrapImpure[MAX_CPUS]; - -char *unix_boot_alloc(int pages) +char * +unix_boot_alloc(int pages) { - char *ret = (char *) unix_boot_mem; - unix_boot_mem += (pages * 8192); - return ret; + char *ret = (char *) unix_boot_mem; + unix_boot_mem += (pages * PAGE_SIZE); + return ret; } -ul *first = 0; -ul *third_rpb = 0; -ul *reservedFixup = 0; +ulong *first = 0; +ulong *third_rpb = 0; +ulong *reservedFixup = 0; int strcpy(char *dst, char *src); struct rpb *rpb; +extern ulong _end; +void unixBoot(int go, int argc, char **argv) { - ul *second, *third_kernel, ptr, *tbb, size, *percpu_logout; - unsigned char *mdt_bitmap; - long *lp1, *lp2, sum; - int i, cl; - int kern_first_page; - int mem_size = simosConf.mem_size; - - int mem_pages = mem_size / 8192, cons_pages; - ul kernel_bytes, ksp, kernel_end, *unix_kernel_stack, bss, ksp_bottom, ksp_top; - struct rpb_ctb *rpb_ctb; - struct ctb_tt *ctb_tt; - struct rpb_dsr *rpb_dsr; - struct rpb_crb *rpb_crb; - struct _xxm_rpb_mdt *rpb_mdt; - int *rpb_lurt; - char *rpb_name; - ul nextPtr; - - printf_lock( "memsize %x pages %x \n",mem_size,mem_pages); - - - -#ifdef notnow - if (unixArgs()) return; -#endif - - /* Allocate: - * two pages for the HWRPB - * five page table pages: - * 1: First level page table - * 1: Second level page table - * 1: Third level page table for HWRPB - * 2: Third level page table for kernel (for up to 16MB) - * set up the page tables - * load the kernel at the physical address 0x230000 - * build the HWRPB - * set up memory descriptor table to give up the - * physical memory between the end of the page - * tables and the start of the kernel - * enable kseg addressing - * jump to the kernel - */ - - unix_boot_mem = ROUNDUP8K(&_end); - - printf_lock("First free page after ROM 0x%x\n", unix_boot_mem); - - rpb = (struct rpb *) unix_boot_alloc( HWRPB_PAGES); - - mdt_bitmap = (unsigned char *) unix_boot_alloc(MDT_BITMAP_PAGES); - first = (ul *)unix_boot_alloc(1); - second = (ul *)unix_boot_alloc(1); - third_rpb = (ul *)unix_boot_alloc(1); - reservedFixup = (ul*) unix_boot_alloc(1); - third_kernel = (ul *)unix_boot_alloc(NUM_KERNEL_THIRD); - percpu_logout = (ul*)unix_boot_alloc(1); - - - cons_pages = KSEG_TO_PHYS(unix_boot_mem) / 8192; - - /* Set up the page tables */ - bzero((char *)first, 8192); - bzero((char *)second, 8192); - bzero((char *)reservedFixup,8192); - bzero((char *)third_rpb, HWRPB_PAGES * 8192); - bzero((char *)third_kernel, 8192 * NUM_KERNEL_THIRD); - - first[0] = KPTE(PFN(second)); - first[1] = KPTE(PFN(first)); /* Region 3 */ - - second[SECOND(0x10000000)] = KPTE(PFN(third_rpb)); /* Region 0 */ - - for (i=0;i (0x800000*NUM_KERNEL_THIRD)) { + printf_lock("Kernel is more than 8MB 0x%x - 0x%x = 0x%x\n", + kernel_end, m5Conf.kernStart, + kernel_end - m5Conf.kernStart ); + panic("kernel too big\n"); + } + + /* Map the kernel's pages into the third level of region 2 */ + for (ptr = m5Conf.kernStart; ptr < kernel_end; ptr += PAGE_SIZE) { + third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); + } + + /* blow 2 pages of phys mem for guards since it maintains 1-to-1 mapping */ + ksp = ksp_top + (3 * PAGE_SIZE); + if (ksp - m5Conf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { + printf_lock("Kernel stack pushd us over 8MB\n"); + panic("ksp too big\n"); + } + if (THIRD_XXX((ulong)ksp_top) > NUM_KERNEL_THIRD * 1024) { + panic("increase NUM_KERNEL_THIRD, and change THIRD_XXX\n"); + } + ptr = (ulong) ksp_top; + bzero((char *)ptr, PAGE_SIZE * 2); + third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ + ptr += PAGE_SIZE; + third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); /* Kernel Stack Pages */ + ptr += PAGE_SIZE; + third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); + ptr += PAGE_SIZE; + third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ + + /* put argv into the bottom of the stack - argv starts at 1 because + * the command thatr got us here (i.e. "unixboot) is in argv[0]. + */ + ksp -= 8; /* Back up one longword */ + ksp -= argc * sizeof(char *); /* Make room for argv */ + kargv = (char **) ksp; + for (i = 1; i < argc; i++) { /* Copy arguments to stack */ + ksp -= ((strlen(argv[i]) + 1) + 7) & ~0x7; + kargv[i-1] = (char *) ksp; + strcpy(kargv[i - 1], argv[i]); + } + kargc = i - 1; + kargv[kargc] = NULL; /* just to be sure; doesn't seem to be used */ + ksp -= sizeof(char *); /* point above last arg for no real reason */ + + free_pfn = PFN(ptr); + + bcopy((char *)&m5_rpb, (char *)rpb, sizeof(struct rpb)); + + rpb->rpb_selfref = (struct rpb *) KSEG_TO_PHYS(rpb); + rpb->rpb_string = 0x0000004250525748; + + tbb = (ulong *) (((char *) rpb) + ROUNDUP8(sizeof(struct rpb))); + rpb->rpb_trans_off = (ulong)tbb - (ulong)rpb; + bcopy((char *)m5_tbb, (char *)tbb, sizeof(m5_tbb)); + + /* + * rpb_counter. Use to determine timeouts in OS. + * XXX must be patched after a checkpoint restore (I guess) + */ + + printf_lock("CPU Clock at %d MHz IntrClockFrequency=%d \n", + m5Conf.cpuClock, m5Conf.intrClockFrequency); + rpb->rpb_counter = m5Conf.cpuClock * 1000 * 1000; + + /* + * By definition, the rpb_clock is scaled by 4096 (in hz) + */ + rpb->rpb_clock = m5Conf.intrClockFrequency * 4096; + + /* + * Per CPU Slots. Multiprocessor support. + */ + int percpu_size = ROUNDUP128(sizeof(struct rpb_percpu)); + + printf_lock("Booting with %d processor(s) \n", m5Conf.numCPUs); + + rpb->rpb_numprocs = m5Conf.numCPUs; + rpb->rpb_slotsize = percpu_size; + rpb_percpu = (struct rpb_percpu *) + ROUNDUP128(((ulong)tbb) + (sizeof(m5_tbb))); + + rpb->rpb_percpu_off = (ulong)rpb_percpu - (ulong)rpb; + + for (i = 0; i < m5Conf.numCPUs; i++) { + struct rpb_percpu *thisCPU = (struct rpb_percpu*) + ((ulong)rpb_percpu + percpu_size * i); + + bzero((char *)thisCPU, percpu_size); + bcopy((char *)&m5_rpb_percpu, (char *)thisCPU, + sizeof(struct rpb_percpu)); + + thisCPU->rpb_pcb.rpb_ksp = ksp; + thisCPU->rpb_pcb.rpb_ptbr = PFN(first); + + thisCPU->rpb_logout = KSEG_TO_PHYS(percpu_logout); + thisCPU->rpb_logout_len = PAGE_SIZE; + + printf_lock("KSP: 0x%x PTBR 0x%x\n", + thisCPU->rpb_pcb.rpb_ksp, thisCPU->rpb_pcb.rpb_ptbr); + + if (i) { + bootStrapImpure[i] = (ulong)unix_boot_alloc(1); + } + } + + nextPtr = (ulong)rpb_percpu + percpu_size * m5Conf.numCPUs; + + /* + * Console Terminal Block + */ + rpb_ctb = (struct rpb_ctb *) nextPtr; + ctb_tt = (struct ctb_tt*) rpb_ctb; + + rpb->rpb_ctb_off = ((ulong)rpb_ctb) - (ulong)rpb; + rpb->rpb_ctb_size = sizeof(struct rpb_ctb); + + bzero((char *)rpb_ctb, sizeof(struct ctb_tt)); + + rpb_ctb->rpb_type = CONS_DZ; + rpb_ctb->rpb_length = sizeof(ctb_tt) - sizeof(rpb_ctb); + + /* + * uart initizliation + */ + ctb_tt->ctb_csr = 0; + ctb_tt->ctb_tivec = 0x6c0; /* matches tlaser pal code */ + ctb_tt->ctb_rivec = 0x680; /* matches tlaser pal code */ + ctb_tt->ctb_baud = 9600; + ctb_tt->ctb_put_sts = 0; + ctb_tt->ctb_get_sts = 0; + + rpb_crb = (struct rpb_crb *) (((ulong)rpb_ctb) + sizeof(struct ctb_tt)); + rpb->rpb_crb_off = ((ulong)rpb_crb) - (ulong)rpb; + + bzero((char *)rpb_crb, sizeof(struct rpb_crb)); + + /* + * console callback stuff (m5) + */ + rpb_crb->rpb_num = 1; + rpb_crb->rpb_mapped_pages = HWRPB_PAGES; + rpb_crb->rpb_map[0].rpb_virt = 0x10000000; + rpb_crb->rpb_map[0].rpb_phys = KSEG_TO_PHYS(((ulong)rpb) & ~0x1fff); + rpb_crb->rpb_map[0].rpb_pgcount = HWRPB_PAGES; -#ifdef original__xxm - if (unixLoadKernel(AOUT_LOAD_ADDR, argv[1]) == -1) return; - aoutfixup(AOUT_LOAD_ADDR); -#else - /* aoutfixup(simosConf.kernelFileHdr); */ -#endif -#if 0 - bss = aout_bss_addr; - - kern_first_page = (KSEG_TO_PHYS(aout_text_start) / 8192); - kernel_end = ksp_top = ROUNDUP8K(aout_bss_addr + aout_bss_size); - bootadr = aout_entry; -#endif - - kern_first_page = (KSEG_TO_PHYS(simosConf.kernStart)/8192); - kernel_end = ksp_top = ROUNDUP8K(simosConf.kernEnd); - bootadr = simosConf.entryPoint; - - - printf_lock("HWRPB 0x%x l1pt 0x%x l2pt 0x%x l3pt_rpb 0x%x l3pt_kernel 0x%x l2reserv 0x%x\n", - rpb, first, second, third_rpb, third_kernel,reservedFixup); - if (kernel_end - simosConf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { - printf_lock("Kernel is more than 8MB 0x%x - 0x%x = 0x%x\n", - kernel_end, simosConf.kernStart, - kernel_end -simosConf.kernStart ); - panic("kernel too big\n"); - - } - /* Map the kernel's pages into the third level of region 2 */ - - for (ptr = simosConf.kernStart; ptr < kernel_end; ptr += 8192) { - - third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); - } - /* blow 2 pages of phys mem for guards since it maintains 1-to-1 mapping */ - ksp = ksp_top + (3 * 8192); - if (ksp - simosConf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { - printf_lock("Kernel stack pushd us over 8MB\n"); - panic("ksp too big\n"); - } - if (THIRD_XXX((ul)ksp_top) > NUM_KERNEL_THIRD * 1024) { - panic("increase NUM_KERNEL_THIRD, and change THIRD_XXX\n"); - } - ptr = (ul) ksp_top; - bzero((char *)ptr, 8192 * 2); - third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ - ptr += 8192; - third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); /* Kernel Stack Pages */ - ptr += 8192; - third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); - ptr += 8192; - third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ + printf_lock("Console Callback at 0x%x, fixup at 0x%x, crb offset: 0x%x\n", + rpb_crb->rpb_va_disp, rpb_crb->rpb_va_fixup, rpb->rpb_crb_off); - /* put argv into the bottom of the stack - argv starts at 1 because - * the command thatr got us here (i.e. "unixboot) is in argv[0]. - */ - ksp -= 8; /* Back up one longword */ - ksp -= argc * sizeof(char *); /* Make room for argv */ - kargv = (char **) ksp; - for (i = 1; i < argc; i++) { /* Copy arguments to stack */ - ksp -= ((strlen(argv[i]) + 1) + 7) & ~0x7; - kargv[i-1] = (char *) ksp; - strcpy(kargv[i-1], argv[i]); - } - kargc = i - 1; - kargv[kargc] = NULL; /* just to be sure; doesn't seem to be used */ - ksp -= sizeof(char *); /* point above last arg for no real reason */ + rpb_mdt = (struct _m5_rpb_mdt *)((ulong)rpb_crb + sizeof(struct rpb_crb)); + rpb->rpb_mdt_off = (ulong)rpb_mdt - (ulong)rpb; + bcopy((char *)&m5_rpb_mdt, (char *)rpb_mdt, sizeof(struct _m5_rpb_mdt)); + + + cl = 0; + rpb_mdt->rpb_cluster[cl].rpb_pfncount = kern_first_page; + cl++; + + rpb_mdt->rpb_cluster[cl].rpb_pfn = kern_first_page; + rpb_mdt->rpb_cluster[cl].rpb_pfncount = mem_pages - kern_first_page; + rpb_mdt->rpb_cluster[cl].rpb_pfntested = + rpb_mdt->rpb_cluster[cl].rpb_pfncount; + rpb_mdt->rpb_cluster[cl].rpb_pa = KSEG_TO_PHYS(mdt_bitmap); + rpb_mdt->rpb_cluster[cl].rpb_va = 0x10000000 + HWRPB_PAGES * PAGE_SIZE; + cl++; + + rpb_mdt->rpb_numcl = cl; + + for (i = 0; i < cl; i++) + printf_lock("Memory cluster %d [%d - %d]\n", i, + rpb_mdt->rpb_cluster[i].rpb_pfn, + rpb_mdt->rpb_cluster[i].rpb_pfncount); - free_pfn = PFN(ptr); - - bcopy((char *)&xxm_rpb, (char *)rpb, sizeof(struct rpb)); - - rpb->rpb_selfref = (struct rpb *) KSEG_TO_PHYS(rpb); - rpb->rpb_string = 0x0000004250525748; - - tbb = (ul *) (((char *) rpb) + ROUNDUP8(sizeof(struct rpb))); - rpb->rpb_trans_off = (ul)tbb - (ul)rpb; - bcopy((char *)xxm_tbb, (char *)tbb, sizeof(xxm_tbb)); - - - /* - * rpb_counter. Use to determine timeouts in OS. - * XXX must be patched after a checkpoint restore (I guess) - */ - - printf_lock("CPU Clock at %d MHz IntrClockFrequency=%d \n", simosConf.cpuClock,simosConf.intrClockFrequency); - rpb->rpb_counter = simosConf.cpuClock * 1000 * 1000; - - /* - * By definition, the rpb_clock is scaled by 4096 (in hz) - */ - rpb->rpb_clock = simosConf.intrClockFrequency * 4096; - - - - /* - * Per CPU Slots. Multiprocessor support. - */ - { - int i; - int size = ROUNDUP128(sizeof(struct rpb_percpu)); - - printf_lock("Booting with %d processor(s) \n",simosConf.numCPUs); - - rpb->rpb_numprocs = simosConf.numCPUs; - rpb->rpb_slotsize = size; - rpb_percpu = (struct rpb_percpu *) - ROUNDUP128(((ul) tbb) +(sizeof(xxm_tbb))); - - rpb->rpb_percpu_off = (ul)rpb_percpu - (ul)rpb; - - for (i=0;irpb_pcb.rpb_ksp = ksp; - thisCPU->rpb_pcb.rpb_ptbr = PFN(first); - - thisCPU->rpb_logout = KSEG_TO_PHYS(percpu_logout); - thisCPU->rpb_logout_len = 8192; - -/* thisCPU->rpb_pcb.rpb_ptbr = PFN(second);*/ - - printf_lock("KSP: 0x%x PTBR 0x%x\n", thisCPU->rpb_pcb.rpb_ksp, thisCPU->rpb_pcb.rpb_ptbr); - - if (i) { - bootStrapImpure[i] = (ul)unix_boot_alloc(1); - } - - } - - nextPtr = (ul)rpb_percpu + size*simosConf.numCPUs; - } - - /* - * Console Terminal Block - */ - - - rpb_ctb = (struct rpb_ctb *) nextPtr; - ctb_tt = (struct ctb_tt*) rpb_ctb; - - rpb->rpb_ctb_off = ((ul)rpb_ctb) - (ul)rpb; - rpb->rpb_ctb_size = sizeof(struct rpb_ctb); - - bzero((char *)rpb_ctb, sizeof(struct ctb_tt)); - -#ifdef original_xxm - if (tga_slot == -1) - rpb_ctb->rpb_type = CONS_DZ; - else { - rpb_ctb->rpb_type = CONS_GRPH; - rpb_ctb->rpb_unit = (SLOTINFO_PCI << 16) | (0 << 8) | tga_slot; - } -#else - rpb_ctb->rpb_type = CONS_DZ; -#endif - - rpb_ctb->rpb_length = sizeof(ctb_tt)-sizeof(rpb_ctb); - - /* - * uart initizliation - */ - ctb_tt->ctb_csr = 0; - ctb_tt->ctb_tivec = 0x6c0; /* matches tlaser pal code */ - ctb_tt->ctb_rivec = 0x680; /* matches tlaser pal code */ - ctb_tt->ctb_baud = 9600; - ctb_tt->ctb_put_sts = 0; - ctb_tt->ctb_get_sts = 0; - - - rpb_crb = (struct rpb_crb *) (((ul)rpb_ctb) + sizeof(struct ctb_tt)); - rpb->rpb_crb_off = ((ul)rpb_crb) - (ul)rpb; - - bzero((char *)rpb_crb, sizeof(struct rpb_crb)); - /* - * console callback stuff (simos) - */ - - rpb_crb->rpb_num = 1; - rpb_crb->rpb_mapped_pages = HWRPB_PAGES; - rpb_crb->rpb_map[0].rpb_virt = 0x10000000; - rpb_crb->rpb_map[0].rpb_phys = KSEG_TO_PHYS(((ul)rpb) & ~0x1fff); - rpb_crb->rpb_map[0].rpb_pgcount = HWRPB_PAGES; - - - printf_lock("Console Callback at 0x%x, fixup at 0x%x, crb offset: 0x%x\n", - rpb_crb->rpb_va_disp, - rpb_crb->rpb_va_fixup, - rpb->rpb_crb_off); - - rpb_mdt = (struct _xxm_rpb_mdt *) (((ul)rpb_crb) + sizeof(struct rpb_crb)); - rpb->rpb_mdt_off = (ul)rpb_mdt - (ul)rpb; - bcopy((char *)&xxm_rpb_mdt, (char *)rpb_mdt, sizeof(struct _xxm_rpb_mdt)); - - - cl = 0; -#ifdef undef - /* Until Digital Unix can handle it, account all pages below the kernel - * as "console" memory. */ - rpb_mdt->rpb_cluster[cl].rpb_pfncount = cons_pages; -#endif - rpb_mdt->rpb_cluster[cl].rpb_pfncount = kern_first_page; - cl++; - - rpb_mdt->rpb_cluster[cl].rpb_pfn = kern_first_page; - rpb_mdt->rpb_cluster[cl].rpb_pfncount = mem_pages - kern_first_page; - rpb_mdt->rpb_cluster[cl].rpb_pfntested=rpb_mdt->rpb_cluster[cl].rpb_pfncount; - rpb_mdt->rpb_cluster[cl].rpb_pa = KSEG_TO_PHYS(mdt_bitmap); - rpb_mdt->rpb_cluster[cl].rpb_va = 0x10000000 + HWRPB_PAGES * 8192; - cl++; - -#ifdef undef - /* The stupid Unix kernel needs to have all mdt clusters in ascending - * order, and the last cluster is used to compute the top of memory. - * It can't make use of memory between the console and the kernel. - */ - rpb_mdt->rpb_cluster[cl].rpb_pfn = cons_pages; - rpb_mdt->rpb_cluster[cl].rpb_pfncount = kern_first_page - cons_pages; - rpb_mdt->rpb_cluster[cl].rpb_pfntested=rpb_mdt->rpb_cluster[cl].rpb_pfncount; - rpb_mdt->rpb_cluster[cl].rpb_pa = KSEG_TO_PHYS(mdt_bitmap); - rpb_mdt->rpb_cluster[cl].rpb_va = 0x10000000 + HWRPB_PAGES * 8192; - cl++; -#endif - - rpb_mdt->rpb_numcl = cl; - - for (i = 0; i < cl; i++) - printf_lock("Memory cluster %d [%d - %d]\n", i, rpb_mdt->rpb_cluster[i].rpb_pfn, rpb_mdt->rpb_cluster[i].rpb_pfncount); - - - - /* Checksum the rpb for good luck */ - sum = 0; - lp1 = (long *)&rpb_mdt->rpb_impaddr; - lp2 = (long *)&rpb_mdt->rpb_cluster[cl]; - while (lp1 < lp2) sum += *lp1++; - rpb_mdt->rpb_checksum = sum; - - /* XXX should checksum the cluster descriptors */ - - bzero((char *)mdt_bitmap, MDT_BITMAP_PAGES * 8192); - for (i = 0; i < mem_pages/8; i++) ((unsigned char *)mdt_bitmap)[i] = 0xff; - - printf_lock("Initalizing mdt_bitmap addr 0x%x mem_pages %x \n", - (long)mdt_bitmap,(long)mem_pages); - - xxm_rpb.rpb_config_off = 0; - xxm_rpb.rpb_fru_off = 0; - - rpb_dsr = (struct rpb_dsr *) (((ul)rpb_mdt) + sizeof(struct _xxm_rpb_mdt)); - rpb->rpb_dsr_off = ((ul)rpb_dsr) - (ul)rpb; - bzero((char *)rpb_dsr, sizeof(struct rpb_dsr)); - rpb_dsr->rpb_smm = 1578; /* Official XXM SMM number as per SRM */ - rpb_dsr->rpb_smm = 1089; /* Official Alcor SMM number as per SRM */ - - rpb_lurt = (int *) ROUNDUP8(((ul)rpb_dsr) + sizeof(struct rpb_dsr)); - rpb_dsr->rpb_lurt_off = ((ul) rpb_lurt) - (ul) rpb_dsr; - bcopy((char *)xxm_lurt, (char *)rpb_lurt, sizeof(xxm_lurt)); - - rpb_name = (char *) ROUNDUP8(((ul)rpb_lurt) + sizeof(xxm_lurt)); - rpb_dsr->rpb_sysname_off = ((ul) rpb_name) - (ul) rpb_dsr; + /* Checksum the rpb for good luck */ + sum = 0; + lp1 = (long *)&rpb_mdt->rpb_impaddr; + lp2 = (long *)&rpb_mdt->rpb_cluster[cl]; + while (lp1 < lp2) sum += *lp1++; + rpb_mdt->rpb_checksum = sum; + + /* XXX should checksum the cluster descriptors */ + bzero((char *)mdt_bitmap, MDT_BITMAP_PAGES * PAGE_SIZE); + for (i = 0; i < mem_pages/8; i++) + ((unsigned char *)mdt_bitmap)[i] = 0xff; + + printf_lock("Initalizing mdt_bitmap addr 0x%x mem_pages %x \n", + (long)mdt_bitmap,(long)mem_pages); + + m5_rpb.rpb_config_off = 0; + m5_rpb.rpb_fru_off = 0; + + rpb_dsr = (struct rpb_dsr *)((ulong)rpb_mdt + sizeof(struct _m5_rpb_mdt)); + rpb->rpb_dsr_off = (ulong)rpb_dsr - (ulong)rpb; + bzero((char *)rpb_dsr, sizeof(struct rpb_dsr)); + rpb_dsr->rpb_smm = 1578; /* Official XXM SMM number as per SRM */ + rpb_dsr->rpb_smm = 1089; /* Official Alcor SMM number as per SRM */ + + rpb_lurt = (int *) ROUNDUP8((ulong)rpb_dsr + sizeof(struct rpb_dsr)); + rpb_dsr->rpb_lurt_off = ((ulong) rpb_lurt) - (ulong) rpb_dsr; + bcopy((char *)m5_lurt, (char *)rpb_lurt, sizeof(m5_lurt)); + + rpb_name = (char *) ROUNDUP8(((ulong)rpb_lurt) + sizeof(m5_lurt)); + rpb_dsr->rpb_sysname_off = ((ulong) rpb_name) - (ulong) rpb_dsr; #define THENAME " M5/Alpha " - sum = sizeof(THENAME); - bcopy(THENAME, rpb_name, sum); - *(ul *)rpb_name = sizeof(THENAME); /* put in length field */ - - /* calculate size of rpb */ - rpb->rpb_size = ((ul) &rpb_name[sum]) - (ul)rpb; - - if (rpb->rpb_size > 8192*HWRPB_PAGES) { - panic("HWRPB_PAGES=%d too small for HWRPB !!! \n"); - } - - - { - ul *ptr = (ul*)((char*)rpb_dsr + sizeof(struct rpb_dsr )); - rpb_crb->rpb_pa_disp = KSEG_TO_PHYS(ptr); - rpb_crb->rpb_va_disp = 0x10000000 + (((ul)ptr - (ul)rpb) & (0x2000*HWRPB_PAGES-1)); - printf_lock("ConsoleDispatch at virt %x phys %x val %x\n", - rpb_crb->rpb_va_disp, - rpb_crb->rpb_pa_disp, - consoleCallback); - *ptr++ = 0; - *ptr++ = (ul) consoleCallback; - rpb_crb->rpb_pa_fixup = KSEG_TO_PHYS(ptr); - rpb_crb->rpb_va_fixup = 0x10000000 + (((ul)ptr - (ul)rpb) & (0x2000*HWRPB_PAGES-1)); - *ptr++ = 0; - - *ptr++ = (ul) consoleFixup; - } - - - /* Checksum the rpb for good luck */ - sum = 0; - lp1 = (long *)rpb; - lp2 = &rpb->rpb_checksum; - while (lp1 < lp2) - sum += *lp1++; - *lp2 = sum; - + sum = sizeof(THENAME); + bcopy(THENAME, rpb_name, sum); + *(ulong *)rpb_name = sizeof(THENAME); /* put in length field */ + + /* calculate size of rpb */ + rpb->rpb_size = ((ulong) &rpb_name[sum]) - (ulong)rpb; + + if (rpb->rpb_size > PAGE_SIZE * HWRPB_PAGES) { + panic("HWRPB_PAGES=%d too small for HWRPB !!! \n"); + } + + ulong *rpbptr = (ulong*)((char*)rpb_dsr + sizeof(struct rpb_dsr)); + rpb_crb->rpb_pa_disp = KSEG_TO_PHYS(rpbptr); + rpb_crb->rpb_va_disp = 0x10000000 + + (((ulong)rpbptr - (ulong)rpb) & (0x2000 * HWRPB_PAGES - 1)); + printf_lock("ConsoleDispatch at virt %x phys %x val %x\n", + rpb_crb->rpb_va_disp, rpb_crb->rpb_pa_disp, consoleCallback); + *rpbptr++ = 0; + *rpbptr++ = (ulong) consoleCallback; + rpb_crb->rpb_pa_fixup = KSEG_TO_PHYS(rpbptr); + rpb_crb->rpb_va_fixup = 0x10000000 + + (((ulong)rpbptr - (ulong)rpb) & (0x2000 * HWRPB_PAGES - 1)); + *rpbptr++ = 0; + + *rpbptr++ = (ulong) consoleFixup; + + /* Checksum the rpb for good luck */ + sum = 0; + lp1 = (long *)rpb; + lp2 = &rpb->rpb_checksum; + while (lp1 < lp2) + sum += *lp1++; + *lp2 = sum; /* * MP bootstrap */ - - { - int i; - for (i=1;ibootStrapImpure = bootStrapImpure[i]; k1Conf->bootStrapCPU = i; - } - } - - /* - * Make sure that we are not stepping on the kernel - */ - if ((ul)unix_boot_mem >= (ul)simosConf.kernStart) { - panic("CONSOLE: too much memory. Smashing kernel \n"); - } else { - printf_lock("unix_boot_mem ends at %x \n",unix_boot_mem); - } - - -#ifdef undef -#define CSERVE_K_JTOKERN 0x18 - cServe(bootadr, (ul) rpb_percpu, CSERVE_K_JTOKERN, free_pfn); -#endif - - if (go) JToKern(bootadr, rpb_percpu, free_pfn, kargc, kargv, NULL); -} - - -#if 0 -aoutfixup(char *p) -{ - int i; - unsigned long rem, len, off, dst; - - - struct new_aouthdr *ao = (struct new_aouthdr *) &p[NEW_FILHSZ]; -#if 0 - struct scnhdr *s = (struct scnhdr *) &p[FILHSZ + AOUTHSZ]; - struct scnhdr *t, *d, *b; - printf("aoutfixup: %d sections \n",fh->f_nscns); -#endif - - - aout_text_start = ((ul)ao->text_start_hi<<32) + ao->text_start; - aout_data_addr = ((ul)ao->data_start_hi<<32) + ao->data_start; - aout_bss_addr = ((ul)ao->bss_start_hi<<32) + ao->bss_start; - aout_bss_size = ((ul)ao->bsize_hi<<32) + ao->bsize; - aout_entry = ((ul)ao->entry_hi<<32) + ao->entry; - - printf("_text 0x%16x %8d @ %08d\n", aout_text_start, ao->tsize,0 /* t->s_scnptr*/); - printf("_data 0x%16x %8d @ %08d\n", aout_data_addr, ao->dsize,0/* d->s_scnptr*/); - printf("_bss 0x%16x %8d\n", aout_bss_addr, ao->bsize); - printf("entry 0x%16x\n", aout_entry); -#if 0 - for (i = 0; i < fh->f_nscns; i++) { - printf("section %d %s \n",i,s[i].s_name); - if (!strcmp(s[i].s_name, ".text")) t = &s[i]; - else if (!strcmp(s[i].s_name, ".data")) d = &s[i]; - else if (!strcmp(s[i].s_name, ".bss")) b = &s[i]; - } - bcopy(&p[t->s_scnptr], (char *)ao->text_start, ao->tsize); - bcopy(&p[d->s_scnptr], (char *)ao->data_start, ao->dsize); -#endif + } + + /* + * Make sure that we are not stepping on the kernel + */ + if ((ulong)unix_boot_mem >= (ulong)m5Conf.kernStart) { + panic("CONSOLE: too much memory. Smashing kernel\n"); + } else { + printf_lock("unix_boot_mem ends at %x \n", unix_boot_mem); + } + + if (go) + JToKern((char *)bootadr, (ulong)rpb_percpu, free_pfn, kargc, kargv, + NULL); } -#endif -extern ui palJToKern[]; -JToKern(bootadr, rpb_percpu, free_pfn, k_argc, k_argv, envp) -char * bootadr; -ul rpb_percpu; -ul free_pfn; -ul k_argc; -char **k_argv; -char **envp; +void +JToKern(char *bootadr, ulong rpb_percpu, ulong free_pfn, ulong k_argc, + char **k_argv, char **envp) { - struct _kernel_params *kernel_params = (struct _kernel_params *) KSEG; - int i; - - printf_lock("k_argc = %d ", k_argc); - for (i = 0; i < k_argc; i++) { - printf_lock("'%s' ", k_argv[i]); - } - printf_lock("\n"); - -/* rpb_percpu |= 0xfffffc0000000000;*/ - kernel_params->bootadr = bootadr; - kernel_params->rpb_percpu = KSEG_TO_PHYS(rpb_percpu); - kernel_params->free_pfn = free_pfn; - kernel_params->argc = k_argc; - kernel_params->argv = (ul)k_argv; - kernel_params->envp = (ul)envp; - printf_lock("jumping to kernel at 0x%x, (PCBB 0x%x pfn %d)\n", bootadr, rpb_percpu, free_pfn); - jToPal(KSEG_TO_PHYS((ul)palJToKern)); - printf_lock("returned from jToPal. Looping\n"); - while(1) continue; + extern ulong palJToKern[]; + + struct _kernel_params *kernel_params = (struct _kernel_params *) KSEG; + int i; + + printf_lock("k_argc = %d ", k_argc); + for (i = 0; i < k_argc; i++) { + printf_lock("'%s' ", k_argv[i]); + } + printf_lock("\n"); + + kernel_params->bootadr = bootadr; + kernel_params->rpb_percpu = KSEG_TO_PHYS(rpb_percpu); + kernel_params->free_pfn = free_pfn; + kernel_params->argc = k_argc; + kernel_params->argv = (ulong)k_argv; + kernel_params->envp = (ulong)envp; + printf_lock("jumping to kernel at 0x%x, (PCBB 0x%x pfn %d)\n", + bootadr, rpb_percpu, free_pfn); + JToPal(KSEG_TO_PHYS(palJToKern)); + printf_lock("returned from JToPal. Looping\n"); + while (1) + continue; } - -void jToPal(ul bootadr) +void +JToPal(ulong bootadr) { - cServe(bootadr, 0, CSERVE_K_JTOPAL); + cServe(bootadr, 0, CSERVE_K_JTOPAL); -/* - * Make sure that floating point is enabled incase - * it was disabled by the user program. - */ - wrfen(1); + /* + * Make sure that floating point is enabled incase + * it was disabled by the user program. + */ + wrfen(1); } - -int strcpy(char *dst, char *src) +int +strcpy(char *dst, char *src) { - int i=0; - while(*src) { - *dst++ = *src++; - i++; - } - return i; + int i = 0; + while (*src) { + *dst++ = *src++; + i++; + } + return i; } - - - -/* ***************************************** +/* * Console I/O - * ******************************************/ + * + */ int numOpenDevices = 11; struct { - char name[128]; + char name[128]; } deviceState[32]; #define BOOTDEVICE_NAME "SCSI 1 0 0 1 100 0" @@ -1030,35 +866,27 @@ struct { void DeviceOperation(long op, long channel, long count, long address, long block) { - struct AlphaAccess *k1Conf = (struct AlphaAccess *) - (ALPHA_ACCESS_BASE); - - long pAddr; - -#if 0 - printf("Console::DeviceRead count=0x%x address=0x%x block=0x%x\n", - count,address,block); -#endif - - if (strcmp(deviceState[channel].name, BOOTDEVICE_NAME )) { - panic("DeviceRead: only implemented for root disk \n"); - } - pAddr = KSEG_TO_PHYS(address); - if (pAddr + count > simosConf.mem_size) { - panic("DeviceRead: request out of range \n"); - } - - k1Conf->diskCount = count; - k1Conf->diskPAddr = pAddr; - k1Conf->diskBlock = block; - k1Conf->diskOperation = op; /* launch */ + struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); + long pAddr; + + if (strcmp(deviceState[channel].name, BOOTDEVICE_NAME )) { + panic("DeviceRead: only implemented for root disk \n"); + } + pAddr = KSEG_TO_PHYS(address); + if (pAddr + count > m5Conf.mem_size) { + panic("DeviceRead: request out of range \n"); + } + + k1Conf->diskCount = count; + k1Conf->diskPAddr = pAddr; + k1Conf->diskBlock = block; + k1Conf->diskOperation = op; /* launch */ } - - -/* ************************************************************************* - * SimoS Console callbacks - * **************************************************/ +/* + * M5 Console callbacks + * + */ /* AXP manual 2-31 */ #define CONSCB_GETC 0x1 @@ -1109,39 +937,38 @@ DeviceOperation(long op, long channel, long count, long address, long block) #define MAX_ENVLEN 32 -char env_auto_action[MAX_ENVLEN] = "BOOT"; -char env_boot_dev[MAX_ENVLEN] = ""; -char env_bootdef_dev[MAX_ENVLEN] = ""; -char env_booted_dev[MAX_ENVLEN] = BOOTDEVICE_NAME; -char env_boot_file[MAX_ENVLEN] = ""; -char env_booted_file[MAX_ENVLEN] = ""; -char env_boot_osflags[MAX_ENVLEN] = ""; -char env_booted_osflags[MAX_ENVLEN] = ""; -char env_boot_reset[MAX_ENVLEN] = ""; -char env_dump_dev[MAX_ENVLEN] = ""; -char env_enable_audit[MAX_ENVLEN] = ""; -char env_license[MAX_ENVLEN] = ""; -char env_char_set[MAX_ENVLEN] = ""; -char env_language[MAX_ENVLEN] = ""; -char env_tty_dev[MAX_ENVLEN] = "0"; -char env_scsiid[MAX_ENVLEN] = ""; -char env_scsifast[MAX_ENVLEN] = ""; -char env_com1_baud[MAX_ENVLEN] = ""; -char env_com1_modem[MAX_ENVLEN] = ""; -char env_com1_flow[MAX_ENVLEN] = ""; -char env_com1_misc[MAX_ENVLEN] = ""; -char env_com2_baud[MAX_ENVLEN] = ""; -char env_com2_modem[MAX_ENVLEN] = ""; -char env_com2_flow[MAX_ENVLEN] = ""; -char env_com2_misc[MAX_ENVLEN] = ""; -char env_password[MAX_ENVLEN] = ""; -char env_secure[MAX_ENVLEN] = ""; -char env_logfail[MAX_ENVLEN] = ""; -char env_srm2dev_id[MAX_ENVLEN] = ""; +char env_auto_action[MAX_ENVLEN] = "BOOT"; +char env_boot_dev[MAX_ENVLEN] = ""; +char env_bootdef_dev[MAX_ENVLEN] = ""; +char env_booted_dev[MAX_ENVLEN] = BOOTDEVICE_NAME; +char env_boot_file[MAX_ENVLEN] = ""; +char env_booted_file[MAX_ENVLEN] = ""; +char env_boot_osflags[MAX_ENVLEN] = ""; +char env_booted_osflags[MAX_ENVLEN] = ""; +char env_boot_reset[MAX_ENVLEN] = ""; +char env_dump_dev[MAX_ENVLEN] = ""; +char env_enable_audit[MAX_ENVLEN] = ""; +char env_license[MAX_ENVLEN] = ""; +char env_char_set[MAX_ENVLEN] = ""; +char env_language[MAX_ENVLEN] = ""; +char env_tty_dev[MAX_ENVLEN] = "0"; +char env_scsiid[MAX_ENVLEN] = ""; +char env_scsifast[MAX_ENVLEN] = ""; +char env_com1_baud[MAX_ENVLEN] = ""; +char env_com1_modem[MAX_ENVLEN] = ""; +char env_com1_flow[MAX_ENVLEN] = ""; +char env_com1_misc[MAX_ENVLEN] = ""; +char env_com2_baud[MAX_ENVLEN] = ""; +char env_com2_modem[MAX_ENVLEN] = ""; +char env_com2_flow[MAX_ENVLEN] = ""; +char env_com2_misc[MAX_ENVLEN] = ""; +char env_password[MAX_ENVLEN] = ""; +char env_secure[MAX_ENVLEN] = ""; +char env_logfail[MAX_ENVLEN] = ""; +char env_srm2dev_id[MAX_ENVLEN] = ""; #define MAX_ENV_INDEX 100 -char *env_ptr[MAX_ENV_INDEX] = -{ +char *envptr[MAX_ENV_INDEX] = { 0, /* 0x00 */ env_auto_action, /* 0x01 */ env_boot_dev, /* 0x02 */ @@ -1187,140 +1014,128 @@ char *env_ptr[MAX_ENV_INDEX] = long CallBackDispatcher(long a0, long a1, long a2, long a3, long a4) { - long i; - switch (a0) { - case CONSCB_GETC: - return GetChar(); - - case CONSCB_PUTS: - for(i = 0; i < a3; i++) - PutChar(*((char *)a2+i)); - return a3; - - case CONSCB_GETENV: - if (a1 >= 0 && a1 < MAX_ENV_INDEX && env_ptr[a1] != 0 && *env_ptr[a1]) { - i = strcpy((char*)a2, env_ptr[a1]); - } else { - strcpy((char*)a2, ""); - i = (long)0xc000000000000000; - if (a1 >= 0 && a1 < MAX_ENV_INDEX) - printf_lock("GETENV unsupported option %d (0x%x)\n", a1, a1); - else - printf_lock("GETENV unsupported option %s\n", a1); - } - - if (i > a3) - panic("CONSCB_GETENV overwrote buffer\n"); - return i; - - case CONSCB_OPEN: - bcopy((char*)a1,deviceState[numOpenDevices].name,a2); - deviceState[numOpenDevices].name[a2] = '\0'; - printf_lock("CONSOLE OPEN : %s --> success \n", - deviceState[numOpenDevices].name); - return numOpenDevices++; - - case CONSCB_READ: - DeviceOperation(a0,a1,a2,a3,a4); - break; - - case CONSCB_CLOSE: - break; - case CONSCB_OPEN_CONSOLE: - printf_lock("CONSOLE OPEN\n"); - return 0; /* success */ - break; /* not rearched */ - case CONSCB_CLOSE_CONSOLE: - printf_lock("CONSOLE CLOSE\n"); - return 0; /* success */ - break; /* not reached */ - - default: - panic("cher (%x,%x,%x,%x)\n", a0, a1, a2, a3); - } - - return 0; + long i; + switch (a0) { + case CONSCB_GETC: + return GetChar(); + + case CONSCB_PUTS: + for (i = 0; i < a3; i++) + PutChar(*((char *)a2 + i)); + return a3; + + case CONSCB_GETENV: + if (a1 >= 0 && a1 < MAX_ENV_INDEX && envptr[a1] != 0 && *envptr[a1]) { + i = strcpy((char*)a2, envptr[a1]); + } else { + strcpy((char*)a2, ""); + i = (long)0xc000000000000000; + if (a1 >= 0 && a1 < MAX_ENV_INDEX) + printf_lock("GETENV unsupported option %d (0x%x)\n", a1, a1); + else + printf_lock("GETENV unsupported option %s\n", a1); + } + + if (i > a3) + panic("CONSCB_GETENV overwrote buffer\n"); + return i; + + case CONSCB_OPEN: + bcopy((char*)a1, deviceState[numOpenDevices].name, a2); + deviceState[numOpenDevices].name[a2] = '\0'; + printf_lock("CONSOLE OPEN : %s --> success \n", + deviceState[numOpenDevices].name); + return numOpenDevices++; + + case CONSCB_READ: + DeviceOperation(a0, a1, a2, a3, a4); + break; + + case CONSCB_CLOSE: + break; + + case CONSCB_OPEN_CONSOLE: + printf_lock("CONSOLE OPEN\n"); + return 0; /* success */ + break; /* not reached */ + + case CONSCB_CLOSE_CONSOLE: + printf_lock("CONSOLE CLOSE\n"); + return 0; /* success */ + break; /* not reached */ + + default: + panic("CallBackDispatcher(%x,%x,%x,%x,%x)\n", a0, a1, a2, a3, a4); + } + + return 0; } -long CallBackFixup(int a0, int a1, int a2) +long +CallBackFixup(int a0, int a1, int a2) { - long temp; - /* Linux uses r8 for the current pointer (pointer to data structure - contating info about currently running process). It is set when the - kernel starts and is expected to remain there... Problem is that the - unlike the kernel, the console does not prevent the assembler from - using r8. So here is a work around. So far this has only been a problem - in CallBackFixup() but any other call back functions could cause a problem - at some point */ - - /* save off the current pointer to a temp variable */ - asm("bis $8, $31, %0" : "=r" (temp)); - - /* call original code */ - printf_lock("CallbackFixup %x %x, t7=%x\n",a0,a1,temp); - - /* restore the current pointer */ - asm("bis %0, $31, $8" : : "r" (temp) : "$8"); - -#if 0 - if (first[FIRST(a1)]==0) { - first[FIRST(a1)] = KPTE(PFN(reservedFixup)); - } else { - panic("CallBakcfixup\n"); - } - second[SECOND(a1)] = KPTE(PFN(third_rpb)); /* Region 0 */ - printf("Fixup: FISRT(a1)=0x%x SECOND(a1)=0x%x THIRD(a1)=0x%x\n", - FIRST(a1),SECOND(a1),THIRD(a1)); - -#endif - return 0; + long temp; + /* + * Linux uses r8 for the current pointer (pointer to data + * structure contating info about currently running process). It + * is set when the kernel starts and is expected to remain + * there... Problem is that the unlike the kernel, the console + * does not prevent the assembler from using r8. So here is a work + * around. So far this has only been a problem in CallBackFixup() + * but any other call back functions couldd cause a problem at + * some point + */ + + /* save off the current pointer to a temp variable */ + asm("bis $8, $31, %0" : "=r" (temp)); + + /* call original code */ + printf_lock("CallbackFixup %x %x, t7=%x\n", a0, a1, temp); + + /* restore the current pointer */ + asm("bis %0, $31, $8" : : "r" (temp) : "$8"); + + return 0; } - - - - -void SlaveCmd(int cpu, struct rpb_percpu *my_rpb) +void +SlaveCmd(int cpu, struct rpb_percpu *my_rpb) { -/* extern void palJToSlave[]; */ - extern unsigned int palJToSlave[]; + extern ulong palJToSlave[]; - printf_lock("Slave CPU %d console command %s", cpu,my_rpb->rpb_iccb.iccb_rxbuf); + printf_lock("Slave CPU %d console command %s", cpu, + my_rpb->rpb_iccb.iccb_rxbuf); - my_rpb->rpb_state |= STATE_BIP; - my_rpb->rpb_state &= ~STATE_RC; + my_rpb->rpb_state |= STATE_BIP; + my_rpb->rpb_state &= ~STATE_RC; - printf_lock("SlaveCmd: restart %x %x vptb %x my_rpb %x my_rpb_phys %x\n", - rpb->rpb_restart, - rpb->rpb_restart_pv, - rpb->rpb_vptb, my_rpb, - KSEG_TO_PHYS(my_rpb)); + printf_lock("SlaveCmd: restart %x %x vptb %x my_rpb %x my_rpb_phys %x\n", + rpb->rpb_restart, rpb->rpb_restart_pv, rpb->rpb_vptb, my_rpb, + KSEG_TO_PHYS(my_rpb)); - cServe(KSEG_TO_PHYS((ul)palJToSlave), - (ul)rpb->rpb_restart, - CSERVE_K_JTOPAL, - rpb->rpb_restart_pv, - rpb->rpb_vptb, - KSEG_TO_PHYS(my_rpb)); + cServe(KSEG_TO_PHYS(palJToSlave), (ulong)rpb->rpb_restart, + CSERVE_K_JTOPAL, rpb->rpb_restart_pv, rpb->rpb_vptb, + KSEG_TO_PHYS(my_rpb)); - panic("SlaveCmd returned \n"); + panic("SlaveCmd returned \n"); } -void SlaveLoop( int cpu) +void +SlaveLoop(int cpu) { - int size = ROUNDUP128(sizeof(struct rpb_percpu)); - struct rpb_percpu *my_rpb = (struct rpb_percpu*) - ((ul)rpb_percpu + size*cpu); - - if (cpu==0) { - panic("CPU 0 entering slaveLoop. Reenetering the console. HOSED \n"); - } else { - printf_lock("Entering slaveloop for cpu %d my_rpb=%x \n",cpu,my_rpb); - } - - // swap the processors context to the one in the - // rpb_percpu struct very carefully (i.e. no stack usage) - // so that linux knows which processor ends up in __smp_callin - // and we don't trash any data is the process - SlaveSpin(cpu,my_rpb,&my_rpb->rpb_iccb.iccb_rxlen); + int size = ROUNDUP128(sizeof(struct rpb_percpu)); + struct rpb_percpu *my_rpb = (struct rpb_percpu*) + ((ulong)rpb_percpu + size * cpu); + + if (cpu == 0) { + panic("CPU 0 entering slaveLoop. Reenetering the console. HOSED\n"); + } else { + printf_lock("Entering slaveloop for cpu %d my_rpb=%x\n", cpu, my_rpb); + } + + // swap the processors context to the one in the + // rpb_percpu struct very carefully (i.e. no stack usage) + // so that linux knows which processor ends up in __smp_callin + // and we don't trash any data is the process + SlaveSpin(cpu, my_rpb, &my_rpb->rpb_iccb.iccb_rxlen); } -- cgit v1.2.3 From 941db36a67baeff563ea0eb9d66dad0b41c51200 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 28 Jun 2005 01:13:20 -0400 Subject: pass the location of the m5 backdoor via the m5AlphaAccess variable only compile one console console/Makefile: Now that the location of the m5 backdoor is passed into the console via the m5AlphaAccess variable, we only need to compile one console, and don't need to define TLASER or TSUNAMI console/console.c: Don't hardcode the location of the AlphaAccess structure, but rely on m5 to pass in the correct value. Setup "volatile struct AlphaAccess *m5AlphaAccess" for use and get rid of the hardcoded usage. --- system/alpha/console/console.c | 71 +++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 42 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 1cd5f1a6c..657242dad 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -73,14 +73,6 @@ #define K1BASE 0xfffffc8000000000 #define KSEG_TO_PHYS(x) (((ulong)x) & ~KSEG) -#ifdef TSUNAMI -#define ALPHA_ACCESS_BASE 0xfffffd0200000000 -#elif TLASER -#define ALPHA_ACCESS_BASE 0xfffffc8000a00000 -#else -#error TSUNAMI/TLASER not defined. -#endif - #define ROUNDUP8(x) ((ulong)(((ulong)x)+7) & ~7) #define ROUNDUP128(x) ((ulong)(((ulong)x) + 127) & ~127) #define ROUNDUP8K(x) ((ulong)(((ulong)(x)) + 8191) & ~8191) @@ -113,6 +105,7 @@ void JToKern(char *bootadr, ulong rpb_percpu, ulong free_pfn, ulong k_argc, void JToPal(ulong bootadr); void SlaveLoop(int cpu); +volatile struct AlphaAccess *m5AlphaAccess; struct AlphaAccess m5Conf; ulong theLock; @@ -146,15 +139,13 @@ InitConsole() char GetChar() { - struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); - return k1Conf->inputChar; + return m5AlphaAccess->inputChar; } void PutChar(char c) { - struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); - k1Conf->outputChar = c; + m5AlphaAccess->outputChar = c; } int @@ -167,36 +158,35 @@ int main(int argc, char **argv) { int x, i; - struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); uint *k1ptr, *ksegptr; InitConsole(); - printf_lock("M5 console\n"); + printf_lock("M5 console: m5AlphaAccess @ 0x%x\n", m5AlphaAccess); /* * get configuration from backdoor */ - m5Conf.last_offset = k1Conf->last_offset; + m5Conf.last_offset = m5AlphaAccess->last_offset; printf_lock("Got Configuration %d\n", m5Conf.last_offset); - m5Conf.last_offset = k1Conf->last_offset; - m5Conf.version = k1Conf->version; - m5Conf.numCPUs = k1Conf->numCPUs; - m5Conf.intrClockFrequency = k1Conf->intrClockFrequency; - m5Conf.cpuClock = k1Conf->cpuClock; - m5Conf.mem_size = k1Conf->mem_size; - m5Conf.kernStart = k1Conf->kernStart; - m5Conf.kernEnd = k1Conf->kernEnd; - m5Conf.entryPoint = k1Conf->entryPoint; - m5Conf.diskUnit = k1Conf->diskUnit; - m5Conf.diskCount = k1Conf->diskCount; - m5Conf.diskPAddr = k1Conf->diskPAddr; - m5Conf.diskBlock = k1Conf->diskBlock; - m5Conf.diskOperation = k1Conf->diskOperation; - m5Conf.outputChar = k1Conf->outputChar; - m5Conf.inputChar = k1Conf->inputChar; - m5Conf.bootStrapImpure = k1Conf->bootStrapImpure; - m5Conf.bootStrapCPU = k1Conf->bootStrapCPU; + m5Conf.last_offset = m5AlphaAccess->last_offset; + m5Conf.version = m5AlphaAccess->version; + m5Conf.numCPUs = m5AlphaAccess->numCPUs; + m5Conf.intrClockFrequency = m5AlphaAccess->intrClockFrequency; + m5Conf.cpuClock = m5AlphaAccess->cpuClock; + m5Conf.mem_size = m5AlphaAccess->mem_size; + m5Conf.kernStart = m5AlphaAccess->kernStart; + m5Conf.kernEnd = m5AlphaAccess->kernEnd; + m5Conf.entryPoint = m5AlphaAccess->entryPoint; + m5Conf.diskUnit = m5AlphaAccess->diskUnit; + m5Conf.diskCount = m5AlphaAccess->diskCount; + m5Conf.diskPAddr = m5AlphaAccess->diskPAddr; + m5Conf.diskBlock = m5AlphaAccess->diskBlock; + m5Conf.diskOperation = m5AlphaAccess->diskOperation; + m5Conf.outputChar = m5AlphaAccess->outputChar; + m5Conf.inputChar = m5AlphaAccess->inputChar; + m5Conf.bootStrapImpure = m5AlphaAccess->bootStrapImpure; + m5Conf.bootStrapCPU = m5AlphaAccess->bootStrapCPU; if (m5Conf.version != ALPHA_ACCESS_VERSION) { panic("Console version mismatch. Console expects %d. has %d \n", @@ -776,12 +766,10 @@ unixBoot(int go, int argc, char **argv) * MP bootstrap */ for (i = 1; i < m5Conf.numCPUs; i++) { - volatile struct AlphaAccess *k1Conf; - k1Conf = (volatile struct AlphaAccess *)(ALPHA_ACCESS_BASE); printf_lock("Bootstraping CPU %d with sp=0x%x\n", i, bootStrapImpure[i]); - k1Conf->bootStrapImpure = bootStrapImpure[i]; - k1Conf->bootStrapCPU = i; + m5AlphaAccess->bootStrapImpure = bootStrapImpure[i]; + m5AlphaAccess->bootStrapCPU = i; } /* @@ -866,7 +854,6 @@ struct { void DeviceOperation(long op, long channel, long count, long address, long block) { - struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE); long pAddr; if (strcmp(deviceState[channel].name, BOOTDEVICE_NAME )) { @@ -877,10 +864,10 @@ DeviceOperation(long op, long channel, long count, long address, long block) panic("DeviceRead: request out of range \n"); } - k1Conf->diskCount = count; - k1Conf->diskPAddr = pAddr; - k1Conf->diskBlock = block; - k1Conf->diskOperation = op; /* launch */ + m5AlphaAccess->diskCount = count; + m5AlphaAccess->diskPAddr = pAddr; + m5AlphaAccess->diskBlock = block; + m5AlphaAccess->diskOperation = op; /* launch */ } /* -- cgit v1.2.3 From fce2978d4182b2c2434c1742c1de613b7747deed Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 28 Jun 2005 23:22:28 -0400 Subject: console code cleanup console/console.c: the go parameter to unixBoot is never used, so get rid of it. just panic if we return from unixBoot since it's never supposed to happen. remove the MAX_CPUS parameter and the bootStrapImpure variable and just allocate memory as needed. (Can in theory support many more CPUs.) --- system/alpha/console/console.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 657242dad..508cd1fc1 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -99,7 +99,7 @@ } while (0) -void unixBoot(int go, int argc, char **argv); +void unixBoot(int argc, char **argv); void JToKern(char *bootadr, ulong rpb_percpu, ulong free_pfn, ulong k_argc, char **k_argv, char **envp); void JToPal(ulong bootadr); @@ -196,12 +196,10 @@ main(int argc, char **argv) /* * setup arguments to kernel */ - unixBoot(1, argc, argv); + unixBoot(argc, argv); - x = *(volatile int *)(K1BASE-4); - while (1) - continue; - return x; + panic("unix failed to boot\n"); + return 1; } /* @@ -381,14 +379,10 @@ int kargc; ulong free_pfn; struct rpb_percpu *rpb_percpu; -#define MAX_CPUS 32 - -ulong bootStrapImpure[MAX_CPUS]; - char * unix_boot_alloc(int pages) { - char *ret = (char *) unix_boot_mem; + char *ret = (char *)unix_boot_mem; unix_boot_mem += (pages * PAGE_SIZE); return ret; } @@ -403,7 +397,7 @@ struct rpb *rpb; extern ulong _end; void -unixBoot(int go, int argc, char **argv) +unixBoot(int argc, char **argv) { ulong *second, *third_kernel, ptr, *tbb, size, *percpu_logout; unsigned char *mdt_bitmap; @@ -447,9 +441,9 @@ unixBoot(int go, int argc, char **argv) printf_lock("First free page after ROM 0x%x\n", unix_boot_mem); - rpb = (struct rpb *) unix_boot_alloc( HWRPB_PAGES); + rpb = (struct rpb *)unix_boot_alloc(HWRPB_PAGES); - mdt_bitmap = (unsigned char *) unix_boot_alloc(MDT_BITMAP_PAGES); + mdt_bitmap = (unsigned char *)unix_boot_alloc(MDT_BITMAP_PAGES); first = (ulong *)unix_boot_alloc(1); second = (ulong *)unix_boot_alloc(1); third_rpb = (ulong *)unix_boot_alloc(1); @@ -624,10 +618,6 @@ unixBoot(int go, int argc, char **argv) printf_lock("KSP: 0x%x PTBR 0x%x\n", thisCPU->rpb_pcb.rpb_ksp, thisCPU->rpb_pcb.rpb_ptbr); - - if (i) { - bootStrapImpure[i] = (ulong)unix_boot_alloc(1); - } } nextPtr = (ulong)rpb_percpu + percpu_size * m5Conf.numCPUs; @@ -766,9 +756,9 @@ unixBoot(int go, int argc, char **argv) * MP bootstrap */ for (i = 1; i < m5Conf.numCPUs; i++) { - printf_lock("Bootstraping CPU %d with sp=0x%x\n", - i, bootStrapImpure[i]); - m5AlphaAccess->bootStrapImpure = bootStrapImpure[i]; + ulong stack = (ulong)unix_boot_alloc(1); + printf_lock("Bootstraping CPU %d with sp=0x%x\n", i, stack); + m5AlphaAccess->bootStrapImpure = stack; m5AlphaAccess->bootStrapCPU = i; } @@ -781,9 +771,7 @@ unixBoot(int go, int argc, char **argv) printf_lock("unix_boot_mem ends at %x \n", unix_boot_mem); } - if (go) - JToKern((char *)bootadr, (ulong)rpb_percpu, free_pfn, kargc, kargv, - NULL); + JToKern((char *)bootadr, (ulong)rpb_percpu, free_pfn, kargc, kargv, NULL); } -- cgit v1.2.3 From 5da70b93db7cb550be6c10797cd502ce4af35226 Mon Sep 17 00:00:00 2001 From: Benjamin Nash Date: Tue, 26 Jul 2005 12:42:02 -0400 Subject: New console terminal block structure, fix kernel stack pointer. console/console.c: Use virtual addresses for kernel stack pointer, use new ctb structure. h/rpb.h: Update console terminal block structure. --- system/alpha/console/console.c | 58 ++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 31 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 508cd1fc1..c616c1cdb 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -470,6 +470,7 @@ unixBoot(int argc, char **argv) /* Region 1 */ second[SECOND(0x20000000) + i] = KPTE(PFN(third_kernel) + i); } + /* Region 2 */ second[SECOND(0x40000000)] = KPTE(PFN(second)); @@ -489,8 +490,9 @@ unixBoot(int argc, char **argv) #define DATABASE_END 0x20020000 ulong *dbPage = (ulong*)unix_boot_alloc(1); + bzero(dbPage, PAGE_SIZE); second[SECOND(DATABASE_BASE)] = KPTE(PFN(dbPage)); - for (i = DATABASE_BASE; i < DATABASE_END ; i += 8096) { + for (i = DATABASE_BASE; i < DATABASE_END ; i += PAGE_SIZE) { ulong *db = (ulong*)unix_boot_alloc(1); dbPage[THIRD(i)] = KPTE(PFN(db)); } @@ -523,30 +525,27 @@ unixBoot(int argc, char **argv) kernel_end - m5Conf.kernStart ); panic("kernel too big\n"); } - + printf_lock("kstart = 0x%x, kend = 0x%x, kentry = 0x%x, numCPUs = 0x%x\n", m5Conf.kernStart, m5Conf.kernEnd, m5Conf.entryPoint, m5Conf.numCPUs); /* Map the kernel's pages into the third level of region 2 */ - for (ptr = m5Conf.kernStart; ptr < kernel_end; ptr += PAGE_SIZE) { - third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); - } - - /* blow 2 pages of phys mem for guards since it maintains 1-to-1 mapping */ - ksp = ksp_top + (3 * PAGE_SIZE); - if (ksp - m5Conf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { - printf_lock("Kernel stack pushd us over 8MB\n"); - panic("ksp too big\n"); - } - if (THIRD_XXX((ulong)ksp_top) > NUM_KERNEL_THIRD * 1024) { - panic("increase NUM_KERNEL_THIRD, and change THIRD_XXX\n"); - } + //for (ptr = m5Conf.kernStart; ptr < kernel_end; ptr += PAGE_SIZE) { + // third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); + //} + + ksp_top = (ulong)unix_boot_alloc(1); + ksp = ksp_top + PAGE_SIZE; + + //if (ksp - m5Conf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { + // printf_lock("Kernel stack pushd us over 8MB\n"); + // panic("ksp too big\n"); + //} + //if (THIRD_XXX((ulong)ksp_top) > NUM_KERNEL_THIRD * 1024) { + // panic("increase NUM_KERNEL_THIRD, and change THIRD_XXX\n"); + //} ptr = (ulong) ksp_top; bzero((char *)ptr, PAGE_SIZE * 2); - third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ - ptr += PAGE_SIZE; - third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); /* Kernel Stack Pages */ - ptr += PAGE_SIZE; - third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); - ptr += PAGE_SIZE; - third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ + dbPage[THIRD(0x20040000)] = 0; /* Stack Guard Page */ + dbPage[THIRD(0x20042000)] = KPTE(PFN(ptr)); /* Kernel Stack Pages */ + dbPage[THIRD(0x20046000)] = 0; /* Stack Guard Page */ /* put argv into the bottom of the stack - argv starts at 1 because * the command thatr got us here (i.e. "unixboot) is in argv[0]. @@ -563,7 +562,7 @@ unixBoot(int argc, char **argv) kargv[kargc] = NULL; /* just to be sure; doesn't seem to be used */ ksp -= sizeof(char *); /* point above last arg for no real reason */ - free_pfn = PFN(ptr); + free_pfn = PFN(kernel_end); bcopy((char *)&m5_rpb, (char *)rpb, sizeof(struct rpb)); @@ -610,7 +609,7 @@ unixBoot(int argc, char **argv) bcopy((char *)&m5_rpb_percpu, (char *)thisCPU, sizeof(struct rpb_percpu)); - thisCPU->rpb_pcb.rpb_ksp = ksp; + thisCPU->rpb_pcb.rpb_ksp = (0x20044000 - 0x18); thisCPU->rpb_pcb.rpb_ptbr = PFN(first); thisCPU->rpb_logout = KSEG_TO_PHYS(percpu_logout); @@ -633,18 +632,15 @@ unixBoot(int argc, char **argv) bzero((char *)rpb_ctb, sizeof(struct ctb_tt)); - rpb_ctb->rpb_type = CONS_DZ; + rpb_ctb->rpb_type = CONS_REM; rpb_ctb->rpb_length = sizeof(ctb_tt) - sizeof(rpb_ctb); /* * uart initizliation */ - ctb_tt->ctb_csr = 0; - ctb_tt->ctb_tivec = 0x6c0; /* matches tlaser pal code */ - ctb_tt->ctb_rivec = 0x680; /* matches tlaser pal code */ - ctb_tt->ctb_baud = 9600; - ctb_tt->ctb_put_sts = 0; - ctb_tt->ctb_get_sts = 0; + ctb_tt->ctb_tintr_vec = 0x6c0; /* matches tlaser pal code */ + ctb_tt->ctb_rintr_vec = 0x680; /* matches tlaser pal code */ + ctb_tt->ctb_term_type = CTB_GRAPHICS; rpb_crb = (struct rpb_crb *) (((ulong)rpb_ctb) + sizeof(struct ctb_tt)); rpb->rpb_crb_off = ((ulong)rpb_crb) - (ulong)rpb; -- cgit v1.2.3 From fa1512e206b4872e7b37175037c5bc11892daafc Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Thu, 28 Jul 2005 12:26:05 -0400 Subject: changes console/console.c: fixed bootstrap stack h/rpb.h: ctb_term_type instead of ctb_baud --- system/alpha/console/console.c | 46 +++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 508cd1fc1..af4e367b2 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -69,6 +69,8 @@ #define PAGE_SIZE (8192) +#define KSTACK_REGION_VA 0x20040000 + #define KSEG 0xfffffc0000000000 #define K1BASE 0xfffffc8000000000 #define KSEG_TO_PHYS(x) (((ulong)x) & ~KSEG) @@ -470,6 +472,7 @@ unixBoot(int argc, char **argv) /* Region 1 */ second[SECOND(0x20000000) + i] = KPTE(PFN(third_kernel) + i); } + /* Region 2 */ second[SECOND(0x40000000)] = KPTE(PFN(second)); @@ -489,8 +492,9 @@ unixBoot(int argc, char **argv) #define DATABASE_END 0x20020000 ulong *dbPage = (ulong*)unix_boot_alloc(1); + bzero(dbPage, PAGE_SIZE); second[SECOND(DATABASE_BASE)] = KPTE(PFN(dbPage)); - for (i = DATABASE_BASE; i < DATABASE_END ; i += 8096) { + for (i = DATABASE_BASE; i < DATABASE_END ; i += PAGE_SIZE) { ulong *db = (ulong*)unix_boot_alloc(1); dbPage[THIRD(i)] = KPTE(PFN(db)); } @@ -511,7 +515,7 @@ unixBoot(int argc, char **argv) /* Set up third_kernel after it's loaded, when we know where it is */ kern_first_page = (KSEG_TO_PHYS(m5Conf.kernStart)/PAGE_SIZE); - kernel_end = ksp_top = ROUNDUP8K(m5Conf.kernEnd); + kernel_end = ROUNDUP8K(m5Conf.kernEnd); bootadr = m5Conf.entryPoint; printf_lock("HWRPB 0x%x l1pt 0x%x l2pt 0x%x l3pt_rpb 0x%x l3pt_kernel 0x%x" @@ -523,35 +527,21 @@ unixBoot(int argc, char **argv) kernel_end - m5Conf.kernStart ); panic("kernel too big\n"); } + printf_lock("kstart = 0x%x, kend = 0x%x, kentry = 0x%x, numCPUs = 0x%x\n", m5Conf.kernStart, m5Conf.kernEnd, m5Conf.entryPoint, m5Conf.numCPUs); - /* Map the kernel's pages into the third level of region 2 */ - for (ptr = m5Conf.kernStart; ptr < kernel_end; ptr += PAGE_SIZE) { - third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); - } + ksp_bottom = (ulong)unix_boot_alloc(1); + ksp_top = ksp_bottom + PAGE_SIZE; - /* blow 2 pages of phys mem for guards since it maintains 1-to-1 mapping */ - ksp = ksp_top + (3 * PAGE_SIZE); - if (ksp - m5Conf.kernStart > (0x800000*NUM_KERNEL_THIRD)) { - printf_lock("Kernel stack pushd us over 8MB\n"); - panic("ksp too big\n"); - } - if (THIRD_XXX((ulong)ksp_top) > NUM_KERNEL_THIRD * 1024) { - panic("increase NUM_KERNEL_THIRD, and change THIRD_XXX\n"); - } - ptr = (ulong) ksp_top; - bzero((char *)ptr, PAGE_SIZE * 2); - third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ - ptr += PAGE_SIZE; - third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); /* Kernel Stack Pages */ - ptr += PAGE_SIZE; - third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); - ptr += PAGE_SIZE; - third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */ + ptr = (ulong) ksp_bottom; + bzero((char *)ptr, PAGE_SIZE); + dbPage[THIRD(KSTACK_REGION_VA)] = 0; /* Stack Guard Page */ + dbPage[THIRD(KSTACK_REGION_VA + PAGE_SIZE)] = KPTE(PFN(ptr)); /* Kernel Stack Page */ + dbPage[THIRD(KSTACK_REGION_VA + 2*PAGE_SIZE)] = 0; /* Stack Guard Page */ /* put argv into the bottom of the stack - argv starts at 1 because * the command thatr got us here (i.e. "unixboot) is in argv[0]. */ - ksp -= 8; /* Back up one longword */ + ksp = ksp_top - 8; /* Back up one longword */ ksp -= argc * sizeof(char *); /* Make room for argv */ kargv = (char **) ksp; for (i = 1; i < argc; i++) { /* Copy arguments to stack */ @@ -563,7 +553,7 @@ unixBoot(int argc, char **argv) kargv[kargc] = NULL; /* just to be sure; doesn't seem to be used */ ksp -= sizeof(char *); /* point above last arg for no real reason */ - free_pfn = PFN(ptr); + free_pfn = PFN(kernel_end); bcopy((char *)&m5_rpb, (char *)rpb, sizeof(struct rpb)); @@ -610,7 +600,7 @@ unixBoot(int argc, char **argv) bcopy((char *)&m5_rpb_percpu, (char *)thisCPU, sizeof(struct rpb_percpu)); - thisCPU->rpb_pcb.rpb_ksp = ksp; + thisCPU->rpb_pcb.rpb_ksp = (KSTACK_REGION_VA + 2*PAGE_SIZE - (ksp_top - ksp)); thisCPU->rpb_pcb.rpb_ptbr = PFN(first); thisCPU->rpb_logout = KSEG_TO_PHYS(percpu_logout); @@ -642,7 +632,7 @@ unixBoot(int argc, char **argv) ctb_tt->ctb_csr = 0; ctb_tt->ctb_tivec = 0x6c0; /* matches tlaser pal code */ ctb_tt->ctb_rivec = 0x680; /* matches tlaser pal code */ - ctb_tt->ctb_baud = 9600; + ctb_tt->ctb_term_type = 2; ctb_tt->ctb_put_sts = 0; ctb_tt->ctb_get_sts = 0; -- cgit v1.2.3 From c3d47c1de8db97e1bf6d4a075d9bcc42af010e34 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 18 Aug 2005 13:34:03 -0400 Subject: Fix console to work on all systems. console/console.c: CONS_REM (remote console) doesn't work on Tru64. Use CONS_DZ which seems to work alright everywhere. --- system/alpha/console/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 6d0020370..e5be19f5f 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -621,7 +621,7 @@ unixBoot(int argc, char **argv) bzero((char *)rpb_ctb, sizeof(struct ctb_tt)); - rpb_ctb->rpb_type = CONS_REM; + rpb_ctb->rpb_type = CONS_DZ; rpb_ctb->rpb_length = sizeof(ctb_tt) - sizeof(rpb_ctb); /* -- cgit v1.2.3 From a50e054ceded6fa3f700385ed93dcc76c05cb13b Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Thu, 23 Feb 2006 15:00:04 -0500 Subject: change from bootStrap* to using the cpuStack array for setting up other processor stacks --- system/alpha/console/console.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index e5be19f5f..1bf6a3ce2 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -187,8 +187,6 @@ main(int argc, char **argv) m5Conf.diskOperation = m5AlphaAccess->diskOperation; m5Conf.outputChar = m5AlphaAccess->outputChar; m5Conf.inputChar = m5AlphaAccess->inputChar; - m5Conf.bootStrapImpure = m5AlphaAccess->bootStrapImpure; - m5Conf.bootStrapCPU = m5AlphaAccess->bootStrapCPU; if (m5Conf.version != ALPHA_ACCESS_VERSION) { panic("Console version mismatch. Console expects %d. has %d \n", @@ -743,8 +741,7 @@ unixBoot(int argc, char **argv) for (i = 1; i < m5Conf.numCPUs; i++) { ulong stack = (ulong)unix_boot_alloc(1); printf_lock("Bootstraping CPU %d with sp=0x%x\n", i, stack); - m5AlphaAccess->bootStrapImpure = stack; - m5AlphaAccess->bootStrapCPU = i; + m5AlphaAccess->cpuStack[i] = stack; } /* -- cgit v1.2.3 From 4d1f6a8aca88b08b258ffaf17e192d19f860877e Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Wed, 16 Aug 2006 15:26:52 -0400 Subject: update our copyrights to the new format --- system/alpha/console/console.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index 1bf6a3ce2..e8bc647f3 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -3,10 +3,7 @@ * The Regents of The University of Michigan * All Rights Reserved * - * This code is part of the M5 simulator, developed by Nathan Binkert, - * Erik Hallnor, Steve Raasch, and Steve Reinhardt, with contributions - * from Ron Dreslinski, Dave Greene, Lisa Hsu, Ali Saidi, and Andrew - * Schultz. + * This code is part of the M5 simulator. * * Permission is granted to use, copy, create derivative works and * redistribute this software and such derivative works for any purpose, @@ -26,6 +23,9 @@ * DAMAGES, WITH RESPECT TO ANY CLAIM ARISING OUT OF OR IN CONNECTION * WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS BEEN OR IS HEREAFTER * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * Modified for M5 by: Ali G. Saidi + * Nathan L. Binkert */ /* -- cgit v1.2.3 From 10253f80d11818520f2c4d9dbf57f5703c7b52df Mon Sep 17 00:00:00 2001 From: Geoffrey Blake Date: Fri, 19 Oct 2007 16:44:02 -0400 Subject: Fix bug in MDT BITMAP to allow more than 2GB of memory. Signed-off by Ali Saidi --- system/alpha/console/console.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index e8bc647f3..c8f181985 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -60,7 +60,7 @@ #include #define CONSOLE -#include "alpha_access.h" +#include "access.h" #include "cserve.h" #include "rpb.h" @@ -89,7 +89,6 @@ #define KPTE(x) ((ulong)((((ulong)(x)) << 32) | 0x1101)) #define HWRPB_PAGES 16 -#define MDT_BITMAP_PAGES 4 #define NUM_KERNEL_THIRD (4) @@ -403,10 +402,12 @@ unixBoot(int argc, char **argv) unsigned char *mdt_bitmap; long *lp1, *lp2, sum; int i, cl; - int kern_first_page; - int mem_size = m5Conf.mem_size; + ulong kern_first_page; + ulong mem_size = m5Conf.mem_size; + + ulong mem_pages = mem_size / PAGE_SIZE, cons_pages; + ulong mdt_bitmap_pages = mem_pages / (PAGE_SIZE*8); - int mem_pages = mem_size / PAGE_SIZE, cons_pages; ulong kernel_bytes, ksp, kernel_end, *unix_kernel_stack, bss, ksp_bottom, ksp_top; struct rpb_ctb *rpb_ctb; @@ -443,7 +444,7 @@ unixBoot(int argc, char **argv) rpb = (struct rpb *)unix_boot_alloc(HWRPB_PAGES); - mdt_bitmap = (unsigned char *)unix_boot_alloc(MDT_BITMAP_PAGES); + mdt_bitmap = (unsigned char *)unix_boot_alloc(mdt_bitmap_pages); first = (ulong *)unix_boot_alloc(1); second = (ulong *)unix_boot_alloc(1); third_rpb = (ulong *)unix_boot_alloc(1); @@ -503,13 +504,13 @@ unixBoot(int argc, char **argv) third_rpb[i] = KPTE(PFN(rpb) + i); /* Map the MDT bitmap table */ - for (i = 0; i < MDT_BITMAP_PAGES; i++) { + for (i = 0; i < mdt_bitmap_pages; i++) { third_rpb[HWRPB_PAGES + i] = KPTE(PFN(mdt_bitmap) + i); } /* Protect the PAL pages */ for (i = 1; i < PFN(first); i++) - third_rpb[HWRPB_PAGES + MDT_BITMAP_PAGES + i] = KPTE(i); + third_rpb[HWRPB_PAGES + mdt_bitmap_pages + i] = KPTE(i); /* Set up third_kernel after it's loaded, when we know where it is */ kern_first_page = (KSEG_TO_PHYS(m5Conf.kernStart)/PAGE_SIZE); @@ -678,7 +679,7 @@ unixBoot(int argc, char **argv) rpb_mdt->rpb_checksum = sum; /* XXX should checksum the cluster descriptors */ - bzero((char *)mdt_bitmap, MDT_BITMAP_PAGES * PAGE_SIZE); + bzero((char *)mdt_bitmap, mdt_bitmap_pages * PAGE_SIZE); for (i = 0; i < mem_pages/8; i++) ((unsigned char *)mdt_bitmap)[i] = 0xff; -- cgit v1.2.3 From 99e7e5e7efc7b0cac3229e1b16fb41350cdccd6b Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 16 Feb 2011 00:34:01 -0600 Subject: copyright: update copyright on alpha system files --- system/alpha/console/console.c | 73 ++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 49 deletions(-) (limited to 'system/alpha/console/console.c') diff --git a/system/alpha/console/console.c b/system/alpha/console/console.c index c8f181985..f57ce054f 100644 --- a/system/alpha/console/console.c +++ b/system/alpha/console/console.c @@ -1,55 +1,30 @@ /* - * Copyright (c) 2003, 2004 - * The Regents of The University of Michigan - * All Rights Reserved + * Copyright (c) 2003-2004 The Regents of The University of Michigan + * Copyright (c) 1993 The Hewlett-Packard Development Company + * All rights reserved. * - * This code is part of the M5 simulator. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * 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; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. * - * Permission is granted to use, copy, create derivative works and - * redistribute this software and such derivative works for any purpose, - * so long as the copyright notice above, this grant of permission, and - * the disclaimer below appear in all copies made; and so long as the - * name of The University of Michigan is not used in any advertising or - * publicity pertaining to the use or distribution of this software - * without specific, written prior authorization. - * - * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE - * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND WITHOUT - * WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE REGENTS OF - * THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE FOR ANY DAMAGES, - * INCLUDING DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL - * DAMAGES, WITH RESPECT TO ANY CLAIM ARISING OUT OF OR IN CONNECTION - * WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS BEEN OR IS HEREAFTER - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * Modified for M5 by: Ali G. Saidi - * Nathan L. Binkert - */ - -/* - * Copyright 1993 Hewlett-Packard Development Company, L.P. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 COPYRIGHT + * OWNER OR CONTRIBUTORS 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. */ /* ****************************************** -- cgit v1.2.3