Skip to content

Commit

Permalink
Moved defines to headeer file.
Browse files Browse the repository at this point in the history
  • Loading branch information
IPlayZed committed Feb 20, 2022
1 parent 5e8f58e commit 6024b5a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/gdt.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#include "gdt.h"

#define _64_MEGABYTES 64*1024*1024
#define CSS_FLAGS 0x9A
#define DSS_FLAGS 0x92
#define EXPECTED_BYTES_NUM 2
#define GDT_ADDRESS 0
#define SEGMENT_INTEGER_HIGH_BYTES 1
#define HIGH_BYTES_LSHIFT 16

GlobalDescriptorTable::GlobalDescriptorTable()
: nullSegmentSelector(0, 0, 0), unusedSegmentSelector(0, 0, 0),
codeSegmentSelector(0, _64_MEGABYTES, CSS_FLAGS),
Expand All @@ -30,3 +22,14 @@ uint16_t GlobalDescriptorTable::GetDataSegmentSelectorOffset(){
uint16_t GlobalDescriptorTable::GetCodeSegmentSelectorOffset() {
return (uint8_t*)&codeSegmentSelector - (uint8_t*)this;
}

GlobalDescriptorTable::SegmentDescriptor::SegmentDescriptor(uint32_t base, uint32_t limit, uint8_t flags) {
uint8_t* targetSegmentDescriptor = (uint8_t*)this;
if (limit <= SMALL_LIMIT_16) {
targetSegmentDescriptor[SEGMENT_DESCRIPTOR_ACCESS] = 0x40;
}
else {
// TODO
}

}
10 changes: 10 additions & 0 deletions src/gdt.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#ifndef __GDT_H
#define __GDT_H

#define _64_MEGABYTES 64*1024*1024
#define CSS_FLAGS 0x9A
#define DSS_FLAGS 0x92
#define EXPECTED_BYTES_NUM 2
#define GDT_ADDRESS 0
#define SEGMENT_INTEGER_HIGH_BYTES 1
#define HIGH_BYTES_LSHIFT 16
#define SMALL_LIMIT_16 65536
#define SEGMENT_DESCRIPTOR_ACCESS 6

#include "types.h"
class GlobalDescriptorTable {
public:
Expand Down

0 comments on commit 6024b5a

Please sign in to comment.