bootcon.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. /* Always-on COM1 capture used by `seriallog save` on serial-less boards.
  19. * The xHCI/USB/touchpad debug lines go here even though the UART is absent. */
  20. #define BOOTCON_SERLOG_PAGES 16
  21. void bootcon_init(void);
  22. int bootcon_ok(void);
  23. void bootcon_set_enabled(int on);
  24. void bootcon_puts(const char *s);
  25. /* Switch drawing to the LFB's kernel address once paging is on (the LFB may
  26. * live in the ioremap window, not at its physical address); 0 is ignored. */
  27. void bootcon_set_lfb(void *va);
  28. void bootcon_dec(unsigned int v);
  29. void bootcon_hex(unsigned int v);
  30. /* One line with the cached mode geometry and LFB address. */
  31. void bootcon_fb_info(void);
  32. /* Allocate the RAM log after the page allocator is up. The buffer is taken
  33. * from the frame allocator, not BSS, to keep _end below the 0x90000 wall. */
  34. void bootcon_log_init(void);
  35. /* Everything written through bootcon_puts() after bootcon_log_init(),
  36. * including text produced after the WM has taken over the framebuffer. The
  37. * returned buffer is NUL terminated; *len is the number of valid bytes. */
  38. const char *bootcon_log(unsigned int *len);
  39. int bootcon_log_truncated(void);
  40. /* Capture the bootscan kernel thread's serial output. begin() is called by
  41. * the thread itself (it allocates the ring and records the thread pid), end()
  42. * stops the capture when the thread returns. serial_putc() feeds every COM1
  43. * character through bootcon_scan_char(), which keeps only the owning
  44. * thread's output. The ring survives end() so the `bootscan` window can
  45. * still tail the completed log. */
  46. void bootcon_scan_begin(void);
  47. void bootcon_scan_end(void);
  48. void bootcon_scan_char(char c);
  49. unsigned int bootcon_scan_total(void);
  50. unsigned int bootcon_scan_start(void);
  51. unsigned int bootcon_scan_capacity(void);
  52. int bootcon_scan_running(void);
  53. /* Copy up to max bytes from absolute offset off; off is clamped to the
  54. * oldest byte still in the ring. Returns the byte count. */
  55. unsigned int bootcon_scan_read(unsigned int off, char *dst, unsigned int max);
  56. /* Always-on COM1 log (independent of the bootscan thread). It starts at
  57. * bootcon_log_init() and keeps the first BOOTCON_SERLOG_PAGES pages of
  58. * serial output; later output is dropped after the buffer fills. */
  59. void bootcon_serlog_char(char c);
  60. const char *bootcon_serlog(unsigned int *len);
  61. int bootcon_serlog_truncated(void);
  62. #endif