This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

added documentation

Ivan Ilak (Apr 24, 2023, 5:48 PM +0200) 0c60b588 bf035759

+146 -19
+49 -1
os/include/kernel/chars_pixels.h
··· 1 1 #include <stdint.h> 2 2 #ifndef CHAR_BMPS_H 3 3 #define CHAR_BMPS_H 4 - /* From https://github.com/dhepper/font8x8/blob/master/font8x8_block.h */ 4 + 5 + /** 6 + * @file chars_pixels.h 7 + * @brief Contains the font bitmap for the 8x8 font 8 + */ 9 + 10 + /** 11 + * @brief Get the font bitmap for a character 12 + * 13 + * @param c The character to get the bitmap for 14 + * @return The bitmap for the character (as const uint8_t*). 15 + * 16 + * The following description is directly taken from where the front is: 17 + * https://github.com/dhepper/font8x8/blob/master/font8x8_block.h 18 + * 19 + * Every character in the font is encoded row-wise in 8 bytes. 20 + * 21 + * The least significant bit of each byte corresponds to the first pixel in a 22 + * row. 23 + * 24 + * The character 'A' (0x41 / 65) is encoded as 25 + * <code>{ 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}</code> 26 + * 27 + * <code> 28 + 0x0C => 0000 1100 => ..XX.... <br> 29 + 0X1E => 0001 1110 => .XXXX... <br> 30 + 0x33 => 0011 0011 => XX..XX.. <br> 31 + 0x33 => 0011 0011 => XX..XX.. <br> 32 + 0x3F => 0011 1111 => xxxxxx.. <br> 33 + 0x33 => 0011 0011 => XX..XX.. <br> 34 + 0x33 => 0011 0011 => XX..XX.. <br> 35 + 0x00 => 0000 0000 => ........ <br> 36 + </code> 37 + * 38 + * To access the nth pixel in a row, right-shift by n. 39 + * \verbatim 40 + . . X X . . . . 41 + | | | | | | | | 42 + (0x0C >> 0) & 1 == 0-+ | | | | | | | 43 + (0x0C >> 1) & 1 == 0---+ | | | | | | 44 + (0x0C >> 2) & 1 == 1-----+ | | | | | 45 + (0x0C >> 3) & 1 == 1-------+ | | | | 46 + (0x0C >> 4) & 1 == 0---------+ | | | 47 + (0x0C >> 5) & 1 == 0-----------+ | | 48 + (0x0C >> 6) & 1 == 0-------------+ | 49 + (0x0C >> 7) & 1 == 0---------------+ 50 + \endverbatim 51 + */ 52 + 5 53 const uint8_t *font(int c) 6 54 { 7 55 static const char f[128][8] = {
+97 -15
os/include/kernel/mailbox.h
··· 3 3 #ifndef MAILBOX_H 4 4 #define MAILBOX_H 5 5 6 + /** 7 + * @file mailbox.h 8 + * @brief Mailbox interface 9 + * 10 + * The mailbox is a way to communicate with the GPU. It is a FIFO queue of 11 + * messages. The GPU can send messages to the CPU, and the CPU can send 12 + * messages to the GPU. The CPU can also send messages to itself. 13 + * 14 + */ 15 + 6 16 #define MAILBOX_OFFSET 0xB880 7 17 8 18 #define MAILBOX_BASE MMIO_BASE + MAILBOX_OFFSET 9 19 #define MAIL0_READ (((mail_message_t *)(0x00 + MAILBOX_BASE))) 10 20 #define MAIL0_STATUS (((mail_status_t *)(0x18 + MAILBOX_BASE))) 11 21 #define MAIL0_WRITE (((mail_message_t *)(0x20 + MAILBOX_BASE))) 22 + 12 23 #define PROPERTY_CHANNEL 8 13 24 #define FRAMEBUFFER_CHANNEL 1 14 25 26 + /** 27 + * @brief A message that can be sent to the mailbox 28 + * 29 + * The mailbox has 16 channels, and each channel has a 32 bit buffer 30 + * associated with it. The buffer is used to store the data for the message 31 + * that is being sent. 32 + * 33 + * A message is 32 bits, with the first 4 bits being the channel, and the 34 + * remaining 28 bits being the data to be sent. The channel is used to route 35 + * the message to the correct buffer, and the data is the actual data that is 36 + * being sent. The data is not interpreted by the mailbox or the GPU, it is 37 + * just passed through. The data is interpreted by the driver that is recieving 38 + * the message. The driver will know what to do with the data, and will know 39 + * how to interpret it. 40 + */ 15 41 typedef struct 16 42 { 17 43 uint8_t channel : 4; 18 44 uint32_t data : 28; 19 45 } mail_message_t; 20 46 47 + /** 48 + * @brief The status of the mailbox 49 + * 50 + * The mailbox has a status register that can be used to check if there is 51 + * mail to read, or if there is space to write mail to. The status register 52 + * is 32 bits, with the first 30 bits being reserved, and the last 2 bits 53 + * being the full and empty flags. 54 + * 55 + * The full and empty flags are mutually exclusive, so if the full flag is 56 + * set, then the empty flag will not be set, and vice versa. 57 + * 58 + * The reserved bits are reserved for future use, and should be set to 0. If 59 + * they are not set to 0, then the behavior is undefined. 60 + * 61 + * What goes into the reserved bits is not specified, so it is not possible 62 + * to check if the mailbox is empty or full by checking if the reserved bits 63 + * are 0 or not. The empty and full flags must be used instead. 64 + */ 21 65 typedef struct 22 66 { 23 67 uint32_t reserved : 30; ··· 29 73 void mailbox_send(mail_message_t msg, int channel); 30 74 31 75 /** 76 + * @brief A tag that can be sent to the mailbox 77 + * 32 78 * A property message can either be a request, or a response, and a response 33 - * can be successfull or an error 79 + * can be successfull or an error. 34 80 */ 35 81 typedef enum 36 82 { ··· 39 85 RESPONSE_ERROR = 0x80000001 40 86 } buffer_req_res_code_t; 41 87 42 - /* 43 - * A buffer that holds many property messages. 88 + /** 89 + * @brief A buffer that holds many property messages 90 + * 44 91 * The last tag must be a 4 byte zero, and then padding to make the whole thing 45 - * 4 byte aligned 92 + * 4 byte aligned. The size field is the size of the whole buffer, including 93 + * the size field itself. 46 94 */ 47 95 typedef struct 48 96 { 49 - uint32_t size; // Size includes the size itself 97 + uint32_t size; /**< Size includes the size itself */ 50 98 buffer_req_res_code_t req_res_code; 51 - uint32_t tags[1]; // A concatenated sequence of tags. will use overrun to 52 - // make large enough 99 + uint32_t tags[1]; /**< The tags start here. Will use overrun to make large 100 + enough */ 53 101 } property_message_buffer_t; 54 102 55 103 /** 56 - * A message is identified by a tag. These are some of the possible tags 104 + * @brief A tag that can be sent to the mailbox 105 + * 106 + * A message is identified by a tag. These are some of the possible tags. The 107 + * full list can be found in the BCM2835 ARM Peripherals manual, section 6.1 108 + * (page 102) 109 + * https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf 110 + * 111 + * For general information about the mailbox, see the following link: 112 + * https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface 57 113 */ 58 114 typedef enum 59 115 { ··· 74 130 * buffer, and the response value buffer 75 131 */ 76 132 133 + /** 134 + * @brief Request value buffer for FB_ALLOCATE_BUFFER 135 + * 136 + * The request value buffer for FB_ALLOCATE_BUFFER is just the alignment 137 + * that the framebuffer should be aligned to. The alignment must be 138 + * a power of 2 and at least 16 bytes. 139 + */ 77 140 typedef struct 78 141 { 79 142 void *fb_addr; 80 143 uint32_t fb_size; 81 144 } fb_allocate_res_t; 82 145 146 + /** 147 + * @brief Response value buffer for FB_ALLOCATE_BUFFER 148 + * 149 + * The response value buffer for FB_ALLOCATE_BUFFER is the address and size 150 + * of the framebuffer. 151 + */ 83 152 typedef struct 84 153 { 85 154 uint32_t width; 86 155 uint32_t height; 87 156 } fb_screen_size_t; 88 157 89 - /* 90 - * The value buffer can be any one of these types 158 + /** 159 + * @brief Union of all possible value buffers 160 + * 161 + * Different types of data that can be sent with the tags, depending on the 162 + * specific tag being used. 91 163 */ 92 164 typedef union 93 165 { ··· 98 170 uint32_t fb_bytes_per_row; 99 171 } value_buffer_t; 100 172 101 - /* 102 - * A message_buffer can contain any number of these 173 + /** 174 + * @brief A message that can be sent to the mailbox. 175 + * 176 + * A tag is a property tag, and a value buffer. The value buffer is the data 177 + * that is sent with the tag. 103 178 */ 104 179 typedef struct 105 180 { ··· 108 183 } property_message_tag_t; 109 184 110 185 /** 111 - * given an array of tags, will send all of the tags given, and will populate 112 - * that array with the responses. the given array should end with a "null tag" 113 - * with the proptag field set to 0. returns 0 on success 186 + * @brief Send a message to the mailbox 187 + * 188 + * @param tags The tags to send. 189 + * @return 0 on success, -1 on failure 190 + * 191 + * 192 + * Given an array of tags, will send all of the tags given, and will populate 193 + * that array with the responses. The last tag must be a 4 byte zero, and then 194 + * padding to make the whole thing 4 byte aligned. The size field is the size 195 + * of the whole buffer, including the size field itself. 114 196 */ 115 197 int send_messages(property_message_tag_t *tags); 116 198
-3
os/src/kernel/mailbox.c
··· 38 38 *MAIL0_WRITE = msg; 39 39 } 40 40 41 - /** 42 - * returns the max of the size of the request and result buffer for each tag 43 - */ 44 41 static uint32_t get_value_buffer_len(property_message_tag_t *tag) 45 42 { 46 43 switch(tag->proptag)