graphic.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /*
  27. * we supports PSF format in XNIX.
  28. * in linux, PSF fonts are in /usr/share/kbd/consolefonts, and they are always compressed.
  29. * */
  30. #define PSF_MAGIC 0x864ab572
  31. struct psf_header {
  32. __uint32_t magic;
  33. /* zero */
  34. __uint32_t version;
  35. __uint32_t header_size;
  36. /* zero if there's no unicode table */
  37. __uint32_t flags;
  38. /* in psf, a font calls glyph */
  39. __uint32_t glyphs_count;
  40. /* size of a glyph */
  41. __uint32_t glyph_size;
  42. __uint32_t height;
  43. __uint32_t width;
  44. };
  45. /* '__uint64_t * ' can change to other types */
  46. /* because they are all just lables with an address */
  47. extern __uint8_t *font_start;
  48. extern __uint8_t *font_end;
  49. /* but 'font_size' must be __uint64_t because it's a value */
  50. extern __uint64_t font_size;
  51. #define FB_ADDR ((__uint32_t *) 0x400000)
  52. /* x and y in this vga mode */
  53. #define VGA_X (bootarg->vga_x)
  54. #define VGA_Y (bootarg->vga_y)
  55. /* this is default value */
  56. #define CHAR_HEIGHT 8
  57. #define CHAR_WIDTH 16
  58. #define X_CHARS (VGA_X / CHAR_WIDTH)
  59. #define Y_LINES (VGA_Y / CHAR_HEIGHT)
  60. #endif