コード例 #1
0
ファイル: start.c プロジェクト: AdamRLukaitis/spoon
/** This is the function called from _start which is the environment
 * initialization code. It's responsibility is to zero the bss sections,
 * call the global constructors, set up the command line parameters,
 * etc, etc.
 *
 * This function then calls the standard main entry point with the
 * command line parameters.
 * 
 */
int spoon_start( uint32 eax, uint32 ebx, uint32 ecx, uint32 edx )
{
	int32 ans;
	int pcount;
	int i;
	char **parmlist;


	zero_bss();
	smk_init_console();
        call_ctors();

	pcount = 0;
	parmlist = NULL;

	parmlist = spoon_parse_parameters( &pcount, (char*)edx );

		ans = main( pcount , parmlist );	

	if ( parmlist != NULL ) 
	{
		for ( i = 0; i < pcount; i++)
		  smk_mem_free( parmlist[i] );
	
		smk_mem_free( parmlist );
	}

	call_dtors();

	return ans;
}
コード例 #2
0
extern "C" void
_start(uint32 _unused1, uint32 _unused3, void *openFirmwareEntry)
{
	// According to the PowerPC bindings, OpenFirmware should have created
	// a stack of 32kB or higher for us at this point

	clear_bss();
	call_ctors();
		// call C++ constructors before doing anything else

	start(openFirmwareEntry);
}
コード例 #3
0
ファイル: start.cpp プロジェクト: SummerSnail2014/haiku
extern "C" uint32
_start(uint64 handle, uint64 entry, uint32 _unused, uint32 signature)
{

	if (signature != CFE_EPTSEAL)
		return 123;//XXX:something?

	clear_bss();
	call_ctors();
		// call C++ constructors before doing anything else
	//return 456;

	start(handle, entry);
}
コード例 #4
0
ファイル: start.c プロジェクト: nielx/haiku-serviceskit
void
pi_start(void)
{
#warning IMPLEMENT _start
	stage2_args args;

	clear_bss();
	call_ctors();

	cpu_init();
	gpio_init();

	// Flick on "OK" led
	GPIO_CLR(16);

	mmu_init();
	serial_init();
	console_init();

	args.heap_size = HEAP_SIZE;
	args.arguments = NULL;

	main(&args);
}
コード例 #5
0
ファイル: start.cpp プロジェクト: SummerSnail2014/haiku
extern "C" int
start_gen(int argc, const char **argv, struct image_header *uimage, void *fdt)
{
	stage2_args args;

	clear_bss();
		// call C++ constructors before doing anything else
	call_ctors();
	args.heap_size = HEAP_SIZE;
	args.arguments = NULL;
	args.arguments_count = 0;
	args.platform.boot_tgz_data = NULL;
	args.platform.boot_tgz_size = 0;
	args.platform.fdt_data = NULL;
	args.platform.fdt_size = 0;

	gUImage = uimage;
	gFDT = fdt;	//XXX: make a copy?
		// TODO: check for atags instead and convert them

	if (argv) {
		// skip the kernel name
		++argv;
		--argc;
	}
	// TODO: Ensure cmdline is mapped into memory by MMU before usage.

	// if we get passed a uimage, try to find the third blob
	// only if we do not have FDT data yet
	if (gUImage != NULL
		&& !gFDT
		&& image_multi_getimg(gUImage, 2,
			(uint32*)&args.platform.fdt_data,
			&args.platform.fdt_size)) {
		// found a blob, assume it is FDT data, when working on a platform
		// which does not have an FDT enabled U-Boot
		gFDT = args.platform.fdt_data;
	}

	// We have to cpu_init *before* calling FDT functions
	cpu_init();

	serial_init(gFDT);

	#if defined(__ARM__)
	arch_mailbox_init();
	#endif

	// initialize the OpenFirmware wrapper
	of_init(NULL);

	console_init();

	// if we get passed an FDT, check /chosen for initrd and bootargs
	if (gFDT != NULL) {
		int node = fdt_path_offset(gFDT, "/chosen");
		const void *prop;
		int len;
		phys_addr_t initrd_start = 0, initrd_end = 0;

		if (node >= 0) {
			prop = fdt_getprop(gFDT, node, "linux,initrd-start", &len);
			if (prop && len == 4)
				initrd_start = fdt32_to_cpu(*(uint32_t *)prop);
			prop = fdt_getprop(gFDT, node, "linux,initrd-end", &len);
			if (prop && len == 4)
				initrd_end = fdt32_to_cpu(*(uint32_t *)prop);
			if (initrd_end > initrd_start) {
				args.platform.boot_tgz_data = (void *)initrd_start;
				args.platform.boot_tgz_size = initrd_end - initrd_start;
				dprintf("Found boot tgz from FDT @ %p, %" B_PRIu32 " bytes\n",
					args.platform.boot_tgz_data, args.platform.boot_tgz_size);
			}
			// we check for bootargs after remapping the FDT
		}
	}

	// if we get passed a uimage, try to find the second blob
	if (gUImage != NULL
		&& image_multi_getimg(gUImage, 1,
			(uint32*)&args.platform.boot_tgz_data,
			&args.platform.boot_tgz_size)) {
		dprintf("Found boot tgz from uimage @ %p, %" B_PRIu32 " bytes\n",
			args.platform.boot_tgz_data, args.platform.boot_tgz_size);
	}

	{ //DEBUG:
		int i;
		dprintf("argc = %d\n", argc);
		for (i = 0; i < argc; i++)
			dprintf("argv[%d] @%lx = '%s'\n", i, (uint32)argv[i], argv[i]);
		dprintf("os: %d\n", (int)gUBootOS);
		dprintf("gd @ %p\n", gUBootGlobalData);
		if (gUBootGlobalData) {
			dprintf("gd->bd @ %p\n", gUBootGlobalData->bd);
			dprintf("gd->fb_base @ %p\n", (void*)gUBootGlobalData->fb_base);
		}
		if (gUImage)
			dump_uimage(gUImage);
		if (gFDT)
			dump_fdt(gFDT);
	}
	
	if (args.platform.boot_tgz_size > 0) {
		insert_physical_allocated_range((addr_t)args.platform.boot_tgz_data,
			args.platform.boot_tgz_size);
	}

	// save the size of the FDT so we can map it easily after mmu_init
	size_t fdtSize = gFDT ? fdt_totalsize(gFDT) : 0;
	dprintf("fdtSize: 0x%" B_PRIxSIZE "\n", fdtSize);

	mmu_init();

	// Handle our tarFS post-mmu
	if (args.platform.boot_tgz_size > 0) {
		args.platform.boot_tgz_data = (void*)mmu_map_physical_memory((addr_t)
			args.platform.boot_tgz_data, args.platform.boot_tgz_size,
			kDefaultPageFlags);
	}
	// .. and our FDT
	if (gFDT != NULL)
		gFDT = (void*)mmu_map_physical_memory((addr_t)gFDT, fdtSize, kDefaultPageFlags);

	// if we get passed an FDT, check /chosen for bootargs now
	// to avoid having to copy them.
	if (gFDT != NULL) {
		int node = fdt_path_offset(gFDT, "/chosen");
		const void *prop;
		int len;

		if (node >= 0) {
			prop = fdt_getprop(gFDT, node, "bootargs", &len);
			if (prop) {
				dprintf("Found bootargs: %s\n", (const char *)prop);
				static const char *sArgs[] = { NULL, NULL };
				sArgs[0] = (const char *)prop;
				// override main() args
				args.arguments = sArgs;
				args.arguments_count = 1;
			}
		}
		dprintf("args.arguments_count = %" B_PRId32 "\n", args.arguments_count);
		for (int i = 0; i < args.arguments_count; i++)
			dprintf("args.arguments[%d] @%lx = '%s'\n", i,
				(uint32)args.arguments[i], args.arguments[i]);
	}

	// wait a bit to give the user the opportunity to press a key
//	spin(750000);

	// reading the keyboard doesn't seem to work in graphics mode
	// (maybe a bochs problem)
//	sBootOptions = check_for_boot_keys();
	//if (sBootOptions & BOOT_OPTION_DEBUG_OUTPUT)
		serial_enable();

	main(&args);
	return 0;
}
コード例 #6
0
extern "C" int
start_raw(int argc, const char **argv)
{
	stage2_args args;

	clear_bss();
		// call C++ constructors before doing anything else
	call_ctors();
	args.heap_size = HEAP_SIZE;
	args.arguments = NULL;
	args.platform.boot_tgz_data = NULL;
	args.platform.boot_tgz_size = 0;
	args.platform.fdt_data = NULL;
	args.platform.fdt_size = 0;

	// if we get passed a uimage, try to find the third blob only if we do not have FDT data yet
	if (gUImage != NULL
		&& !gFDT
		&& image_multi_getimg(gUImage, 2,
			(uint32*)&args.platform.fdt_data,
			&args.platform.fdt_size)) {
		// found a blob, assume it is FDT data, when working on a platform
		// which does not have an FDT enabled U-Boot
		gFDT = args.platform.fdt_data;
	}

	serial_init(gFDT);
	console_init();
	cpu_init();

	if (args.platform.fdt_data) {
		dprintf("Found FDT from uimage @ %p, %" B_PRIu32 " bytes\n",
			args.platform.fdt_data, args.platform.fdt_size);
	} else if (gFDT) {
		/* Fixup args so we can pass the gFDT on to the kernel */
		args.platform.fdt_data = gFDT;
		args.platform.fdt_size = fdt_totalsize(gFDT);
	}

	// if we get passed an FDT, check /chosen for initrd
	if (gFDT != NULL) {
		int node = fdt_path_offset(gFDT, "/chosen");
		const void *prop;
		int len;
		phys_addr_t initrd_start = 0, initrd_end = 0;

		if (node >= 0) {
			prop = fdt_getprop(gFDT, node, "linux,initrd-start", &len);
			if (prop && len == 4)
				initrd_start = fdt32_to_cpu(*(uint32_t *)prop);
			prop = fdt_getprop(gFDT, node, "linux,initrd-end", &len);
			if (prop && len == 4)
				initrd_end = fdt32_to_cpu(*(uint32_t *)prop);
			if (initrd_end > initrd_start) {
				args.platform.boot_tgz_data = (void *)initrd_start;
				args.platform.boot_tgz_size = initrd_end - initrd_start;
		dprintf("Found boot tgz from FDT @ %p, %" B_PRIu32 " bytes\n",
			args.platform.boot_tgz_data, args.platform.boot_tgz_size);
			}
		}
	}

	// if we get passed a uimage, try to find the second blob
	if (gUImage != NULL
		&& image_multi_getimg(gUImage, 1,
			(uint32*)&args.platform.boot_tgz_data,
			&args.platform.boot_tgz_size)) {
		dprintf("Found boot tgz from uimage @ %p, %" B_PRIu32 " bytes\n",
			args.platform.boot_tgz_data, args.platform.boot_tgz_size);
	}

	{ //DEBUG:
		int i;
		dprintf("argc = %d\n", argc);
		for (i = 0; i < argc; i++)
			dprintf("argv[%d] @%lx = '%s'\n", i, (uint32)argv[i], argv[i]);
		dprintf("os: %d\n", (int)gUBootOS);
		dprintf("gd @ %p\n", gUBootGlobalData);
		if (gUBootGlobalData)
			dprintf("gd->bd @ %p\n", gUBootGlobalData->bd);
		//dprintf("fb_base %p\n", (void*)gUBootGlobalData->fb_base);
		if (gUImage)
			dump_uimage(gUImage);
		if (gFDT)
			dump_fdt(gFDT);
	}
	
	mmu_init();

	// wait a bit to give the user the opportunity to press a key
//	spin(750000);

	// reading the keyboard doesn't seem to work in graphics mode
	// (maybe a bochs problem)
//	sBootOptions = check_for_boot_keys();
	//if (sBootOptions & BOOT_OPTION_DEBUG_OUTPUT)
		serial_enable();

	main(&args);
	return 0;
}
コード例 #7
0
ファイル: crt0start.c プロジェクト: ztane/zsos
void __CRT_startup() {
	char *argv[] = { "exe", 0 };
	call_ctors();
	int rv = main(1, argv);
	exit(rv);
}