graphic.h 2.3 KB

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