示例#1
0
文件: ata-main.c 项目: vladsor/chaos
int main (void)
{
  ipc_structure_type ipc_structure;
  ata_drive_type *ata_drive;
  unsigned int drive_number;

  /* Set the name of the server. */

  system_process_name_set (PACKAGE_NAME);
  system_thread_name_set ("Initialising");

  log_init (&log_structure, PACKAGE_NAME, &empty_tag);

  for ( drive_number = 0 ; drive_number < number_of_probe ; drive_number++ )
  {
    if (!register_ports (ata_probe_drives[drive_number]))
    {
      continue;
    }

    ata_drive = ata_probe (ata_probe_drives[drive_number]);

    if (ata_drive != NULL)
    {
      switch (ata_drive->type)
      {
	case ATA_HARD_DRIVE :
        {
	  create_hard_drive_service (ata_drive);
          break;
        }

	case ATA_CDROM :
        {
	  create_cdrom_service (ata_drive);
          break;
        }
        /* FIXME: what we must do there ? */
        default :
        {
        }
      }
      ata_drivers[number_of_drives] = ata_drive;
      number_of_drives++;
    }
    else
    {
      unregister_ports (ata_probe_drives[drive_number]);
    }
  }

  system_call_process_parent_unblock ();
  return 0;
}
示例#2
0
int main (void)
{
  pci_device_info_type *device_info;
  unsigned int number_of_devices;
  unsigned int counter;
  unsigned int probe_counter;
  
  system_process_name_set (PACKAGE_NAME);
  system_thread_name_set ("Initialising");
  
  if (log_init (&log_structure, PACKAGE_NAME, &empty_tag) !=
      LOG_RETURN_SUCCESS)
  {
    return -1;
  }
  
  if (pci_init (&pci_structure, &empty_tag) != PCI_RETURN_SUCCESS)
  {
    log_print (&log_structure, LOG_URGENCY_EMERGENCY, 
               "Couldn't create connection to PCI service.");
    return -1;
  }

  system_call_process_parent_unblock ();

  for (probe_counter = 0; pci_device_probe[probe_counter].vendor_id !=
         0xFFFF; probe_counter++)
  {
    pci_device_exists (&pci_structure, &pci_device_probe[probe_counter],
                       &device_info, &number_of_devices);
    
    if (number_of_devices != 0)
    {
      for (counter = 0; counter < number_of_devices; counter++)
      {
        if (system_thread_create () == SYSTEM_RETURN_THREAD_NEW)
        {
          handle_8139 (&device_info[counter]);
        }
      }
    }
  }

  return 0;
}
示例#3
0
int main (void)
{
  ipc_structure_type ipc_structure;
  mailbox_id_type mailbox_id[10];
  unsigned int services = 10;

  system_process_name_set (PACKAGE_NAME);
  system_thread_name_set ("Initialising");
  
  if (log_init (&log_structure, PACKAGE_NAME, &empty_tag) !=
      LOG_RETURN_SUCCESS)
  {
    return -1;
  }
    
  /* Create our service. */

  if (ipc_service_create ("file_system", &ipc_structure, &empty_tag) != 
      STORM_RETURN_SUCCESS)
  {
    log_print (&log_structure, LOG_URGENCY_EMERGENCY,
               "Couldn't create a file system service.");
    return -1;
  }

  system_call_process_parent_unblock ();

  if (ipc_service_resolve ("virtual_file_system", mailbox_id, &services, 0, 
                           &empty_tag) != IPC_RETURN_SUCCESS)
  {
    log_print (&log_structure, LOG_URGENCY_EMERGENCY, 
               "Couldn't resolve VFS service.");
    return -1;
  }

  ipc_structure.output_mailbox_id = mailbox_id[0];
  ipc_service_connection_request (&ipc_structure);
  handle_connection (&ipc_structure);

  return 0;
}
示例#4
0
文件: boot.c 项目: vladsor/chaos
int main (void)
{
#if FALSE
  virtual_file_system_mount_type mount;
  mailbox_id_type mailbox_id[10];
  ipc_structure_type vfs_structure;
  message_parameter_type message_parameter;
  file_read_type read;
  file_handle_type handle;
  file_verbose_directory_entry_type directory_entry;
  u8 *buffer;
  u8 *server_name_buffer;
  char *server[MAX_SERVERS];
  unsigned int where, number_of_servers = 0, server_number;
  process_id_type process_id;
  unsigned int bytes_read;
  unsigned int services = 10;
#endif

  /* Set our name. */

  system_process_name_set (PACKAGE_NAME);
  system_thread_name_set ("Initialising");

  if (log_init (&log_structure, PACKAGE_NAME, &empty_tag) !=
      LOG_RETURN_SUCCESS)
  {
    return -1;
  }

#if FALSE

  /* Mount the initial ramdisk as //ramdisk. To do this, we must first
     hook up a connection to the VFS service and resolve the first
     block service. */
    
  if (ipc_service_resolve ("virtual_file_system", mailbox_id, &services, 5, 
                           &empty_tag) != IPC_RETURN_SUCCESS)
  {
    log_print (&log_structure, LOG_URGENCY_EMERGENCY,
               "Couldn't resolve the VFS service.");
    return -1;
  }

  vfs_structure.output_mailbox_id = mailbox_id[0];

  if (ipc_service_connection_request (&vfs_structure) != IPC_RETURN_SUCCESS)
  {
    log_print (&log_structure, LOG_URGENCY_EMERGENCY,
               "Couldn't connect to the VFS service.");
    return -1;
  }

  services = 1;

  if (ipc_service_resolve ("block", mailbox_id, &services, 5, &empty_tag) !=
      IPC_RETURN_SUCCESS)
  {
    log_print (&log_structure, LOG_URGENCY_EMERGENCY, 
               "No block services found.");
    return -1;
  }

  mount.mailbox_id = mailbox_id[0];
  string_copy (mount.location, "ramdisk");

  /* That's it. Send the message. */

  message_parameter.protocol = IPC_PROTOCOL_VIRTUAL_FILE_SYSTEM;
  message_parameter.message_class = IPC_VIRTUAL_FILE_SYSTEM_MOUNT;
  message_parameter.data = &mount;
  message_parameter.length = sizeof (virtual_file_system_mount_type);
  message_parameter.block = TRUE;
  ipc_send (vfs_structure.output_mailbox_id, &message_parameter);

  log_print (&log_structure, LOG_URGENCY_DEBUG,
             "Mounted the first available block service as //ramdisk.");

  /* Now, read the list of servers to start from here. */

  log_print (&log_structure, LOG_URGENCY_DEBUG, "Reading startup script...");
  string_copy (directory_entry.path_name, STARTUP_FILE);
  if (file_get_info (&vfs_structure, &directory_entry) != FILE_RETURN_SUCCESS)
  {
    log_print (&log_structure, LOG_URGENCY_ERROR,
               STARTUP_FILE " not found.");
    return -1;
  }

  memory_allocate ((void **) &server_name_buffer, directory_entry.size);

  file_open (&vfs_structure, STARTUP_FILE, FILE_MODE_READ, &handle);
  file_read (&vfs_structure, handle, directory_entry.size,
             &server_name_buffer);

  /* Parse the file. */

  server[0] = &server_name_buffer[0];
  number_of_servers++;

  for (where = 1; where < directory_entry.size; where++)
  {

    if (server_name_buffer[where] == '\n')
    {
      server_name_buffer[where] = '\0';
      if (where + 1 < directory_entry.size)
      {
        server[number_of_servers] = &server_name_buffer[where + 1];
        number_of_servers++;
      }
    }
  }

  log_print_formatted (&log_structure, LOG_URGENCY_DEBUG,
                       "Starting %u servers.", number_of_servers);

  for (server_number = 0; server_number < number_of_servers; server_number++)
  {
    log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE, 
                         "Starting %s.", server[server_number]);

    string_copy (directory_entry.path_name, server[server_number]);
    if (file_get_info (&vfs_structure, &directory_entry) !=
        FILE_RETURN_SUCCESS)
    {
      log_print_formatted (&log_structure, LOG_URGENCY_ERROR,
                           "'%s' could not be accessed!",
                           server[server_number]);
      continue;
    }

    /* Open the file. */

    file_open (&vfs_structure, server[server_number], FILE_MODE_READ, &handle);
    read.file_handle = handle;
    
    bytes_read = 0;

    log_print_formatted (&log_structure, LOG_URGENCY_DEBUG,
                         "Allocating %lu bytes for %s.",
                         directory_entry.size, server[server_number]);

    memory_allocate ((void **) &buffer, directory_entry.size);

    log_print_formatted (&log_structure, LOG_URGENCY_DEBUG,
                         "Buffer is at %p.", buffer);
    
    while (bytes_read < directory_entry.size)
    {
      unsigned int bytes;

      /* Read the file. */
    
      bytes = directory_entry.size - bytes_read;
      if (bytes > 32 * KB)
      {
        bytes = 32 * KB;
      }
      file_read (&vfs_structure, handle, bytes, &buffer[bytes_read]);
      bytes_read += bytes;
    }
    
    switch (execute_elf ((elf_header_type *) buffer, "", &process_id))
    {
      case EXECUTE_ELF_RETURN_SUCCESS:
      {
        log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE,
                             "New process ID %lu.",
                              process_id);
        break;
      }
      
      case EXECUTE_ELF_RETURN_IMAGE_INVALID:
      {
        log_print (&log_structure, LOG_URGENCY_ERROR,
                   "Invalid ELF image.");
        break;
      }
      
      case EXECUTE_ELF_RETURN_ELF_UNSUPPORTED:
      {
        log_print (&log_structure, LOG_URGENCY_ERROR,
                   "Unsupported ELF.");
        break;
      }
      
      case EXECUTE_ELF_RETURN_FAILED:
      {
        log_print (&log_structure, LOG_URGENCY_ERROR,
                   "system_process_create failed.");
        break;
      }
    }

    memory_deallocate ((void **) &buffer);
  }

#endif

  system_call_process_parent_unblock ();

  log_print (&log_structure, LOG_URGENCY_DEBUG, "surf");

  return 0;
}