init.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <libc/unistd.h>
  2. #include <libc/stdio.h>
  3. #include <libc/fcntl.h>
  4. #include <libc/stdlib.h>
  5. int main()
  6. {
  7. char string[] = "333.txt";
  8. uint8_t buf[128] = {0};
  9. char tips_str[] = "The first application 'init.bin' started successfully!\n";
  10. put_string(tips_str, COLOR_GREEN, COLOR_BLACK);
  11. printf("test printf: %s size: %d\n", string, sizeof(string));
  12. /*
  13. int fd = open(string, 0);
  14. printf("fd=%d\n", fd);
  15. read(fd, buf, 128);
  16. put_string(buf, COLOR_ORANGE, COLOR_BLACK);
  17. lseek(fd, 0, SEEK_SET);
  18. write(fd, tips_str, sizeof(tips_str)-1);
  19. lseek(fd, 0, SEEK_SET);
  20. // 由于暂时没有实现用户态的memset,因此先手动清零
  21. for(int i=0;i<128;++i)
  22. buf[i] = 0;
  23. read(fd, buf, 128);
  24. put_string(buf, COLOR_YELLOW, COLOR_BLACK);
  25. close(fd);
  26. */
  27. char *p = malloc(100);
  28. *p = 'a';
  29. printf("p=%lld\t*p=%c\n", (uint64_t)p, *p);
  30. // *p = 'a';
  31. /*
  32. pid_t p = fork();
  33. if(p == 0)
  34. put_string("subproc\n", COLOR_PURPLE, COLOR_BLACK);
  35. else put_string("parent proc\n", COLOR_ORANGE, COLOR_BLACK);
  36. */
  37. while (1)
  38. ;
  39. }