mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2026-01-20 04:15:19 -08:00
Compare commits
7 Commits
gbowne1-pa
...
gbowne1-pa
| Author | SHA1 | Date | |
|---|---|---|---|
| 23cb50a73f | |||
| b6c158957e | |||
|
|
a7b0d1152f | ||
|
|
e38f1aa2ee | ||
|
|
78d5e9a7ab | ||
|
|
daead5ee57 | ||
|
|
4fb81d2e57 |
24
.clang-format
Normal file
24
.clang-format
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
BasedOnStyle: Google
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
ColumnLimit: 80
|
||||||
|
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
PointerAlignment: Right
|
||||||
|
ReferenceAlignment: Right
|
||||||
|
|
||||||
|
AlignConsecutiveMacros: Consecutive
|
||||||
|
AlignTrailingComments:
|
||||||
|
Kind: Always
|
||||||
|
OverEmptyLines: 0
|
||||||
|
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IncludeCategories:
|
||||||
|
# Std headers
|
||||||
|
- Regex: '<[[:alnum:]_.]+>'
|
||||||
|
Priority: 2
|
||||||
|
|
||||||
|
# Other headers
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
6
.clangd
Normal file
6
.clangd
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
CompileFlags:
|
||||||
|
CompilationDatabase: build
|
||||||
|
|
||||||
|
Diagnostics:
|
||||||
|
UnusedIncludes: Strict
|
||||||
|
MissingIncludes: Strict
|
||||||
12
.editorconfig
Normal file
12
.editorconfig
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 8
|
||||||
|
tab_width = 8
|
||||||
6
Makefile
6
Makefile
@@ -18,9 +18,9 @@ KERNEL_OBJ += $(patsubst kernel/%.asm, $(BUILD_DIR)/asm_%.o, $(KERNEL_ASM_SRC))
|
|||||||
KLIBC_SRC = $(wildcard klibc/src/*.c)
|
KLIBC_SRC = $(wildcard klibc/src/*.c)
|
||||||
KLIBC_OBJ = $(patsubst klibc/src/%.c, $(BUILD_DIR)/klibc/%.o, $(KLIBC_SRC))
|
KLIBC_OBJ = $(patsubst klibc/src/%.c, $(BUILD_DIR)/klibc/%.o, $(KLIBC_SRC))
|
||||||
|
|
||||||
|
.PHONY: all stage1 stage2 kernel compile-commands $(BUILD_DIR)/compile_commands.json run gdb clean clean-cross clean-all
|
||||||
all: $(DISK_IMG)
|
all: $(DISK_IMG)
|
||||||
|
|
||||||
.PHONY: stage1 stage2 kernel run gdb clean
|
|
||||||
stage1: $(BUILD_DIR)
|
stage1: $(BUILD_DIR)
|
||||||
$(AS) $(ASFLAGS) -o $(BUILD_DIR)/$@.o bootloader/$@.asm
|
$(AS) $(ASFLAGS) -o $(BUILD_DIR)/$@.o bootloader/$@.asm
|
||||||
$(LD) -Ttext=0x7c00 -melf_i386 -o $(BUILD_DIR)/$@.elf $(BUILD_DIR)/$@.o
|
$(LD) -Ttext=0x7c00 -melf_i386 -o $(BUILD_DIR)/$@.elf $(BUILD_DIR)/$@.o
|
||||||
@@ -57,6 +57,10 @@ $(BUILD_DIR):
|
|||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
mkdir -p $(BUILD_DIR)/klibc
|
mkdir -p $(BUILD_DIR)/klibc
|
||||||
|
|
||||||
|
compile-commands: $(BUILD_DIR)/compile_commands.json
|
||||||
|
$(BUILD_DIR)/compile_commands.json: $(BUILD_DIR)
|
||||||
|
bear --output $@ -- make -B
|
||||||
|
|
||||||
run:
|
run:
|
||||||
qemu-system-i386 -s -S $(DISK_IMG)
|
qemu-system-i386 -s -S $(DISK_IMG)
|
||||||
|
|
||||||
|
|||||||
43
kernel/ata.h
Normal file
43
kernel/ata.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#ifndef ATA_H
|
||||||
|
#define ATA_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/* ATA I/O ports */
|
||||||
|
#define ATA_PRIMARY_IO 0x1F0
|
||||||
|
#define ATA_PRIMARY_CTRL 0x3F6
|
||||||
|
|
||||||
|
/* ATA registers */
|
||||||
|
#define ATA_REG_DATA 0x00
|
||||||
|
#define ATA_REG_ERROR 0x01
|
||||||
|
#define ATA_REG_FEATURES 0x01
|
||||||
|
#define ATA_REG_SECCOUNT0 0x02
|
||||||
|
#define ATA_REG_LBA0 0x03
|
||||||
|
#define ATA_REG_LBA1 0x04
|
||||||
|
#define ATA_REG_LBA2 0x05
|
||||||
|
#define ATA_REG_HDDEVSEL 0x06
|
||||||
|
#define ATA_REG_COMMAND 0x07
|
||||||
|
#define ATA_REG_STATUS 0x07
|
||||||
|
|
||||||
|
/* ATA commands */
|
||||||
|
#define ATA_CMD_READ_PIO 0x20
|
||||||
|
#define ATA_CMD_WRITE_PIO 0x30
|
||||||
|
#define ATA_CMD_IDENTIFY 0xEC
|
||||||
|
|
||||||
|
/* Status flags */
|
||||||
|
#define ATA_SR_BSY 0x80
|
||||||
|
#define ATA_SR_DRDY 0x40
|
||||||
|
#define ATA_SR_DRQ 0x08
|
||||||
|
#define ATA_SR_ERR 0x01
|
||||||
|
|
||||||
|
/* Drive select */
|
||||||
|
#define ATA_MASTER 0x00
|
||||||
|
#define ATA_SLAVE 0x10
|
||||||
|
|
||||||
|
/* Public API */
|
||||||
|
bool ata_init(void);
|
||||||
|
bool ata_read_sector(uint32_t lba, uint8_t* buffer);
|
||||||
|
bool ata_write_sector(uint32_t lba, const uint8_t* buffer);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user