Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e1947e1)
raw | patch | inline | side by side (parent: e1947e1)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Thu, 4 Nov 2021 15:22:43 +0000 (23:22 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Thu, 4 Nov 2021 15:22:43 +0000 (23:22 +0800) |
22 files changed:
| drivers/console.c | patch | blob | history | |
| drivers/ide.c | patch | blob | history | |
| drivers/keyboard.c | patch | blob | history | |
| drivers/vga.c | patch | blob | history | |
| fs/ext2.c | patch | blob | history | |
| include/assert.h | patch | blob | history | |
| include/linkage.h | patch | blob | history | |
| include/pci.h | patch | blob | history | |
| include/sched.h | patch | blob | history | |
| include/string.h | patch | blob | history | |
| kernel/assert.c | patch | blob | history | |
| kernel/cpuid.c | patch | blob | history | |
| kernel/fork.c | patch | blob | history | |
| kernel/init.c | patch | blob | history | |
| kernel/pci.c | patch | blob | history | |
| kernel/printk.c | patch | blob | history | |
| kernel/sched.c | patch | blob | history | |
| kernel/semaphore.c | patch | blob | history | |
| kernel/wait.c | patch | blob | history | |
| mm/buddy.c | patch | blob | history | |
| mm/mm.c | patch | blob | history | |
| mm/slub.c | patch | blob | history |
diff --git a/drivers/console.c b/drivers/console.c
--- a/drivers/console.c
+++ b/drivers/console.c
*/
#include <console.h>
+#include <sched.h>
#include <string.h>
#include <wait.h>
+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
--- a/drivers/ide.c
+++ b/drivers/ide.c
#include <irq.h>
#include <pci.h>
#include <printk.h>
+#include <sched.h>
#include <semaphore.h>
#include <string.h>
#include <types.h>
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;
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() {
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;
}
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);
}
}
}
}
- 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
--- a/drivers/keyboard.c
+++ b/drivers/keyboard.c
#include <io.h>
#include <printk.h>
#include <stdio.h>
+#include <string.h>
#include <syscall.h>
#include <system.h>
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, 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};
void kbd_handler(unsigned int irq, pt_regs_t *regs, void *dev_id) {
diff --git a/drivers/vga.c b/drivers/vga.c
--- a/drivers/vga.c
+++ b/drivers/vga.c
#include <io.h>
#include <irq.h>
+#include <string.h>
typedef struct {
u8_t c;
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
--- a/fs/ext2.c
+++ b/fs/ext2.c
#include "fs.h"
#include "mm.h"
+#include "string.h"
#include "system.h"
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;
}
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);
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
--- a/include/assert.h
+++ b/include/assert.h
#include <global.h>
+#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
--- a/include/linkage.h
+++ b/include/linkage.h
#ifndef __LINKAGE_H
#define __LINKAGE_H
+#ifdef ASM
+
#define ALIGN .align 0x04, 0x90
#define ALIGN_STR ".align 0x04,0x90"
#define ENTRY(symbol) \
#endif
+#endif
+
#define __initdata __attribute__((__section__(".init.data")))
diff --git a/include/pci.h b/include/pci.h
--- a/include/pci.h
+++ b/include/pci.h
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
--- a/include/sched.h
+++ b/include/sched.h
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
--- a/include/string.h
+++ b/include/string.h
#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
--- a/kernel/assert.c
+++ b/kernel/assert.c
*--------------------------------------------------------------------------
*/
-void assert_fail(char *exp, char *file, unsigned int line, char *func) {
+#include <printk.h>
+
+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
--- a/kernel/cpuid.c
+++ b/kernel/cpuid.c
*--------------------------------------------------------------------------
*/
#include <bits.h>
+#include <printk.h>
+#include <string.h>
#define TEST_FEATURE(val, bit, fea) \
do { \
diff --git a/kernel/fork.c b/kernel/fork.c
--- a/kernel/fork.c
+++ b/kernel/fork.c
#include <page.h>
#include <sched.h>
-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();
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
--- a/kernel/init.c
+++ b/kernel/init.c
#include <types.h>
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
--- a/kernel/pci.c
+++ b/kernel/pci.c
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) {
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
--- a/kernel/printk.c
+++ b/kernel/printk.c
*--------------------------------------------------------------------------
*/
+#include <system.h>
+
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
--- a/kernel/sched.c
+++ b/kernel/sched.c
}
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
--- a/kernel/semaphore.c
+++ b/kernel/semaphore.c
* ------------------------------------------------------------------------
*/
#include <irq.h>
+#include <sched.h>
#include <semaphore.h>
typedef struct semaphore_waiter {
diff --git a/kernel/wait.c b/kernel/wait.c
--- a/kernel/wait.c
+++ b/kernel/wait.c
*
*--------------------------------------------------------------------------
*/
+#include <sched.h>
#include <wait.h>
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
--- a/mm/buddy.c
+++ b/mm/buddy.c
// 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");
--- a/mm/mm.c
+++ b/mm/mm.c
#include <mm.h>
#include <page.h>
#include <printk.h>
+#include <string.h>
#include <system.h>
#include <types.h>
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)));
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
--- a/mm/slub.c
+++ b/mm/slub.c
#include <irq.h>
#include <mm.h>
+#include <string.h>
#include <system.h>
list_head_t slub_caches = LIST_HEAD_INIT(slub_caches);