diff --git a/02_Architecture/04_GDT.md b/02_Architecture/04_GDT.md index 299e5d7..9f56288 100644 --- a/02_Architecture/04_GDT.md +++ b/02_Architecture/04_GDT.md @@ -196,7 +196,9 @@ For future reference, we should define macros for these selectors. So let's assu To create a GDT populated with these entries we'd do something like the following: ```c -uint64_t gdt_entries[]; +#define NUM_GDT_ENTRIES 5 + +uint64_t gdt_entries[NUM_GDT_ENTRIES]; //null descriptor, required to be here. gdt_entries[0] = 0; @@ -251,8 +253,8 @@ To load a new GDT, use the `lgdt` instruction. It takes the address of a GDTR st ```c //populate these as you will. -uint64_t num_gdt_entries; -uint64_t gdt_entries[]; +#define NUM_GDT_ENTRIES 7 +uint64_t gdt_entries[NUM_GDT_ENTRIES]; struct GDTR { @@ -262,7 +264,7 @@ struct GDTR GDTR example_gdtr = { - .limit = num_gdt_entries * sizeof(uint64_t) - 1; + .limit = NUM_GDT_ENTRIES * sizeof(uint64_t) - 1; .address = (uint64_t)gdt_entries; }; diff --git a/03_Video_Output/02_DrawingTextOnFB.md b/03_Video_Output/02_DrawingTextOnFB.md index fe93c82..8a5a409 100644 --- a/03_Video_Output/02_DrawingTextOnFB.md +++ b/03_Video_Output/02_DrawingTextOnFB.md @@ -126,7 +126,7 @@ Let's assume from now on that we have a data structure called `PSF_font` with al // We have linked _binary_font_psf_start from another .o file so we must // specify that we are dealing with an external variable. extern char _binary_font_psf_start; -PSF_font *default_font = (PSF_font *)&_binary_font_psf_start +PSF_font *default_font = (PSF_font *)&_binary_font_psf_start; ``` ## Glyph @@ -159,7 +159,7 @@ The glyphs start right after the psf header, the address of the first character ```C uint8_t* first_glyph = (uint8_t*) &_binary_font_psf_start + - default_font->headersize + default_font->headersize; ``` Since we know that every glyph has the same size, and this is available in the `PSF_Header`, if we want to access the *i-th* character, we just need to do the following: @@ -185,7 +185,7 @@ Before proceeding let's talk about the position parameters. Now what they are de So our function header will be something like that: ```C -void fb_putchar( char symbol, uint16_t x, uint16_t y, uint32_t fg, uint32_t bg) +void fb_putchar( char symbol, uint16_t x, uint16_t y, uint32_t fg, uint32_t bg); ``` Clearly what it should do is read the glyph stored in the position given by symbol, and draw it at row x and column y (don't forget they are "character" coordinates) using colors fg for foreground color and bg for background (we draw the foreground color when the bit in the bitmap is 1, and the bg color when is 0). diff --git a/08_VirtualFileSystem/02_VirtualFileSystem.md b/08_VirtualFileSystem/02_VirtualFileSystem.md index 78e834b..6c5c6a6 100644 --- a/08_VirtualFileSystem/02_VirtualFileSystem.md +++ b/08_VirtualFileSystem/02_VirtualFileSystem.md @@ -283,7 +283,7 @@ typedef struct { We need to declare a variable that contains the opened file descriptors, as usual we are using a naive approach, and just use an array for simplicity, this means that we will have a limited number of files that can be opened: ```c -struct file_descriptors_t vfs_opened_files[MAX_OPENED_FILES]; +file_descriptors_t vfs_opened_files[MAX_OPENED_FILES]; ``` Where the `mountpoint_id` fields is the id of the mounted file system that is containing the requested file. The `fs_file_id` is the fs specific id of the fs opened by the file descriptor, `buf_read_pos` and `buf_write_pos` are the current positions of the buffer pointer for the read and write operations and `file_size` is the size of the opened file. @@ -399,7 +399,7 @@ ssize_t read(int fildes, void *buf, size_t nbytes) { int mountpoint_id = vfs_opened_files[fildes].mountpoint_id; mountpoint_t *mountpoint = get_mountpoint_by_id(mountpoint_id); int fs_file_id = vfs_opened_files[fildes].fs_file_id; - int bytes_read = mountpoints.read(fs_file_id, buf, nbytes) + int bytes_read = mountpoints->operations.read(fs_file_id, buf, nbytes); if (opened_files[fildes].buf_read_pos + nbytes < opened_files[fildes].file_size) { opened_files[fildes].buf_read_pos += nbytes; } else {