1
0

common.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * common.h
  3. *
  4. * Copyright (C) 2016 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _COMMON_H_
  20. #define _COMMON_H_
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <sdk/defs.h>
  24. #include <cpu.h>
  25. /* Monolithium-specific Helper Macros */
  26. #define SEGMENT_RPL(x) ((x) & 0x03)
  27. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  28. #define MAX(a, b) ((a) > (b) ? (a) : (b))
  29. #define VIDEO_MEMORY 0xF0000000
  30. #define TEXT_VIDEO_MEMORY 0xB8000
  31. #define TEXT_WIDTH 80
  32. #define TEXT_HEIGHT 25
  33. #define DOUBLE_HORIZONTAL_BAR 0xCD
  34. #define DOUBLE_VERTICAL_BAR 0xBA
  35. #define DOUBLE_CORNER_LEFT_MID 0xBA
  36. #define DOUBLE_CORNER_LEFT_DOWN 0xBB
  37. #define DOUBLE_CORNER_LEFT_UP 0xBC
  38. #define DOUBLE_CORNER_RIGHT_UP 0xC8
  39. #define DOUBLE_CORNER_RIGHT_DOWN 0xC9
  40. #define DOUBLE_CORNER_RIGHT_MID 0xCC
  41. static inline void enable_nmi()
  42. {
  43. cpu_write_port_byte(0x70, cpu_read_port_byte(0x70) & 0x7F);
  44. }
  45. static inline void disable_nmi()
  46. {
  47. cpu_write_port_byte(0x70, cpu_read_port_byte(0x70) | 0x80);
  48. }
  49. #endif