Skip to content

Commit a5a976f

Browse files
author
tthomps
committed
Fix PAGE_ENTRY_WRITABLE and PAGE_ENTRY_USER_ACCESSIBLE definitions, which were previously swapped.
Assign default values to the three graphicsX globals in Display_HAL.c Remove MODE_TYPE define and use variables specifically for text mode instead of giving graphics defines text-based values. Conditionally use the appropriate defines in multiboot.h. NOTE: Using GRUB with text mode has regressed and these changes are meant to help marginally, but fixing text-mode is a low-priority.
1 parent 9ee2100 commit a5a976f

File tree

6 files changed

+29
-17
lines changed

6 files changed

+29
-17
lines changed

MyOS_1/Graphics/Display_HAL.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
bool graphicsPresent = false;
99
bool textMode = true;
1010
uint32_t *linearFrameBuffer = NULL;
11-
unsigned int graphicsBpp;
12-
unsigned int graphicsWidth;
13-
unsigned int graphicsHeight;
11+
unsigned int graphicsBpp = 32;
12+
unsigned int graphicsWidth = GRAPHICS_WIDTH;
13+
unsigned int graphicsHeight = GRAPHICS_HEIGHT;
1414

1515
// TODO: Create HAL interface and tie Bochs_VGA into it
1616

MyOS_1/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,17 @@ MULTIBOOT_INFO _MultibootInfo =
259259
// GRUB doesn't actually copy the kernel there, so we need to do some math
260260
// to find the actual address of KeStartup.
261261
(uint32_t)KeStartup - (uint32_t)NonPagingAddressOffset,
262-
(uint32_t)MODE_TYPE,
262+
#if GRUB_GRAPHICS
263+
(uint32_t)GRAPHICS_MODE,
263264
(uint32_t)GRAPHICS_WIDTH,
264265
(uint32_t)GRAPHICS_HEIGHT,
265266
(uint32_t)GRAPHICS_DEPTH
267+
#else
268+
(uint32_t)TEXT_MODE,
269+
(uint32_t)TEXT_WIDTH,
270+
(uint32_t)TEXT_HEIGHT,
271+
(uint32_t)TEXT_DEPTH
272+
#endif
266273
};
267274

268275
#pragma comment(linker, "/merge:.text=.a")

MyOS_1/multiboot.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,19 @@ BASE_ADDRESS 0xC0000000
320320
#define STACK_SIZE 0x4000
321321
#define CHECKSUM -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
322322

323-
#define GRAPHICS_MODE 0
324-
#define TEXT_MODE 1
325-
#define FLIP_MODE "Love Em"
326-
/*#define MODE_TYPE TEXT_MODE
327-
#define GRAPHICS_WIDTH 80
328-
#define GRAPHICS_HEIGHT 25
329-
#define GRAPHICS_DEPTH 0*/
330-
#define MODE_TYPE GRAPHICS_MODE
331-
#define GRAPHICS_WIDTH 800
332-
#define GRAPHICS_HEIGHT 600
333-
#define GRAPHICS_DEPTH 32
323+
#define GRUB_GRAPHICS 1 /* set to 1 to request GRUB to setup graphics, 0 for text-mode display (not working)*/
324+
#define GRAPHICS_MODE 0
325+
#define TEXT_MODE 1
326+
#define FLIP_MODE "Love Em"
327+
328+
// TODO: Text mode has regressed when booting with GRUB (see paging.h), but I don't think we really need it
329+
#define TEXT_WIDTH 80
330+
#define TEXT_HEIGHT 25
331+
#define TEXT_DEPTH 0
332+
333+
#define GRAPHICS_WIDTH 800
334+
#define GRAPHICS_HEIGHT 600
335+
#define GRAPHICS_DEPTH 32
334336

335337
#endif /* ! ASM_FILE */
336338

MyOS_1/paging.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ typedef /*__declspec(align(4096))*/ uint32_t PAGE_DIRECTORY_ENTRY;
1010
typedef /*__declspec(align(4096))*/ uint32_t PAGE_TABLE_ENTRY;
1111

1212
#define PAGE_ENTRY_PRESENT 1
13-
#define PAGE_ENTRY_USER_ACCESSIBLE 2
14-
#define PAGE_ENTRY_WRITABLE 4
13+
#define PAGE_ENTRY_WRITABLE 2
14+
#define PAGE_ENTRY_USER_ACCESSIBLE 4
1515

1616
#define DIRECTORY_ENTRY_PRESENT 1
1717
#define DIRECTORY_ENTRY_WRITABLE 2
@@ -85,6 +85,8 @@ inline void Paging_Enable(multiboot_info *multibootInfo)
8585
// TEMPTEMP HACKHACK! - identity map the linear frame buffer, which on my Qemu starts at 0xFD00 0000
8686
uint32_t lfbAddress = 0xFD000000;
8787

88+
// TODO: This section of code will bug out if GRUB_GRAPHICS isn't defined in VirtualBox
89+
// TODO: We can conditionally comment this out, but then the gfx command fails to switch modes properly
8890
// see if Grub gave us an lfb address and use that one if it did
8991
if (multibootInfo->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO)
9092
{
@@ -98,6 +100,7 @@ inline void Paging_Enable(multiboot_info *multibootInfo)
98100
{
99101
videoIdentityTable[i] = (lfbAddress + i * 0x1000) | PAGE_ENTRY_PRESENT | PAGE_ENTRY_WRITABLE; // attributes: supervisor level, read/write, present
100102
}
103+
// End buggy section
101104

102105
// put the lfb page table in the page directory
103106
uint32_t page = lfbAddress / 0x400000;

Release/MyOS_1.dll

-512 Bytes
Binary file not shown.

Release/myos.iso

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)