Bootstrap.c 2.7 KB

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