Example #1
0
void
mach_init(void)
{
	void *kernend;
	uint32_t memsize;

	extern char edata[], end[];	/* XXX */

	/* clear the BSS segment */
	kernend = (void *)mips_round_page(end);

	memset(edata, 0, (char *)kernend - edata);

	/* setup early console */
	atheros_set_platformsw();

	/* set CPU model info for sysctl_hw */
	snprintf(cpu_model, 64, "Atheros %s", atheros_get_cpuname());

	/*
	 * Set up the exception vectors and CPU-specific function
	 * vectors early on.  We need the wbflush() vector set up
	 * before comcnattach() is called (or at least before the
	 * first printf() after that is called).
	 * Sets up mips_cpu_flags that may be queried by other
	 * functions called during startup.
	 * Also clears the I+D caches.
	 */
	mips_vector_init(NULL, false);

	/*
	 * Calibrate timers.
	 */
	cal_timer();

	/*
	 * Set the VM page size.
	 */
	uvm_setpagesize();

	/*
	 * Look at arguments passed to us and compute boothowto.
	 */
	boothowto = RB_AUTOBOOT;
#ifdef KADB
	boothowto |= RB_KDB;
#endif

	/*
	 * This would be a good place to parse a boot command line, if
	 * we got one from the bootloader.  Right now we have no way to
	 * get one from e.g. vxworks.
	 */

	/*
	 * Determine the memory size.
	 *
	 * Note: Reserve the first page!  That's where the trap
	 * vectors are located.
	 */
	memsize = atheros_get_memsize();

	printf("Memory size: 0x%08x\n", memsize);
	physmem = btoc(memsize);

	mem_clusters[mem_cluster_cnt].start = PAGE_SIZE;
	mem_clusters[mem_cluster_cnt].size =
	    memsize - mem_clusters[mem_cluster_cnt].start;
	mem_cluster_cnt++;

	/*
	 * Load the available pages into the VM system.
	 */
	mips_page_physload(MIPS_KSEG0_START, (vaddr_t)kernend,
	    mem_clusters, mem_cluster_cnt, NULL, 0);

	/*
	 * Initialize message buffer (at end of core).
	 */
	mips_init_msgbuf();

	/*
	 * Initialize the virtual memory system.
	 */
	pmap_bootstrap();

	/*
	 * Allocate uarea page for lwp0 and set it.
	 */
	mips_init_lwp0_uarea();

	/*
	 * Initialize busses.
	 */
	atheros_bus_init();

	/*
	 * Turn off (ignore) the hardware watchdog.  If we got this
	 * far, then we shouldn't need it anymore.
	 */
	atheros_wdog_reload(0);

	/*
	 * Turn off watchpoint that may have been enabled by the
	 * PROM.  VxWorks bootloader seems to leave one set.
	 */ 
	__asm volatile (
		"mtc0	$0, $%0\n\t"
		"nop\n\t"
		"nop\n\t" :: "n"(MIPS_COP_0_WATCH_LO));

	/*
	 * Initialize debuggers, and break into them, if appropriate.
	 */
#ifdef DDB
	if (boothowto & RB_KDB)
		Debugger();
#endif
}
Example #2
0
void
mach_init(void)
{
	vaddr_t kernend;
	psize_t memsize;

	extern char kernel_text[];
	extern char edata[], end[];	/* From Linker */

	/* clear the BSS segment */
	kernend = mips_round_page(end);

	memset(edata, 0, kernend - (vaddr_t)edata);

#ifdef RALINK_CONSOLE_EARLY
	/*
	 * set up early console
	 *  cannot printf until sometime (?) in mips_vector_init
	 *  meanwhile can use the ra_console_putc primitive if necessary
	 */
	ralink_console_early();
#endif

	/* set CPU model info for sysctl_hw */
	uint32_t tmp1, tmp2;
	char id1[5], id2[5];
	tmp1 = sysctl_read(RA_SYSCTL_ID0);
	memcpy(id1, &tmp1, sizeof(tmp1));
	tmp2 = sysctl_read(RA_SYSCTL_ID1);
	memcpy(id2, &tmp2, sizeof(tmp2));
	id2[4] = id1[4] = '\0';
	if (id2[2] == ' ') {
		id2[2] = '\0';
	} else if (id2[3] == ' ') {
		id2[3] = '\0';
	} else {
		id2[4] = '\0';
	}
	cpu_setmodel("%s%s", id1, id2);

	/*
	 * Set up the exception vectors and CPU-specific function
	 * vectors early on.  We need the wbflush() vector set up
	 * before comcnattach() is called (or at least before the
	 * first printf() after that is called).
	 * Sets up mips_cpu_flags that may be queried by other
	 * functions called during startup.
	 * Also clears the I+D caches.
	 */
	mips_vector_init(NULL, false);

	/*
	 * Calibrate timers.
	 */
	cal_timer();

	/*
	 * Set the VM page size.
	 */
	uvm_setpagesize();

	/*
	 * Look at arguments passed to us and compute boothowto.
	 */
	boothowto = RB_AUTOBOOT;
#ifdef KADB
	boothowto |= RB_KDB;
#endif

	/*
	 * Determine the memory size.
	 */
#if defined(MT7620)
	memsize = 128 << 20;
#else
	memsize = *(volatile uint32_t *)
	    MIPS_PHYS_TO_KSEG1(RA_SYSCTL_BASE + RA_SYSCTL_CFG0);
	memsize = __SHIFTOUT(memsize, SYSCTL_CFG0_DRAM_SIZE);
	if (__predict_false(memsize == 0)) {
		memsize = 2 << 20;
	} else {
		memsize = 4 << (20 + memsize);
	}
#endif

	physmem = btoc(memsize);

	mem_clusters[mem_cluster_cnt].start = 0;
	mem_clusters[mem_cluster_cnt].size = memsize;
	mem_cluster_cnt++;

	/*
	 * Load the memory into the VM system
	 */
	mips_page_physload((vaddr_t)kernel_text, kernend,
	    mem_clusters, mem_cluster_cnt,
	    NULL, 0);

	/*
	 * Initialize message buffer (at end of core).
	 */
	mips_init_msgbuf();

	/*
	 * Initialize the virtual memory system.
	 */
	pmap_bootstrap();

	/*
	 * Init mapping for u page(s) for proc0.
	 */
	mips_init_lwp0_uarea();

	/*
	 * Initialize busses.
	 */
	ra_bus_init();

#ifdef DDB
	if (boothowto & RB_KDB)
		Debugger();
#endif
}
Example #3
0
void
mach_init(void)
{
	void *kernend;
	uint32_t memsize;
	extern char edata[], end[];	/* XXX */

	/* clear the BSS segment */
	kernend = (void *)mips_round_page(end);

	memset(edata, 0, (char *)kernend - edata);

	/* setup early console */
	ingenic_putchar_init();

	/* set CPU model info for sysctl_hw */
	cpu_setmodel("Ingenic XBurst");
	mips_vector_init(NULL, false);
	cal_timer();
	uvm_setpagesize();
	/*
	 * Look at arguments passed to us and compute boothowto.
	 */
	boothowto = RB_AUTOBOOT;
#ifdef KADB
	boothowto |= RB_KDB;
#endif

	/*
	 * Determine the memory size.
	 *
	 * Note: Reserve the first page!  That's where the trap
	 * vectors are located.
	 */
	memsize = 0x40000000;

	printf("Memory size: 0x%08x\n", memsize);
	physmem = btoc(memsize);

	/*
	 * memory is at 0x20000000 with first 256MB mirrored to 0x00000000 so
	 * we can see them through KSEG*
	 * assume 1GB for now, the SoC can theoretically support up to 3GB
	 */
	mem_clusters[0].start = PAGE_SIZE;
	mem_clusters[0].size = 0x10000000 - PAGE_SIZE;
	mem_clusters[1].start = 0x30000000;
	mem_clusters[1].size = 0x30000000;
	mem_cluster_cnt = 2;

	/*
	 * Load the available pages into the VM system.
	 */
	mips_page_physload(MIPS_KSEG0_START, (vaddr_t)kernend,
	    mem_clusters, mem_cluster_cnt, NULL, 0);

	/*
	 * Initialize message buffer (at end of core).
	 */
	mips_init_msgbuf();

	/*
	 * Initialize the virtual memory system.
	 */
	pmap_bootstrap();

	/*
	 * Allocate uarea page for lwp0 and set it.
	 */
	mips_init_lwp0_uarea();

#ifdef MULTIPROCESSOR
	mutex_init(&ingenic_ipi_lock, MUTEX_DEFAULT, IPL_HIGH);
	mips_locoresw.lsw_send_ipi = ingenic_send_ipi;
	mips_locoresw.lsw_cpu_init = ingenic_cpu_init;
#endif

	apbus_init();
	/*
	 * Initialize debuggers, and break into them, if appropriate.
	 */
#ifdef DDB
	if (boothowto & RB_KDB)
		Debugger();
#endif
}
void
mach_init(void)
{
	void *kernend;
	uint32_t memsize;
	extern char edata[], end[];	/* XXX */

	/* clear the BSS segment */
	kernend = (void *)mips_round_page(end);

	memset(edata, 0, (char *)kernend - edata);

	/* setup early console */
	ingenic_putchar_init();

	/* set CPU model info for sysctl_hw */
	cpu_setmodel("Ingenic XBurst");
	mips_vector_init(NULL, false);
	cal_timer();
	uvm_setpagesize();
	/*
	 * Look at arguments passed to us and compute boothowto.
	 */
	boothowto = RB_AUTOBOOT;
#ifdef KADB
	boothowto |= RB_KDB;
#endif

	/*
	 * Determine the memory size.
	 *
	 * Note: Reserve the first page!  That's where the trap
	 * vectors are located.
	 */
	memsize = 0x40000000;

	printf("Memory size: 0x%08x\n", memsize);
	physmem = btoc(memsize);

	/* XXX this is CI20 specific */
	mem_clusters[0].start = PAGE_SIZE;
	mem_clusters[0].size = 0x10000000 - PAGE_SIZE;
	mem_clusters[1].start = 0x30000000;
	mem_clusters[1].size = 0x30000000;
	mem_cluster_cnt = 2;

	/*
	 * Load the available pages into the VM system.
	 */
	mips_page_physload(MIPS_KSEG0_START, (vaddr_t)kernend,
	    mem_clusters, mem_cluster_cnt, NULL, 0);

	/*
	 * Initialize message buffer (at end of core).
	 */
	mips_init_msgbuf();

	/*
	 * Initialize the virtual memory system.
	 */
	pmap_bootstrap();

	/*
	 * Allocate uarea page for lwp0 and set it.
	 */
	mips_init_lwp0_uarea();

	apbus_init();
	/*
	 * Initialize debuggers, and break into them, if appropriate.
	 */
#ifdef DDB
	if (boothowto & RB_KDB)
		Debugger();
#endif
}