From 03035c98b4ba3297b837e96080e78e0aac1e86db Mon Sep 17 00:00:00 2001 From: Aleksa Vučković Date: Mon, 31 Jan 2022 11:16:38 +0100 Subject: Promene --- include/03.gdt/deo1 | 1 - include/03.gdt/deo2 | 9 --------- include/03.gdt/deo3 | 5 ----- include/03.gdt/deo4 | 1 - include/03.gdt/deo5 | 2 -- include/03.gdt/deo6 | 9 --------- include/03.gdt/deo7 | 4 ---- include/03.gdt/deo8 | 5 ----- include/03.gdt/deo9 | 2 -- include/03.gdt/gdt.c | 36 +++++++++++------------------------- include/03.gdt/gdt.h | 26 ++++++++++++++++++++++++++ include/03.gdt/gdt1.c | 2 ++ include/03.gdt/gdt1.h | 2 ++ include/03.gdt/gdt2.c | 1 + include/03.gdt/gdt2.h | 1 + include/03.gdt/gdt3.c | 2 ++ include/03.gdt/gdt3.h | 9 +++++++++ include/03.gdt/gdt4.c | 10 ++++++++++ include/03.gdt/gdt4.h | 5 +++++ include/03.gdt/gdt5.c | 4 ++++ include/03.gdt/gdt5.h | 3 +++ include/03.gdt/gdt6.c | 5 +++++ include/03.gdt/gdt6.h | 1 + include/03.gdt/gdt7.c | 2 ++ 24 files changed, 84 insertions(+), 63 deletions(-) delete mode 100644 include/03.gdt/deo1 delete mode 100644 include/03.gdt/deo2 delete mode 100644 include/03.gdt/deo3 delete mode 100644 include/03.gdt/deo4 delete mode 100644 include/03.gdt/deo5 delete mode 100644 include/03.gdt/deo6 delete mode 100644 include/03.gdt/deo7 delete mode 100644 include/03.gdt/deo8 delete mode 100644 include/03.gdt/deo9 create mode 100644 include/03.gdt/gdt.h create mode 100644 include/03.gdt/gdt1.c create mode 100644 include/03.gdt/gdt1.h create mode 100644 include/03.gdt/gdt2.c create mode 100644 include/03.gdt/gdt2.h create mode 100644 include/03.gdt/gdt3.c create mode 100644 include/03.gdt/gdt3.h create mode 100644 include/03.gdt/gdt4.c create mode 100644 include/03.gdt/gdt4.h create mode 100644 include/03.gdt/gdt5.c create mode 100644 include/03.gdt/gdt5.h create mode 100644 include/03.gdt/gdt6.c create mode 100644 include/03.gdt/gdt6.h create mode 100644 include/03.gdt/gdt7.c (limited to 'include/03.gdt') diff --git a/include/03.gdt/deo1 b/include/03.gdt/deo1 deleted file mode 100644 index c45e28b..0000000 --- a/include/03.gdt/deo1 +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/include/03.gdt/deo2 b/include/03.gdt/deo2 deleted file mode 100644 index cbc5e1d..0000000 --- a/include/03.gdt/deo2 +++ /dev/null @@ -1,9 +0,0 @@ -struct gdt_entry -{ - uint16_t limit; - uint16_t base1; - uint8_t base2; - uint8_t access; - uint8_t limit_flags; - uint8_t base3; -} __attribute__((packed)); diff --git a/include/03.gdt/deo3 b/include/03.gdt/deo3 deleted file mode 100644 index e708661..0000000 --- a/include/03.gdt/deo3 +++ /dev/null @@ -1,5 +0,0 @@ -struct gdt_pointer -{ - uint16_t size; - uint32_t offset; -} __attribute__((packed)); diff --git a/include/03.gdt/deo4 b/include/03.gdt/deo4 deleted file mode 100644 index 1abf809..0000000 --- a/include/03.gdt/deo4 +++ /dev/null @@ -1 +0,0 @@ -extern void load_gdt(struct gdt_pointer *gdtp); diff --git a/include/03.gdt/deo5 b/include/03.gdt/deo5 deleted file mode 100644 index ba7c6e2..0000000 --- a/include/03.gdt/deo5 +++ /dev/null @@ -1,2 +0,0 @@ -struct gdt_entry gdt[5]; -struct gdt_pointer gdtp; diff --git a/include/03.gdt/deo6 b/include/03.gdt/deo6 deleted file mode 100644 index 8d6a1f0..0000000 --- a/include/03.gdt/deo6 +++ /dev/null @@ -1,9 +0,0 @@ -void init_gdt_entry(size_t num, uint32_t limit, uint32_t base, uint8_t access, uint8_t limit_flags) -{ - gdt[num].limit=limit; - gdt[num].base1=(base & 0xffff); - gdt[num].base2=(base & 0xff0000) >> 16; - gdt[num].access=access; - gdt[num].limit_flags=limit_flags; - gdt[num].base3=(base & 0xff000000) >> 24; -} diff --git a/include/03.gdt/deo7 b/include/03.gdt/deo7 deleted file mode 100644 index d69d009..0000000 --- a/include/03.gdt/deo7 +++ /dev/null @@ -1,4 +0,0 @@ -void init_gdt_table() -{ - gdtp.size=sizeof(gdt)-1; - gdtp.offset=(uint32_t)&gdt; diff --git a/include/03.gdt/deo8 b/include/03.gdt/deo8 deleted file mode 100644 index a122d84..0000000 --- a/include/03.gdt/deo8 +++ /dev/null @@ -1,5 +0,0 @@ - init_gdt_entry(0,0,0,0,0); // null segment - init_gdt_entry(1,0xffffffff,0,0b10011010,0b11001111); // code segment - init_gdt_entry(2,0xffffffff,0,0b10010010,0b11001111); // data segment - init_gdt_entry(3,0xffffffff,0,0b11111010,0b11001111); // user mode code segment - init_gdt_entry(4,0xffffffff,0,0b11110010,0b11001111); // user mode data segment diff --git a/include/03.gdt/deo9 b/include/03.gdt/deo9 deleted file mode 100644 index 89736a5..0000000 --- a/include/03.gdt/deo9 +++ /dev/null @@ -1,2 +0,0 @@ - load_gdt(&gdtp); -} diff --git a/include/03.gdt/gdt.c b/include/03.gdt/gdt.c index e3d2b4c..76ae9dd 100644 --- a/include/03.gdt/gdt.c +++ b/include/03.gdt/gdt.c @@ -1,46 +1,32 @@ +#include #include -struct gdt_entry -{ - uint16_t limit; - uint16_t base1; - uint8_t base2; - uint8_t access; - uint8_t limit_flags; - uint8_t base3; -} __attribute__((packed)); - -struct gdt_pointer -{ - uint16_t size; - uint32_t offset; -} __attribute__((packed)); - extern void load_gdt(struct gdt_pointer *gdtp); struct gdt_entry gdt[5]; struct gdt_pointer gdtp; -void init_gdt_entry(size_t num, uint32_t limit, uint32_t base, uint8_t access, uint8_t limit_flags) +void init_gdt_entry(size_t num, uint16_t limit, uint32_t base, uint8_t access, + uint8_t limit_flags) { gdt[num].limit=limit; gdt[num].base1=(base & 0xffff); - gdt[num].base2=(base & 0xff0000) >> 16; + gdt[num].base2=(uint8_t)((base & 0xff0000) >> 16); gdt[num].access=access; gdt[num].limit_flags=limit_flags; - gdt[num].base3=(base & 0xff000000) >> 24; + gdt[num].base3=(uint8_t)((base & 0xff000000) >> 24); } -void init_gdt_table() +void init_gdt_table(void) { gdtp.size=sizeof(gdt)-1; gdtp.offset=(uint32_t)&gdt; - init_gdt_entry(0,0,0,0,0); // null segment - init_gdt_entry(1,0xffffffff,0,0b10011010,0b11001111); // code segment - init_gdt_entry(2,0xffffffff,0,0b10010010,0b11001111); // data segment - init_gdt_entry(3,0xffffffff,0,0b11111010,0b11001111); // user mode code segment - init_gdt_entry(4,0xffffffff,0,0b11110010,0b11001111); // user mode data segment + init_gdt_entry(0,0,0,0,0); // null segment + init_gdt_entry(1,0xffff,0,0x9a,0xcf); // code segment + init_gdt_entry(2,0xffff,0,0x92,0xcf); // data segment + init_gdt_entry(3,0xffff,0,0xfa,0xcf); // user mode code segment + init_gdt_entry(4,0xffff,0,0xf2,0xcf); // user mode data segment load_gdt(&gdtp); } diff --git a/include/03.gdt/gdt.h b/include/03.gdt/gdt.h new file mode 100644 index 0000000..f31a982 --- /dev/null +++ b/include/03.gdt/gdt.h @@ -0,0 +1,26 @@ +#ifndef SOURCE_GDT_H +#define SOURCE_GDT_H + +#include + +struct gdt_entry +{ + uint16_t limit; + uint16_t base1; + uint8_t base2; + uint8_t access; + uint8_t limit_flags; + uint8_t base3; +} __attribute__((packed)); + +struct gdt_pointer +{ + uint16_t size; + uint32_t offset; +} __attribute__((packed)); + +void init_gdt_entry(size_t num, uint16_t limit, uint32_t base, uint8_t access, + uint8_t limit_flags); +void init_gdt_table(void); + +#endif diff --git a/include/03.gdt/gdt1.c b/include/03.gdt/gdt1.c new file mode 100644 index 0000000..dfd3835 --- /dev/null +++ b/include/03.gdt/gdt1.c @@ -0,0 +1,2 @@ +#include +#include diff --git a/include/03.gdt/gdt1.h b/include/03.gdt/gdt1.h new file mode 100644 index 0000000..07fcf62 --- /dev/null +++ b/include/03.gdt/gdt1.h @@ -0,0 +1,2 @@ +#ifndef SOURCE_GDT_H +#define SOURCE_GDT_H diff --git a/include/03.gdt/gdt2.c b/include/03.gdt/gdt2.c new file mode 100644 index 0000000..1abf809 --- /dev/null +++ b/include/03.gdt/gdt2.c @@ -0,0 +1 @@ +extern void load_gdt(struct gdt_pointer *gdtp); diff --git a/include/03.gdt/gdt2.h b/include/03.gdt/gdt2.h new file mode 100644 index 0000000..c45e28b --- /dev/null +++ b/include/03.gdt/gdt2.h @@ -0,0 +1 @@ +#include diff --git a/include/03.gdt/gdt3.c b/include/03.gdt/gdt3.c new file mode 100644 index 0000000..ba7c6e2 --- /dev/null +++ b/include/03.gdt/gdt3.c @@ -0,0 +1,2 @@ +struct gdt_entry gdt[5]; +struct gdt_pointer gdtp; diff --git a/include/03.gdt/gdt3.h b/include/03.gdt/gdt3.h new file mode 100644 index 0000000..cbc5e1d --- /dev/null +++ b/include/03.gdt/gdt3.h @@ -0,0 +1,9 @@ +struct gdt_entry +{ + uint16_t limit; + uint16_t base1; + uint8_t base2; + uint8_t access; + uint8_t limit_flags; + uint8_t base3; +} __attribute__((packed)); diff --git a/include/03.gdt/gdt4.c b/include/03.gdt/gdt4.c new file mode 100644 index 0000000..ebff5cb --- /dev/null +++ b/include/03.gdt/gdt4.c @@ -0,0 +1,10 @@ +void init_gdt_entry(size_t num, uint16_t limit, uint32_t base, uint8_t access, + uint8_t limit_flags) +{ + gdt[num].limit=limit; + gdt[num].base1=(base & 0xffff); + gdt[num].base2=(uint8_t)((base & 0xff0000) >> 16); + gdt[num].access=access; + gdt[num].limit_flags=limit_flags; + gdt[num].base3=(uint8_t)((base & 0xff000000) >> 24); +} diff --git a/include/03.gdt/gdt4.h b/include/03.gdt/gdt4.h new file mode 100644 index 0000000..e708661 --- /dev/null +++ b/include/03.gdt/gdt4.h @@ -0,0 +1,5 @@ +struct gdt_pointer +{ + uint16_t size; + uint32_t offset; +} __attribute__((packed)); diff --git a/include/03.gdt/gdt5.c b/include/03.gdt/gdt5.c new file mode 100644 index 0000000..c41ef42 --- /dev/null +++ b/include/03.gdt/gdt5.c @@ -0,0 +1,4 @@ +void init_gdt_table(void) +{ + gdtp.size=sizeof(gdt)-1; + gdtp.offset=(uint32_t)&gdt; diff --git a/include/03.gdt/gdt5.h b/include/03.gdt/gdt5.h new file mode 100644 index 0000000..430309c --- /dev/null +++ b/include/03.gdt/gdt5.h @@ -0,0 +1,3 @@ +void init_gdt_entry(size_t num, uint16_t limit, uint32_t base, uint8_t access, + uint8_t limit_flags); +void init_gdt_table(void); diff --git a/include/03.gdt/gdt6.c b/include/03.gdt/gdt6.c new file mode 100644 index 0000000..974a942 --- /dev/null +++ b/include/03.gdt/gdt6.c @@ -0,0 +1,5 @@ + init_gdt_entry(0,0,0,0,0); // null segment + init_gdt_entry(1,0xffff,0,0x9a,0xcf); // code segment + init_gdt_entry(2,0xffff,0,0x92,0xcf); // data segment + init_gdt_entry(3,0xffff,0,0xfa,0xcf); // user mode code segment + init_gdt_entry(4,0xffff,0,0xf2,0xcf); // user mode data segment diff --git a/include/03.gdt/gdt6.h b/include/03.gdt/gdt6.h new file mode 100644 index 0000000..69331c3 --- /dev/null +++ b/include/03.gdt/gdt6.h @@ -0,0 +1 @@ +#endif diff --git a/include/03.gdt/gdt7.c b/include/03.gdt/gdt7.c new file mode 100644 index 0000000..89736a5 --- /dev/null +++ b/include/03.gdt/gdt7.c @@ -0,0 +1,2 @@ + load_gdt(&gdtp); +} -- cgit v1.2.3