Beispiel #1
0
int initialize_network(void)
{
#if WITH_TUNTAP
    const char *str;

    network = calloc(sizeof(*network), 1);

    // install the network register handlers
    install_mem_handler(NET_REGS_BASE, NET_REGS_SIZE, &network_regs_get_put, NULL);

    // try to intialize the tun/tap interface
    str = get_config_key_string("network", "device", NULL);
    if (!str) {
        SYS_TRACE(0, "sys: no network device node specified in config file, aborting.\n");
        exit(1);
    }

    // try to open the device
    network->fd = open_tun(str);
    if (network->fd < 0) {
        SYS_TRACE(0, "sys: failed to open tun/tap interface at '%s'\n", str);
        exit(1);
    }

    // start a network reader/writer thread
    SDL_CreateThread(&network_thread, NULL);
#endif

    return 0;
}
Beispiel #2
0
int initialize_mainmem(const char *rom_file, long load_offset)
{
	// allocate some ram
	mainmem.size = MAINMEM_SIZE;
	mainmem.base = MAINMEM_BASE;
	mainmem.mem = calloc(1, mainmem.size);	

	printf("sys: initializing mainmem from rom file %s, offset %ld\n", rom_file, load_offset);

	// put it in the memory map
	install_mem_handler(mainmem.base, mainmem.size, &mainmem_get_put, &mainmem_get_ptr);

	// read in a file, if specified
	if(rom_file) {
		FILE *fp = fopen(rom_file, "r");
		if(fp) {
			fread(mainmem.mem + load_offset, 1, mainmem.size, fp);
			fclose(fp);
		}
	}

	return 0;
}