..Bootstrap.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: %016x\n", pal_control.process_id);
  24. /* unique host ID */
  25. pal_printf("Host ID: %016x\n", pal_control.host_id);
  26. /* parent process */
  27. pal_printf("Parent Process: %016lx\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: %d\n", pal_control.pagesize);
  33. /* Allocation Alignment */
  34. pal_printf("Allocation Alignment: %d\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. return 0;
  55. }