graphic.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Copyright (C) 2021 Rain */
  2. /* This file is part of XNIX. */
  3. /*
  4. XNIX is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) and later version.
  8. */
  9. /*
  10. XNIX is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. */
  15. /*
  16. You should have received a copy of the GNU General Public License
  17. along with XNIX. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _GRAPHIC_H
  20. #define _GRAPHIC_H
  21. #include <kernel/types.h>
  22. void putblock(__uint32_t, int, int, int, int);
  23. void putc(char, __uint32_t, __uint32_t);
  24. void print(__uint32_t, __uint32_t, char *);
  25. int printk(__uint32_t, __uint32_t, char *, ...);
  26. void syslog(const char *);
  27. /*
  28. * we supports PSF format in XNIX.
  29. * in linux, PSF fonts are in /usr/share/kbd/consolefonts, and they are always compressed.
  30. * */
  31. #define PSF_MAGIC 0x864ab572
  32. struct psf_header {
  33. __uint32_t magic;
  34. /* zero */
  35. __uint32_t version;
  36. __uint32_t header_size;
  37. /* zero if there's no unicode table */
  38. __uint32_t flags;
  39. /* in psf, a font calls glyph */
  40. __uint32_t glyphs_count;
  41. /* size of a glyph */
  42. __uint32_t glyph_size;
  43. __uint32_t height;
  44. __uint32_t width;
  45. };
  46. /* '__uint64_t * ' can change to other types */
  47. /* because they are all just lables with an address */
  48. extern __uint8_t *font_start;
  49. extern __uint8_t *font_end;
  50. /* but 'font_size' must be __uint64_t because it's a value */
  51. extern __uint64_t font_size;
  52. #define FB_ADDR ((__uint32_t *) 0x400000)
  53. /* x and y in this vga mode */
  54. #define VGA_X (bootarg->vga_x)
  55. #define VGA_Y (bootarg->vga_y)
  56. /* this is default value */
  57. #define CHAR_HEIGHT 16
  58. #define CHAR_WIDTH 8
  59. #define X_CHARS (VGA_X / CHAR_WIDTH)
  60. #define Y_LINES (VGA_Y / CHAR_HEIGHT)
  61. #endif