Example #1
0
void cpu_init_f(void)
{
	/* Pointer is writable since we allocated a register for it */
	gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);

	/* Clear initial global data */
	memset ((void *) gd, 0, sizeof (gd_t));

#ifdef CONFIG_FSL_LAW
	init_laws();
#endif

	setup_bats();

	init_early_memctl_regs();

#if defined(CONFIG_FSL_DMA)
	dma_init();
#endif

	/* enable the timebase bit in HID0 */
	set_hid0(get_hid0() | 0x4000000);

	/* enable EMCP, SYNCBE | ABE bits in HID1 */
	set_hid1(get_hid1() | 0x80000C00);
}
Example #2
0
void boot(int a1, int a2, void *prom)
{
    unsigned sa, len;
    void *dst;
    unsigned char *im;
    unsigned initrd_start, initrd_size;

    printf("coffboot starting: loaded at 0x%p\n", &_start);
    setup_bats(ram_start);

    initrd_size = (char *)(&__ramdisk_end) - (char *)(&__ramdisk_begin);
    if (initrd_size) {
	initrd_start = (ram_end - initrd_size) & ~0xFFF;
	a1 = initrd_start;
	a2 = initrd_size;
	claim(initrd_start, ram_end - initrd_start, 0);
	printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n\r",
	       initrd_start, (char *)(&__ramdisk_begin), initrd_size);
	memcpy((char *)initrd_start, (char *)(&__ramdisk_begin), initrd_size);
	prog_size = initrd_start - prog_start;
    } else
	a2 = 0xdeadbeef;

    im = (char *)(&__image_begin);
    len = (char *)(&__image_end) - (char *)(&__image_begin);
    /* claim 4MB starting at PROG_START */
    claim(prog_start, prog_size, 0);
    map(prog_start, prog_start, prog_size);
    dst = (void *) prog_start;
    if (im[0] == 0x1f && im[1] == 0x8b) {
	/* set up scratch space */
	begin_avail = avail_high = avail_ram = heap;
	end_avail = heap + sizeof(heap);
	printf("heap at 0x%p\n", avail_ram);
	printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
	gunzip(dst, prog_size, im, &len);
	printf("done %u bytes\n", len);
	printf("%u bytes of heap consumed, max in use %u\n",
	       avail_high - begin_avail, heap_max);
    } else {
	memmove(dst, im, len);
    }

    flush_cache(dst, len);
    make_bi_recs(((unsigned long) dst + len), "coffboot", _MACH_Pmac,
		    (prog_start + prog_size));

    sa = (unsigned long)prog_start;
    printf("start address = 0x%x\n", sa);

    (*(kernel_start_t)sa)(a1, a2, prom);

    printf("returned?\n");

    pause();
}
Example #3
0
boot(int a1, int a2, void *prom)
{
    int ns, oh, i;
    unsigned sa, len;
    void *dst;
    unsigned char *im;
    unsigned initrd_start, initrd_size;
    
    printf("coffboot starting: loaded at 0x%x\n", _start);
    setup_bats(RAM_START);
    if (initrd_len) {
	initrd_size = initrd_len;
	initrd_start = (RAM_END - initrd_size) & ~0xFFF;
	a1 = initrd_start;
	a2 = initrd_size;
	claim(initrd_start - RAM_START, RAM_END - initrd_start, 0);
	printf("initial ramdisk moving 0x%x <- 0x%x (%x bytes)\n",
	       initrd_start, initrd_data, initrd_size);
	memcpy((char *)initrd_start, initrd_data, initrd_size);
    }
    im = image_data;
    len = image_len;
    /* claim 3MB starting at 0 */
    claim(0, 3 << 20, 0);
    dst = (void *) RAM_START;
    if (im[0] == 0x1f && im[1] == 0x8b) {
	/* claim 512kB for scratch space */
	avail_ram = claim(0, 512 << 10, 0x10) + RAM_START;
	end_avail = avail_ram + (512 << 10);
	printf("avail_ram = %x\n", avail_ram);
	printf("gunzipping (0x%x <- 0x%x:0x%0x)...", dst, im, im+len);
	gunzip(dst, 3 << 20, im, &len);
	printf("done %u bytes\n", len);
    } else {
	memmove(dst, im, len);
    }

    flush_cache(dst, len);
    make_bi_recs((unsigned long)dst + len);
    
    sa = (unsigned long)PROG_START;
    printf("start address = 0x%x\n", sa);

#if 0
    pause();
#endif
    (*(void (*)())sa)(a1, a2, prom);

    printf("returned?\n");

    pause();
}
Example #4
0
coffboot(int a1, int a2, void *prom)
{
    void *options;
    unsigned loadbase;
    struct external_filehdr *eh;
    struct external_scnhdr *sp;
    struct external_scnhdr *isect, *rsect;
    int ns, oh, i;
    unsigned sa, len;
    void *dst;
    unsigned char *im;
    unsigned initrd_start, initrd_size;

    printf("coffboot starting\n");
    options = finddevice("/options");
    if (options == (void *) -1)
	exit();
    if (getprop(options, "load-base", &loadbase, sizeof(loadbase))
	!= sizeof(loadbase)) {
	printf("error getting load-base\n");
	exit();
    }
    setup_bats(RAM_START);

    loadbase += RAM_START;
    eh = (struct external_filehdr *) loadbase;
    ns = get_16be(eh->f_nscns);
    oh = get_16be(eh->f_opthdr);

    sp = (struct external_scnhdr *) (loadbase + sizeof(struct external_filehdr) + oh);
    isect = rsect = NULL;
    for (i = 0; i < ns; ++i, ++sp) {
	if (strcmp(sp->s_name, "image") == 0)
	    isect = sp;
	else if (strcmp(sp->s_name, "initrd") == 0)
	    rsect = sp;
    }
    if (isect == NULL) {
	printf("image section not found\n");
	exit();
    }

    if (rsect != NULL && (initrd_size = get_32be(rsect->s_size)) != 0) {
	initrd_start = (RAM_END - initrd_size) & ~0xFFF;
	a1 = initrd_start;
	a2 = initrd_size;
	printf("initial ramdisk at %x (%u bytes)\n",
	       initrd_start, initrd_size);
	memcpy((char *) initrd_start,
	       (char *) (loadbase + get_32be(rsect->s_scnptr)),
	       initrd_size);
	end_avail = (char *) initrd_start;
    } else {
	end_avail = (char *) RAM_END;
    }
	
    im = (unsigned char *)(loadbase + get_32be(isect->s_scnptr));
    len = get_32be(isect->s_size);
    dst = (void *) PROG_START;

    if (im[0] == 0x1f && im[1] == 0x8b) {
	void *cp = (void *) RAM_FREE;
	avail_ram = (void *) (RAM_FREE + ((len + 7) & -8));
	memcpy(cp, im, len);
	printf("gunzipping... ");
	gunzip(dst, 0x400000, cp, &len);
	printf("done\n");

    } else {
	memmove(dst, im, len);
    }

    flush_cache(dst, len);

    sa = (unsigned long)dst;
    printf("start address = 0x%x\n", sa);

#if 0
    pause();
#endif
    {
	    struct bi_record *rec;
	    
	    rec = (struct bi_record *)_ALIGN((unsigned long)dst+len+(1<<20)-1,(1<<20));
	    
	    rec->tag = BI_FIRST;
	    rec->size = sizeof(struct bi_record);
	    rec = (struct bi_record *)((unsigned long)rec + rec->size);

	    rec->tag = BI_BOOTLOADER_ID;
	    sprintf( (char *)rec->data, "coffboot");
	    rec->size = sizeof(struct bi_record) + strlen("coffboot") + 1;
	    rec = (struct bi_record *)((unsigned long)rec + rec->size);
	    
	    rec->tag = BI_MACHTYPE;
	    rec->data[0] = _MACH_Pmac;
	    rec->data[1] = 1;
	    rec->size = sizeof(struct bi_record) + sizeof(unsigned long);
	    rec = (struct bi_record *)((unsigned long)rec + rec->size);
	    
	    rec->tag = BI_LAST;
	    rec->size = sizeof(struct bi_record);
	    rec = (struct bi_record *)((unsigned long)rec + rec->size);
    }
    
    (*(void (*)())sa)(a1, a2, prom);

    printf("returned?\n");

    pause();
}
Example #5
0
void cpu_init_f(void)
{
	volatile immap_t    *immap = (immap_t *)CONFIG_SYS_IMMR;
	volatile ccsr_lbc_t *memctl = &immap->im_lbc;

	/* Pointer is writable since we allocated a register for it */
	gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);

	/* Clear initial global data */
	memset ((void *) gd, 0, sizeof (gd_t));

#ifdef CONFIG_FSL_LAW
	init_laws();
#endif

	setup_bats();

	/* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
	 * addresses - these have to be modified later when FLASH size
	 * has been determined
	 */

#if defined(CONFIG_SYS_OR0_REMAP)
	memctl->or0 = CONFIG_SYS_OR0_REMAP;
#endif
#if defined(CONFIG_SYS_OR1_REMAP)
	memctl->or1 = CONFIG_SYS_OR1_REMAP;
#endif

	/* now restrict to preliminary range */
#if defined(CONFIG_SYS_BR0_PRELIM) && defined(CONFIG_SYS_OR0_PRELIM)
	memctl->br0 = CONFIG_SYS_BR0_PRELIM;
	memctl->or0 = CONFIG_SYS_OR0_PRELIM;
#endif

#if defined(CONFIG_SYS_BR1_PRELIM) && defined(CONFIG_SYS_OR1_PRELIM)
	memctl->or1 = CONFIG_SYS_OR1_PRELIM;
	memctl->br1 = CONFIG_SYS_BR1_PRELIM;
#endif

#if defined(CONFIG_SYS_BR2_PRELIM) && defined(CONFIG_SYS_OR2_PRELIM)
	memctl->or2 = CONFIG_SYS_OR2_PRELIM;
	memctl->br2 = CONFIG_SYS_BR2_PRELIM;
#endif

#if defined(CONFIG_SYS_BR3_PRELIM) && defined(CONFIG_SYS_OR3_PRELIM)
	memctl->or3 = CONFIG_SYS_OR3_PRELIM;
	memctl->br3 = CONFIG_SYS_BR3_PRELIM;
#endif

#if defined(CONFIG_SYS_BR4_PRELIM) && defined(CONFIG_SYS_OR4_PRELIM)
	memctl->or4 = CONFIG_SYS_OR4_PRELIM;
	memctl->br4 = CONFIG_SYS_BR4_PRELIM;
#endif

#if defined(CONFIG_SYS_BR5_PRELIM) && defined(CONFIG_SYS_OR5_PRELIM)
	memctl->or5 = CONFIG_SYS_OR5_PRELIM;
	memctl->br5 = CONFIG_SYS_BR5_PRELIM;
#endif

#if defined(CONFIG_SYS_BR6_PRELIM) && defined(CONFIG_SYS_OR6_PRELIM)
	memctl->or6 = CONFIG_SYS_OR6_PRELIM;
	memctl->br6 = CONFIG_SYS_BR6_PRELIM;
#endif

#if defined(CONFIG_SYS_BR7_PRELIM) && defined(CONFIG_SYS_OR7_PRELIM)
	memctl->or7 = CONFIG_SYS_OR7_PRELIM;
	memctl->br7 = CONFIG_SYS_BR7_PRELIM;
#endif
#if defined(CONFIG_FSL_DMA)
	dma_init();
#endif

	/* enable the timebase bit in HID0 */
	set_hid0(get_hid0() | 0x4000000);

	/* enable EMCP, SYNCBE | ABE bits in HID1 */
	set_hid1(get_hid1() | 0x80000C00);
}