Skip to content

Commit 35871d8

Browse files
authored
Fix C Code (#130)
* Add the number of gdt entries * Add missing ';' * Fix wrong struct definition and Fix callback calling
1 parent 9049637 commit 35871d8

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

02_Architecture/04_GDT.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ For future reference, we should define macros for these selectors. So let's assu
196196
To create a GDT populated with these entries we'd do something like the following:
197197
198198
```c
199-
uint64_t gdt_entries[];
199+
#define NUM_GDT_ENTRIES 5
200+
201+
uint64_t gdt_entries[NUM_GDT_ENTRIES];
200202
201203
//null descriptor, required to be here.
202204
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
251253

252254
```c
253255
//populate these as you will.
254-
uint64_t num_gdt_entries;
255-
uint64_t gdt_entries[];
256+
#define NUM_GDT_ENTRIES 7
257+
uint64_t gdt_entries[NUM_GDT_ENTRIES];
256258

257259
struct GDTR
258260
{
@@ -262,7 +264,7 @@ struct GDTR
262264

263265
GDTR example_gdtr =
264266
{
265-
.limit = num_gdt_entries * sizeof(uint64_t) - 1;
267+
.limit = NUM_GDT_ENTRIES * sizeof(uint64_t) - 1;
266268
.address = (uint64_t)gdt_entries;
267269
};
268270

03_Video_Output/02_DrawingTextOnFB.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Let's assume from now on that we have a data structure called `PSF_font` with al
126126
// We have linked _binary_font_psf_start from another .o file so we must
127127
// specify that we are dealing with an external variable.
128128
extern char _binary_font_psf_start;
129-
PSF_font *default_font = (PSF_font *)&_binary_font_psf_start
129+
PSF_font *default_font = (PSF_font *)&_binary_font_psf_start;
130130
```
131131

132132
## Glyph
@@ -159,7 +159,7 @@ The glyphs start right after the psf header, the address of the first character
159159

160160
```C
161161
uint8_t* first_glyph = (uint8_t*) &_binary_font_psf_start +
162-
default_font->headersize
162+
default_font->headersize;
163163
```
164164

165165
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
185185
So our function header will be something like that:
186186

187187
```C
188-
void fb_putchar( char symbol, uint16_t x, uint16_t y, uint32_t fg, uint32_t bg)
188+
void fb_putchar( char symbol, uint16_t x, uint16_t y, uint32_t fg, uint32_t bg);
189189
```
190190
191191
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).

08_VirtualFileSystem/02_VirtualFileSystem.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ typedef struct {
283283
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:
284284

285285
```c
286-
struct file_descriptors_t vfs_opened_files[MAX_OPENED_FILES];
286+
file_descriptors_t vfs_opened_files[MAX_OPENED_FILES];
287287
```
288288

289289
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) {
399399
int mountpoint_id = vfs_opened_files[fildes].mountpoint_id;
400400
mountpoint_t *mountpoint = get_mountpoint_by_id(mountpoint_id);
401401
int fs_file_id = vfs_opened_files[fildes].fs_file_id;
402-
int bytes_read = mountpoints.read(fs_file_id, buf, nbytes)
402+
int bytes_read = mountpoints->operations.read(fs_file_id, buf, nbytes);
403403
if (opened_files[fildes].buf_read_pos + nbytes < opened_files[fildes].file_size) {
404404
opened_files[fildes].buf_read_pos += nbytes;
405405
} else {

0 commit comments

Comments
 (0)