init.c 734 B

12345678910111213141516171819202122232425262728293031
  1. #include <libc/unistd.h>
  2. #include <libc/stdio.h>
  3. #include <libc/fcntl.h>
  4. int main()
  5. {
  6. char string[] = "333.txt";
  7. uint8_t buf[128] = {0};
  8. char tips_str[] = "The first application 'init.bin' started successfully!\n";
  9. put_string(tips_str, COLOR_GREEN, COLOR_BLACK);
  10. int fd = open(string, 0);
  11. read(fd, buf, 128);
  12. put_string(buf, COLOR_ORANGE, COLOR_BLACK);
  13. lseek(fd, 0, SEEK_SET);
  14. write(fd, tips_str, sizeof(tips_str)-1);
  15. lseek(fd, 0, SEEK_SET);
  16. // 由于暂时没有实现用户态的memset,因此先手动清零
  17. for(int i=0;i<128;++i)
  18. buf[i] = 0;
  19. read(fd, buf, 128);
  20. put_string(buf, COLOR_YELLOW, COLOR_BLACK);
  21. close(fd);
  22. while (1)
  23. ;
  24. }