{"id":294443,"date":"2019-09-09T15:00:19","date_gmt":"2019-09-09T15:00:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=294443"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=294443","title":{"rendered":"\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u043e\u0439 Unix \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 OS \u2014 \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0436\u0443\u0440\u043d\u0430\u043b \u044f\u0434\u0440\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/466709\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439<\/a> \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e \u0441\u0447\u0435\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0421. \u0412 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0436\u0443\u0440\u043d\u0430\u043b \u044f\u0434\u0440\u0430.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<h4>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>  1. \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 (make, gcc, gas). \u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 (multiboot). \u0417\u0430\u043f\u0443\u0441\u043a (qemu). \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 C (strcpy, memcpy, strext).<br \/>  2. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 C (sprintf, strcpy, strcmp, strtok, va_list &#8230;). \u0421\u0431\u043e\u0440\u043a\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u044f\u0434\u0440\u0430 \u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>  3. \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0436\u0443\u0440\u043d\u0430\u043b \u044f\u0434\u0440\u0430. \u0412\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u044c. \u0412\u044b\u0432\u043e\u0434 \u043d\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b (kprintf, kpanic, kassert).<br \/>  4. \u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c, \u043a\u0443\u0447\u0430 (kmalloc, kfree).<br \/>  6. \u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 (GDT, IDT, PIC, syscall). \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<br \/>  5. \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c (\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446).<br \/>  6. \u041f\u0440\u043e\u0446\u0435\u0441\u0441. \u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a. \u041c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u044c. \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b (kill, exit, ps).<br \/>  7. \u0424\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u044f\u0434\u0440\u0430 (initrd), elf \u0438 \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b (exec).<br \/>  8. \u0414\u0440\u0430\u0439\u0432\u0435\u0440\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432. \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b (ioctl, fopen, fread, fwrite). \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 C (fopen, fclose, fprintf, fscanf).<br \/>  9. \u041e\u0431\u043e\u043b\u043e\u0447\u043a\u0430 \u043a\u0430\u043a \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u044f\u0434\u0440\u0430.<br \/>  10. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0440\u0435\u0436\u0438\u043c \u0437\u0430\u0449\u0438\u0442\u044b (ring3). \u0421\u0435\u0433\u043c\u0435\u043d\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 (tss).<\/p>\n<h4>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0436\u0443\u0440\u043d\u0430\u043b \u044f\u0434\u0440\u0430<\/h4>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u0442\u044c, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0440\u0442\u0430\u043c\u0438 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430. \u041f\u043e\u0440\u0442\u044b \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u044f\u0447\u0435\u0435\u043a \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u044d\u0442\u0438\u043c\u0438 \u043f\u043e\u0440\u0442\u0430\u043c\u0438, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043a \u0448\u0438\u043d\u0435 \u043f\u0430\u043c\u044f\u0442\u0438. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043d\u0438\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e. \u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u0432\u0435 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0440\u0442\u0430\u043c\u0438 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430, \u0432\u0435\u0434\u044c \u043a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u044f \u043d\u0435 \u0442\u0435\u0440\u043f\u043b\u044e \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0445 \u0432\u0441\u0442\u0430\u0432\u043e\u043a.<br \/>  <code>extern u_char asm_read_port(u_char port);<br \/>  extern void asm_write_port(u_int port, u_char data);<br \/>  <\/code><\/p>\n<p>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u0432\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u043a\u0438\u0440\u0443\u0435\u043c\u044b\u043c\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<br \/>  <code>extern void asm_lock();<br \/>  extern void asm_unlock();<br \/>  <\/code><\/p>\n<p>  \u041d\u0443 \u0438 \u0434\u043b\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0443\u0436\u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<br \/>  <code>extern void asm_hlt();<br \/>  <\/code><\/p>\n<p>  \u041a\u0430\u043a \u0442\u044b \u043f\u043e\u043c\u043d\u0438\u0448\u044c, \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 0xB8000, \u043d\u043e \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432 \u0431\u0443\u0444\u0435\u0440 \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0410 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u044d\u0442\u043e\u0442 \u0431\u0443\u0444\u0435\u0440 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u044c \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0446\u0432\u0435\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0442\u0438\u043b\u0438\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0430\u043c\u0438\u043c\u0438 \u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438. \u041e\u0434\u0438\u043d \u0431\u0443\u0444\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u044f\u0434\u0440\u0430, \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u043e\u0432. \u041f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0430 \u044d\u043a\u0440\u0430\u043d\u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430\u0434 \u0431\u0443\u0444\u0435\u0440\u043e\u043c. \u0418 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f video_flush \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u0444\u0444\u0435\u0440 \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u044c, \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u044f \u0435\u0433\u043e \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438.<br \/>  <code>extern void video_init();<br \/>  extern void video_disable_cursor();<br \/>  extern void* video_scroll(char const* video_buff, char* pos);<br \/>  extern char* video_clear(char const* video_buff);<br \/>  extern void video_flush(char const* video_buff);<br \/>  <\/code><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u0432\u0435\u0441\u0442\u0438 \u0441\u0430\u043c\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u044f\u0434\u0440\u0430, \u043a\u043e\u0433\u0434\u0430 \u043b\u0435\u043d\u044c \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u0434\u0435\u0431\u0430\u0433\u0433\u0435\u0440\u043e\u043c. \u041f\u043e\u0432\u0435\u0440\u044c, \u044f \u043d\u0435 \u0440\u0430\u0437\u0443 \u043d\u0435 \u044e\u0437\u0430\u043b \u0434\u0435\u0431\u0430\u0433\u0433\u0435\u0440 \u043a\u043e\u0433\u0434\u0430 \u043f\u0438\u0441\u0430\u043b \u044d\u0442\u043e \u044f\u0434\u0440\u043e.<br \/>  <code>extern void kpanic(char* message, ...);<br \/>  extern void kassert(const char* file, u_int line, bool expr);<br \/>  extern void kunreachable(const char* file, u_int line);<br \/>  <\/code><\/p>\n<p>  \u041d\u0443 \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u043c \u044f\u0434\u0440\u0430. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f, \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0436\u0443\u0440\u043d\u0430\u043b \u0438\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u044f \u0432\u0432\u0435\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u044e kmode. \u0410 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u0432 \u0431\u0443\u0444\u0444\u0435\u0440 \u043d\u0443\u0436\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f klog, \u0438\u0431\u043e \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u044f\u0434\u0440\u0443 \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u0447\u0435\u0440\u0435\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b.<br \/>  <code>extern void kclear();<br \/>  extern void kprintf(const char* format, ...);<br \/>  extern void kvprintf(const char* format, va_list list);<br \/>  extern void kmode(bool is_early);<br \/>  extern void klog(char* buf, u_int n);<br \/>  <\/code><\/p>\n<p>  \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0442\u0443\u0442:  <\/p>\n<pre><code class=\"cpp\">\/*  * Api - Scroll video buffer up  *   Returns new position  *\/ extern void* video_scroll(char const* video_buff, char* pos) {     char* ptr = (void*)video_buff;      \/* scroll up *\/     for (int i = 1; i &lt; VIDEO_SCREEN_HEIGHT; ++i) {         for (int j = 0; j &lt; VIDEO_SCREEN_WIDTH; ++j) {             ptr[(i - 1) * VIDEO_SCREEN_WIDTH + j] = ptr[i * VIDEO_SCREEN_WIDTH + j];         }     }      \/* empty last line *\/     for (int j = 0; j &lt; VIDEO_SCREEN_WIDTH; ++j) {         ptr[(VIDEO_SCREEN_HEIGHT - 1) * VIDEO_SCREEN_WIDTH + j] = ' ';     }      \/* move position up *\/     pos -= VIDEO_SCREEN_WIDTH;      return pos; } <\/code><\/pre>\n<pre><code class=\"cpp\">\/*  * Api - Print kernel message  *\/ extern void kvprintf(const char* format, va_list list) {     char buff[VIDEO_SCREEN_WIDTH];     int len = vsprintf(buff, format, list);      for (int i = 0; i &lt; len; ++i) {         if (buff[i] != '\\n') {             kputc(buff[i]);         } else {             int line_pos = (syslog_pos - syslog) % VIDEO_SCREEN_WIDTH;             for (int j = 0; j &lt; VIDEO_SCREEN_WIDTH - line_pos; ++j) {                 kputc(' ');             }         }     }      kflush(); } <\/code><\/pre>\n<pre><code class=\"cpp\">\/*  * Put character to syslog  *\/ static void kputc(char ch) {     if ((size_t)syslog_pos - (size_t)syslog + 1 &lt; VIDEO_SCREEN_SIZE) {         *syslog_pos++ = ch;     } else {         syslog_pos = video_scroll(syslog, syslog_pos);         kputc(ch);     } } <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u0441\u043c\u043e\u0442\u0440\u0438 \u0432 \u0432\u0438\u0434\u0435\u043e\u0443\u0440\u043e\u043a\u0435.<\/p>\n<h4>\u0421\u0441\u044b\u043b\u043a\u0438<\/h4>\n<p>  <a href=\"https:\/\/www.youtube.com\/watch?v=hcrazJ4XkLs&amp;t=1s\">\u0412\u0438\u0434\u0435\u043e\u0443\u0440\u043e\u043a \u043a \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a><br \/>  <a href=\"https:\/\/github.com\/ArseniyBorezkiy\/oc-kernel\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 (\u0442\u0435\u0431\u0435 \u043d\u0443\u0436\u043d\u0430 \u0432\u0435\u0442\u043a\u0430 lesson3)<\/a><\/p>\n<h4>\u0421\u043f\u0438\u0441\u043e\u043a \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b<\/h4>\n<p>  1. James Molloy. Roll your own toy UNIX-clone OS.<br \/>  2. \u0417\u0443\u0431\u043a\u043e\u0432. \u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u0434\u043b\u044f DOS, Windows, Unix<br \/>  3. \u041a\u0430\u043b\u0430\u0448\u043d\u0438\u043a\u043e\u0432. \u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e!<br \/>  4. \u0422\u0430\u043d\u0435\u043d\u0431\u0430\u0443\u043c. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430.<br \/>  5. \u0420\u043e\u0431\u0435\u0440\u0442 \u041b\u0430\u0432. \u042f\u0434\u0440\u043e Linux. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/466765\/\"> https:\/\/habr.com\/ru\/post\/466765\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/466709\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439<\/a> \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e \u0441\u0447\u0435\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0421. \u0412 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0436\u0443\u0440\u043d\u0430\u043b \u044f\u0434\u0440\u0430.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-294443","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294443"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294443\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}