Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I cleaned up your code for you! #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ objs = $(boot_dir)/head.o \
$(klib_dir)/string.o \
$(klib_dir)/kmalloc.o \
$(klib_dir)/stdlib.o \
$(klib_dir)/abort.o
$(klib_dir)/abort.o

all: build $(objs)
$(LD) $(LDFLAGS) $(objs) -o $(kernel)
$(LD) $(LDFLAGS) $(objs) -o $(kernel)

build:
cd $(boot_dir) && make
Expand Down Expand Up @@ -82,13 +82,13 @@ qemu_test:
create_test_data:
sudo mount test/img/hda.img /media/test -o loop
mkdir -p /media/test/dir_a/dir_b /media/test/dir_A/dir_B
echo "foobar" > /media/test/dir_a/dir_b/foobar.txt
echo "foobar" > /media/test/dir_a/dir_b/foobar.txt
echo "ABCDE" > /media/test/test.txt
cd test/test_program/ && make && cp hello /media/test/.
sudo umount /media/test
sudo umount /media/test

clean:
cd $(boot_dir) && make clean
cd $(boot_dir) && make clean
cd $(init_dir) && make clean
cd $(kern_dir) && make clean
cd $(kern_mm_dir) && make clean
Expand All @@ -100,6 +100,6 @@ clean:
cd $(klib_dir) && make clean
cd test/test_program && make clean
-rm -f $(kernel) *.log
find . -name '*~' -exec rm {} \;
find . -name '*~' -exec rm {} \;

.PHONY: clean all install test
2 changes: 1 addition & 1 deletion Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CC = gcc
LD = ld

CFLAGS = -Wall -Wextra -fno-builtin
CFLAGS += -fno-common -nostdlib -nostdinc -nostartfiles -nodefaultlibs
CFLAGS += -fno-common -nostdlib -nostdinc -nostartfiles -nodefaultlibs
CFLAGS += -m32
CFLAGS += -mno-red-zone -ffreestanding -fno-stack-protector

6 changes: 3 additions & 3 deletions boot/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/
#define ASM 1
#include <mikoOS/multiboot.h>
.section .entry

.section .entry
.code32

.globl _start
_start:
jmp entry
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/ata/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CFLAGS += -I../../../include -I.
objs = ata_hdd.o

all: $(objs)

.c.o:
$(CC) $(CFLAGS) $< -c

Expand Down
28 changes: 14 additions & 14 deletions drivers/block/ata/ata_hdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ static u_int32_t max_logical_sector_num = 0;
// driver operations.
static int open_ATA_disk(void);
static int close_ATA_disk(void);
static int read_sector(int device, u_int32_t sector,
static int read_sector(int device, u_int32_t sector,
sector_t *buf, size_t buf_size);
static int write_sector(int device, u_int32_t sector,
static int write_sector(int device, u_int32_t sector,
sector_t *buf, size_t buf_size);

// For find IDE interface.
Expand Down Expand Up @@ -97,7 +97,7 @@ static void sector_rw_test(void)
// buf[0] = 0x6261;
// buf[1] = 0x6463;
// buf[2] = 0xa065;

// write_sector(0, 222, buf, sizeof(buf) / sizeof(buf[0]));

memset(block.sector, 0x0, sizeof(block.sector));
Expand Down Expand Up @@ -148,7 +148,7 @@ static int close_ATA_disk(void)
* @param data size. it should be 256.
* @return negative if fail to write data.
*/
int write_sector(int device, u_int32_t sector,
int write_sector(int device, u_int32_t sector,
sector_t *buf, size_t buf_size)
{
bool ret;
Expand All @@ -160,7 +160,7 @@ int write_sector(int device, u_int32_t sector,

finish_sector_rw();

for (i = 0; i < buf_size; i++)
for (i = 0; i < buf_size; i++)
outw(DATA_REGISTER, buf[i]);

return 0;
Expand All @@ -174,7 +174,7 @@ int write_sector(int device, u_int32_t sector,
* @param data size. it should be 256.
* @return 0 if process is success. if something wrong it returns negative value
*/
int read_sector(int device, u_int32_t sector,
int read_sector(int device, u_int32_t sector,
sector_t *buf, size_t buf_size)
{
bool ret;
Expand All @@ -184,7 +184,7 @@ int read_sector(int device, u_int32_t sector,
printk("buf_size isn't 256\n");
while (1);
}

ret = sector_rw_common(PIO_SECTOR_READ_CMD, device, sector);
if (!ret)
return -1;
Expand Down Expand Up @@ -418,7 +418,7 @@ static bool is_device_fault(void)
u_int8_t data;

data = inb(STATUS_REGISTER);

return (data >> 5 & 0x01) == 1 ? true : false;
}

Expand Down Expand Up @@ -499,7 +499,7 @@ static bool sector_rw_common(u_int8_t cmd, int device, u_int32_t sector)
print_error_register(device);
return false;
}

if (!is_drq_active(status)) {
if (loop > 5) {
printk("DRQ didn't be active\n");
Expand Down Expand Up @@ -568,7 +568,7 @@ static bool do_identify_device(int device, sector_t *buf)

for (i = 0; i < 256; i++)
buf[i] = inw(DATA_REGISTER);
}
}

return true;

Expand All @@ -583,11 +583,11 @@ static void do_soft_reset(int device)
// Initialize master/slave.
set_device_number(device);

// Do DEVICE RESET command.
// Do DEVICE RESET command.
write_command(0x08);

// Wait sometime after DEVICE RESET.
wait_loop_usec(5);
wait_loop_usec(5);
}

// It represents device type.
Expand Down Expand Up @@ -655,7 +655,7 @@ static bool initialize_common(int device)
}

max_logical_sector_num = ((u_int32_t) buf[61] << 16) | buf[60];

return true;
}

Expand Down Expand Up @@ -685,7 +685,7 @@ bool init_ata_disk_driver(void)
{
if (!find_ata_device())
return false;

set_bus_master_bit();

get_base_address();
Expand Down
8 changes: 4 additions & 4 deletions drivers/block/block_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct blk_device_drivers blk_drivers_head = {
.op = NULL,
.next = &blk_drivers_head,
};

/**
* Regist block driver operation to the list.
* @param op
Expand All @@ -21,7 +21,7 @@ void register_blk_driver(struct blk_dev_driver_operations *op)
p = kmalloc(sizeof(*p));
if (!p)
KERN_ABORT("kmalloc failed");

p->op = op;
p->next = blk_drivers_head.next;
blk_drivers_head.next = p;
Expand Down Expand Up @@ -61,7 +61,7 @@ void show_all_registered_driver(void)
* @param name is device driver name.
* @return non null / null.
*/
struct blk_device_drivers *get_blk_driver(const char *name)
struct blk_device_drivers *get_blk_driver(const char *name)
{
struct blk_device_drivers *p;

Expand All @@ -79,7 +79,7 @@ struct blk_device_drivers *get_blk_driver(const char *name)
* @param how much block do you want to read?
* @return 0 is success.
*/
int blk_read_sector(const struct blk_device_drivers *blk_driver, block_data_t *out,
int blk_read_sector(const struct blk_device_drivers *blk_driver, block_data_t *out,
unsigned long sector_num, int count)
{
int i;
Expand Down
2 changes: 1 addition & 1 deletion drivers/pci/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CFLAGS += -I../../include -I.
objs = pci.o

all: $(objs)

.c.o:
$(CC) $(CFLAGS) $< -c

Expand Down
40 changes: 20 additions & 20 deletions drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ static inline u_int32_t read_pci_class(struct pci_configuration_register *reg);
static inline u_int32_t read_pci_header_type(struct pci_configuration_register *reg);
static u_int32_t find_pci_data(u_int8_t bus, u_int8_t dev);

static bool store_pci_device_to_list(u_int8_t bus, u_int8_t devfn,
u_int32_t data, u_int8_t func,
static bool store_pci_device_to_list(u_int8_t bus, u_int8_t devfn,
u_int32_t data, u_int8_t func,
u_int32_t class, u_int32_t header,
u_int32_t subsystem);

Expand All @@ -76,9 +76,9 @@ static inline int is_multi_function(u_int32_t data)
return (data & 0x800000) ? 1 : 0;
}

static bool
store_pci_device_to_list(u_int8_t bus, u_int8_t devfn,
u_int32_t data, u_int8_t func,
static bool
store_pci_device_to_list(u_int8_t bus, u_int8_t devfn,
u_int32_t data, u_int8_t func,
u_int32_t class, u_int32_t header,
u_int32_t subsystem)
{
Expand Down Expand Up @@ -134,7 +134,7 @@ static u_int32_t read_pci_data(struct pci_configuration_register *reg)

// write data to CONFIG_ADDRESS.
write_pci_config_address(reg);

data = inl(CONFIG_DATA_1);

finish_access_to_config_data(reg);
Expand All @@ -155,7 +155,7 @@ static void write_pci_data(struct pci_configuration_register *reg, u_int32_t dat

// write data to CONFIG_ADDRESS.
write_pci_config_address(reg);

outl(CONFIG_DATA_1, data);
finish_access_to_config_data(reg);
}
Expand All @@ -170,13 +170,13 @@ static inline void write_pci_config_address(const struct pci_configuration_regis
u_int32_t data = 0;

data = (reg->enable_bit << 31) |
(reg->reserved << 24) |
(reg->bus_num << 16) |
(reg->dev_num << 11) |
(reg->reserved << 24) |
(reg->bus_num << 16) |
(reg->dev_num << 11) |
(reg->func_num << 8) |
reg->reg_num;

outl(PCI_CONFIG_ADDRESS, data);
outl(PCI_CONFIG_ADDRESS, data);
}

/**
Expand Down Expand Up @@ -264,7 +264,7 @@ static u_int32_t find_pci_data(u_int8_t bus, u_int8_t dev)

// Check all function numbers.
for (i = 0; i < PCI_FUNCTION_MAX; i++) {
reg.func_num = i;
reg.func_num = i;
data = read_pci_reg00(&reg);
if (data != 0xffffffff) {

Expand All @@ -282,7 +282,7 @@ static u_int32_t find_pci_data(u_int8_t bus, u_int8_t dev)
return 0;
}
}

return 0;
}

Expand All @@ -302,7 +302,7 @@ static bool find_pci_bios32(void)
for (addr = 0xe0000; addr < 0xffff0; addr += 16) {
bios32 = (union pci_bios32 *) addr;

if (bios32 != NULL &&
if (bios32 != NULL &&
bios32->fields.sig[0] == '_' &&
bios32->fields.sig[1] == '3' &&
bios32->fields.sig[2] == '2' &&
Expand All @@ -321,11 +321,11 @@ static bool find_pci_bios32(void)
}
}
}

}
printk("pci bios32 not found\n");
return false;

}
#endif // USE_PCI_BIOS32

Expand Down Expand Up @@ -355,9 +355,9 @@ void show_all_pci_device(void)
struct pci_device_list *p;

for (p = pci_device_head.next; p != &pci_device_head; p = p->next)
printk("Found Device: Bus %d:Devfn %d:Vender 0x%x:Device 0x%x:func %d:header 0x%x:Class 0x%lx-0x%lx:Multi %d\n",
p->data.bus, p->data.devfn,
p->data.vender, p->data.devid,
printk("Found Device: Bus %d:Devfn %d:Vender 0x%x:Device 0x%x:func %d:header 0x%x:Class 0x%lx-0x%lx:Multi %d\n",
p->data.bus, p->data.devfn,
p->data.vender, p->data.devid,
p->data.func, p->data.header_type,
p->data.base_class, p->data.sub_class,
p->data.multi);
Expand Down Expand Up @@ -420,6 +420,6 @@ void pci_data_write(struct pci_device *pci, u_int8_t reg_num, u_int32_t data)
reg.func_num = pci->func;
reg.dev_num = pci->devfn;
reg.bus_num = pci->bus;

write_pci_data(&reg, data);
}
2 changes: 1 addition & 1 deletion fs/ext2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ objs = ext2_superblock.o \
ext2_rw_test.o

all: $(objs)

.c.o:
$(CC) $(CFLAGS) $< -c

Expand Down
4 changes: 2 additions & 2 deletions fs/ext2/ext2_dentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct ext2_dentry {

// hash versions.
enum {
DX_HASH_LEGACY = 0,
DX_HASH_LEGACY = 0,
DX_HASH_HALF_MD4,
DX_HASH_TEA,
};
Expand All @@ -40,4 +40,4 @@ struct ext2_indexed_entry_count_and_limit {
u_int16_t count;
};

#endif // __MIKOOS_EXT2_DENTRY_H
#endif // __MIKOOS_EXT2_DENTRY_H
2 changes: 1 addition & 1 deletion fs/ext2/ext2_inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
enum {
EXT2_BAD_INO = 1, // bad blocks inode
EXT2_ROOT_INO, // root directory inode
EXT2_ACL_IDX_INO, // ACL index inode
EXT2_ACL_IDX_INO, // ACL index inode
EXT2_ACL_DATA_INO, // ACL data inode
EXT2_BOOT_LOADER_INO, // boot loader inode
EXT2_UNDEL_DIR_INO, // undelete directory inode
Expand Down
2 changes: 1 addition & 1 deletion fs/ext2/ext2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ enum {

// for s_feature_compat.
#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 // Block pre-allocation for new directories
#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 // An Ext3 journal exists
#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 // Extended inode attributes are present
#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010 // Non-standard inode size used
Expand Down
Loading