Example #1
0
/**
 * @brief Initializes the OpenBoot PROM interface on an early boot stage.
 * Before using any routines in the prom library, prom_init() must be
 * called. This should be one of the first things to be done on bootup,
 * since it provides the output sink and the prom version that it used
 * for feedback and debugging purposes.
 */
void prom_init() {

  node_chosen = prom_finddevice("/chosen");
  if (!node_chosen || (int) node_chosen == -1)
    prom_exit();

  if(prom_getprop(node_chosen, "stdout", &node_stdout,
      sizeof(node_stdout)) <= 0)
    node_stdout = 0;

  if(prom_getprop(node_stdin, "stdin", &node_stdin,
      sizeof(node_stdin)) <= 0)
    node_stdin = 0;

  node_root = prom_finddevice("/");
  if (!node_root || (int) node_root == -1) {
    printk("Error: / device not found.\n");
    prom_exit();
  }

  if(prom_getprop(node_root, "compatible", prom_subarch,
    sizeof(prom_subarch)) <= 0) {
    printk("Note: compatible property not set.\n");
    /* not important, we can check compatibility with the %ver register */
    strncpy(prom_subarch, "unknown", 7);
  }

  node_obp = prom_finddevice("/openprom");
  if (!node_obp || (int) node_obp == -1) {
    printk("Error: /openprom device not found.\n");
    prom_exit();
  }

  if(prom_getprop(node_obp, "version", prom_version,
    sizeof(prom_version)) <= 0) {
    printk("Error: /openprom version property not found.\n");
    prom_exit();
  }
  if(strncmp("OBP ", prom_version, 4)) {
    printk("Error: Unknown OpenPROM version.\n");
    prom_exit();
  }

  prom_getprop(node_chosen, "bootpath", prom_bootpath,
               sizeof(prom_bootpath));
  prom_getprop(node_chosen, "bootargs", prom_bootargs,
               sizeof(prom_bootargs));

  /* if we found stdout, we can now clear the screen for the boot messages */
  if(node_stdout != 0)
    clear_screen();
}
Example #2
0
void exit(int status) {
	prom_exit();
}
Example #3
0
File: main.c Project: andreiw/iQUIK
/* Here we are launched */
void
iquik_main(void *a1,
           void *a2,
           void *prom_entry)
{
   char *params;
   quik_err_t err;
   load_state_t image;

   err = prom_init(prom_entry);
   if (err != ERR_NONE) {
      prom_exit();
   }

   printk("\niQUIK OldWorld Bootloader\n");
   printk("Copyright (C) 2016 Andrei Warkentin <*****@*****.**>\n");
   if (bi->flags & SHIM_OF) {
      printk("This firmware requires a shim to work around bugs\n");
   }

   err = malloc_init();
   if (err != ERR_NONE) {
      goto error;
   }

   err = cmd_init();
   if (err != ERR_NONE) {
      goto error;
   }

   err = env_init();
   if (err != ERR_NONE) {
      goto error;
   }

   err = load_config();
   if (err != ERR_NONE) {
      printk("No configration file parsed: %r\n", err);
   }

   for (;;) {
      params = NULL;

      err = try_load_loop(&image, &params);
      if (err == ERR_NONE) {
         break;
      }
   }

   err = elf_relo(&image);
   if (err != ERR_NONE) {
      goto error;
   }

   if (bi->flags & BOOT_PRE_2_4 &&
       bi->flags & SHIM_OF) {
      printk("OF shimming unsupported for pre-2.4 kernels\n");
      bi->flags ^= SHIM_OF;
   }

   if (bi->flags & DEBUG_BEFORE_BOOT) {
      if (bi->flags & BOOT_PRE_2_4) {
         printk("Booting pre-2.4 kernel\n");
      }

      printk("Kernel: 0x%x @ 0x%x\n", image.text_len, image.linked_base);
      printk("Initrd: 0x%x @ 0x%x\n", bi->initrd_len, bi->initrd_base);
      printk("Kernel parameters: %s\n", params);
      printk("Kernel entry: 0x%x\n", image.entry);
      prom_pause(NULL);
   } else if (bi->flags & PAUSE_BEFORE_BOOT) {
      prom_pause(bi->pause_message);
   }

   err = elf_boot(&image, params);
error:
   printk("Exiting on error: %r", err);
   prom_exit();
}