device.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * device.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 __MONOLITHIUM_DEVICE_H__
  20. #define __MONOLITHIUM_DEVICE_H__
  21. #include "object.h"
  22. #define MAX_DEVICE_NAME 32
  23. typedef enum
  24. {
  25. BLOCK_DEVICE,
  26. CHAR_DEVICE
  27. } device_type_t;
  28. /* Generic block device IOCTLs and related data */
  29. #define IOCTL_BLOCK_DEV_INFO 0xB0000000
  30. #define IOCTL_BLOCK_DEV_MEDIA_INFO 0xB0000001
  31. #define IOCTL_BLOCK_DEV_MEDIA_LOAD 0xB0000002
  32. #define IOCTL_BLOCK_DEV_MEDIA_EJECT 0xB0000003
  33. #define BLOCK_DEVICE_REMOVABLE_MEDIA (1 << 0)
  34. /* Generic character device IOCTLs and related data */
  35. #define IOCTL_CHAR_DEV_CHECK_INPUT 0xC0000000
  36. #define IOCTL_CHAR_DEV_CHECK_OUTPUT 0xC0000001
  37. /* Video IOCTLs and related data */
  38. #define IOCTL_VIDEO_GET_MODE 0xC9000000
  39. #define IOCTL_VIDEO_SET_MODE 0xC9000001
  40. #define IOCTL_VIDEO_LIST_MODES 0xC9000002
  41. #define IOCTL_VIDEO_QUERY_MODE 0xC9000003
  42. #define IOCTL_VIDEO_MAP_FRAMEBUFFER 0xC9000004
  43. #define IOCTL_VIDEO_BITBLT 0xC9000005
  44. #define IOCTL_VIDEO_READ_PALETTE 0xC9000006
  45. #define IOCTL_VIDEO_WRITE_PALETTE 0xC9000007
  46. #define IOCTL_VIDEO_READ_FONT 0xC9000008
  47. #define IOCTL_VIDEO_WRITE_FONT 0xC9000009
  48. #define IOCTL_VIDEO_SET_TEXT_CURSOR 0xC900000A
  49. #define VIDEO_MODE_ALPHANUMERIC (1 << 0)
  50. #define VIDEO_MODE_USES_PALETTE (1 << 1)
  51. #define IOCTL_VIDEO_GET_MODE 0xC9000000
  52. #define IOCTL_VIDEO_SET_MODE 0xC9000001
  53. #define IOCTL_VIDEO_LIST_MODES 0xC9000002
  54. #define IOCTL_VIDEO_QUERY_MODE 0xC9000003
  55. #define IOCTL_VIDEO_MAP_FRAMEBUFFER 0xC9000004
  56. #define IOCTL_VIDEO_BITBLT 0xC9000005
  57. #define IOCTL_VIDEO_READ_PALETTE 0xC9000006
  58. #define IOCTL_VIDEO_WRITE_PALETTE 0xC9000007
  59. #define IOCTL_VIDEO_READ_FONT 0xC9000008
  60. #define IOCTL_VIDEO_WRITE_FONT 0xC9000009
  61. #define IOCTL_VIDEO_SET_TEXT_CURSOR 0xC900000A
  62. #define BITBLT_RESULT_INVERT (1 << 2)
  63. #define BITBLT_SOURCE_INVERT (1 << 3)
  64. #define BITBLT_DEST_INVERT (1 << 4)
  65. #define BITBLT_SOURCE_ENABLED (1 << 30)
  66. #define BITBLT_DEST_ENABLED (1 << 31)
  67. enum
  68. {
  69. BITBLT_OPERATION_NONE,
  70. BITBLT_OPERATION_AND,
  71. BITBLT_OPERATION_OR,
  72. BITBLT_OPERATION_XOR,
  73. };
  74. typedef struct
  75. {
  76. dword_t source_x;
  77. dword_t source_y;
  78. dword_t dest_x;
  79. dword_t dest_y;
  80. dword_t width;
  81. dword_t height;
  82. dword_t operation;
  83. } video_bitblt_parameters_t;
  84. typedef struct
  85. {
  86. void *address;
  87. uintptr_t offset;
  88. size_t size;
  89. } video_map_framebuffer_t;
  90. typedef struct
  91. {
  92. dword_t row;
  93. dword_t column;
  94. } video_cursor_location_t;
  95. typedef struct
  96. {
  97. dword_t number;
  98. dword_t flags;
  99. dword_t width;
  100. dword_t height;
  101. dword_t bpp;
  102. dword_t scanline_size;
  103. uintptr_t framebuffer_phys;
  104. byte_t red_mask_size;
  105. byte_t red_field_pos;
  106. byte_t green_mask_size;
  107. byte_t green_field_pos;
  108. byte_t blue_mask_size;
  109. byte_t blue_field_pos;
  110. byte_t reserved_mask_size;
  111. byte_t reserved_field_pos;
  112. } video_mode_t;
  113. sysret_t syscall_device_ioctl(handle_t device, dword_t control_code, const void *in_buffer, size_t in_length, void *out_buffer, size_t out_length);
  114. #endif