From 0ab5044bf5fc492779f08ff0a3323e1943aa0d4a Mon Sep 17 00:00:00 2001 From: acevest Date: Thu, 4 Nov 2021 23:22:43 +0800 Subject: [PATCH] fix compile warnings --- drivers/console.c | 3 + drivers/ide.c | 26 +++-- drivers/keyboard.c | 31 +++-- drivers/vga.c | 4 +- fs/ext2.c | 16 ++- include/assert.h | 3 + include/linkage.h | 4 + include/pci.h | 2 +- include/sched.h | 2 + include/string.h | 1 + kernel/assert.c | 4 +- kernel/cpuid.c | 2 + kernel/fork.c | 4 +- kernel/init.c | 1 + kernel/pci.c | 284 +++++++++++++++++++++++---------------------- kernel/printk.c | 3 + kernel/sched.c | 1 - kernel/semaphore.c | 1 + kernel/wait.c | 1 + mm/buddy.c | 1 + mm/mm.c | 3 + mm/slub.c | 1 + 22 files changed, 224 insertions(+), 174 deletions(-) diff --git a/drivers/console.c b/drivers/console.c index 1985a4a..f0bbbb0 100644 --- a/drivers/console.c +++ b/drivers/console.c @@ -8,9 +8,12 @@ */ #include +#include #include #include +void vga_putc(unsigned int nr, unsigned char c, const unsigned char color); + cnsl_t cnsl; static bool empty(const cnsl_queue_t *q) { return q->head == q->tail; } diff --git a/drivers/ide.c b/drivers/ide.c index 07cf935..1aa22c0 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -127,7 +128,8 @@ void ide_do_read(u64_t lba, u32_t scnt, char *buf) { task->state = TASK_WAIT; irq_save(flags); finish = r->finish; - // printd("%s pid %d finish %u read_scnt %u scnt %u\n", __func__, sysc_getpid(), r->finish, r->read_scnt, r->scnt); + // printd("%s pid %d finish %u read_scnt %u scnt %u\n", __func__, sysc_getpid(), r->finish, r->read_scnt, + // r->scnt); irq_restore(flags); if (finish) break; @@ -174,8 +176,10 @@ void ide_pci_init(pci_device_t *pci) { HD_CHL1_CMD_BASE = pci->bars[2] ? pci->bars[2] : HD_CHL1_CMD_BASE; HD_CHL1_CTL_BASE = pci->bars[3] ? pci->bars[3] : HD_CHL1_CTL_BASE; - printk("channel0: cmd %04x ctl %04x channel1: cmd %04x ctl %04x\n", HD_CHL0_CMD_BASE, HD_CHL0_CTL_BASE, HD_CHL1_CMD_BASE, HD_CHL1_CTL_BASE); - // printl(18, "channel0: cmd %04x ctl %04x channel1: cmd %04x ctl %04x", HD_CHL0_CMD_BASE, HD_CHL0_CTL_BASE, HD_CHL1_CMD_BASE, HD_CHL1_CTL_BASE); + printk("channel0: cmd %04x ctl %04x channel1: cmd %04x ctl %04x\n", HD_CHL0_CMD_BASE, HD_CHL0_CTL_BASE, + HD_CHL1_CMD_BASE, HD_CHL1_CTL_BASE); + // printl(18, "channel0: cmd %04x ctl %04x channel1: cmd %04x ctl %04x", HD_CHL0_CMD_BASE, HD_CHL0_CTL_BASE, + // HD_CHL1_CMD_BASE, HD_CHL1_CTL_BASE); } void ide_status() { @@ -200,8 +204,10 @@ void ide_debug() { void init_pci_controller(unsigned int classcode) { pci_device_t *pci = pci_find_device_by_classcode(classcode); if (pci != 0 && pci->intr_line < 16) { - printk("found pci vendor %04x device %04x class %04x intr %d\n", pci->vendor, pci->device, pci->classcode, pci->intr_line); - // printl(17, "found pci vendor %04x device %04x class %04x intr %d", pci->vendor, pci->device, pci->classcode, pci->intr_line); + printk("found pci vendor %04x device %04x class %04x intr %d\n", pci->vendor, pci->device, pci->classcode, + pci->intr_line); + // printl(17, "found pci vendor %04x device %04x class %04x intr %d", pci->vendor, pci->device, pci->classcode, + // pci->intr_line); ide_pci_init(pci); drv.pci = pci; } @@ -371,11 +377,12 @@ void ide_read_extended_partition(u64_t lba, unsigned int inx) { if (p->type != 0x05) { drv.part[inx].lba_start = part_lba; drv.part[inx].lba_end = part_lba + part_scnt; - printk(" logic partition[%02d] [%02x] LBA base %10d end %10d\n", inx, p->type, (unsigned int)(drv.part[inx].lba_start), - (unsigned int)(drv.part[inx].lba_end - 1)); + printk(" logic partition[%02d] [%02x] LBA base %10d end %10d\n", inx, p->type, + (unsigned int)(drv.part[inx].lba_start), (unsigned int)(drv.part[inx].lba_end - 1)); } else { part_lba = drv.ext_lba_base + p->lba; - printk(" extended [%02x] LBA base %10d end %10d\n", p->type, (unsigned int)(part_lba), (unsigned int)(part_lba + part_scnt - 1)); + printk(" extended [%02x] LBA base %10d end %10d\n", p->type, (unsigned int)(part_lba), + (unsigned int)(part_lba + part_scnt - 1)); ide_read_extended_partition(part_lba, inx + 1); } } @@ -416,7 +423,8 @@ void ide_read_partition() { } } - printk("primary partition[%02d] [%02x] LBA base %10d end %10d\n", i, p->type, (unsigned int)(part_lba), (unsigned int)(part_lba + part_scnt - 1)); + printk("primary partition[%02d] [%02x] LBA base %10d end %10d\n", i, p->type, (unsigned int)(part_lba), + (unsigned int)(part_lba + part_scnt - 1)); } kfree(buf); diff --git a/drivers/keyboard.c b/drivers/keyboard.c index 82830f3..bebef5c 100644 --- a/drivers/keyboard.c +++ b/drivers/keyboard.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -28,22 +29,28 @@ void debug_sched(); void vga_dbg_toggle(); int debug_wait_queue_put(unsigned int v); void ide_dma_pci_lba48(); +void vga_switch(unsigned int nr); void kbd_debug(unsigned char scan_code); char kbd_char_tbl[] = { - 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', 0, 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a', - 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0, 0, 0, ' ', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', 0, 'q', 'w', 'e', 'r', 't', 'y', + 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', + 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0, 0, 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; void kbd_handler(unsigned int irq, pt_regs_t *regs, void *dev_id) { diff --git a/drivers/vga.c b/drivers/vga.c index fb4ae2c..ed3fe3f 100644 --- a/drivers/vga.c +++ b/drivers/vga.c @@ -12,6 +12,7 @@ #include #include +#include typedef struct { u8_t c; @@ -208,7 +209,8 @@ void vga_dbg_puts(unsigned int line, unsigned int offset, const char *buf) { int i; char *p = (char *)buf; - vga_char_t *const pv = (vga_char_t *const)(VIDEO_ADDR + (VIDEO_DBG_LINE + line) * BYTES_PER_LINE + offset * sizeof(vga_char_t)); + vga_char_t *const pv = + (vga_char_t *const)(VIDEO_ADDR + (VIDEO_DBG_LINE + line) * BYTES_PER_LINE + offset * sizeof(vga_char_t)); for (i = 0; *p; ++i, ++p) { pv[i] = vga_char(*p, vga_dbg_color); diff --git a/fs/ext2.c b/fs/ext2.c index 5182191..ed56e5b 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -10,6 +10,7 @@ #include "fs.h" #include "mm.h" +#include "string.h" #include "system.h" struct { @@ -18,6 +19,7 @@ struct { } ext2_fs; extern void blk_rw(dev_t dev, u64_t offset, u32_t scnt, char *buf); +extern void kmem_cache_free(kmem_cache_t *cache, void *addr); #define BLKRW(blkid, blkcnt, buf) \ do { \ @@ -125,7 +127,8 @@ unsigned int ext2_search_indir(const char *name, const ext2_inode_t *inode, unsi while (dirent->name_len != 0) { memcpy(tmp, dirent->name, dirent->name_len); tmp[dirent->name_len] = 0; - printd(" dirent %s inode %u rec_len %u name_len %u type %02d\n", tmp, dirent->inode, dirent->rec_len, dirent->name_len, dirent->file_type); + printd(" dirent %s inode %u rec_len %u name_len %u type %02d\n", tmp, dirent->inode, dirent->rec_len, + dirent->name_len, dirent->file_type); if (strcmp(name, tmp) == 0) { ino = dirent->inode; @@ -213,9 +216,10 @@ void ext2_setup_fs() { } printk("Ext2 File System Information:\n"); - printk(" inodes %u blocks %u free blocks %u free inodes %u\n", EXT2_SB->s_inodes_count, EXT2_SB->s_blocks_count, EXT2_SB->s_free_blocks_count, - EXT2_SB->s_free_inodes_count); - printk(" block size %u log block size %u first data block %u\n", EXT2_BLOCK_SIZE, EXT2_SB->s_log_block_size, EXT2_SB->s_first_data_block); + printk(" inodes %u blocks %u free blocks %u free inodes %u\n", EXT2_SB->s_inodes_count, EXT2_SB->s_blocks_count, + EXT2_SB->s_free_blocks_count, EXT2_SB->s_free_inodes_count); + printk(" block size %u log block size %u first data block %u\n", EXT2_BLOCK_SIZE, EXT2_SB->s_log_block_size, + EXT2_SB->s_first_data_block); printk(" blocks per group %u inodes per group %u\n", EXT2_SB->s_blocks_per_group, EXT2_SB->s_inodes_per_group); ext2_block_cache = kmem_cache_create("ext2_block_cache", EXT2_BLOCK_SIZE, EXT2_BLOCK_SIZE); @@ -233,8 +237,8 @@ void ext2_setup_fs() { gps += (EXT2_SB->s_blocks_count % EXT2_SB->s_blocks_per_group) ? 1 : 0; unsigned int i; for (i = 0; i < gps; ++i) { - printd(" [%2u] inode table %u free blocks %u free inode %u used dir %u\n", i, ext2_gd(i)->bg_inode_table, ext2_gd(i)->bg_free_blocks_count, - ext2_gd(i)->bg_free_inodes_count, ext2_gd(i)->bg_used_dirs_count); + printd(" [%2u] inode table %u free blocks %u free inode %u used dir %u\n", i, ext2_gd(i)->bg_inode_table, + ext2_gd(i)->bg_free_blocks_count, ext2_gd(i)->bg_free_inodes_count, ext2_gd(i)->bg_used_dirs_count); } ext2_read_inode(2, &ext2_root_inode); diff --git a/include/assert.h b/include/assert.h index 2e67f27..f6b82d6 100644 --- a/include/assert.h +++ b/include/assert.h @@ -15,6 +15,9 @@ #include +#ifndef ASM +void assert_fail(char *exp, char *file, unsigned int line, const char *func); #define assert(exp) ((exp) ? (void)(0) : assert_fail(__STRING(exp), __FILE__, __LINE__, __PRETTY_FUNCTION__)) +#endif #endif //_ASSERT_H diff --git a/include/linkage.h b/include/linkage.h index 975a7d1..ef66a08 100644 --- a/include/linkage.h +++ b/include/linkage.h @@ -16,6 +16,8 @@ #ifndef __LINKAGE_H #define __LINKAGE_H +#ifdef ASM + #define ALIGN .align 0x04, 0x90 #define ALIGN_STR ".align 0x04,0x90" #define ENTRY(symbol) \ @@ -25,4 +27,6 @@ #endif +#endif + #define __initdata __attribute__((__section__(".init.data"))) diff --git a/include/pci.h b/include/pci.h index cf23ee0..ae7dc48 100644 --- a/include/pci.h +++ b/include/pci.h @@ -85,7 +85,7 @@ typedef struct pci_device { unsigned int primary_bus_nr; /* only for pci bridge */ unsigned int secondary_bus_nr; -} __attribute__((packed)) pci_device_t; +} pci_device_t; #if 0 typedef union pci_device diff --git a/include/sched.h b/include/sched.h index 175a87b..d1cb999 100644 --- a/include/sched.h +++ b/include/sched.h @@ -27,3 +27,5 @@ unsigned long schedule(); void wake_up(wait_queue_head_t *wqh); extern task_union root_task; + +extern void load_cr3(task_union *tsk); diff --git a/include/string.h b/include/string.h index 9cb3205..27dfd20 100644 --- a/include/string.h +++ b/include/string.h @@ -18,6 +18,7 @@ #define _STRING_H #include "types.h" + char *strcpy(char *dest, const char *src); size_t strlen(const char *str); int strcmp(const char *a, const char *b); diff --git a/kernel/assert.c b/kernel/assert.c index e723cdd..0de5c40 100644 --- a/kernel/assert.c +++ b/kernel/assert.c @@ -10,7 +10,9 @@ *-------------------------------------------------------------------------- */ -void assert_fail(char *exp, char *file, unsigned int line, char *func) { +#include + +void assert_fail(char *exp, char *file, unsigned int line, const char *func) { printk("%s:%d: %s: Assertion \'%s\' failed.\n", file, line, func, exp); while (1) diff --git a/kernel/cpuid.c b/kernel/cpuid.c index bde3866..e64fc69 100644 --- a/kernel/cpuid.c +++ b/kernel/cpuid.c @@ -14,6 +14,8 @@ *-------------------------------------------------------------------------- */ #include +#include +#include #define TEST_FEATURE(val, bit, fea) \ do { \ diff --git a/kernel/fork.c b/kernel/fork.c index f064622..ea2848c 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -13,8 +13,6 @@ #include #include -int sysc_fork(pt_regs_t regs) { return do_fork(®s, 0); } - extern void ret_from_fork_user(); extern void ret_from_fork_krnl(); extern pid_t get_next_pid(); @@ -112,3 +110,5 @@ int do_fork(pt_regs_t *regs, unsigned long flags) { return (int)tsk->pid; } + +int sysc_fork(pt_regs_t regs) { return do_fork(®s, 0); } \ No newline at end of file diff --git a/kernel/init.c b/kernel/init.c index e3dfa51..b4434d7 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -11,6 +11,7 @@ #include void root_task_entry(); +int do_fork(pt_regs_t *regs, unsigned long flags); System system; TSS tss; diff --git a/kernel/pci.c b/kernel/pci.c index f6ff165..ba3a02d 100644 --- a/kernel/pci.c +++ b/kernel/pci.c @@ -144,7 +144,8 @@ void dump_pci_dev() { list_for_each(p, &pci_devs) { pci_device_t *pci = list_entry(p, pci_device_t, list); - printk("vendor %04x device %04x class %04x intr %3d ", pci->vendor, pci->device, pci->classcode, pci->intr_line); + printk("vendor %04x device %04x class %04x intr %3d ", pci->vendor, pci->device, pci->classcode, + pci->intr_line); printk("%s\n", pci_get_info(pci->classcode, pci->progif)); continue; switch (pci->hdr_type) { @@ -213,146 +214,147 @@ typedef struct pci_info { const char *detail; } pci_info_t; -pci_info_t pci_info[] = {{0x000000, 0, "VGA-Compatible devices", "Any device except for VGA-Compatible devices"}, - {0x000100, 0, "VGA-Compatible device", "VGA-Compatible Device"}, - {0x010000, 0, "SCSI Bus Controller", "SCSI Bus Controller"}, - {0x0101, 1, "IDE Controller", "IDE Controller"}, - {0x010200, 0, "Floppy Disk Controller", "Floppy Disk Controller"}, - {0x010300, 0, "IPI Bus Controller", "IPI Bus Controller"}, - {0x010400, 0, "RAID Controller", "RAID Controller"}, - {0x010520, 0, "ATA Controller", "ATA Controller (Single DMA)"}, - {0x010530, 0, "ATA Controller", "ATA Controller (Chained DMA)"}, - {0x010600, 0, "Serial ATA", "Serial ATA (Vendor Specific Interface)"}, - {0x010601, 0, "Serial ATA", "Serial ATA (AHCI 1.0)"}, - {0x010700, 0, "SCSI", "Serial Attached SCSI (SAS)"}, - {0x018000, 0, "Storage Controller", "Other Mass Storage Controller"}, - {0x020000, 0, "Ethernet Controller", "Ethernet Controller"}, - {0x020100, 0, "Token Ring Controller", "Token Ring Controller"}, - {0x020200, 0, "FDDI Controller", "FDDI Controller"}, - {0x020300, 0, "ATM Controller", "ATM Controller"}, - {0x020400, 0, "ISDN Controller", "ISDN Controller"}, - {0x020500, 0, "WorldFip Controller", "WorldFip Controller"}, - {0x0206, 1, "PICMG 2.14", "PICMG 2.14 Multi Computing"}, - {0x028000, 0, "Network Controller", "Other Network Controller"}, - {0x030000, 0, "VGA-Compatible Controller", "VGA-Compatible Controller"}, - {0x030001, 0, "8512-Compatible Controller", "8512-Compatible Controller"}, - {0x030100, 0, "XGA Controller", "XGA Controller"}, - {0x030200, 0, "3D Controller (Not VGA-Compatible)", "3D Controller (Not VGA-Compatible)"}, - {0x038000, 0, "Display Controller", "Other Display Controller"}, - {0x040000, 0, "Video Device", "Video Device"}, - {0x040100, 0, "Audio Device", "Audio Device"}, - {0x040200, 0, "Computer Telephony Device", "Computer Telephony Device"}, - {0x048000, 0, "Other Multimedia Device", "Other Multimedia Device"}, - {0x050000, 0, "RAM Controller", "RAM Controller"}, - {0x050100, 0, "Flash Controller", "Flash Controller"}, - {0x058000, 0, "Memory Controller", "Other Memory Controller"}, - {0x060000, 0, "Host Bridge", "Host Bridge"}, - {0x060100, 0, "ISA Bridge", "ISA Bridge"}, - {0x060200, 0, "EISA Bridge", "EISA Bridge"}, - {0x060300, 0, "MCA Bridge", "MCA Bridge"}, - {0x060400, 0, "PCI-to-PCI Bridge", "PCI-to-PCI Bridge"}, - {0x060401, 0, "PCI-to-PCI Bridge", "PCI-to-PCI Bridge (Subtractive Decode)"}, - {0x060500, 0, "PCMCIA Bridge", "PCMCIA Bridge"}, - {0x060600, 0, "NuBus Bridge", "NuBus Bridge"}, - {0x060700, 0, "CardBus Bridge", "CardBus Bridge"}, - {0x0608, 1, "RACEway Bridge", "RACEway Bridge"}, - {0x060940, 0, "PCI-to-PCI Bridge", "PCI-to-PCI Bridge (Semi-Transparent, Primary)"}, - {0x060980, 0, "PCI-to-PCI Bridge", "PCI-to-PCI Bridge (Semi-Transparent, Secondary)"}, - {0x060A00, 0, "InfiniBrand-to-PCI Host Bridge", "InfiniBrand-to-PCI Host Bridge"}, - {0x068000, 0, "Bridge Device", "Other Bridge Device"}, - {0x070000, 0, "Serial Controller", "Generic XT-Compatible Serial Controller"}, - {0x070001, 0, "Serial Controller", "16450-Compatible Serial Controller"}, - {0x070002, 0, "Serial Controller", "16550-Compatible Serial Controller"}, - {0x070003, 0, "Serial Controller", "16650-Compatible Serial Controller"}, - {0x070004, 0, "Serial Controller", "16750-Compatible Serial Controller"}, - {0x070005, 0, "Serial Controller", "16850-Compatible Serial Controller"}, - {0x070006, 0, "Serial Controller", "16950-Compatible Serial Controller"}, - {0x070100, 0, "Parallel Port", "Parallel Port"}, - {0x070101, 0, "Parallel Port", "Bi-Directional Parallel Port"}, - {0x070102, 0, "X Parallel Port", "ECP 1.X Compliant Parallel Port"}, - {0x070103, 0, "IEEE 1284 Controller", "IEEE 1284 Controller"}, - {0x0701FE, 0, "IEEE 1284 Target Device", "IEEE 1284 Target Device"}, - {0x070200, 0, "Serial Controller", "Multiport Serial Controller"}, - {0x070300, 0, "Generic Modem", "Generic Modem"}, - {0x070301, 0, "Hayes Compatible Modem", "Hayes Compatible Modem (16450-Compatible Interface)"}, - {0x070302, 0, "Hayes Compatible Modem", "Hayes Compatible Modem (16550-Compatible Interface)"}, - {0x070303, 0, "Hayes Compatible Modem", "Hayes Compatible Modem (16650-Compatible Interface)"}, - {0x070304, 0, "Hayes Compatible Modem", "Hayes Compatible Modem (16750-Compatible Interface)"}, - {0x070400, 0, "IEEE 488.1/2 Controller", "IEEE 488.1/2 (GPIB) Controller"}, - {0x070500, 0, "Smart Card", "Smart Card"}, - {0x078000, 0, "Communications Device", "Other Communications Device"}, - {0x080000, 0, "Generic 8259 PIC", "Generic 8259 PIC"}, - {0x080001, 0, "ISA PIC", "ISA PIC"}, - {0x080002, 0, "EISA PIC", "EISA PIC"}, - {0x080010, 0, "APIC Interrupt Controller", "I/O APIC Interrupt Controller"}, - {0x080020, 0, "APIC Interrupt Controller", "I/O(x) APIC Interrupt Controller"}, - {0x080100, 0, "8237 DMA Controller", "Generic 8237 DMA Controller"}, - {0x080101, 0, "ISA DMA Controller", "ISA DMA Controller"}, - {0x080102, 0, "EISA DMA Controller", "EISA DMA Controller"}, - {0x080200, 0, "8254 System Timer", "Generic 8254 System Timer"}, - {0x080201, 0, "ISA System Timer", "ISA System Timer"}, - {0x080202, 0, "EISA System Timer", "EISA System Timer"}, - {0x080300, 0, "Generic RTC Controller", "Generic RTC Controller"}, - {0x080301, 0, "ISA RTC Controller", "ISA RTC Controller"}, - {0x080400, 0, "Generic PCI Hot-Plug Controller", "Generic PCI Hot-Plug Controller"}, - {0x088000, 0, "Other System Peripheral", "Other System Peripheral"}, - {0x090000, 0, "Keyboard Controller", "Keyboard Controller"}, - {0x090100, 0, "Digitizer", "Digitizer"}, - {0x090200, 0, "Mouse Controller", "Mouse Controller"}, - {0x090300, 0, "Scanner Controller", "Scanner Controller"}, - {0x090400, 0, "Gameport Controller (Generic)", "Gameport Controller (Generic)"}, - {0x090410, 0, "Gameport Contrlller (Legacy)", "Gameport Contrlller (Legacy)"}, - {0x098000, 0, "Other Input Controller", "Other Input Controller"}, - {0x0A0000, 0, "Generic Docking Station", "Generic Docking Station"}, - {0x0A8000, 0, "Other Docking Station", "Other Docking Station"}, - {0x0B0000, 0, "386 Processor", "386 Processor"}, - {0x0B0100, 0, "486 Processor", "486 Processor"}, - {0x0B0200, 0, "Pentium Processor", "Pentium Processor"}, - {0x0B1000, 0, "Alpha Processor", "Alpha Processor"}, - {0x0B2000, 0, "PowerPC Processor", "PowerPC Processor"}, - {0x0B3000, 0, "MIPS Processor", "MIPS Processor"}, - {0x0B4000, 0, "Co-Processor", "Co-Processor"}, - {0x0C0000, 0, "IEEE 1394 Controller", "IEEE 1394 Controller (FireWire)"}, - {0x0C0010, 0, "IEEE 1394 Controller", "IEEE 1394 Controller (1394 OpenHCI Spec)"}, - {0x0C0100, 0, "ACCESS.bus", "ACCESS.bus"}, - {0x0C0200, 0, "SSA", "SSA"}, - {0x0C0300, 0, "USB", "USB (Universal Host Controller Spec)"}, - {0x0C0310, 0, "USB", "USB (Open Host Controller Spec"}, - {0x0C0320, 0, "USB2 Host Controller", "USB2 Host Controller (Intel Enhanced Host Controller Interface)"}, - {0x0C0380, 0, "USB", "USB"}, - {0x0C03FE, 0, "USB", "USB (Not Host Controller)"}, - {0x0C0400, 0, "Fibre Channel", "Fibre Channel"}, - {0x0C0500, 0, "SMBus", "SMBus"}, - {0x0C0600, 0, "InfiniBand", "InfiniBand"}, - {0x0C0700, 0, "IPMI SMIC Interface", "IPMI SMIC Interface"}, - {0x0C0701, 0, "IPMI Kybd Interface", "IPMI Kybd Controller Style Interface"}, - {0x0C0702, 0, "IPMI Block Interface", "IPMI Block Transfer Interface"}, - {0x0C0800, 0, "SERCOS Interface", "SERCOS Interface Standard (IEC 61491)"}, - {0x0C0900, 0, "CANbus", "CANbus"}, - {0x0D0000, 0, "iRDA Controller", "iRDA Compatible Controller"}, - {0x0D0100, 0, "IR Controller", "Consumer IR Controller"}, - {0x0D1000, 0, "RF Controller", "RF Controller"}, - {0x0D1100, 0, "Bluetooth Controller", "Bluetooth Controller"}, - {0x0D1200, 0, "Broadband Controller", "Broadband Controller"}, - {0x0D2000, 0, "Ethernet Controller (802.11a)", "Ethernet Controller (802.11a)"}, - {0x0D2100, 0, "Ethernet Controller (802.11b)", "Ethernet Controller (802.11b)"}, - {0x0D8000, 0, "Wireless Controller", "Other Wireless Controller"}, - {0x0E00, 1, "I20 Architecture", "I20 Architecture"}, - {0x0E0000, 0, "Message FIFO", "Message FIFO"}, - {0x0F0100, 0, "TV Controller", "TV Controller"}, - {0x0F0200, 0, "Audio Controller", "Audio Controller"}, - {0x0F0300, 0, "Voice Controller", "Voice Controller"}, - {0x0F0400, 0, "Data Controller", "Data Controller"}, - {0x100000, 0, "Computing Encrpytion/Decryption", "Network and Computing Encrpytion/Decryption"}, - {0x101000, 0, "Entertainment Encryption/Decryption", "Entertainment Encryption/Decryption"}, - {0x108000, 0, "Other Encryption/Decryption", "Other Encryption/Decryption"}, - {0x110000, 0, "DPIO Modules", "DPIO Modules"}, - {0x110100, 0, "Performance Counters", "Performance Counters"}, - {0x111000, 0, "Communications Syncrhonization Plus Time and Frequency Test/Measurment", - "Communications Syncrhonization Plus Time and Frequency Test/Measurment"}, - {0x112000, 0, "Management Card", "Management Card"}, - {0x118000, 0, "Acquisition/Signal Processing Controller", "Other Data Acquisition/Signal Processing Controller"}, - {0x000000, 0, 0}}; +pci_info_t pci_info[] = { + {0x000000, 0, "VGA-Compatible devices", "Any device except for VGA-Compatible devices"}, + {0x000100, 0, "VGA-Compatible device", "VGA-Compatible Device"}, + {0x010000, 0, "SCSI Bus Controller", "SCSI Bus Controller"}, + {0x0101, 1, "IDE Controller", "IDE Controller"}, + {0x010200, 0, "Floppy Disk Controller", "Floppy Disk Controller"}, + {0x010300, 0, "IPI Bus Controller", "IPI Bus Controller"}, + {0x010400, 0, "RAID Controller", "RAID Controller"}, + {0x010520, 0, "ATA Controller", "ATA Controller (Single DMA)"}, + {0x010530, 0, "ATA Controller", "ATA Controller (Chained DMA)"}, + {0x010600, 0, "Serial ATA", "Serial ATA (Vendor Specific Interface)"}, + {0x010601, 0, "Serial ATA", "Serial ATA (AHCI 1.0)"}, + {0x010700, 0, "SCSI", "Serial Attached SCSI (SAS)"}, + {0x018000, 0, "Storage Controller", "Other Mass Storage Controller"}, + {0x020000, 0, "Ethernet Controller", "Ethernet Controller"}, + {0x020100, 0, "Token Ring Controller", "Token Ring Controller"}, + {0x020200, 0, "FDDI Controller", "FDDI Controller"}, + {0x020300, 0, "ATM Controller", "ATM Controller"}, + {0x020400, 0, "ISDN Controller", "ISDN Controller"}, + {0x020500, 0, "WorldFip Controller", "WorldFip Controller"}, + {0x0206, 1, "PICMG 2.14", "PICMG 2.14 Multi Computing"}, + {0x028000, 0, "Network Controller", "Other Network Controller"}, + {0x030000, 0, "VGA-Compatible Controller", "VGA-Compatible Controller"}, + {0x030001, 0, "8512-Compatible Controller", "8512-Compatible Controller"}, + {0x030100, 0, "XGA Controller", "XGA Controller"}, + {0x030200, 0, "3D Controller (Not VGA-Compatible)", "3D Controller (Not VGA-Compatible)"}, + {0x038000, 0, "Display Controller", "Other Display Controller"}, + {0x040000, 0, "Video Device", "Video Device"}, + {0x040100, 0, "Audio Device", "Audio Device"}, + {0x040200, 0, "Computer Telephony Device", "Computer Telephony Device"}, + {0x048000, 0, "Other Multimedia Device", "Other Multimedia Device"}, + {0x050000, 0, "RAM Controller", "RAM Controller"}, + {0x050100, 0, "Flash Controller", "Flash Controller"}, + {0x058000, 0, "Memory Controller", "Other Memory Controller"}, + {0x060000, 0, "Host Bridge", "Host Bridge"}, + {0x060100, 0, "ISA Bridge", "ISA Bridge"}, + {0x060200, 0, "EISA Bridge", "EISA Bridge"}, + {0x060300, 0, "MCA Bridge", "MCA Bridge"}, + {0x060400, 0, "PCI-to-PCI Bridge", "PCI-to-PCI Bridge"}, + {0x060401, 0, "PCI-to-PCI Bridge", "PCI-to-PCI Bridge (Subtractive Decode)"}, + {0x060500, 0, "PCMCIA Bridge", "PCMCIA Bridge"}, + {0x060600, 0, "NuBus Bridge", "NuBus Bridge"}, + {0x060700, 0, "CardBus Bridge", "CardBus Bridge"}, + {0x0608, 1, "RACEway Bridge", "RACEway Bridge"}, + {0x060940, 0, "PCI-to-PCI Bridge", "PCI-to-PCI Bridge (Semi-Transparent, Primary)"}, + {0x060980, 0, "PCI-to-PCI Bridge", "PCI-to-PCI Bridge (Semi-Transparent, Secondary)"}, + {0x060A00, 0, "InfiniBrand-to-PCI Host Bridge", "InfiniBrand-to-PCI Host Bridge"}, + {0x068000, 0, "Bridge Device", "Other Bridge Device"}, + {0x070000, 0, "Serial Controller", "Generic XT-Compatible Serial Controller"}, + {0x070001, 0, "Serial Controller", "16450-Compatible Serial Controller"}, + {0x070002, 0, "Serial Controller", "16550-Compatible Serial Controller"}, + {0x070003, 0, "Serial Controller", "16650-Compatible Serial Controller"}, + {0x070004, 0, "Serial Controller", "16750-Compatible Serial Controller"}, + {0x070005, 0, "Serial Controller", "16850-Compatible Serial Controller"}, + {0x070006, 0, "Serial Controller", "16950-Compatible Serial Controller"}, + {0x070100, 0, "Parallel Port", "Parallel Port"}, + {0x070101, 0, "Parallel Port", "Bi-Directional Parallel Port"}, + {0x070102, 0, "X Parallel Port", "ECP 1.X Compliant Parallel Port"}, + {0x070103, 0, "IEEE 1284 Controller", "IEEE 1284 Controller"}, + {0x0701FE, 0, "IEEE 1284 Target Device", "IEEE 1284 Target Device"}, + {0x070200, 0, "Serial Controller", "Multiport Serial Controller"}, + {0x070300, 0, "Generic Modem", "Generic Modem"}, + {0x070301, 0, "Hayes Compatible Modem", "Hayes Compatible Modem (16450-Compatible Interface)"}, + {0x070302, 0, "Hayes Compatible Modem", "Hayes Compatible Modem (16550-Compatible Interface)"}, + {0x070303, 0, "Hayes Compatible Modem", "Hayes Compatible Modem (16650-Compatible Interface)"}, + {0x070304, 0, "Hayes Compatible Modem", "Hayes Compatible Modem (16750-Compatible Interface)"}, + {0x070400, 0, "IEEE 488.1/2 Controller", "IEEE 488.1/2 (GPIB) Controller"}, + {0x070500, 0, "Smart Card", "Smart Card"}, + {0x078000, 0, "Communications Device", "Other Communications Device"}, + {0x080000, 0, "Generic 8259 PIC", "Generic 8259 PIC"}, + {0x080001, 0, "ISA PIC", "ISA PIC"}, + {0x080002, 0, "EISA PIC", "EISA PIC"}, + {0x080010, 0, "APIC Interrupt Controller", "I/O APIC Interrupt Controller"}, + {0x080020, 0, "APIC Interrupt Controller", "I/O(x) APIC Interrupt Controller"}, + {0x080100, 0, "8237 DMA Controller", "Generic 8237 DMA Controller"}, + {0x080101, 0, "ISA DMA Controller", "ISA DMA Controller"}, + {0x080102, 0, "EISA DMA Controller", "EISA DMA Controller"}, + {0x080200, 0, "8254 System Timer", "Generic 8254 System Timer"}, + {0x080201, 0, "ISA System Timer", "ISA System Timer"}, + {0x080202, 0, "EISA System Timer", "EISA System Timer"}, + {0x080300, 0, "Generic RTC Controller", "Generic RTC Controller"}, + {0x080301, 0, "ISA RTC Controller", "ISA RTC Controller"}, + {0x080400, 0, "Generic PCI Hot-Plug Controller", "Generic PCI Hot-Plug Controller"}, + {0x088000, 0, "Other System Peripheral", "Other System Peripheral"}, + {0x090000, 0, "Keyboard Controller", "Keyboard Controller"}, + {0x090100, 0, "Digitizer", "Digitizer"}, + {0x090200, 0, "Mouse Controller", "Mouse Controller"}, + {0x090300, 0, "Scanner Controller", "Scanner Controller"}, + {0x090400, 0, "Gameport Controller (Generic)", "Gameport Controller (Generic)"}, + {0x090410, 0, "Gameport Contrlller (Legacy)", "Gameport Contrlller (Legacy)"}, + {0x098000, 0, "Other Input Controller", "Other Input Controller"}, + {0x0A0000, 0, "Generic Docking Station", "Generic Docking Station"}, + {0x0A8000, 0, "Other Docking Station", "Other Docking Station"}, + {0x0B0000, 0, "386 Processor", "386 Processor"}, + {0x0B0100, 0, "486 Processor", "486 Processor"}, + {0x0B0200, 0, "Pentium Processor", "Pentium Processor"}, + {0x0B1000, 0, "Alpha Processor", "Alpha Processor"}, + {0x0B2000, 0, "PowerPC Processor", "PowerPC Processor"}, + {0x0B3000, 0, "MIPS Processor", "MIPS Processor"}, + {0x0B4000, 0, "Co-Processor", "Co-Processor"}, + {0x0C0000, 0, "IEEE 1394 Controller", "IEEE 1394 Controller (FireWire)"}, + {0x0C0010, 0, "IEEE 1394 Controller", "IEEE 1394 Controller (1394 OpenHCI Spec)"}, + {0x0C0100, 0, "ACCESS.bus", "ACCESS.bus"}, + {0x0C0200, 0, "SSA", "SSA"}, + {0x0C0300, 0, "USB", "USB (Universal Host Controller Spec)"}, + {0x0C0310, 0, "USB", "USB (Open Host Controller Spec"}, + {0x0C0320, 0, "USB2 Host Controller", "USB2 Host Controller (Intel Enhanced Host Controller Interface)"}, + {0x0C0380, 0, "USB", "USB"}, + {0x0C03FE, 0, "USB", "USB (Not Host Controller)"}, + {0x0C0400, 0, "Fibre Channel", "Fibre Channel"}, + {0x0C0500, 0, "SMBus", "SMBus"}, + {0x0C0600, 0, "InfiniBand", "InfiniBand"}, + {0x0C0700, 0, "IPMI SMIC Interface", "IPMI SMIC Interface"}, + {0x0C0701, 0, "IPMI Kybd Interface", "IPMI Kybd Controller Style Interface"}, + {0x0C0702, 0, "IPMI Block Interface", "IPMI Block Transfer Interface"}, + {0x0C0800, 0, "SERCOS Interface", "SERCOS Interface Standard (IEC 61491)"}, + {0x0C0900, 0, "CANbus", "CANbus"}, + {0x0D0000, 0, "iRDA Controller", "iRDA Compatible Controller"}, + {0x0D0100, 0, "IR Controller", "Consumer IR Controller"}, + {0x0D1000, 0, "RF Controller", "RF Controller"}, + {0x0D1100, 0, "Bluetooth Controller", "Bluetooth Controller"}, + {0x0D1200, 0, "Broadband Controller", "Broadband Controller"}, + {0x0D2000, 0, "Ethernet Controller (802.11a)", "Ethernet Controller (802.11a)"}, + {0x0D2100, 0, "Ethernet Controller (802.11b)", "Ethernet Controller (802.11b)"}, + {0x0D8000, 0, "Wireless Controller", "Other Wireless Controller"}, + {0x0E00, 1, "I20 Architecture", "I20 Architecture"}, + {0x0E0000, 0, "Message FIFO", "Message FIFO"}, + {0x0F0100, 0, "TV Controller", "TV Controller"}, + {0x0F0200, 0, "Audio Controller", "Audio Controller"}, + {0x0F0300, 0, "Voice Controller", "Voice Controller"}, + {0x0F0400, 0, "Data Controller", "Data Controller"}, + {0x100000, 0, "Computing Encrpytion/Decryption", "Network and Computing Encrpytion/Decryption"}, + {0x101000, 0, "Entertainment Encryption/Decryption", "Entertainment Encryption/Decryption"}, + {0x108000, 0, "Other Encryption/Decryption", "Other Encryption/Decryption"}, + {0x110000, 0, "DPIO Modules", "DPIO Modules"}, + {0x110100, 0, "Performance Counters", "Performance Counters"}, + {0x111000, 0, "Communications Syncrhonization Plus Time and Frequency Test/Measurment", + "Communications Syncrhonization Plus Time and Frequency Test/Measurment"}, + {0x112000, 0, "Management Card", "Management Card"}, + {0x118000, 0, "Acquisition/Signal Processing Controller", "Other Data Acquisition/Signal Processing Controller"}, + {0x000000, 0, 0}}; const char *pci_get_info(unsigned int classcode, unsigned int progif) { pci_info_t *p = pci_info; diff --git a/kernel/printk.c b/kernel/printk.c index 4094972..9eb1d1c 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -15,8 +15,11 @@ *-------------------------------------------------------------------------- */ +#include + extern void vga_puts(unsigned int nr, const char *buf, unsigned char color); extern void vga_dbg_puts(unsigned int line, unsigned int offset, const char *buf); +extern int vsprintf(char *buf, const char *fmt, char *args); unsigned int printk_screen_nr = 0; diff --git a/kernel/sched.c b/kernel/sched.c index 6d53af5..535d464 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -137,7 +137,6 @@ static const char *task_state(unsigned int state) { } unsigned long schedule() { - static turn = 0; task_union *sel = &root_task; task_union *p = 0; list_head_t *pos = 0, *t = 0; diff --git a/kernel/semaphore.c b/kernel/semaphore.c index 3e0fb69..04c0a69 100644 --- a/kernel/semaphore.c +++ b/kernel/semaphore.c @@ -7,6 +7,7 @@ * ------------------------------------------------------------------------ */ #include +#include #include typedef struct semaphore_waiter { diff --git a/kernel/wait.c b/kernel/wait.c index 0d94545..e8cb71d 100644 --- a/kernel/wait.c +++ b/kernel/wait.c @@ -9,6 +9,7 @@ * *-------------------------------------------------------------------------- */ +#include #include void init_wait_queue(wait_queue_head_t *wqh) { INIT_LIST_HEAD(&wqh->task_list); } diff --git a/mm/buddy.c b/mm/buddy.c index e7f58cf..0184743 100644 --- a/mm/buddy.c +++ b/mm/buddy.c @@ -186,6 +186,7 @@ void init_buddy_system() { // init page map unsigned long page_map_size = pfn_cnt * sizeof(page_t); + void *alloc_from_bootmem(unsigned long size, char *title); buddy_system.page_map = alloc_from_bootmem(page_map_size, "buddy"); if (0 == buddy_system.page_map) { printk("can not go on playing...\n"); diff --git a/mm/mm.c b/mm/mm.c index 323306e..c3907b0 100644 --- a/mm/mm.c +++ b/mm/mm.c @@ -19,12 +19,14 @@ #include #include #include +#include #include #include extern char etext, edata, end; extern void init_buddy_system(); extern void init_slub_system(); +extern void init_bootmem(); pde_t __initdata init_pgd[PDECNT_PER_PAGE] __attribute__((__aligned__(PAGE_SIZE))); pte_t __initdata init_pgt[PTECNT_PER_PAGE * BOOT_INIT_PAGETBL_CNT] __attribute__((__aligned__(PAGE_SIZE))); @@ -52,6 +54,7 @@ void init_paging() { unsigned long ti = pfn % PAGE_PTE_CNT; unsigned long page_addr = pfn2pa(pfn); if (ti == 0) { + void *alloc_from_bootmem(unsigned long size, char *title); pgtb_addr = (unsigned long)va2pa(alloc_from_bootmem(PAGE_SIZE, "paging")); if (0 == pgtb_addr) panic("No Pages for Paging..."); diff --git a/mm/slub.c b/mm/slub.c index 92547e9..b14bd49 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -9,6 +9,7 @@ #include #include +#include #include list_head_t slub_caches = LIST_HEAD_INIT(slub_caches); -- 2.44.0