graphic.h 2.0 KB

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