Compare commits
	
		
			5 Commits
		
	
	
		
			5781f730d9
			...
			e82392e9d9
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| e82392e9d9 | |||
| 64c87a2a58 | |||
| 04470edcc6 | |||
| 2970806705 | |||
| e8df6ec628 | 
							
								
								
									
										7
									
								
								.gdbinit
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								.gdbinit
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| target remote localhost:1234 | ||||
|  | ||||
| file root/boot/myos.bin | ||||
| symbol-file kernel.sym | ||||
|  | ||||
| break prekernel/prekernel.cpp:18 | ||||
| continue | ||||
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -11,3 +11,5 @@ root/ | ||||
| *.a | ||||
|  | ||||
|  | ||||
| /CoreLib/warnings.log | ||||
| /kernel/warnings.log | ||||
|  | ||||
| @ -15,8 +15,6 @@ $(OUTPUTFILE): $(OFILES) | ||||
| 	pwd | ||||
| 	ar -rc $(OUTPUTFILE) $(OFILES) | ||||
|  | ||||
|  | ||||
|  | ||||
| $(OBJ_FOLDER)/ctype.o: ctype.cpp | ||||
| 	$(CPP) -c ctype.cpp -o $(OBJ_FOLDER)/ctype.o $(CFLAGS) | ||||
|  | ||||
|  | ||||
| @ -108,7 +108,7 @@ int isprint (int ch){ | ||||
|         return 1; | ||||
|     if(isspace(ch)) | ||||
|         return 1; | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -39,7 +39,7 @@ OFILES = $(OBJ_DIR)/boot.o	\ | ||||
| OBJ_LINK_LIST = $(CRTI_OBJ) $(CRTBEGIN_OBJ) $(OFILES) $(CRTEND_OBJ) $(CRTN_OBJ)   | ||||
| INTERNAL_OBJS = $(CRTI_OBJ) $(OFILES) $(CRTN_OBJ) | ||||
|  | ||||
| all:  build | ||||
| all: clean build | ||||
|  | ||||
| clean: | ||||
| 	rm $(OBJ_DIR)/* -r | ||||
| @ -49,7 +49,7 @@ build: $(OBJ_LINK_LIST) | ||||
| 	$(CPP) -T linker.ld -o $(BUILD_DIR)/myos.bin -ffreestanding -ggdb -Og -nostdlib $(OBJ_LINK_LIST) -lgcc -L ../build/CoreLib -lCoreLib | ||||
|  | ||||
| # C++ definition -> Object files | ||||
| $(OBJ_DIR)/kernel.o: | ||||
| $(OBJ_DIR)/kernel.o: kernel.cpp | ||||
| 	$(CPP) -c kernel.cpp -o $(OBJ_DIR)/kernel.o $(CFLAGS) -fno-exceptions -fno-rtti | ||||
|  | ||||
| $(OBJ_DIR)/kterm.o: | ||||
|  | ||||
| @ -1,20 +1,22 @@ | ||||
| #include "acpi.h" | ||||
| #include "../../CoreLib/Memory.h" | ||||
| #include "../memory/VirtualMemoryManager.h" | ||||
|  | ||||
| RSDPDescriptor* ACPI::rsd_ptr; | ||||
| RSCPDescriptor20* ACPI::rsd2_ptr; | ||||
| RSDT* ACPI::rsd_table; | ||||
|  | ||||
|  | ||||
| const int KERNEL_OFFSET = 0xC0000000; | ||||
|  | ||||
| void ACPI::initialize(){ | ||||
|  | ||||
|     // Find the Root System Description Pointer | ||||
|     ACPI::rsd_ptr = FindRSD(); | ||||
|     printf("RSD address: 0x%x\n", ACPI::rsd_ptr); | ||||
|     //printRSD(rsd_ptr); | ||||
|     printRSD(rsd_ptr); | ||||
|  | ||||
|  | ||||
|     if( rsd_ptr->Revision == 0 ){ | ||||
|         // Using veriosn 1.0 of the ACPI specifiction | ||||
|         // Using version 1.0 of the ACPI specification | ||||
|         int sum = rsd_ptr->Checksum; | ||||
|         for (int i =0; i < sizeof(RSDPDescriptor) ; i++) { | ||||
|             sum += ((char*)rsd_ptr)[i]; | ||||
| @ -26,11 +28,34 @@ void ACPI::initialize(){ | ||||
|         else | ||||
|             printf("invalid rsd\n"); | ||||
|  | ||||
|         printf("rsdp: 0x%x\n", rsd_ptr); | ||||
|  | ||||
|         printf("0x%x address\n", (rsd_ptr->RsdtAddress)); | ||||
|         Immediate_Map(rsd_ptr->RsdtAddress + KERNEL_OFFSET, rsd_ptr->RsdtAddress); | ||||
|  | ||||
|         RSDT* rootSystemDescriptionTable = (RSDT*)(rsd_ptr->RsdtAddress + KERNEL_OFFSET); | ||||
|         //printf("0x%x Root System Descriptor address\n", rootSystemDescriptionTable); | ||||
|         // checksum it, but we'll ignore it for now | ||||
|         printf("signature "); | ||||
|         for (int i = 0; i < 4; i++) { | ||||
|             kterm_put( rootSystemDescriptionTable->h.Signature[i]); | ||||
|         } | ||||
|         kterm_put('\n'); | ||||
|  | ||||
|  | ||||
|         int entries = (rootSystemDescriptionTable->h.Length - sizeof (rootSystemDescriptionTable->h)) /4; | ||||
|         printf("%d num entries\n", entries); | ||||
|         for( int i = 0; i < entries; i++){ | ||||
|             ACPISDTHeader* h = (ACPISDTHeader*) rootSystemDescriptionTable->PointerToSDT + i ; | ||||
|             if(strncmp(h->Signature, "FACP", 4)){ | ||||
|                 printf("Found FACP Entry!\n"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
|         //  Get the Root System Description Table NOTE: might need memory mapping | ||||
|         //RSDT* rootSystemDescriptionTable = (RSDT*) (rsd_ptr->RsdtAddress + 0xC0000000); | ||||
|     } else{ | ||||
|         // parse it as of version2.0 | ||||
|         printf("rsd2_ptr\n"); | ||||
|         ACPI::rsd2_ptr = (RSCPDescriptor20*)rsd_ptr; | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -23,11 +23,22 @@ RSDPDescriptor* FindRSD(){ | ||||
|     char* memory_byte = (char*) 0x000f2e14; | ||||
|     const void* string = "RSD PTR "; | ||||
|  | ||||
|     for( ; (uint32_t) memory_byte < 0x00100000; memory_byte+=10){ | ||||
|  | ||||
|     for( ; (uint32_t) memory_byte < 0x0100000; memory_byte+=10){ | ||||
|         if( memcmp(memory_byte , string , 8 ) ==  0 ) { | ||||
|         printf("RSD PTR found at 0x%x !\n", memory_byte); | ||||
|         return (RSDPDescriptor*) memory_byte; | ||||
|         break; | ||||
|         } | ||||
|     } | ||||
|     return (RSDPDescriptor*) memory_byte; | ||||
|  | ||||
|     memory_byte = (char*) 0x000E0000; | ||||
|     for ( ;(uint32_t) memory_byte < 0x000FFFFF; memory_byte += 1) | ||||
|     { | ||||
|         if( memcmp(memory_byte , string , 8 ) ==  0 ) { | ||||
|             printf("RSD PTR found at 0x%x !\n", memory_byte); | ||||
|             return (RSDPDescriptor*) memory_byte; | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -16,10 +16,9 @@ struct ACPISDTHeader{ | ||||
|     uint32_t CreatorRevision; | ||||
| }; | ||||
|  | ||||
|  | ||||
| struct RSDT{ | ||||
|     struct ACPISDTHeader h; | ||||
|     uint32_t PointerToSDT[]; // Length of array : (header.Length - sizeof(header))/ 4 | ||||
|     uint32_t *PointerToSDT; // Length of array : (header.Length - sizeof(header))/ 4 | ||||
| }__attribute__((packed)); | ||||
|  | ||||
|  | ||||
| @ -28,7 +27,7 @@ struct RSDPDescriptor { | ||||
|     uint8_t Checksum ; | ||||
|     char OEMID [6]; | ||||
|     uint8_t Revision; | ||||
|     RSDT* RsdtAddress; | ||||
|     uint32_t RsdtAddress; | ||||
| }__attribute__((packed)); | ||||
|  | ||||
| struct RSCPDescriptor20{ | ||||
|  | ||||
| @ -42,43 +42,33 @@ extern "C" void kernel () | ||||
| { | ||||
|     init_serial(); | ||||
|     kterm_init(); | ||||
|  | ||||
|     print_serial("kterm initialized...\n"); | ||||
|     setup_tss(); | ||||
|     initGDT(); | ||||
|     initidt(); | ||||
|     LoadGlobalDescriptorTable(); | ||||
|     flush_tss(); | ||||
|     printf("Memory setup complete!\n"); | ||||
|  | ||||
|     print_serial("Memory initialized....\n"); | ||||
|     // Enable interrupts | ||||
|     asm volatile("STI"); | ||||
|  | ||||
|     initHeap(); | ||||
|     pit_initialise(); | ||||
|     ACPI::initialize(); | ||||
|     PCI::Scan(); | ||||
|     print_serial("Heap initialized...\n"); | ||||
|     //pit_initialise(); | ||||
|  | ||||
|  | ||||
|     //ACPI::initialize(); | ||||
|     //PCI::Scan(); | ||||
|     processor::initialize(); | ||||
|     processor::enable_protectedMode(); | ||||
|     initBootDrive(); | ||||
|     VirtualFileSystem::initialize(); | ||||
|  | ||||
|      | ||||
|  | ||||
|     print_serial("Run test!"); | ||||
| #define VFS_EXAMPLE | ||||
| #ifdef VFS_EXAMPLE | ||||
|     auto fontFile = VirtualFileSystem::open("/FONT    PSF", 0); | ||||
|     if(grubcfg->flags == 0){ | ||||
|         uint16_t* contents = (uint16_t*) malloc(sizeof(uint16_t) * 256); | ||||
|         grubcfg->read(grubcfg, contents, 512); | ||||
|  | ||||
|         for(int i =0 ; i < grubcfg->root->size; i++ ){ | ||||
|             kterm_put(contents[i] & 0x00ff); | ||||
|             kterm_put(contents[i] >> 8); | ||||
|         } | ||||
|         kterm_put('\n'); | ||||
|         free((void*)contents); | ||||
|     }else{ | ||||
|         printf("Could not find file\n"); | ||||
|     } | ||||
|     printf("Size of font file: %d bytes", fontFile->root->size); // COOL This Works like a charm | ||||
| #endif | ||||
|  | ||||
| #ifdef USERMODE_RELEASE | ||||
| @ -86,6 +76,7 @@ extern "C" void kernel () | ||||
|     jump_usermode(); | ||||
| #else | ||||
|     startSuperVisorTerminal(); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| } | ||||
| @ -1,4 +1,6 @@ | ||||
| #include "VirtualMemoryManager.h" | ||||
| #include "../../CoreLib/Memory.h" | ||||
|  | ||||
| #define ALIGN(addr, align) (((addr) & ~((align) - 1 )) + (align)) | ||||
|  | ||||
| extern uint32_t boot_page_directory[1024] ; // points to the wrong location | ||||
| @ -14,7 +16,7 @@ void flush_cr3(){ | ||||
|  | ||||
| void AllocatePage(uint32_t vaddr) | ||||
| { | ||||
|     uint32_t page_aligned_address = ALIGN(vaddr, 4096); | ||||
|     //uint32_t page_aligned_address = ALIGN(vaddr, 4096); | ||||
|  | ||||
|     // allocate a page at  virtual address | ||||
|     int PageDirectoryEntryIndex = vaddr >> 22; | ||||
| @ -54,16 +56,16 @@ void AllocatePage(uint32_t vaddr) | ||||
|  | ||||
| void FreePage(uint32_t vaddr ) | ||||
| { | ||||
|     uint32_t page_aligned_address = ALIGN(vaddr, 4096); | ||||
|     // uint32_t page_aligned_address = ALIGN(vaddr, 4096); | ||||
|  | ||||
|     // allocate a page at  virtual address | ||||
|     int PageDirectoryEntryIndex = vaddr >> 22; | ||||
|     int PageTableEntryIndex = (vaddr >> 12) & 0x1FFF; | ||||
|  | ||||
|     uint32_t* pageTable = (uint32_t*)(boot_page_directory[PageDirectoryEntryIndex] & 0xFFFFE000 + 0xC0000000); | ||||
|     uint32_t* pageTable = (uint32_t*)(boot_page_directory[PageDirectoryEntryIndex] & (0xFFFFE000 + 0xC0000000)); | ||||
|  | ||||
|  | ||||
|     void* physicalAddressToFree = (void*)(pageTable[PageTableEntryIndex] & 0xFFFFE000 + 0xC0000000); | ||||
|     void* physicalAddressToFree = (void*)(pageTable[PageTableEntryIndex] & (0xFFFFE000 + 0xC0000000)); | ||||
|     free_block(physicalAddressToFree); | ||||
|  | ||||
|     pageTable[PageTableEntryIndex] = 0x0; | ||||
| @ -80,9 +82,9 @@ void Immediate_Map (  uint32_t vaddr, uint32_t paddr) | ||||
|     int PageTableEntryIndex = (vaddr >> 12) & 0x1FFF; | ||||
|  | ||||
|     printf("Map address at PDE 0x%x PTE  0x%x\n", PageDirectoryEntryIndex, PageTableEntryIndex); | ||||
|  | ||||
|      if ((boot_page_directory - 0xC0000000)[PageDirectoryEntryIndex] & 0x1 )  | ||||
|     { | ||||
|     printf("boot pagedirectoy address: 0x%x\n", &boot_page_directory); | ||||
|     printf("PDE : 0x%x\n", boot_page_directory[PageTableEntryIndex]); | ||||
|      if (boot_page_directory[PageDirectoryEntryIndex] & 0x1 ) { | ||||
|         printf("Directory entry is marked as present\n"); | ||||
|  | ||||
|     } else { | ||||
| @ -90,37 +92,39 @@ void Immediate_Map (  uint32_t vaddr, uint32_t paddr) | ||||
|         // mark the page table as present and allocate a physical block for it | ||||
|  | ||||
|         void* new_page_dir = allocate_block(); | ||||
|         printf("New page directory address 0x%x\n", new_page_dir); | ||||
|          memset(new_page_dir, 0 , 1024 * sizeof (uint32_t)); | ||||
|         printf("New page directory address 0x%x\n", &new_page_dir); | ||||
|         boot_page_directory[PageDirectoryEntryIndex] = (uint32_t)new_page_dir | 0x3; | ||||
|          | ||||
|     } | ||||
|  | ||||
|     printf("PDE found at : 0x%x\n", (uint32_t) &boot_page_directory[PageDirectoryEntryIndex]); | ||||
|         uint32_t* page_table = (uint32_t*)(boot_page_directory[PageDirectoryEntryIndex] & 0xFFFFE000) ; | ||||
|         //page_table = (uint32_t*) ((uint32_t)page_table - 0xC0000000); // remove kernel offset | ||||
|         printf("Page table address: 0x%x\n", (uint32_t)page_table); | ||||
|     uint32_t* page_table = (uint32_t*)(boot_page_directory[PageDirectoryEntryIndex] & 0xFFFFE000) ; | ||||
|     printf("Page table address: 0x%x\n", (uint32_t)page_table); | ||||
|  | ||||
|           // check if the page table entry is marked as present  | ||||
|         if ( page_table[PageTableEntryIndex] & 0x1 ) | ||||
|         {    | ||||
|             printf("page already present!\n"); | ||||
|             printf("Entry found at addr: 0x%x\n", &(page_table[PageTableEntryIndex])); | ||||
|         } else{ | ||||
|             printf("Mapping a physical page.\n"); | ||||
|             // Map the entry to a physical page | ||||
|             page_table[PageTableEntryIndex] = (uint32_t)(paddr | 0x3); | ||||
|         } | ||||
|       // check if the page table entry is marked as present | ||||
|     if ( page_table[PageTableEntryIndex] & 0x1 ) | ||||
|     { | ||||
|         printf("page already present!\n"); | ||||
|         printf("Entry found at addr: 0x%x\n", &(page_table[PageTableEntryIndex])); | ||||
|     } else{ | ||||
|         printf("Mapping a physical page.\n"); | ||||
|         // Map the entry to a physical page | ||||
|         page_table[PageTableEntryIndex] = (uint32_t)(paddr | 0x3); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     asm ("cli; invlpg (%0); sti" :: "r" (vaddr) : "memory" ); | ||||
|     asm ("invlpg (%0)" :: "r" (vaddr) : "memory" ); | ||||
| } | ||||
|  | ||||
|  | ||||
| // NOT IMPLEMENTED | ||||
| void Immediate_Unmap(uint32_t vaddr) | ||||
| { | ||||
|     // NOTE: I will implement lazy unmapping for now  | ||||
|     uint32_t page_aligned_address = ALIGN(vaddr, 4096); | ||||
|     //uint32_t page_aligned_address = ALIGN(vaddr, 4096); | ||||
|  | ||||
|     // allocate a page at  virtual address | ||||
|     int PageDirectoryEntryIndex = vaddr >> 22; | ||||
|     int PageTableEntryIndex = (vaddr >> 12) & 0x1FFF; | ||||
|     //int PageDirectoryEntryIndex = vaddr >> 22; | ||||
|     //int PageTableEntryIndex = (vaddr >> 12) & 0x1FFF; | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -107,10 +107,10 @@ DirectoryNode* FAT::Lookup (inode* currentDir , DirectoryNode*  dir) | ||||
|     for(int i = 0; i < sizeof(data) / sizeof (DIR); i++) | ||||
|     { | ||||
|         DIR* entry = (DIR*)((uint32_t)directory + (i * sizeof(DIR))); | ||||
|  | ||||
|  | ||||
|         if( | ||||
|             entry->Name[0] == FAT::FREE_DIR || | ||||
|             entry->Name[0] == FAT::FREE_DIR_2 || | ||||
|             entry->Name[0] == 0xE5 || | ||||
|             entry->ATTR & FAT::ATTRIBUTES::ATTR_VOLUME_ID || | ||||
|             entry->ATTR & FAT::ATTRIBUTES::ATTR_SYSTEM || | ||||
|             entry->ATTR & FAT::ATTRIBUTES::ATTR_HIDDEN | ||||
| @ -118,6 +118,20 @@ DirectoryNode* FAT::Lookup (inode* currentDir , DirectoryNode*  dir) | ||||
|             continue; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         if( entry->ATTR & FAT::ATTRIBUTES::ATTR_DIRECTORY){ | ||||
|             printf("entry in directory\n"); | ||||
|             for(int i = 0; i < 11 ;i ++) | ||||
|                 kterm_put(entry->Name[i]); | ||||
|             kterm_put('\n'); | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|         if( entry->Name[0] == FAT::FREE_DIR_2 ) | ||||
|             break; | ||||
|  | ||||
|         auto* dirNode = (DirectoryNode*) malloc(sizeof (DirectoryNode)); | ||||
|  | ||||
|         char* name = (char*)malloc(sizeof(char[11])); | ||||
|  | ||||
| @ -22,22 +22,22 @@ inline MBR* GetPartitions(bool DEBUG = false){ | ||||
|     int S =1; | ||||
|     uint32_t LBA = (C*HPC+H) * SPT + (S-1); | ||||
|  | ||||
|     MBR* mbr =(MBR*) malloc(sizeof (MBR)); | ||||
|     uint16_t* mbr =(uint16_t*) malloc(sizeof (MBR)); | ||||
|  | ||||
|     ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, LBA, (uint16_t*)mbr); | ||||
|     ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, LBA,  mbr ); | ||||
|     auto bootRecord = (MBR*)(mbr); | ||||
|  | ||||
|  | ||||
|     printf("MBR (In Memory) Address 0x%x, Size = %d\n", mbr, sizeof (MBR)); | ||||
|     printf("MBR (In Memory) Address 0x%x, Size = %d\n", bootRecord, sizeof (MBR)); | ||||
|     if(DEBUG){ | ||||
|         printf("BootSector: 0x%x\n", mbr->ValidBootsector ); | ||||
|         printf("BootSector: 0x%x\n", bootRecord->ValidBootsector ); | ||||
|         for( int i = 0 ; i < 4 ; i ++){ | ||||
|             PartitionTableEntry PT = mbr->TableEntries[i]; | ||||
|             PartitionTableEntry PT = bootRecord->TableEntries[i]; | ||||
|  | ||||
|             printf("Partition %d [  %d sectors,  PartitionType: 0x%x, 0x%x, \nLBA Start: 0x%x ]\n" , | ||||
|                    i, PT.Number_sectors_inPartition, PT.PartitionType, mbr->uniqueID,  PT.LBA_partition_start ); | ||||
|                    i, PT.Number_sectors_inPartition, PT.PartitionType, bootRecord->uniqueID,  PT.LBA_partition_start ); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|     return mbr; | ||||
|     return bootRecord; | ||||
| } | ||||
|  | ||||
| @ -80,20 +80,37 @@ FILE* VirtualFileSystem::open(const char* pathname, int flags){ | ||||
|     } | ||||
|  | ||||
|     // let's just loop through the folder first | ||||
|     printf("looking for: "); | ||||
|     for(int i = 0; i < 5; i++) | ||||
|         kterm_put(nextdir[i]); | ||||
|     kterm_put('\n'); | ||||
|     auto* child = rootentry->children; | ||||
|     while(child->next != nullptr){ | ||||
|  | ||||
|         auto* directory = (DirectoryNode*)child->data; | ||||
|  | ||||
|         for(int i = 0; i < 11 ; i++) | ||||
|             kterm_put(directory->name[i]); | ||||
|         kterm_put('\n'); | ||||
|  | ||||
|         if( directory->compare(directory, directory->name, nextdir) == 0){ | ||||
|             nextdir = strtok(nullptr, "/", &tokstate); | ||||
|             printf("Found dir!\n"); | ||||
|             if(nextdir == NULL){ | ||||
|                 file->root = directory->node; | ||||
|                 file->flags =0; | ||||
|                 file->read = FAT::Read; | ||||
|                 return file; | ||||
|             } | ||||
|             printf("continue searching next directory!\n"); | ||||
|             if(directory->children == nullptr) | ||||
|                 directory->node->lookup(directory->node, directory); | ||||
|  | ||||
|  | ||||
|             child = directory->children; | ||||
|  | ||||
|         }else{ | ||||
|             child = child->next; | ||||
|         } | ||||
|         child = child->next; | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -21,7 +21,14 @@ void kterm_init () { | ||||
|     kterm_row = 0; | ||||
|     kterm_column = 0; | ||||
|     kterm_color = vga_entry_color ( VGA_COLOR_LIGHT_GREY , VGA_COLOR_BLACK); | ||||
|     kterm_buffer = (uint16_t*) 0xC03FF000; | ||||
|  | ||||
|     //Physical address | ||||
|     // 0xB8000 | ||||
|     // Virtual address | ||||
|     // 0xC03FF000 | ||||
|  | ||||
|     //kterm_buffer = ((uint16_t*) 0xB8000); | ||||
|     kterm_buffer = ((uint16_t*)  0xC03FF000 ); | ||||
|      | ||||
|     for (size_t y = 0; y < VGA_HEIGHT; y++ ){ | ||||
|         for( size_t x = 0; x < VGA_WIDTH; x++){ | ||||
| @ -59,7 +66,6 @@ void disable_cursor() | ||||
|         outb(0x3D5, 0x20); | ||||
| } | ||||
|  | ||||
|  | ||||
| void update_cursor(int x, int y){ | ||||
|     uint16_t pos = y * VGA_WIDTH + x; | ||||
|  | ||||
| @ -86,8 +92,6 @@ int get_cursor_y (uint16_t cursor_pos ) { | ||||
|     return cursor_pos / VGA_WIDTH; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| /** | ||||
|  *  With the help from: | ||||
|  * https://whiteheadsoftware.dev/operating-systems-development-for-dummies/ | ||||
| @ -134,7 +138,6 @@ void kterm_writestring(const char* data ){ | ||||
|     kterm_write(data, strlen(data)); | ||||
| } | ||||
|  | ||||
|  | ||||
| static void itoa (char *buf, int base, int d) { | ||||
|     char *p = buf; | ||||
|     char *p1, *p2; | ||||
| @ -173,28 +176,28 @@ static void itoa (char *buf, int base, int d) { | ||||
|  | ||||
| void printf ( const char *format, ...) { | ||||
|      | ||||
|     char **arg = (char **)&format; | ||||
|     auto **arg = (unsigned char **)&format; | ||||
|     int c; | ||||
|     char buf[20]; | ||||
|  | ||||
|     arg++; | ||||
|      | ||||
|     while ((c = *format++) != 0){ | ||||
|     while ((c = *(const unsigned char*)format++) != 0){ | ||||
|         if( c != '%') | ||||
|             kterm_put(c); | ||||
|         else{ | ||||
|             char *p, *p2; | ||||
|             char const *p, *p2; | ||||
|             int pad0 = 0, pad = 0; | ||||
|  | ||||
|             c = *format++; | ||||
|             c = *(const unsigned char*)format++; | ||||
|             if(c =='0'){ | ||||
|                 pad0 = 1; | ||||
|                 c = *format++; | ||||
|                 c = *(const unsigned char*)format++; | ||||
|             } | ||||
|  | ||||
|             if ( c >= '0' && c <= '9'){ | ||||
|                 pad = c - '0'; | ||||
|                 c = *format++; | ||||
|                 c = *(const unsigned char*)format++; | ||||
|             } | ||||
|  | ||||
|             switch (c) | ||||
| @ -210,7 +213,7 @@ void printf ( const char *format, ...) { | ||||
|                 break; | ||||
|              | ||||
|             case 's': | ||||
|                 p = *arg++; | ||||
|                 p = (char const *)*arg++; | ||||
|                 if(!p) | ||||
|                     p = "(null)"; | ||||
|                  | ||||
| @ -224,7 +227,7 @@ void printf ( const char *format, ...) { | ||||
|  | ||||
|  | ||||
|             default: | ||||
|                 kterm_put(*((int *)arg++)); | ||||
|                 kterm_put(*(int *) arg++); // NOLINT(cppcoreguidelines-narrowing-conversions) | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
							
								
								
									
										22
									
								
								run.sh
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								run.sh
									
									
									
									
									
								
							| @ -3,23 +3,25 @@ PROC=$$ | ||||
|  | ||||
| # Build the Corelib static library | ||||
| (cd CoreLib | ||||
| if ! make; then | ||||
|     echo "Build failed!" | ||||
| if ! make 2> warnings.log 1> /dev/null ; then | ||||
|     echo "Build Corelib failed!" | ||||
|     kill -10 $PROC | ||||
| fi) | ||||
|  | ||||
| # Build the kernel image | ||||
| (cd kernel | ||||
| make clean | ||||
| make | ||||
| if ! make; then | ||||
|   echo "Build failed!" | ||||
| # make clean | ||||
| if ! make 2> warnings.log 1> /dev/null ; then | ||||
|   echo "Build kernel failed!" | ||||
|   kill -10 $PROC | ||||
| fi) | ||||
|  | ||||
| ./scripts/update_harddrive.sh | ||||
| ./scripts/create_symbol_lookup.sh | ||||
|  | ||||
|  | ||||
|  | ||||
| ./scripts/run_qemu.sh | ||||
|  | ||||
| args=""; | ||||
| if [[ $1 == "-d" ]] | ||||
| then | ||||
|   args="debug" | ||||
| fi | ||||
| ./scripts/run_qemu.sh $args | ||||
|  | ||||
| @ -1,3 +1,4 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| objcopy --only-keep-debug build/kernel/myos.bin kernel.sym | ||||
| echo "creating symbols file" | ||||
| echo $(pwd) | ||||
| objcopy --only-keep-debug root/boot/myos.bin kernel.sym | ||||
| @ -1,7 +1,13 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| if [[ $1 == "debug" ]] | ||||
| then | ||||
|   qemu-system-i386 -s -boot d -drive format=raw,file=disk.img -serial stdio -vga std -display gtk -m 2G -cpu core2duo -d int -no-shutdown -no-reboot | ||||
| else | ||||
|   qemu-system-i386 -s -boot d -drive format=raw,file=disk.img -serial stdio -vga std -display gtk -m 2G -cpu core2duo | ||||
| fi | ||||
| # Run from harddisk | ||||
| qemu-system-i386 -boot d -drive format=raw,file=disk.img -serial stdio -vga std -display gtk -m 2G -cpu core2duo | ||||
| #qemu-system-i386 -boot d -drive format=raw,file=disk.img -serial stdio -vga std -display gtk -m 2G -cpu core2duo -d int -no-shutdown -no-reboot | ||||
|  | ||||
| # Run disk version | ||||
| # qemu-system-i386 -cdrom barinkOS.iso -serial stdio -vga std -display gtk -m 2G -cpu core2duo -s -d int -no-shutdown -no-reboot | ||||
|  | ||||
		Reference in New Issue
	
	Block a user