提交 577f85e1 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

more c++

上级 9bbaf1df
extern "C" {
#include "types.h"
#include "amd64.h"
#include "kernel.h"
#include "pci.h"
#include "spinlock.h"
#include "e1000reg.h"
}
#define TX_RING_SIZE 64
#define RX_RING_SIZE 64
......@@ -34,7 +36,7 @@ static inline u32
erd(u32 reg)
{
paddr pa = e1000.membase + reg;
volatile u32 *ptr = p2v(pa);
volatile u32 *ptr = (u32*) p2v(pa);
return *ptr;
}
......@@ -42,7 +44,7 @@ static inline void
ewr(u32 reg, u32 val)
{
paddr pa = e1000.membase + reg;
volatile u32 *ptr = p2v(pa);
volatile u32 *ptr = (u32*) p2v(pa);
*ptr = val;
}
......
......@@ -85,7 +85,7 @@ updatepages(pme_t *pml4, void *begin, void *end, int perm)
// Map from 0 to 128Gbytes starting at KBASE.
void
initpg(char* (*alloc)(void))
initpg(void)
{
extern char end[];
void *va = (void*)KBASE;
......
// Intel 8253/8254/82C54 Programmable Interval Timer (PIT).
// http://en.wikipedia.org/wiki/Intel_8253
extern "C" {
#include "types.h"
#include "amd64.h"
#include "kernel.h"
}
#define IO_TIMER1 0x040 // 8253 Timer #1
#define TIMER_FREQ 1193182
......
......@@ -132,6 +132,7 @@ pme_t * walkpgdir(pml4e_t*, const void*, int);
// hz.c
void microdelay(u64);
u64 nsectime(void);
void inithz(void);
// ide.c
void ideinit(void);
......@@ -351,3 +352,30 @@ void initcilkframe(struct cilkframe *wq);
#define cilk_trywork() 0
#define initcilkframe(x) do { } while (0)
#endif
// various init functions
void initpic(void);
void initioapic(void);
void inituart(void);
void initcga(void);
void initconsole(void);
void initpg(void);
void initmp(void);
void initlapic(void);
void inittls(void);
void inittrap(void);
void initseg(void);
void initkalloc(u64 mbaddr);
void initrcu(void);
void initproc(void);
void initbio(void);
void initinode(void);
void initdisk(void);
void inituser(void);
void initcilk(void);
void initsamp(void);
void initpci(void);
void initnet(void);
void initsched(void);
void initlockstat(void);
......@@ -4,32 +4,6 @@
#include "cpu.h"
#include "amd64.h"
extern void initpic(void);
extern void initioapic(void);
extern void inituart(void);
extern void initcga(void);
extern void initconsole(void);
extern void initpg(void);
extern void initmp(void);
extern void initlapic(void);
extern void inittls(void);
extern void inittrap(void);
extern void initseg(void);
extern void initkalloc(u64 mbaddr);
extern void initrcu(void);
extern void initproc(void);
extern void initbio(void);
extern void initinode(void);
extern void initdisk(void);
extern void inituser(void);
extern void inithz(void);
extern void initcilk(void);
extern void initsamp(void);
extern void initpci(void);
extern void initnet(void);
extern void initsched(void);
extern void initlockstat(void);
static volatile int bstate;
void
......
// Fake IDE disk; stores blocks in memory.
// Useful for running kernel without scratch disk.
extern "C" {
#include "types.h"
#include "mmu.h"
#include "kernel.h"
......@@ -11,6 +12,7 @@
#include "amd64.h"
#include "traps.h"
#include "buf.h"
}
extern u8 _fs_img_start[];
extern u64 _fs_img_size;
......
extern "C" {
#include "types.h"
#include "amd64.h"
#include "kernel.h"
#include "pci.h"
#include "pcireg.h"
}
extern int e1000attach(struct pci_func *pcif);
extern int e1000eattach(struct pci_func *pcif);
......@@ -45,26 +47,26 @@ struct pci_driver pci_attach_vendor[] = {
static const char *pci_class[] =
{
[0x0] = "Unknown",
[0x1] = "Storage controller",
[0x2] = "Network controller",
[0x3] = "Display controller",
[0x4] = "Multimedia device",
[0x5] = "Memory controller",
[0x6] = "Bridge device",
"Unknown",
"Storage controller",
"Network controller",
"Display controller",
"Multimedia device",
"Memory controller",
"Bridge device",
};
static void
pci_print_func(struct pci_func *f)
{
const char *class = pci_class[0];
const char *classname = pci_class[0];
if (PCI_CLASS(f->dev_class) < sizeof(pci_class) / sizeof(pci_class[0]))
class = pci_class[PCI_CLASS(f->dev_class)];
classname = pci_class[PCI_CLASS(f->dev_class)];
cprintf("PCI: %x:%x.%d: %x:%x: class: %x.%x (%s) irq: %d\n",
f->bus->busno, f->dev, f->func,
PCI_VENDOR(f->dev_id), PCI_PRODUCT(f->dev_id),
PCI_CLASS(f->dev_class), PCI_SUBCLASS(f->dev_class), class,
PCI_CLASS(f->dev_class), PCI_SUBCLASS(f->dev_class), classname,
f->irq_line);
}
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论