示例#1
0
文件: main.c 项目: JanmanX/KUDOS
void init(void)
{
    TID_t startup_thread;
    int numcpus;

    /* Initialise Static Allocation */
    stalloc_init();

    /* Initialize polling TTY driver for kprintf() usage. */
    polltty_init();

    kwrite("Kudos is an educational operating system by the University of Copenhagen\n");
    kwrite("========================================================================\n");
    kwrite("Based on the Buenos operating system skeleton\n");
    kwrite("\n");

    kprintf("Copyright (C) 2003-2016  Juha Aatrokoski, Timo Lilja,\n");
    kprintf("  Leena Salmela, Teemu Takanen, Aleksi Virtanen, Philip Meulengracht,\n");
    kprintf("  Troels Henriksen, Annie Jane Pinder, Niels Gustav Westphal Serup,\n");
    kprintf("  Nicklas Warming Jacobsen, Oleksandr Shturmov.\n");
    kwrite("See the file COPYING for licensing details.\n");
    kwrite("\n");

    kwrite("Reading boot arguments\n");
    bootargs_init((void*)BOOT_ARGUMENT_AREA);

    /* Seed the random number generator. */
    if (bootargs_get("randomseed") == NULL) {
        _set_rand_seed(0);
    } else {
        int seed = atoi(bootargs_get("randomseed"));
        kprintf("Seeding pseudorandom number generator with %i\n", seed);
        _set_rand_seed(seed);
    }

    numcpus = cpustatus_count();
    kprintf("Detected %i CPUs\n", numcpus);
    KERNEL_ASSERT(numcpus <= CONFIG_MAX_CPUS);

    kwrite("Initializing interrupt handling\n");
    interrupt_init(numcpus);

    kwrite("Initializing threading system\n");
    thread_table_init();

    kwrite("Initializing sleep queue\n");
    sleepq_init();

    kwrite("Initializing semaphores\n");
    semaphore_init();

    kwrite("Initializing device drivers\n");
    device_init();

    kprintf("Initializing virtual filesystem\n");
    vfs_init();

    kwrite("Initializing scheduler\n");
    scheduler_init();

    kwrite("Initializing virtual memory\n");
    vm_init();

    kprintf("Creating initialization thread\n");
    startup_thread = thread_create(&init_startup_thread, 0);
    thread_run(startup_thread);

    kprintf("Starting threading system and SMP\n");

    /* Let other CPUs run */
    kernel_bootstrap_finished = 1;

    _interrupt_clear_bootstrap();
    _interrupt_enable();

    /* Enter context switch, scheduler will be run automatically,
       since thread_switch() behaviour is identical to timer tick
       (thread timeslice is over). */
    thread_switch();

    /* We should never get here */
    KERNEL_PANIC("Threading system startup failed.");
}
示例#2
0
文件: main.c 项目: cfrost/buenos
void init(void)
{
    TID_t startup_thread;
    int numcpus;

    /* Initialize polling TTY driver for kprintf() usage. */
    polltty_init();

    kwrite("BUENOS is a University Educational Nutshell Operating System\n");
    kwrite("==========================================================\n");
    kwrite("\n");

    kwrite("Copyright (C) 2003-2006  Juha Aatrokoski, Timo Lilja,\n");
    kwrite("  Leena Salmela, Teemu Takanen, Aleksi Virtanen\n");
    kwrite("See the file COPYING for licensing details.\n");
    kwrite("\n");

    kwrite("Initializing memory allocation system\n");
    kmalloc_init();

    kwrite("Reading boot arguments\n");
    bootargs_init();

    /* Seed the random number generator. */
    if (bootargs_get("randomseed") == NULL) {
	_set_rand_seed(0);
    } else {
	int seed = atoi(bootargs_get("randomseed"));
	kprintf("Seeding pseudorandom number generator with %i\n", seed);
	_set_rand_seed(seed);
    }

    numcpus = cpustatus_count();
    kprintf("Detected %i CPUs\n", numcpus);
    KERNEL_ASSERT(numcpus <= CONFIG_MAX_CPUS);

    kwrite("Initializing interrupt handling\n");
    interrupt_init(numcpus);

    kwrite("Initializing threading system\n");
    thread_table_init();

    kwrite("Initializing user process system\n");
    process_init();

    kwrite("Initializing sleep queue\n");
    sleepq_init();

    kwrite("Initializing semaphores\n");
    semaphore_init();

    kwrite("Initializing device drivers\n");
    device_init();

    kprintf("Initializing virtual filesystem\n");
    vfs_init();

    kwrite("Initializing scheduler\n");
    scheduler_init();

    kwrite("Initializing virtual memory\n");
    vm_init();

    kprintf("Creating initialization thread\n");
    startup_thread = thread_create(&init_startup_thread, 0);
    thread_run(startup_thread);

    kprintf("Starting threading system and SMP\n");

    /* Let other CPUs run */
    kernel_bootstrap_finished = 1;
    
    _interrupt_clear_bootstrap();
    _interrupt_enable();

    /* Enter context switch, scheduler will be run automatically,
       since thread_switch() behaviour is identical to timer tick
       (thread timeslice is over). */
    thread_switch();

    /* We should never get here */
    KERNEL_PANIC("Threading system startup failed.");
}
示例#3
0
文件: main.c 项目: DIKU-EDU/kudos
int init(uint64_t magic, uint8_t *multiboot)
{
  /* Setup Static Allocation System */
  multiboot_info_t *mb_info = (multiboot_info_t*)multiboot;
  TID_t startup_thread;
  stalloc_init();

  /* Setup video printing */
  polltty_init();

  kwrite("KUDOS - a skeleton OS for exploring OS concepts\n");
  kwrite("===============================================\n");
  kwrite("\n");
  kwrite("KUDOS is heavily based on BUENOS.\n");
  kwrite("\n");
  kwrite("Copyright (C) 2015-2016 Troels Henriksen, Annie Jane Pinder,\n");
  kwrite("      Niels Gustav Westphal Serup, Oleksandr Shturmov,\n");
  kwrite("      Nicklas Warming Jacobsen.\n");
  kwrite("\n");
  kwrite("Copyright (C) 2014 Philip Meulengracht.\n");
  kwrite("\n");
  kwrite("Copyright (C) 2003-2012 Juha Aatrokoski, Timo Lilja,\n");
  kwrite("      Leena Salmela, Teemu Takanen, Aleksi Virtanen.\n");
  kwrite("\n");
  kwrite("See the file COPYING for licensing details.\n");
  kwrite("\n");

  /* Setup GDT/IDT/Exceptions */
  kprintf("Initializing interrupt handling\n");
  interrupt_init(1);

  /* Read boot args */
  kprintf("Reading boot arguments\n");
  bootargs_init((void*)(uint64_t)mb_info->cmdline);

  /* Setup Memory */
  kprintf("Initializing memory system\n");
  physmem_init(multiboot);
  vm_init();

  /* Seed the random number generator. */
  if (bootargs_get("randomseed") == NULL) {
    _set_rand_seed(0);
  } else {
    int seed = atoi((char*)(uint64_t)bootargs_get("randomseed"));
    kprintf("Seeding pseudorandom number generator with %i\n", seed);
    _set_rand_seed(seed);
  }

  /* Setup Threading */
  kprintf("Initializing threading table\n");
  thread_table_init();

  kprintf("Initializing sleep queue\n");
  sleepq_init();

  kprintf("Initializing semaphores\n");
  semaphore_init();

  /* Start scheduler */
  kprintf("Initializing scheduler\n");
  scheduler_init();

  /* Setup Drivers */
  kprintf("Initializing device drivers\n");
  device_init();

  /* Initialize modules */
  kprintf("Initializing kernel modules\n");
  modules_init();

  kprintf("Initializing virtual filesystem\n");
  vfs_init();

  kprintf("Creating initialization thread\n");
  startup_thread = thread_create(init_startup_thread, 0);
  thread_run(startup_thread);

  kprintf("Starting threading system and SMP\n");

  /* Enter context switch, scheduler will be run automatically,
     since thread_switch() behaviour is identical to timer tick
     (thread timeslice is over). */
  thread_switch();

  return 0xDEADBEEF;
}