Пример #1
0
void
boot(dev_t dev)
{
    u_long marks[MARK_MAX];
    char path[128];

    pdc_init();
    cninit();
    devboot(dev, path);
    strncpy(path + strlen(path), ":/bsd.rd", 9);
    printf(">> OpenBSD/" MACHINE " CDBOOT 0.1\n"
           "booting %s: ", path);

    marks[MARK_START] = (u_long)DEFAULT_KERNEL_ADDRESS;
    if (!loadfile(path, marks, LOAD_KERNEL)) {
        marks[MARK_END] = ALIGN(marks[MARK_END] -
                                (u_long)DEFAULT_KERNEL_ADDRESS);
        fcacheall();

        __asm("mtctl %r0, %cr17");
        __asm("mtctl %r0, %cr17");
        (*(startfuncp)(marks[MARK_ENTRY]))((int)(long)pdc, 0, bootdev,
                                           marks[MARK_END], BOOTARG_APIVER, BOOTARG_LEN,
                                           (caddr_t)BOOTARG_OFF);
        /* not reached */
    }
}
Пример #2
0
void
machdep(void)
{
    pdc_init();
#ifdef notyet
    debug_init();
#endif
    cninit();

#ifdef PDCDEBUG
    if (debug) {
        int i;

        printf("SSTOR:\n");
        printf("pri_boot=");
        DEVPATH_PRINT(&sstor.ss_pri_boot);
        printf("alt_boot=");
        DEVPATH_PRINT(&sstor.ss_alt_boot);
        printf("console =");
        DEVPATH_PRINT(&sstor.ss_console);
        printf("keyboard=");
        DEVPATH_PRINT(&sstor.ss_keyboard);
        printf("mem=%d, fn=%s, osver=%d\nos={",
               sstor.ss_fast_size, sstor.ss_filenames,
               sstor.ss_os_version);
        for (i = 0; i < sizeof(sstor.ss_os); i++)
            printf ("%x%c", sstor.ss_os[i], (i%8)? ',' : '\n');

        printf("}\nPAGE0:\n");
        printf("ivec=%x, pf=%p[%u], toc=%p[%u], rndz=%p, clk/10ms=%u\n",
               PAGE0->ivec_special, PAGE0->ivec_mempf,
               PAGE0->ivec_mempflen, PAGE0->ivec_toc,
               PAGE0->ivec_toclen, PAGE0->ivec_rendz,
               PAGE0->mem_10msec);
        printf ("mem: cont=%u, phys=%u, pdc_spa=%u, resv=%u, free=%x\n"
                "cpu_hpa=%x, pdc=%p, imm_hpa=%p[%u,%u], soft=%u\n",
                PAGE0->memc_cont, PAGE0->memc_phsize, PAGE0->memc_adsize,
                PAGE0->memc_resv, PAGE0->mem_free, PAGE0->mem_hpa,
                PAGE0->mem_pdc, PAGE0->imm_hpa, PAGE0->imm_spa_size,
                PAGE0->imm_max_mem, PAGE0->imm_soft_boot);

        printf("console:  ");
        PZDEV_PRINT(&PAGE0->mem_cons);
        printf("boot:     ");
        PZDEV_PRINT(&PAGE0->mem_boot);
        printf("keyboard: ");
        PZDEV_PRINT(&PAGE0->mem_kbd);
    }
#endif
}
Пример #3
0
void
machdep()
{
	pdc_init();
#ifdef notyet
	debug_init();
#endif
	cninit();

#ifdef PDCDEBUG
	if (debug) {
		printf("SSTOR:\n");
		printf("pri_boot=");	DEVPATH_PRINT(&sstor.ss_pri_boot);
		printf("alt_boot=");	DEVPATH_PRINT(&sstor.ss_alt_boot);
		printf("console =");	DEVPATH_PRINT(&sstor.ss_console);
		printf("keyboard=");	DEVPATH_PRINT(&sstor.ss_keyboard);
		printf("mem=%d, fn=%s, osver=%d\n"
		       "os={%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,\n"
		           "%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x}\n",
		       sstor.ss_fast_size, sstor.ss_filenames,
		       sstor.ss_os_version,
		       sstor.ss_os[0], sstor.ss_os[1], sstor.ss_os[2],
		       sstor.ss_os[3], sstor.ss_os[4], sstor.ss_os[5],
		       sstor.ss_os[6], sstor.ss_os[7], sstor.ss_os[8],
		       sstor.ss_os[9], sstor.ss_os[10], sstor.ss_os[11],
		       sstor.ss_os[12], sstor.ss_os[13], sstor.ss_os[14],
		       sstor.ss_os[15], sstor.ss_os[16], sstor.ss_os[17],
		       sstor.ss_os[18], sstor.ss_os[19], sstor.ss_os[20],
		       sstor.ss_os[21]);

		printf("PAGE0:\n");
		printf("ivec=%x, pf=%p[%u], toc=%p[%u], rendz=%p\n"
		       "mem: cont=%u, phys=%u, pdc_spa=%u, resv=%u, free=%x\n"
		       "cpu_hpa=%p, pdc=%p, imm_hpa=%p[%u,%u]\n"
		       "soft=%u, tic/10ms=%u\n",
		       PAGE0->ivec_special, PAGE0->ivec_mempf,
		       PAGE0->ivec_mempflen, PAGE0->ivec_toc,
		       PAGE0->ivec_toclen, PAGE0->ivec_rendz,
		       PAGE0->memc_cont, PAGE0->memc_phsize, PAGE0->memc_adsize,
		       PAGE0->memc_resv, PAGE0->mem_free, PAGE0->mem_hpa,
		       PAGE0->mem_pdc, PAGE0->imm_hpa, PAGE0->imm_spa_size,
		       PAGE0->imm_max_mem, PAGE0->imm_soft_boot,
		       PAGE0->mem_10msec);
		printf("console:  ");	PZDEV_PRINT(&PAGE0->mem_cons);
		printf("boot:     ");	PZDEV_PRINT(&PAGE0->mem_boot);
		printf("keyboard: ");	PZDEV_PRINT(&PAGE0->mem_kbd);
	}
#endif
}
Пример #4
0
void
hppa_init()
{
	extern int kernel_text, end;
	struct pdc_hwtlb pdc_hwtlb PDC_ALIGNMENT;
	struct pdc_coproc pdc_coproc PDC_ALIGNMENT;
	vm_offset_t v, vstart, vend;
	register int pdcerr;
	int usehpt;

	/* init PDC iface, so we can call em easy */
	pdc_init();

	/* calculate cpu speed */
	cpu_hzticks = (PAGE0->mem_10msec * 100) / hz;
	delay_init();

	/*
	 * get cache parameters from the PDC
	 */
	if ((pdcerr = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_DFLT,
			       &pdc_cache)) < 0) {
#ifdef DIAGNOSTIC
                printf("Warning: PDC_CACHE call Ret'd %d\n", pdcerr);
#endif
	}

	dcache_line_mask = pdc_cache.dc_conf.cc_line * 16 - 1;
	dcache_size = pdc_cache.dc_size;
	dcache_stride = pdc_cache.dc_stride;
	icache_stride = pdc_cache.ic_stride;

	/*
	 * purge TLBs and flush caches
	 */
	if (pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, PDC_BTLB_PURGE_ALL) < 0)
		printf("WARNING: BTLB purge failed\n");
	ptlball();
	fcacheall();

	/* calculate HPT size */
	hpt_hashsize = PAGE0->imm_max_mem / NBPG;
	mtctl(hpt_hashsize - 1, CR_HPTMASK);

	/*
	 * If we want to use the HW TLB support, ensure that it exists.
	 */
	if (pdc_call((iodcio_t)pdc, 0, PDC_TLB, PDC_TLB_INFO, &pdc_hwtlb) &&
	    !pdc_hwtlb.min_size && !pdc_hwtlb.max_size) {
		printf("WARNING: no HW tlb walker\n");
		usehpt = 0;
	} else {
		usehpt = 1;
#ifdef DEBUG
		printf("hwtlb: %u-%u, %u/",
		       pdc_hwtlb.min_size, pdc_hwtlb.max_size, hpt_hashsize);
#endif
		if (hpt_hashsize > pdc_hwtlb.max_size)
			hpt_hashsize = pdc_hwtlb.max_size;
		else if (hpt_hashsize < pdc_hwtlb.min_size)
			hpt_hashsize = pdc_hwtlb.min_size;
#ifdef DEBUG
		printf("%u (0x%x)\n", hpt_hashsize,
		       hpt_hashsize * sizeof(struct hpt_entry));
#endif
	}
	
	totalphysmem = PAGE0->imm_max_mem / NBPG;
	resvmem = ((vm_offset_t)&kernel_text) / NBPG;

	vstart = hppa_round_page(&end);
	vend = VM_MAX_KERNEL_ADDRESS;

	/* we hope this won't fail */
	hppa_ex = extent_create("mem", 0x0, 0xffffffff, M_DEVBUF,
				(caddr_t)mem_ex_storage,
				sizeof(mem_ex_storage),
				EX_NOCOALESCE|EX_NOWAIT);
	if (extent_alloc_region(hppa_ex, 0, (vm_offset_t)PAGE0->imm_max_mem,
				EX_NOWAIT))
		panic("cannot reserve main memory");

	/*
	 * Allocate space for system data structures.  We are given
	 * a starting virtual address and we return a final virtual
	 * address; along the way we set each data structure pointer.
	 *
	 * We call allocsys() with 0 to find out how much space we want,
	 * allocate that much and fill it with zeroes, and the call
	 * allocsys() again with the correct base virtual address.
	 */

	v = vstart;
#define	valloc(name, type, num)	\
	    (name) = (type *)v; v = (vm_offset_t)((name)+(num))

#ifdef REAL_CLISTS
	valloc(cfree, struct cblock, nclist);
#endif
	valloc(callout, struct callout, ncallout);
	nswapmap = maxproc * 2;
	valloc(swapmap, struct map, nswapmap);
#ifdef SYSVSHM
	valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
#endif
#ifdef SYSVSEM 
	valloc(sema, struct semid_ds, seminfo.semmni);
	valloc(sem, struct sem, seminfo.semmns); 
	/* This is pretty disgusting! */
	valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
#endif
#ifdef SYSVMSG
	valloc(msgpool, char, msginfo.msgmax);
	valloc(msgmaps, struct msgmap, msginfo.msgseg);
	valloc(msghdrs, struct msg, msginfo.msgtql);
	valloc(msqids, struct msqid_ds, msginfo.msgmni);
#endif

#ifndef BUFCACHEPERCENT
#define BUFCACHEPERCENT 10
#endif /* BUFCACHEPERCENT */

	if (bufpages == 0)
		bufpages = totalphysmem / BUFCACHEPERCENT / CLSIZE;
	if (nbuf == 0) {
		nbuf = bufpages;
		if (nbuf < 16)
			nbuf = 16;
	}

	/* Restrict to at most 70% filled kvm */
	if (nbuf * MAXBSIZE >
	    (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) * 7 / 10)
		nbuf = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) /
		    MAXBSIZE * 7 / 10;

	/* More buffer pages than fits into the buffers is senseless.  */
	if (bufpages > nbuf * MAXBSIZE / CLBYTES)
		bufpages = nbuf * MAXBSIZE / CLBYTES;

	if (nswbuf == 0) {
		nswbuf = (nbuf / 2) & ~1;	/* force even */
		if (nswbuf > 256)
			nswbuf = 256;		/* sanity */
	}

	valloc(swbuf, struct buf, nswbuf);
	valloc(buf, struct buf, nbuf);
#undef valloc
	bzero ((void *)vstart, (v - vstart));
	vstart = v;

	pmap_bootstrap(&vstart, &vend);
	physmem = totalphysmem - btoc(vstart);

	/* alloc msgbuf */
	if (!(msgbufp = (void *)pmap_steal_memory(sizeof(struct msgbuf),
						  NULL, NULL)))
		panic("cannot allocate msgbuf");
	msgbufmapped = 1;

#ifdef DEBUG
	printf("mem: %x+%x, %x\n", physmem, resvmem, totalphysmem);
#endif
	/* Turn on the HW TLB assist */
	if (usehpt) {
		if ((pdcerr = pdc_call((iodcio_t)pdc, 0, PDC_TLB,
				       PDC_TLB_CONFIG, &pdc_hwtlb, hpt_table,
				       sizeof(struct hpt_entry) * hpt_hashsize,
				       PDC_TLB_WORD3)) < 0) {
			printf("Warning: HW TLB init failed (%d), disabled\n",
			       pdcerr);
			usehpt = 0;
		} else
			printf("HW TLB(%d entries at 0x%x) initialized (%d)\n",
			       hpt_hashsize, hpt_table, pdcerr);
	}

        /*
         * Locate any coprocessors and enable them by setting up the CCR.
         * SFU's are ignored (since we dont have any).  Also, initialize
         * the floating point registers here.
         */
        if ((pdcerr = pdc_call((iodcio_t)pdc, 0, PDC_COPROC, PDC_COPROC_DFLT,
			       &pdc_coproc)) < 0)
                printf("WARNING: PDC_COPROC call Ret'd %d\n", pdcerr);
	else {
#ifdef DEBUG
		printf("pdc_coproc: %x, %x\n", pdc_coproc.ccr_enable,
		       pdc_coproc.ccr_present);
#endif
	}
        copr_sfu_config = pdc_coproc.ccr_enable;
        mtctl(copr_sfu_config & CCR_MASK, CR_CCR);
/*
        fprinit(&fpcopr_version);
	fpcopr_version = (fpcopr_version & 0x003ff800) >> 11;
        mtctl(CR_CCR, 0);
*/
        /*
         * Clear the FAULT light (so we know when we get a real one)
         * PDC_COPROC apparently turns it on (for whatever reason).
         */
        pdcerr = PDC_OSTAT(PDC_OSTAT_RUN) | 0xCEC0;
        (void) (*pdc)(PDC_CHASSIS, PDC_CHASSIS_DISP, pdcerr);

#ifdef DDB
	ddb_init();
#endif
#ifdef DEBUG
	printf("hppa_init: leaving\n");
#endif
	kernelmapped++;
}