Example #1
0
int main(void)
{
	irq_setmask(0);
	irq_setie(1);
	uart_init();

	puts("\nHDMI2USB firmware  http://timvideos.us/");
	printf("Board's DNA: %016x\n", dna_id_read());
	printf("Revision %08x built "__DATE__" "__TIME__"\n", MSC_GIT_ID);

	ci_prompt();
	config_init();
	time_init();
	processor_init();
	processor_start(config_get(CONFIG_KEY_RESOLUTION));
	while(1) {
		processor_service();
		ci_service();
/* XXX FIX DDR conflict between DMA and L2 cache */
#if 0
		pattern_service();
#endif
	}

	return 0;
}
int main(void)
{
	irq_setmask(0);
	irq_setie(1);
	uart_init();
#ifdef CSR_HDMI_OUT0_I2C_W_ADDR
	hdmi_out0_i2c_init();
#endif
#ifdef CSR_HDMI_OUT1_I2C_W_ADDR
	hdmi_out1_i2c_init();
#endif

	puts("\r\nHDMI2USB firmware  http://timvideos.us/");
	print_version();

	fx2_reset_out_write(1);

	config_init();
	time_init();
	processor_init();
	processor_start(config_get(CONFIG_KEY_RESOLUTION));

	// Set HDMI Output 0 to be pattern
#ifdef CSR_HDMI_OUT0_BASE
	processor_set_hdmi_out0_source(VIDEO_IN_PATTERN);
#endif
	// Set HDMI Output 1 to be pattern
#ifdef CSR_HDMI_OUT1_BASE
	processor_set_hdmi_out1_source(VIDEO_IN_PATTERN);
#endif
	processor_update();

	// Reboot the FX2 chip into HDMI2USB mode
#ifdef CSR_FX2_RESET_OUT_ADDR
	//fx2_init();
#endif

	// Set Encoder to be pattern
#ifdef ENCODER_BASE
	processor_set_encoder_source(VIDEO_IN_PATTERN);
	encoder_enable(1);
	processor_update();
#endif
	ci_prompt();
	while(1) {
		processor_service();
		ci_service();

#ifdef CSR_FX2_RESET_OUT_ADDR
		//fx2_service(true);
#endif

/* XXX FIX DDR conflict between DMA and L2 cache */
#if 0
		pattern_service();
#endif
	}

	return 0;
}
Example #3
0
static int __init parisc_init(void)
{
	parisc_proc_mkdir();
	parisc_init_resources();
	do_device_inventory();                  /* probe for hardware */

	parisc_pdc_chassis_init();
	
	/* set up a new led state on systems shipped LED State panel */
	pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BSTART);
	
	processor_init();
	printk(KERN_INFO "CPU(s): %d x %s at %d.%06d MHz\n",
			boot_cpu_data.cpu_count,
			boot_cpu_data.cpu_name,
			boot_cpu_data.cpu_hz / 1000000,
			boot_cpu_data.cpu_hz % 1000000	);

	/* These are in a non-obvious order, will fix when we have an iotree */
#if defined(CONFIG_IOSAPIC)
	iosapic_init();
#endif
#if defined(CONFIG_IOMMU_SBA)
	sba_init();
#endif
#if defined(CONFIG_PCI_LBA)
	lba_init();
#endif

	/* CCIO before any potential subdevices */
#if defined(CONFIG_IOMMU_CCIO)
	ccio_init();
#endif

	/*
	 * Need to register Asp & Wax before the EISA adapters for the IRQ
	 * regions.  EISA must come before PCI to be sure it gets IRQ region
	 * 0.
	 */
#if defined(CONFIG_GSC_LASI) || defined(CONFIG_GSC_WAX)
	gsc_init();
#endif
#ifdef CONFIG_EISA
	eisa_init();
#endif

#if defined(CONFIG_HPPB)
	hppb_init();
#endif

#if defined(CONFIG_GSC_DINO)
	dino_init();
#endif

#ifdef CONFIG_CHASSIS_LCD_LED
	register_led_regions();	/* register LED port info in procfs */
#endif

	return 0;
}
Example #4
0
void
processor_bootstrap(void)
{
	pset_init(&pset0, &pset_node0);
	pset_node0.psets = &pset0;

	simple_lock_init(&pset_node_lock, 0);

	queue_init(&tasks);
	queue_init(&threads);

	simple_lock_init(&processor_list_lock, 0);

	master_processor = cpu_to_processor(master_cpu);

	processor_init(master_processor, master_cpu, &pset0);
}
Example #5
0
static int __init parisc_init(void)
{
	u32 osid = (OS_ID_LINUX << 16);

	parisc_proc_mkdir();
	parisc_init_resources();
	do_device_inventory();                  /* probe for hardware */

	parisc_pdc_chassis_init();
	
	/* set up a new led state on systems shipped LED State panel */
	pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BSTART);

	/* tell PDC we're Linux. Nevermind failure. */
	pdc_stable_write(0x40, &osid, sizeof(osid));
	
	/* start with known state */
	flush_cache_all_local();
	flush_tlb_all_local(NULL);

	processor_init();
#ifdef CONFIG_SMP
	pr_info("CPU(s): %d out of %d %s at %d.%06d MHz online\n",
		num_online_cpus(), num_present_cpus(),
#else
	pr_info("CPU(s): 1 x %s at %d.%06d MHz\n",
#endif
			boot_cpu_data.cpu_name,
			boot_cpu_data.cpu_hz / 1000000,
			boot_cpu_data.cpu_hz % 1000000	);

	apply_alternatives_all();
	parisc_setup_cache_timing();

	/* These are in a non-obvious order, will fix when we have an iotree */
#if defined(CONFIG_IOSAPIC)
	iosapic_init();
#endif
#if defined(CONFIG_IOMMU_SBA)
	sba_init();
#endif
#if defined(CONFIG_PCI_LBA)
	lba_init();
#endif

	/* CCIO before any potential subdevices */
#if defined(CONFIG_IOMMU_CCIO)
	ccio_init();
#endif

	/*
	 * Need to register Asp & Wax before the EISA adapters for the IRQ
	 * regions.  EISA must come before PCI to be sure it gets IRQ region
	 * 0.
	 */
#if defined(CONFIG_GSC_LASI) || defined(CONFIG_GSC_WAX)
	gsc_init();
#endif
#ifdef CONFIG_EISA
	eisa_init();
#endif

#if defined(CONFIG_HPPB)
	hppb_init();
#endif

#if defined(CONFIG_GSC_DINO)
	dino_init();
#endif

#ifdef CONFIG_CHASSIS_LCD_LED
	register_led_regions();	/* register LED port info in procfs */
#endif

	return 0;
}
Example #6
0
int main(int argc, char** argv) {

    int i,r;
    int rbuf[20];
    int data;
    int format;
    processor_init();
    uart1_init();
    uart2_init();

    TRISDbits.TRISD0 = 0;
    TRISBbits.TRISB12 = 0;
    TRISBbits.TRISB11 = 0;

    TRISBbits.TRISB0 = 1;
    TRISBbits.TRISB1 = 1;
    TRISBbits.TRISB2 = 1;
    ADPCFGbits.PCFG0 = 1;
    ADPCFGbits.PCFG1 = 1;
    ADPCFGbits.PCFG2 = 1;

    ledstatus = 0;

    cb = buffer_init();

    while(1)
    {
        if ( buffer_full(cb) )
            /* Signal buffer overflow */
            PORTDbits.RD0 = 1;

        if ( !buffer_empty(cb) )
        {
            int data;

            /* Get a 'char' from the buffer */
            buffer_read(cb, &data);

            if ( data & 0x0100 )
            {

                format = (~PORTB) & 0x3;
                /* Print the last sentence and begin reading the new one */
                PORTBbits.RB12 = 1;
                //transmit_raw_buffer(rbuf, r);
                process_seatalk_string(rbuf, r, format);
                PORTBbits.RB12 = 0;
                r = 0;
                rbuf[r++] = data;
            }

            else
            {
                /* Accumulate data into the buffer */
                //printf("rx: %x\n",data);
                rbuf[r++] = data;
            }

        }
    }

    return (EXIT_SUCCESS);
}
Example #7
0
/* point-of-entry */
int 
main(int argc, char **argv)
{
	int ret = -1, c, index, action = ACTION_NONE, tmp;
	char *action_param = NULL;
        processor_config_t *config = 0, *config2 = 0;
	char *conf_file = 0;
	int load_autoreg = 0;
	int flag_quiet = 0;
	int log_to_file = 0;
	int console_only = 0;
	int do_test = 0; // do whatever the test of the day is

	xmlInitParser();
	xmlInitThreads();
	//initGenericErrorDefaultFunc((xmlGenericErrorFunc *)xml_error_func);

        /* the getopt values */
        static struct option long_options[] =
                {                        
                        {"verbose", no_argument, 0, 0},
                        {"iface", required_argument, 0, 0},
                        {"threads", required_argument, 0, 0},
                        {"help", no_argument, 0, 0},
                        {"version", no_argument, 0, 0},
                        {"console", no_argument, 0, 0},
#ifdef CONFIG_PYTHON_ENABLED
                        {"shell", no_argument, 0, 0},
                        {"run", required_argument, 0, 0},
                        {"no-scripts", no_argument, 0, 0},
#endif
#ifdef CONFIG_SIP_ENABLED
                        {"proxy-iface", required_argument, 0, 0},
                        {"no-mp", no_argument, 0, 0},
                        {"tunnel-mp", no_argument, 0, 0},
                        {"force-mp", no_argument, 0, 0},
                        {"allow-unknown", no_argument, 0, 0},
                        {"allow-untrusted", no_argument, 0, 0},
#endif
                        {"list-ca", no_argument, 0, 0},
                        {"import-ca", required_argument, 0, 0},
                        {"remove-ca", required_argument, 0, 0},
                        {"list", no_argument, 0, 0},
                        {"import", required_argument, 0, 0},
                        {"remove", required_argument, 0, 0},
                        {"idents", required_argument, 0, 0},
                        {"log", required_argument, 0, 0},
#ifdef CONFIG_BROADCAST_ENABLED
                        {"bc-addr", required_argument, 0, 0},
#endif
#ifdef CONFIG_WEBCONF_ENABLED
                        {"webconf", required_argument, 0, 0},
#endif
#ifdef CONFIG_OPENDHT_ENABLED
                        {"opendht", required_argument, 0, 0},
#endif
#ifdef CONFIG_HIP_ENABLED
                        {"list-hits", no_argument, 0, 0},
                        {"rvs", required_argument, 0, 0},
                        {"provide-rvs", no_argument, 0, 0},
#endif
                        {0, 0, 0, 0}
                };        

#ifdef LOCK_DEBUG
	debug2_init();
#endif
#ifdef REF_DEBUG2
	ship_debug_initref();
#endif


	if (!(config = processor_config_new()) || !(config2 = processor_config_new())) {
                USER_ERROR("Error loading application\n");
		goto err;
	}

	if (processor_config_load_defaults(config2)) {
                USER_ERROR("Error loading default configurations\n");
                goto err;
	}
	processor_config_get_string(config2, P2PSHIP_CONF_CONF_FILE, &conf_file);

        opterr = 0;
        while ((c = getopt_long(argc, argv, "LqvhDVs:c:p:i:Rr:kKt", long_options, &index)) != -1) {
                
                if (!c) {
                        if (!strcmp(long_options[index].name, "threads")) {
				processor_config_set_int(config, P2PSHIP_CONF_WORKER_THREADS, atoi(optarg));
                        } else if (!strcmp(long_options[index].name, "help")) {
                                c = '?';
                        } else if (!strcmp(long_options[index].name, "version")) {
                                c = 'V';
                        } else if (!strcmp(long_options[index].name, "verbose")) {
                                c = 'v';
                        } else if (!strcmp(long_options[index].name, "iface")) {
                                c = 'i';
                        } else if (!strcmp(long_options[index].name, "console")) {
				console_only = 1;
#ifdef CONFIG_PYTHON_ENABLED
                        } else if (!strcmp(long_options[index].name, "shell")) {
				processor_config_set_true(config, P2PSHIP_CONF_START_SHELL);
                        } else if (!strcmp(long_options[index].name, "run")) {
				processor_config_set_string(config, P2PSHIP_CONF_RUN_SCRIPT, optarg);
                        } else if (!strcmp(long_options[index].name, "no-scripts")) {
				processor_config_set_false(config, P2PSHIP_CONF_STARTUP_SCRIPTS);
#endif
#ifdef CONFIG_SIP_ENABLED
                        } else if (!strcmp(long_options[index].name, "proxy-iface")) {
				processor_config_set_string(config, P2PSHIP_CONF_SIPP_PROXY_IFACES, optarg);
                        } else if (!strcmp(long_options[index].name, "no-mp")) {
				processor_config_set_string(config, P2PSHIP_CONF_SIPP_MEDIA_PROXY, "no");
                        } else if (!strcmp(long_options[index].name, "tunnel-mp")) {
				processor_config_set_string(config, P2PSHIP_CONF_SIPP_TUNNEL_PROXY, "yes");
                        } else if (!strcmp(long_options[index].name, "force-mp")) {
				processor_config_set_string(config, P2PSHIP_CONF_SIPP_FORCE_PROXY, "yes");
                        } else if (!strcmp(long_options[index].name, "allow-unknown")) {
				processor_config_set_string(config, P2PSHIP_CONF_IDENT_ALLOW_UNKNOWN_REGISTRATIONS, "yes");
                        } else if (!strcmp(long_options[index].name, "allow-untrusted")) {
				processor_config_set_string(config, P2PSHIP_CONF_IDENT_ALLOW_UNTRUSTED, "yes");
#endif
                        } else if (!action && !strcmp(long_options[index].name, "list-ca")) {
				action = ACTION_LIST_CA;
                        } else if (!action && !strcmp(long_options[index].name, "remove-ca")) {
				action = ACTION_REMOVE_CA;
				if (!action_param) action_param = strdup(optarg);
                        } else if (!action && !strcmp(long_options[index].name, "import-ca")) {
				action = ACTION_IMPORT_CA;
				if (!action_param) action_param = strdup(optarg);
			} else if (!action && !strcmp(long_options[index].name, "list")) {
				action = ACTION_LIST;
                        } else if (!action && !strcmp(long_options[index].name, "remove")) {
				action = ACTION_REMOVE;
				if (!action_param) action_param = strdup(optarg);
                        } else if (!action && !strcmp(long_options[index].name, "import")) {
				action = ACTION_IMPORT;
				if (!action_param) action_param = strdup(optarg);
                        } else if (!strcmp(long_options[index].name, "idents")) {
				processor_config_set_string(config, P2PSHIP_CONF_IDENTS_FILE, optarg);
                        } else if (!strcmp(long_options[index].name, "log")) {
				processor_config_set_string(config, P2PSHIP_CONF_LOG_FILE, optarg);
#ifdef CONFIG_BROADCAST_ENABLED
                        } else if (!strcmp(long_options[index].name, "bc-addr")) {
				processor_config_set_string(config, P2PSHIP_CONF_BC_ADDR, optarg);
#endif
#ifdef CONFIG_OPENDHT_ENABLED
                        } else if (!strcmp(long_options[index].name, "opendht")) {
				processor_config_set_string(config, P2PSHIP_CONF_OPENDHT_PROXY, optarg);
#endif
#ifdef CONFIG_HIP_ENABLED
                        } else if (!strcmp(long_options[index].name, "list-hits")) {
				action = ACTION_LIST_HITS;
                        } else if (!strcmp(long_options[index].name, "rvs")) {
				processor_config_set_string(config, P2PSHIP_CONF_RVS, optarg);
                        } else if (!strcmp(long_options[index].name, "provide-rvs")) {
				processor_config_set_string(config, P2PSHIP_CONF_PROVIDE_RVS, "yes");
#endif
#ifdef CONFIG_WEBCONF_ENABLED
                        } else if (!strcmp(long_options[index].name, "webconf")) {
				processor_config_set_string(config, P2PSHIP_CONF_WEBCONF_SS, optarg);
#endif
			} else {
				c  = '?';
			}
		}

                switch (c) {    
                case 0:
                        /* already processed */
                        break;
                case 'v':
                        if (p2pship_log_level > -1)
                                p2pship_log_level++;
                        break;
                case 'q':
                        flag_quiet = 1;
                        p2pship_log_level = -1;
                        break;
                case 'D':
			log_to_file = 1;
			processor_config_set_string(config, P2PSHIP_CONF_DAEMON, "yes");
                        break;
                case 'c':
                        conf_file = optarg;
			processor_config_set_string(config, P2PSHIP_CONF_CONF_FILE, conf_file);
                        break;
                case 'i':
			processor_config_set_string(config, P2PSHIP_CONF_IFACES, optarg);
                        break;
#ifdef CONFIG_SIP_ENABLED
                case 'p':
                        if (sscanf(optarg, "%u", &tmp) != 1) {
                                USER_ERROR("Invalid port %s\n", optarg);
                                return 1;
                        } else {
				processor_config_set_int(config, P2PSHIP_CONF_SIPP_PROXY_PORT, tmp);
			}
                        break;
#endif
                case 's':
                        if (sscanf(optarg, "%u", &tmp) != 1) {
                                USER_ERROR("Invalid port %s\n", optarg);
                                return 1;
                        } else {
				processor_config_set_int(config, P2PSHIP_CONF_SHIP_PORT, tmp);
			}
                        break;
                case 'V':
                        print_version();
                        return 0;
		case 'R':
			load_autoreg = 1;
			break;
		case 'r':
			processor_config_set_string(config, P2PSHIP_CONF_AUTOREG_FILE, optarg);
			break;
		case 'L':
			log_to_file = 1;
			break;
                case 'k':
			processor_kill_existing_pid();
			break;
                case 'K':
			processor_kill_all_existing();
			break;
                case 't':
			do_test = 1;
			break;
                case 'h':
                case '?':
                default:
                        print_version();
                        print_usage();
                        return 1;
                }
        }
        
        if (!flag_quiet)
                print_version();
     
        /* 1. load the defaults (done already), 2. load the conf file, 3. put on the manual overrides */
	/* ensure that we have a config file! */
	if (ship_ensure_file(conf_file, "# Autocreated\n\n") || 
	    processor_config_load(config2, conf_file)) {
		USER_ERROR("Error processing config file %s\n", conf_file);
		goto err;
	}
        
        if (processor_config_transfer(config2, config)) {
                USER_ERROR("Error processing configs\n");
                goto err;
        }

	/* transfer */
	processor_config_free(config);
	config = config2;
	config2 = NULL;

	/* ok, ready to rock! */
	processor_config_ensure_configs(config);
	if (log_to_file) {
		p2pship_log_file = processor_config_string(config, P2PSHIP_CONF_LOG_FILE);
	}

#ifdef CONFIG_START_GLIB_MAIN_LOOP
	if (!g_thread_supported())
		g_thread_init(NULL);
#endif
#ifdef CONFIG_START_GTK
	gdk_threads_init();
	gdk_threads_enter();
	gtk_init(&argc, &argv);
#endif

#ifdef CALL_DEBUG
	calldebug_init();
#endif
	/* mark starttime for uptime calcs */
	time(&p2pship_start);

	/* register each modules */
	ASSERT_ZERO(processor_init(config), err);
#ifdef CONFIG_HIP_ENABLED
	hipapi_register();
#endif
#ifdef CONFIG_SIP_ENABLED
	sipp_register();
#endif
	ident_addr_register();
	ident_register();
#ifdef CONFIG_WEBCONF_ENABLED
	webconf_register();
#endif
#ifdef CONFIG_EXTAPI_ENABLED
	extapi_register();
#endif
#ifdef CONFIG_WEBCACHE_ENABLED
	webcache_register();
#endif
	resourceman_register();
	olclient_register();
	conn_register();
	netio_register();
	netio_events_register();
	netio_ff_register();
	netio_man_register();
	netio_http_register();
	ui_register();
	ui_stdin_register();
	processor_init_module("ui_stdin", config);
	
#ifdef CONFIG_DBUS_ENABLED
	dbus_register();
#endif

	if (!console_only) {
#ifdef CONFIG_GTKUI_ENABLED
		ui_gtk_register();
		processor_init_module("ui_gtk", config);
#endif
	}
	addrbook_register();
#ifdef CONFIG_PYTHON_ENABLED
	pymod_register();	
#endif

#ifdef CONFIG_MEDIA_ENABLED
	media_register();
#endif
	/* check what we actually should do */
	switch (action) {
	case ACTION_LIST_CA: { /* list ca */
		if (processor_init_module("ident", config)) {
			USER_ERROR("Error initializing system\n");
		} else {
			ident_data_print_cas(ident_get_cas());
		}
		break;
	}

	case ACTION_REMOVE_CA: { /* remove ca */
		if (processor_init_module("ident", config)) {
			USER_ERROR("Error initializing system\n");
		} else {
			ident_remove_ca(action_param);
		}
		break;
	}

	case ACTION_LIST: { /* list */
		if (processor_init_module("ident", config)) {
			USER_ERROR("Error initializing system\n");
		} else {
			ident_data_print_idents(ident_get_identities());
		}
		break;
	}

	case ACTION_REMOVE: { /* remove */
		if (processor_init_module("ident", config)) {
			USER_ERROR("Error initializing system\n");
		} else {
			ident_remove_ident(action_param);
		}
		break;
	}

	case ACTION_IMPORT:  /* import */
	case ACTION_IMPORT_CA: { /* import ca */
		if (processor_init_module("ident", config)) {
			USER_ERROR("Error initializing system\n");
		} else {
			if (ident_import_file(action_param, 1)) {
				USER_ERROR("Error loading processing file %s\n", action_param);
			}
		}
		break;
	}
		
#ifdef CONFIG_HIP_ENABLED
	case ACTION_LIST_HITS: {
		if (processor_init_module("hipapi", config)) {
			USER_ERROR("Error initializing system\n");
		} else {
			hipapi_list_hits();
		}
		break;
	}
#endif
	case ACTION_NONE:
	default: {
		struct rlimit rl;
		int result;
		
#ifdef CONFIG_PYTHON_ENABLED
		if (processor_config_is_true(config, P2PSHIP_CONF_START_SHELL))
			processor_config_set_false(config, P2PSHIP_CONF_DAEMON);
#endif
		/* go daemon (..whee!) */
		if (processor_config_is_true(config, P2PSHIP_CONF_DAEMON)) {
			if (fork())
				goto err;			
		}
		
		/* check the stack size */
		if (!(result = getrlimit(RLIMIT_STACK, &rl))) {
			const rlim_t stacksize = 32L * 1024L * 1024L;
			if (rl.rlim_cur < stacksize) {
				LOG_INFO("increasing stack size to %d\n", stacksize);
				rl.rlim_cur = stacksize;
				if (setrlimit(RLIMIT_STACK, &rl)) {
					LOG_ERROR("could not set new stack size!\n");
				}
			}
		} else {
			LOG_ERROR("error checking stack size\n");
		}

		if (processor_init_modules(config) ||
		    (load_autoreg && ident_autoreg_load())) {
			USER_ERROR("Error initializing system\n");
		} else {
#ifdef REMOTE_DEBUG
			ship_remote_debug_init(config);
#endif
			/* start the main loop, blocks */
#ifdef REF_DEBUG2
			//			processor_tasks_add_periodic(ship_debug_reportref, 10000);
#endif

			if (do_test) {
				LOG_DEBUG("Run tests..\n");
			}

			processor_run();
		}
	}
	}
        
	ret = 0;
 err:
#ifdef REF_DEBUG2
	ship_debug_reportref();
#endif
	processor_close();
	freez(action_param);
	processor_config_free(config);
	processor_config_free(config2);

#ifdef LOCK_DEBUG
	debug2_close();
#endif
#ifdef REF_DEBUG2
	ship_debug_closeref();
#endif

	xmlCleanupThreads();
        if (!ret && !flag_quiet)
                USER_ERROR("ending ok\n");

	processor_cleanup_pid();
        return ret;
}
Example #8
0
static void bios_init(void)
{
    KDEBUG(("bios_init()\n"));

    /* initialize Native Features, if available
     * do it as soon as possible so that kprintf can make use of them
     */
#if DETECT_NATIVE_FEATURES
    KDEBUG(("natfeat_init()\n"));
    natfeat_init();
#endif
#if STONX_NATIVE_PRINT
    KDEBUG(("stonx_kprintf_init()\n"));
    stonx_kprintf_init();
#endif
#if CONF_WITH_UAE
    KDEBUG(("amiga_uaelib_init()\n"));
    amiga_uaelib_init();
#endif

    /* Initialize the processor */
    KDEBUG(("processor_init()\n"));
    processor_init();   /* Set CPU type, longframe and FPU type */
    KDEBUG(("vecs_init()\n"));
    vecs_init();        /* setup all exception vectors (above) */
    KDEBUG(("init_delay()\n"));
    init_delay();       /* set 'reasonable' default values for delay */

    /* Detect optional hardware (video, sound, etc.) */
    KDEBUG(("machine_detect()\n"));
    machine_detect();   /* detect hardware */
    KDEBUG(("machine_init()\n"));
    machine_init();     /* initialise machine-specific stuff */

    /* Initialize the screen */
    KDEBUG(("screen_init()\n"));
    screen_init();      /* detect monitor type, ... */

    /* Initialize the BIOS memory management */
    KDEBUG(("bmem_init()\n"));
    bmem_init();        /* this must be done after screen_init() */

    KDEBUG(("cookie_init()\n"));
    cookie_init();      /* sets a cookie jar */
    KDEBUG(("fill_cookie_jar()\n"));
    fill_cookie_jar();  /* detect hardware features and fill the cookie jar */

    /* Set up the BIOS console output */
    KDEBUG(("linea_init()\n"));
    linea_init();       /* initialize screen related line-a variables */
    font_init();        /* initialize font ring (requires cookie_akp) */
    font_set_default(-1);/* set default font */
    vt52_init();        /* initialize the vt52 console */

    /* Now kcprintf() will also send debug info to the screen */
    KDEBUG(("after vt52_init()\n"));

    /* misc. variables */
    dumpflg = -1;
    sysbase = (LONG) os_entry;
    savptr = (LONG) trap_save_area;
    etv_timer = (void(*)(int)) just_rts;
    etv_critic = default_etv_critic;
    etv_term = just_rts;

    /* setup VBL queue */
    nvbls = 8;
    vblqueue = vbl_list;
    {
        int i;
        for(i = 0 ; i < 8 ; i++) {
            vbl_list[i] = 0;
        }
    }

#if CONF_WITH_MFP
    KDEBUG(("mfp_init()\n"));
    mfp_init();
#endif

#if CONF_WITH_TT_MFP
    if (has_tt_mfp)
    {
        KDEBUG(("tt_mfp_init()\n"));
        tt_mfp_init();
    }
#endif

    /* Initialize the system 200 Hz timer */
    KDEBUG(("init_system_timer()\n"));
    init_system_timer();

    /* Initialize the RS-232 port(s) */
    KDEBUG(("chardev_init()\n"));
    chardev_init();     /* Initialize low-memory bios vectors */
    boot_status |= CHARDEV_AVAILABLE;   /* track progress */
    KDEBUG(("init_serport()\n"));
    init_serport();
    boot_status |= RS232_AVAILABLE;     /* track progress */
#if CONF_WITH_SCC
    if (has_scc)
        boot_status |= SCC_AVAILABLE;   /* track progress */
#endif

    /* The sound init must be done before allowing MFC interrupts,
     * because of dosound stuff in the timer C interrupt routine.
     */
#if CONF_WITH_DMASOUND
    KDEBUG(("dmasound_init()\n"));
    dmasound_init();
#endif
    KDEBUG(("snd_init()\n"));
    snd_init();         /* Reset Soundchip, deselect floppies */

    /* Init the two ACIA devices (MIDI and KBD). The three actions below can
     * be done in any order provided they happen before allowing MFP
     * interrupts.
     */
    KDEBUG(("kbd_init()\n"));
    kbd_init();         /* init keyboard, disable mouse and joystick */
    KDEBUG(("midi_init()\n"));
    midi_init();        /* init MIDI acia so that kbd acia irq works */
    KDEBUG(("init_acia_vecs()\n"));
    init_acia_vecs();   /* Init the ACIA interrupt vector and related stuff */
    KDEBUG(("after init_acia_vecs()\n"));
    boot_status |= MIDI_AVAILABLE;  /* track progress */

    /* Now we can enable the interrupts.
     * We need a timer for DMA timeouts in floppy and harddisk initialisation.
     * The VBL processing will be enabled later with the vblsem semaphore.
     */
#if CONF_WITH_ATARI_VIDEO
    /* Keep the HBL disabled */
    set_sr(0x2300);
#else
    set_sr(0x2000);
#endif

    KDEBUG(("calibrate_delay()\n"));
    calibrate_delay();  /* determine values for delay() function */
                        /*  - requires interrupts to be enabled  */
    KDEBUG(("blkdev_init()\n"));
    blkdev_init();      /* floppy and harddisk initialisation */
    KDEBUG(("after blkdev_init()\n"));

    /* initialize BIOS components */

    KDEBUG(("parport_init()\n"));
    parport_init();     /* parallel port */
    //mouse_init();     /* init mouse driver */
    KDEBUG(("clock_init()\n"));
    clock_init();       /* init clock */
    KDEBUG(("after clock_init()\n"));

#if CONF_WITH_NLS
    KDEBUG(("nls_init()\n"));
    nls_init();         /* init native language support */
    nls_set_lang(get_lang_name());
#endif

    /* set start of user interface */
#if WITH_AES
    exec_os = ui_start;
#elif WITH_CLI
    exec_os = coma_start;
#else
    exec_os = NULL;
#endif

    KDEBUG(("osinit()\n"));
    osinit();                   /* initialize BDOS */
    KDEBUG(("after osinit()\n"));
    boot_status |= DOS_AVAILABLE;   /* track progress */

    /* Enable VBL processing */
    vblsem = 1;

#if CONF_WITH_CARTRIDGE
    {
        WORD save_hz = v_hz_rez, save_vt = v_vt_rez, save_pl = v_planes;

        /* Run all boot applications from the application cartridge.
         * Beware: Hatari features a special cartridge which is used
         * for GEMDOS drive emulation. It will hack drvbits and hook Pexec().
         * It will also hack Line A variables to enable extended VDI video modes.
         */
        KDEBUG(("run_cartridge_applications(3)\n"));
        run_cartridge_applications(3); /* Type "Execute prior to bootdisk" */
        KDEBUG(("after run_cartridge_applications()\n"));

        if ((v_hz_rez != save_hz) || (v_vt_rez != save_vt) || (v_planes != save_pl))
        {
            set_rez_hacked();
            font_set_default(-1);   /* set default font */
            vt52_init();            /* initialize the vt52 console */
        }
    }
#endif

#if CONF_WITH_ALT_RAM

#if CONF_WITH_FASTRAM
    /* add TT-RAM that was detected in memory.S */
    if (ramtop != NULL)
    {
        KDEBUG(("xmaddalt()\n"));
        xmaddalt(FASTRAM_START, ramtop - FASTRAM_START);
    }
#endif

#if CONF_WITH_MONSTER
    /* Add MonSTer alt-RAM detected in machine.c */
    if (has_monster)
    {
        /* Dummy read from MonSTer register to initiate write sequence. */
        unsigned short monster_reg = *(volatile unsigned short *)MONSTER_REG;

        /* Only enable 6Mb when on a Mega STE due to address conflict with
           VME bus. Todo: This should be made configurable. */
        if (has_vme)
            monster_reg = 6;
        else
            monster_reg = 8;

        /* Register write sequence: read - write - write */
        *(volatile unsigned short *)MONSTER_REG = monster_reg;
        *(volatile unsigned short *)MONSTER_REG = monster_reg;
        KDEBUG(("xmaddalt()\n"));
        xmaddalt((UBYTE *)0x400000L, monster_reg*0x100000L);
    }
#endif

#ifdef MACHINE_AMIGA
    KDEBUG(("amiga_add_alt_ram()\n"));
    amiga_add_alt_ram();
#endif

#endif /* CONF_WITH_ALT_RAM */

    KDEBUG(("bios_init() end\n"));
}