Bootstrap.c 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. #include "pal.h"
  4. #include "pal_debug.h"
  5. static int test_data = 0;
  6. static int test_func (void) { return 0; }
  7. int main (int argc, char ** argv, char ** envp)
  8. {
  9. /* check if the program is loaded */
  10. pal_printf("User Program Started\n");
  11. /* check control block */
  12. /* check executable name */
  13. pal_printf("Loaded Executable: %s\n", pal_control.executable);
  14. /* check manifest name */
  15. char manifest[30] = "";
  16. DkStreamGetName(pal_control.manifest_handle, manifest, 30);
  17. pal_printf("Loaded Manifest: %s\n", manifest);
  18. /* check arguments */
  19. pal_printf("# of Arguments: %d\n", argc);
  20. for (int i = 0 ; i < argc ; i++)
  21. pal_printf("argv[%d] = %s\n", i, argv[i]);
  22. /* unique process ID */
  23. pal_printf("Process ID: %016lx\n", pal_control.process_id);
  24. /* unique host ID */
  25. pal_printf("Host ID: %016lx\n", pal_control.host_id);
  26. /* parent process */
  27. pal_printf("Parent Process: %p\n", pal_control.parent_process);
  28. /* test debug stream */
  29. char msg[] = "Written to Debug Stream\n";
  30. DkStreamWrite(pal_control.debug_stream, 0, sizeof(msg), msg, NULL);
  31. /* page size */
  32. pal_printf("Page Size: %ld\n", pal_control.pagesize);
  33. /* Allocation Alignment */
  34. pal_printf("Allocation Alignment: %ld\n", pal_control.alloc_align);
  35. /* user address range */
  36. pal_printf("User Address Range: %p - %p\n",
  37. pal_control.user_address.start,
  38. pal_control.user_address.end);
  39. if (pal_control.user_address.start &&
  40. pal_control.user_address.end &&
  41. pal_control.user_address.start < pal_control.user_address.end)
  42. pal_printf("User Address Range OK\n");
  43. /* executable address range */
  44. pal_printf("Executable Range: %p - %p\n",
  45. pal_control.executable_range.start,
  46. pal_control.executable_range.end);
  47. if (pal_control.executable_range.start &&
  48. pal_control.executable_range.end &&
  49. pal_control.executable_range.start < (void *) &test_data &&
  50. (void *) &test_data < pal_control.executable_range.end &&
  51. pal_control.executable_range.start < (void *) &test_func &&
  52. (void *) &test_func < pal_control.executable_range.end)
  53. pal_printf("Executable Range OK\n");
  54. pal_printf("CPU num: %ld\n", pal_control.cpu_info.cpu_num);
  55. pal_printf("CPU vendor: %s\n", pal_control.cpu_info.cpu_vendor);
  56. pal_printf("CPU brand: %s\n", pal_control.cpu_info.cpu_brand);
  57. pal_printf("CPU family: %ld\n", pal_control.cpu_info.cpu_family);
  58. pal_printf("CPU model: %ld\n", pal_control.cpu_info.cpu_model);
  59. pal_printf("CPU stepping: %ld\n", pal_control.cpu_info.cpu_stepping);
  60. pal_printf("CPU flags: %s\n", pal_control.cpu_info.cpu_flags);
  61. return 0;
  62. }