From e98f2c3436ee45f8d6c44fbe90e3eca795598373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20Ren=C3=A7ber?= <86446300+Aermoss@users.noreply.github.com> Date: Thu, 18 Aug 2022 18:50:19 +0300 Subject: [PATCH] Add files via upload --- Makefile | 8 ++++++ bin/boot.bin | Bin 0 -> 512 bytes bin/extended.o | Bin 0 -> 3616 bytes bin/final.bin | Bin 0 -> 21012 bytes bin/final.tmp | Bin 0 -> 8256 bytes bin/kernel.bin | Bin 0 -> 20500 bytes bin/kernel.o | Bin 0 -> 1863 bytes bin/kernel.tmp | Bin 0 -> 8927 bytes boot.asm | 10 +++++++ cpuid.asm | 29 +++++++++++++++++++++ extended.asm | 47 +++++++++++++++++++++++++++++++++ gdt.asm | 36 +++++++++++++++++++++++++ identity_paging.asm | 34 ++++++++++++++++++++++++ io.asm | 42 ++++++++++++++++++++++++++++++ kernel.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++ read_disk.asm | 24 +++++++++++++++++ 16 files changed, 292 insertions(+) create mode 100644 Makefile create mode 100644 bin/boot.bin create mode 100644 bin/extended.o create mode 100644 bin/final.bin create mode 100644 bin/final.tmp create mode 100644 bin/kernel.bin create mode 100644 bin/kernel.o create mode 100644 bin/kernel.tmp create mode 100644 boot.asm create mode 100644 cpuid.asm create mode 100644 extended.asm create mode 100644 gdt.asm create mode 100644 identity_paging.asm create mode 100644 io.asm create mode 100644 kernel.cpp create mode 100644 read_disk.asm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9622eef --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +default: + nasm boot.asm -f bin -o bin/boot.bin + nasm extended.asm -f elf64 -o bin/extended.o + gcc -ffreestanding -mno-red-zone -m64 -c kernel.cpp -o bin/kernel.o + ld -Ttext 0x8000 bin/extended.o bin/kernel.o -o bin/kernel.tmp + objcopy -O binary bin/kernel.tmp bin/kernel.bin + copy /b bin\boot.bin+bin\kernel.bin bin\final.bin + qemu-system-x86_64 bin/final.bin \ No newline at end of file diff --git a/bin/boot.bin b/bin/boot.bin new file mode 100644 index 0000000000000000000000000000000000000000..a228ce2317c167143ff081543bc1695115007954 GIT binary patch literal 512 zcmeAWv#WW*%<%FX^A@Jv3=JC;x_|;(8MZNOWI8Kc#CUkOM$HQahS&en5;JpBQxr<_ z6^c?5QxsA%i?eyT7#OxNoE3Y`aCi$}7rPBZ3F}z_=ht61FdTmI_CL^2u*3%5vjQ8q S&I-I{0E#n=fXD&zp literal 0 HcmV?d00001 diff --git a/bin/extended.o b/bin/extended.o new file mode 100644 index 0000000000000000000000000000000000000000..765e2f8637eeb9f065034a312e0b9381fe742f53 GIT binary patch literal 3616 zcmeH~O=uHA6oB6*+E&}Tt>AA3*C42%F&5O55)ieAB6<*dk!72m#)ULlcBfzjF(s#7 za_CXpiziXRlhER!(SYr(UIg)C5s_domIee-<9oX^O*3shc$7@Y%zNK^^WMyxESbH3 zdGJa^(?B*2E6Ug`9*oh^(XkCQ>f?wkgxgauFTPhMr~>+EI@xjMVau5S~=ywJ;J8`-L|5o=UP-8^a0J~bw%Xk8kUSO!%0YA0 z{L80=1Jvs%Jy;CK$;Du`0B^RF{ka$_)jjY-*Y*PFMtP*Tpy{#lR|@)hvMcgsvNAO^ z@#-vq0oSLehHgxsS>U~u8BANyAANs~aSR@*)M|5pr=Z6^&bLPmfbn@!QBJIrlTv<3 z3!kMDPaGbvkY{neTJ0#`-*F5t2%BQrfvdS5D+-jDxy9{WS z&(c5>Xk@m-O^gjJ%b91oUXHUAXSO+tjtH&c3^T3%1lWuWX38CNY^h{&*>vcb%?S$% z4eDBH2R-l^!62Bx%Y)DOm}@#VY7Wnvp~vPlj=pjhw>+*c&h&{w(639nR@g&AqUQrI z#cR(`OyRQjCloH=$v6ocMxe&W5FnsA3d(Sr_C literal 0 HcmV?d00001 diff --git a/bin/final.bin b/bin/final.bin new file mode 100644 index 0000000000000000000000000000000000000000..9559099401d1a1da3f0407ea3da0b591586ec882 GIT binary patch literal 21012 zcmeI$Urbw77y$6^wz~sy^U$w*it885~FEl^;TwdHTd zEa_r;A&`YPm+e6x^+8Oq;ZF>=yIP2`p}rY?5Epe9stIu@jnQ4da|=2&zKz6~?~tDJ z-E+VDopXL|_?IYs{<7(WjbEH|jwOiAvI(5{5R&kLBlB2TGM0{CHW}pZb+iV11AZ0_ zv2dW(&-}qikE;Y=4l<=VFy~Urdo&ZM-AT6udzn_-N#9)}m;8#T|eJZ9fy(7LVDdqa+m$72_ zcIJrV`x)a#ie)VQgjUQwm=T+gR!@f6sjKA;1ql zmZL@jBtQZrKmz|afo86K$KyXRtx@G#bJ@$9kHyEBbmcJi6<1U~=_^YEh+*R+Ji7?E z=F8)l$I*wCVlE#J7Y}CPVr~%PvPyK^C{QmBK*0X ze7q!~?&bMZQ8envrFXNfLP4?i7C-IFM`}c*Bq8CuW6u@V+~SkXc_n!?AvT@oQ%&}B zO0xM*Ld_XCXY%;R>@{Qe#CY6BRm&#uJS)Ducw6!L!lP0ai(l21s|){_JySC9%DG87 z?G@>+Wic#fJ}We?t@54QJhge4YgwLJcW_Azhj?X*YoDIebY7X|alMIa@|*Zz?$vz@ z;?i={RBKziKhV+H73}Wm zz1SD(zZ8x{2L^|RM@Avi8S!`GcmA^t4bQRT!}Z?Ry|wQCP$W3)js&{g;lN36KB@kN^pg011!)36KB@kN^pg zzySy(bn7R4!E9mtM$@e$7>lufLbu8=7UL+sDlk5P9Z*RUAOR8}0TLhq5+DH*AOR8} z0TLjA0~U~qopN#YA*a*?V8=)QCEm?B;O$U(5+DH*AOR8}0TLhq5+DH*AOR8}0TLhq c5+DH*AOR8}0TLhq5+DH*AOR8}fd?e;2hk_>$^ZZW literal 0 HcmV?d00001 diff --git a/bin/final.tmp b/bin/final.tmp new file mode 100644 index 0000000000000000000000000000000000000000..f4871269bae159715dc570cd9d4d423dfc7765a7 GIT binary patch literal 8256 zcmeHMU2GIp6u!I5N(IVRR5V0nXqqTVyB2~C(FYdVhOL2iZHo{RbD8c=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b4J;0R%oUAwqWnCBBLZFyiRStv-=r-mM(MYinba}IOpaF4fF6d3P zGjGRl-^_fLY%6syw3=mMaBUszad{n{1xFg7EXvq_S{6NgD49p$H%WNr`Lv`Mqgqvv z+KtUSX&3yseAw~xa_RbjUhD->AavvUz*{%`)x=Y!6#*bEeY|rM%PR>-X?uGOWB{rC z`^q7w09|1#kf9FD#aLrdDy?eIO|tT2+zSHwtM0L+Ww^t|Iwx zS8mKtCG6=Zst}w~;f=LCdnt81GWN>%eZ)xd`BbHAp`RY(iO7>hfBw(FJ8N98OttD0da3`hcwJdw_(G)iPEz7#! zJ%r!e`KQ}5@@}3g^P&kyz1+&Sng#jVTkMqDhGD{aX) z&n}7O08e+X@nQ9wubYkORkm}N6*mtuy~c_g4kqy70P8F={j0OO!8&V9GeS%k-^T~* zZ|_+UmlmVEo(P5rOfZ;U#O(<)f~ ztk+iBaAp-RC{(aBul-?J%`ClWzK0pS0=^Gd?S>n*8_(zMpZCpK>PdhENPq+$x4^>u z-0Vy;5ud&ki%wmfyf6_N9~%vi3=a*S44w$|_H=joeg3ZQp5DNT;K{+E;gRs@*mz{( z!sNxNXzbE-JdvE4ots~P_*i^o3_tnLoId@s^3q%|a6ZuEjYZ>;Id42X?wtL*B zCnJ*yWoTaMi%gw4=RFtbQDW24iSTfuQwbjTAIJXyP$K~nAOR8}0TLhq5+DH*AOR8} z0TS2;fsA4OiWhv=9DmRa>oCTA41Qo(9*p_8fL8~``>+ElNdhE50wh2JBtQZrKmsH{ z0wh2JB(To{g3Bqox(+yn5P%&Y`H#4jv(MY1@+3e4BtQZrKmsH{0wh2JBtQZrKmsH{ d0wh2JBtQZrKmsH{0wh2JBtQZrKmw0R;7@`7$AbU> literal 0 HcmV?d00001 diff --git a/bin/kernel.o b/bin/kernel.o new file mode 100644 index 0000000000000000000000000000000000000000..e86408ba5e503b5788b6fa8b11f9db4292cfa830 GIT binary patch literal 1863 zcmZ`(Pi)&%7=Mn_t`w$N(?FHrV2K`9sWC~LW*IOM7}g$Q6**8%LZFg5ZsImeGTUj> zNF7C)P^>D_t{^T*963j<5>mpTo6r#1c^5!J>sAgGhs}pE^L>7fYp>&z{NC?<-|u~Y z-t+qkUmPPSl@UT-a#55>rrI!F%!aK9A=4ZoUq{*cIhaI}`&26A&3u6OESM#^p0s2b zL7Naz*8M3qzhPpi?ul zzw5Cb<`82a&^Kh;m_-!plD2%$)v=fdbbG;$bx*W0X`6O(?!H)e;a*$VzX7^E+WJZS zi1y9#`g<3);lDz^k5^)?e~-J*~F zr2Pk@)EdzK?-9!36s1#rYW;G->d~nIZS`{0a`*3l7zzlXncET48zGeIQL7K>aYxjx z9-Q!xv93JPjtq^ij%{zrHg`YiILfGE?%|p% z&5g$TTHQ4C%e89dQh9YnD;1a3g0hr9lR2H9OU=$C6Umv`)Li;>=1hJ`DX7cElD4v1 zzEr8!F6)L_Ut4c%G>K6(3Pp&_jqxL6Gf|#{hvwoF|ARda=J^i}AUOX4Jptbk&Kc+t z6M%7U!Z!){{JC?li>Dfy^kO;{uT>4L5jWIQTvyi;)8adIt!#=*8{)iHIe#&JF`W`? zdUZur%qcM=B_(*&Ti^r#niFneAN757+eZ}gV*bDt!M?|X?;#ok zgcroSH8HE;TTl8{tddz@@sa3Tv2JEP<)dleDlKbe6;>!u972lRs;XDivZT~%Ov^^h z1BD|Zi9r6(l9xe=x8QPI0!GBUV46k4%?*w@i1&*4pBH$RkMPX{A#4sAme z?C02ac@EDmEWuumXUuaSgbA<;_HlfWJO`KllmvVDsL#Q_E-W+N(mi|bt+3Hso%LqS zIYQ=PWLZu&n@zI#QA#tbc`c`CfahwuRxxw$D*(a CV245g literal 0 HcmV?d00001 diff --git a/bin/kernel.tmp b/bin/kernel.tmp new file mode 100644 index 0000000000000000000000000000000000000000..d59648e969a1e488f23cc500381d19631483e76a GIT binary patch literal 8927 zcmeHMZEPGz8J;`)+|-SG*U%JGiFOk#rIGMqJC5s8q`I|FSqnQp5?f7+U|HX-&zsy= zcK00H!o|^5m9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)Xw4p-&^4K{@y66SkLHZ!k z#=SriaZ72AjC2CNzFlG`08S63H~vK_IYa-0!9QadL<}sGyy}G!E zLeB*C^5~i691(@!{G_ah;u6U3IY)Boc?Ss1ZihqL&|d3x)Y;=tV+Hb$hBTl4w527gXWKvOJ-tFP{iQ_?j%8@Qt6u&9!aco@zLSKg*TYmxK_3#GQ z;~t$_+>X^0z{#*G?dF;7}?>I`;sfn#1X? z==IHtUQ@*JcsN_`Mf26q&O%b2Z`ZAisz+lw>ie^Xp0=W2kByQLOKPey%ES`gG&woR zXnjiOl1Z#dF)q;Zv?a*SV_~>+M7}n z+A~B?E=7!A))6!DPm}Z!ICM}$d!T5O6<(R?|eG5d~8;XKY$nMtLCna*Q$K%?l zre@tP3sYIQGHyIuz6}*6rKjO~#`O5CQ|gpqQid`M<+(;CW1QcZ~Y=8giL5ri0%t*4V{t5kdY5wPco T?Y(d?mNQHYJZ(JD*s}iseFIwl literal 0 HcmV?d00001 diff --git a/boot.asm b/boot.asm new file mode 100644 index 0000000..32c7c00 --- /dev/null +++ b/boot.asm @@ -0,0 +1,10 @@ +[org 0x7c00] + +mov [BOOT_DISK], dl +call read_disk + +jmp PROGRAM_SPACE +%include "read_disk.asm" +%include "io.asm" +times 510 - ($ - $$) db 0 +dw 0xaa55 \ No newline at end of file diff --git a/cpuid.asm b/cpuid.asm new file mode 100644 index 0000000..b971375 --- /dev/null +++ b/cpuid.asm @@ -0,0 +1,29 @@ +detect_cpuid: + pushfd + pop eax + mov ecx, eax + xor eax, 1 << 21 + push eax + popfd + + pushfd + pop eax + push ecx + popfd + + xor eax, ecx + jz no_cpuid + ret + +detect_long_mode: + mov eax, 0x80000001 + cpuid + test edx, 1 << 29 + jz no_long_mode + ret + +no_cpuid: + hlt + +no_long_mode: + hlt \ No newline at end of file diff --git a/extended.asm b/extended.asm new file mode 100644 index 0000000..05e8f36 --- /dev/null +++ b/extended.asm @@ -0,0 +1,47 @@ +jmp enter_protected_mode +%include "gdt.asm" + +enter_protected_mode: + call enable_a20 + cli + lgdt [gdt_descriptor] + mov eax, cr0 + or eax, 1 + mov cr0, eax + jmp codeseg:start_protected_mode + +enable_a20: + in al, 0x92 + or al, 2 + out 0x92, al + ret + +[bits 32] +%include "cpuid.asm" +%include "identity_paging.asm" + +start_protected_mode: + mov ax, dataseg + mov ds, ax + mov es, ax + mov ss, ax + mov fs, ax + mov gs, ax + call detect_cpuid + call detect_long_mode + call setup_identity_paging + call edit_gdt + jmp codeseg:start_long_mode + +[bits 64] +[extern _start] + +start_long_mode: + mov edi, 0xb8000 + mov rax, 0x0f200f200f200f20 + mov ecx, 500 + rep stosq + call _start + jmp $ + +times 2048 - ($ - $$) db 0 \ No newline at end of file diff --git a/gdt.asm b/gdt.asm new file mode 100644 index 0000000..501fae8 --- /dev/null +++ b/gdt.asm @@ -0,0 +1,36 @@ +gdt_nulldesc: + dd 0, 0 + +gdt_codedesc: + dw 0xFFFF + dw 0x0000 + db 0x00 + db 10011010b + db 11001111b + db 0x00 + +gdt_datadesc: + dw 0xFFFF + dw 0x0000 + db 0x00 + db 10010010b + db 11001111b + db 0x00 + +gdt_end: + +gdt_descriptor: + gdt_size: + dw gdt_end - gdt_nulldesc - 1 + dd gdt_nulldesc + +codeseg equ gdt_codedesc - gdt_nulldesc +dataseg equ gdt_datadesc - gdt_nulldesc + +[bits 32] +edit_gdt: + mov [gdt_codedesc + 6], byte 10101111b + mov [gdt_datadesc + 6], byte 10101111b + ret + +[bits 16] \ No newline at end of file diff --git a/identity_paging.asm b/identity_paging.asm new file mode 100644 index 0000000..20baac6 --- /dev/null +++ b/identity_paging.asm @@ -0,0 +1,34 @@ +paging_table_entry equ 0x1000 + +setup_identity_paging: + mov edi, paging_table_entry + mov cr3, edi + mov dword [edi], 0x2003 + add edi, 0x1000 + mov dword [edi], 0x3003 + add edi, 0x1000 + mov dword [edi], 0x4003 + add edi, 0x1000 + + mov ebx, 0x00000003 + mov ecx, 512 + + .set_entry: + mov dword [edi], ebx + add ebx, 0x1000 + add edi, 8 + loop .set_entry + + mov eax, cr4 + or eax, 1 << 5 + mov cr4, eax + + mov ecx, 0xC0000080 + rdmsr + or eax, 1 << 8 + wrmsr + + mov eax, cr0 + or eax, 1 << 31 + mov cr0, eax + ret \ No newline at end of file diff --git a/io.asm b/io.asm new file mode 100644 index 0000000..04d906a --- /dev/null +++ b/io.asm @@ -0,0 +1,42 @@ +get_char: + mov ah, 0x0 + int 0x16 + jmp .exit + + .exit: + ret + +print: + mov ah, 0x0e + + .loop: + mov al, [bx] + cmp al, 0x0 + je .exit + int 0x10 + inc bx + jmp .loop + + .exit: + mov al, 0x0 + ret + +println: + call print + call newline + jmp .exit + + .exit: + ret + +newline: + mov ah, 0x0e + mov al, 0x0d + int 0x10 + mov al, 0xa + int 0x10 + jmp .exit + + .exit: + mov al, 0x0 + ret \ No newline at end of file diff --git a/kernel.cpp b/kernel.cpp new file mode 100644 index 0000000..eb4993d --- /dev/null +++ b/kernel.cpp @@ -0,0 +1,62 @@ +#include +#include + +#define VIDEO_MEMORY 0xb8000 +#define ROW_SIZE 80 +#define COL_SIZE 25 + +char* itoa(int value, char* str, int base) { + char *rc, *ptr, *low; + + if (base < 2 || base > 36) { + *str = '\0'; + return str; + } + + rc = ptr = str; + if (value < 0 && base == 10) *ptr++ = '-'; + low = ptr; + + do { + *ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz" [35 + value % base]; + value /= base; + } while (value); + + *ptr-- = '\0'; + + while (low < ptr) { + char tmp = *low; + *low++ = *ptr; + *ptr-- = tmp; + } + + return rc; +} + +uint64_t cursor_position = 0; +void print(const char* message, uint8_t color = 0x00 | 0x0F) { + for (uint64_t i = 0; 1; i++) { + if (message[i] == '\0') return; + else if (message[i] == '\n') { + cursor_position += ROW_SIZE - (cursor_position % ROW_SIZE); + continue; + } + + *(uint8_t*) (VIDEO_MEMORY + cursor_position * 2) = message[i]; + *(uint8_t*) (VIDEO_MEMORY + (cursor_position * 2) + 1) = color; + cursor_position++; + } +} + +void clear(uint8_t color = 0x00 | 0x00) { + for (uint64_t i = 0; i < ROW_SIZE * COL_SIZE; i++) { + *(uint8_t*) (VIDEO_MEMORY + i * 2) = 219; + *(uint8_t*) (VIDEO_MEMORY + (i * 2) + 1) = color; + } +} + +extern "C" void _start() { + print("sgsdg\n"); + print(itoa(199, nullptr, 10)); + return; +} \ No newline at end of file diff --git a/read_disk.asm b/read_disk.asm new file mode 100644 index 0000000..6eb4eb5 --- /dev/null +++ b/read_disk.asm @@ -0,0 +1,24 @@ +PROGRAM_SPACE equ 0x8000 + +read_disk: + mov ah, 0x02 + mov bx, PROGRAM_SPACE + mov al, 32 + mov dl, [BOOT_DISK] + mov ch, 0x00 + mov dh, 0x00 + mov cl, 0x02 + int 0x13 + jc raise_disk_read_error + ret + +raise_disk_read_error: + mov bx, disk_read_error + call print + jmp $ + +disk_read_error: + db "failed to read disk", 0x0d, 0xa, 0x0 + +BOOT_DISK: + db 0 \ No newline at end of file