Exemplo n.º 1
0
int main(int ac, char **av, char **ev)
{
	struct stat tmp;
	char *file;
	pid_t pid;

	if (ac < 2)
		print_help();
	if (!(file = get_file_path(av[1], ev)))
	{
		ft_putendl_fd("Can't find exec in path", 2);
		exit(EXIT_SUCCESS);
	}
	if (stat(file, &tmp) == -1)
	{
		ft_putstr_fd("ft_strace: \"", 2);
		ft_putstr_fd(av[1], 2);
		ft_putstr_fd("\": No such file or directory", 2);
		exit(EXIT_FAILURE);
	}
	syscalls_init();
	signals_init();
	errno_init();
	pid = fork();
	if (pid == -1)
	{
		ft_putendl_fd("ft_strace: failed to fork", 2);
		exit(EXIT_FAILURE);
	}
	else if (pid == 0)
		child_launch(av, file);
	else
		parent_launch(pid);
	return (EXIT_SUCCESS);
}
Exemplo n.º 2
0
JNIEXPORT void JNICALL
Java_sun_nio_fs_LinuxNativeDispatcher_init(JNIEnv *env, jclass clazz)
{
#ifndef COMPILE_AGAINST_SYSCALLS
    syscalls_init();
#endif

    clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry");
    if (clazz == NULL)
        return;

    entry_name = (*env)->GetFieldID(env, clazz, "name", "[B");
    entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B");
    entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B");
    entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B");
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: pranas/jaos64
void kernel_entry (multiboot_info* bootinfo) 
{
	clear_screen();	puts("Kernel loaded.\n");
	gdt_install();  puts("GDT initialised.\n");
	idt_install();	puts("IDT initialised.\n");
    memman_init(bootinfo);
	kheap_init();
	fat32_init();
	// TODO: figure out how to do it safely
	//acpi_init();
	apic_init();
	ioapic_init(); // keyboard only for now

	register_handler(0x21, keyboard_handler);
	register_handler(0xD, gpf_handler);

	syscalls_init(); // maybe syscalls_init() like acpi_init, apic_init, etc... there should be common naming

	timer_init(0x20, 0x002fffff, 0xB, 1); // vector, counter, divider, periodic -- check manual before using

	// sets up kernel task and registers handler for timer
	scheduler_init();
	// registers locking sys
	monitor_init();
	keyboard_init();

	// testing scheduler
    if (fork_kernel() == 0)
    {
        if (!exec("SHELL"))
        {
            // something horrible happend
            // exit()
        }
        exit();
    }
    else
    {
        for(;;)
        {
			asm volatile("hlt");
        }
    }
	
	asm ("sti"); // release monsters, it can be set earlier, but fails horribly if set before acpi_init
    for(;;);
}
Exemplo n.º 4
0
void IRAM user_init (void)
{
    syscalls_init ();
    thread_isr_stack_init ();

    /* set system frequency */
    system_update_cpu_freq(ESP8266_CPU_FREQUENCY);

    /* reinit system timer as microsecond timer */
    system_timer_reinit ();

    /* setup the serial communication */
    uart_div_modify(0, UART_CLK_FREQ / STDIO_UART_BAUDRATE);

    /* once the ETS initialization is done we can start with our code as callback */
    system_init_done_cb(system_init);

    /* keep wifi interface in null mode per default */
    wifi_set_opmode_current (0);
}
Exemplo n.º 5
0
/**
 * Initializes the minimal system including CPU Clock, UART, and Flash accelerator
 * Be careful of the order of operations!!!
 */
void low_level_init(void)
{
    rtc_init();
    m_rtc_boot_time = rtc_gettime();

    /**
     * Configure System Clock based on desired clock rate @ sys_config.h
     * Setup default interrupt priorities that will work with FreeRTOS
     */
    sys_clock_configure();
    configure_flash_acceleration(sys_get_cpu_clock());
    configure_interrupt_priorities();
    __enable_irq();

    // Setup UART with minimum I/O functions
    uart0_init(UART0_DEFAULT_RATE_BPS);
    sys_set_outchar_func(uart0_putchar);
    sys_set_inchar_func(uart0_getchar);

    /**
     *  If buffers are set to 0, so printf/scanf will behave correctly!
     *  If not set, then printf/scanf will have weird buffering/flushing effects
     */
    setvbuf(stdout, 0, _IONBF, 0);
    setvbuf(stdin,  0, _IONBF, 0);

    /**
     * Set the semaphore for the malloc lock.
     * Initialize newlib fopen() fread() calls support
     */
    syscalls_init();

    /**
     * Enable watchdog to allow us to recover in case of:
     *  - We attempt to run an application and it's not there
     *  - Application we ran crashes
     */
    sys_watchdog_enable();
    print_boot_info();
}
Exemplo n.º 6
0
/**
 * Initializes the minimal system including CPU Clock, UART, and Flash accelerator
 * Be careful of the order of the operations!!!
 */
void low_level_init(void)
{
    rtc_init();
    g_rtc_boot_time = rtc_gettime();

    /* Configure System Clock based on desired clock rate @ sys_config.h */
    sys_clock_configure();
    configure_flash_acceleration(sys_get_cpu_clock());

    /* Setup default interrupt priorities that will work with FreeRTOS */
    configure_interrupt_priorities();

    /* These methods shouldn't be needed but doing it anyway to be safe */
    NVIC_SetPriorityGrouping(0);
    __set_BASEPRI(0);
    __enable_fault_irq();
    __enable_irq();

    /* Setup UART with minimal I/O functions */
    uart0_init(SYS_CFG_UART0_BPS);
    sys_set_outchar_func(uart0_putchar);
    sys_set_inchar_func(uart0_getchar);

    /**
     * Turn off I/O buffering otherwise sometimes printf/scanf doesn't behave
     * correctly due to strange buffering and/or flushing effects.
     */
    setvbuf(stdout, 0, _IONBF, 0);
    setvbuf(stdin,  0, _IONBF, 0);

    /* Initialize newlib fopen() fread() calls support */
    syscalls_init();

    /* Enable the watchdog to allow us to recover in an event of system crash */
    sys_watchdog_enable();

    /* Uart and printf() are initialized, so print our boot-up message */
    print_boot_info();
}
/**
 * Initializes the minimal system including CPU Clock, UART, and Flash accelerator
 * Be careful of the order of operations!!!
 */
void low_level_init(void)
{
    rtc_init();
    g_rtc_boot_time = rtc_gettime();

    /**
     * Configure System Clock based on desired clock rate @ sys_config.h
     * Setup default interrupt priorities that will work with FreeRTOS
     */
    sys_clock_configure();
    configure_flash_acceleration(sys_get_cpu_clock());
    configure_interrupt_priorities();
    __enable_irq();

    // Setup UART with minimum I/O functions
    uart0_init(UART0_DEFAULT_RATE_BPS);
    sys_set_outchar_func(uart0_putchar);
    sys_set_inchar_func(uart0_getchar);

    /**
     * Turn off I/O buffering otherwise sometimes printf/scanf doesn't behave
     * correctly due to strange buffering and/or flushing effects.
     */
    setvbuf(stdout, 0, _IONBF, 0);
    setvbuf(stdin,  0, _IONBF, 0);

    // Initialize newlib fopen() fread() calls support
    syscalls_init();

    /**
     * Enable watchdog to allow us to recover in case of:
     *  - We attempt to run an application and it's not there
     *  - Application we ran crashes
     */
    sys_watchdog_enable();
    print_boot_info();
}
Exemplo n.º 8
0
void monitor_init(uint32_t core_id)
{

#if TARGET_NUM_CORES > 1
    /* Target-dependent master initialization */
    if (core_id == TARGET_PRIMARY_CORE_ID) {
        target_primary_core_init();
    }
#endif /* TARGET_NUM_CORES > 1 */

    /* Barrier: .bss and .data sections is initialization */
    initialization_barrier(core_id);

    /* Set up the Monitor Vector Base Address Register (MVBAR) */
    CP15_MVBAR_WRITE(&monitor_vector_table);

    /* Set up the Secure Configuration Register (SCR) for the T OS */
    CP15_SCR_WRITE(MON_T_SCR);

    /* Set up the Non-Secure Access Control Register (NSACR) */
    CP15_NSACR_WRITE(MON_NSACR);

    /* Target-dependent initialization */
    target_init(core_id);

    /* Barrier: target-dependent initialization */
    phase_barrier(core_id, 1);

    /* Initialize libraries in the primary core only */
    if (core_id == TARGET_PRIMARY_CORE_ID) {
        syscalls_init();
        notifier_init();
    }

    /* Barrier: monitor initialization is finished */
    phase_barrier(core_id, 2);
}