Bootstrap.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include <string.h>
  2. #include "pal.h"
  3. #include "pal_debug.h"
  4. static int test_data = 0;
  5. static int test_func(void) {
  6. return 0;
  7. }
  8. int main(int argc, char** argv, char** envp) {
  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. }
  23. /* unique process ID */
  24. pal_printf("Process ID: %016lx\n", pal_control.process_id);
  25. /* unique host ID */
  26. pal_printf("Host ID: %016lx\n", pal_control.host_id);
  27. /* parent process */
  28. pal_printf("Parent Process: %p\n", pal_control.parent_process);
  29. /* test debug stream */
  30. char* msg = "Written to Debug Stream\n";
  31. DkStreamWrite(pal_control.debug_stream, 0, strlen(msg), msg, NULL);
  32. /* page size */
  33. pal_printf("Page Size: %ld\n", pal_control.pagesize);
  34. /* Allocation Alignment */
  35. pal_printf("Allocation Alignment: %ld\n", pal_control.alloc_align);
  36. /* user address range */
  37. pal_printf("User Address Range: %p - %p\n", pal_control.user_address.start,
  38. pal_control.user_address.end);
  39. if (pal_control.user_address.start && 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", pal_control.executable_range.start,
  44. pal_control.executable_range.end);
  45. if (pal_control.executable_range.start && pal_control.executable_range.end &&
  46. pal_control.executable_range.start < (void*)&test_data &&
  47. (void*)&test_data < pal_control.executable_range.end &&
  48. pal_control.executable_range.start < (void*)&test_func &&
  49. (void*)&test_func < pal_control.executable_range.end)
  50. pal_printf("Executable Range OK\n");
  51. pal_printf("CPU num: %ld\n", pal_control.cpu_info.cpu_num);
  52. pal_printf("CPU vendor: %s\n", pal_control.cpu_info.cpu_vendor);
  53. pal_printf("CPU brand: %s\n", pal_control.cpu_info.cpu_brand);
  54. pal_printf("CPU family: %ld\n", pal_control.cpu_info.cpu_family);
  55. pal_printf("CPU model: %ld\n", pal_control.cpu_info.cpu_model);
  56. pal_printf("CPU stepping: %ld\n", pal_control.cpu_info.cpu_stepping);
  57. pal_printf("CPU flags: %s\n", pal_control.cpu_info.cpu_flags);
  58. return 0;
  59. }