bootcon.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Boot console: the earliest on-screen output.
  2. *
  3. * Draws 8x16 text straight into the boot framebuffer described at 0x600. It
  4. * needs no heap, no paging (the LFB is identity-accessible), no drivers and
  5. * no shadow buffer, so it can be the first C code in kernel_main. Purpose:
  6. * stage tracing on machines without serial, and a last visible screen if the
  7. * kernel wedges before the WM paints. The WM's first frame covers it;
  8. * bootcon_set_enabled(0) stops drawing before that happens. The face, cell
  9. * grid and top-left origin match the BIOS loader text and the ring-3
  10. * terminal, and a full screen scrolls instead of wrapping.
  11. */
  12. #ifndef BOOTCON_H
  13. #define BOOTCON_H
  14. #define BOOTCON_LOG_PAGES 8
  15. /* Ring for the storage scan thread's own serial output (see bootcon.c). It
  16. * is allocated on demand from the frame allocator, not BSS. */
  17. #define BOOTCON_SCAN_PAGES 4
  18. void bootcon_init(void);
  19. int bootcon_ok(void);
  20. void bootcon_set_enabled(int on);
  21. void bootcon_puts(const char *s);
  22. /* Switch drawing to the LFB's kernel address once paging is on (the LFB may
  23. * live in the ioremap window, not at its physical address); 0 is ignored. */
  24. void bootcon_set_lfb(void *va);
  25. void bootcon_dec(unsigned int v);
  26. void bootcon_hex(unsigned int v);
  27. /* One line with the cached mode geometry and LFB address. */
  28. void bootcon_fb_info(void);
  29. /* Allocate the RAM log after the page allocator is up. The buffer is taken
  30. * from the frame allocator, not BSS, to keep _end below the 0x90000 wall. */
  31. void bootcon_log_init(void);
  32. /* Everything written through bootcon_puts() after bootcon_log_init(),
  33. * including text produced after the WM has taken over the framebuffer. The
  34. * returned buffer is NUL terminated; *len is the number of valid bytes. */
  35. const char *bootcon_log(unsigned int *len);
  36. int bootcon_log_truncated(void);
  37. /* Capture the bootscan kernel thread's serial output. begin() is called by
  38. * the thread itself (it allocates the ring and records the thread pid), end()
  39. * stops the capture when the thread returns. serial_putc() feeds every COM1
  40. * character through bootcon_scan_char(), which keeps only the owning
  41. * thread's output. The ring survives end() so the `bootscan` window can
  42. * still tail the completed log. */
  43. void bootcon_scan_begin(void);
  44. void bootcon_scan_end(void);
  45. void bootcon_scan_char(char c);
  46. unsigned int bootcon_scan_total(void);
  47. unsigned int bootcon_scan_start(void);
  48. unsigned int bootcon_scan_capacity(void);
  49. int bootcon_scan_running(void);
  50. /* Copy up to max bytes from absolute offset off; off is clamped to the
  51. * oldest byte still in the ring. Returns the byte count. */
  52. unsigned int bootcon_scan_read(unsigned int off, char *dst, unsigned int max);
  53. #endif