(2006-08-06) rescue-bootcd

This commit is contained in:
2006-08-06 00:00:00 +02:00
parent 2f796b816a
commit decb062d20
21091 changed files with 7076462 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
#ifndef _CPU_H
#define _CPU_H
#include <inttypes.h>
static inline uint64_t rdtsc(void)
{
uint64_t v;
asm volatile("rdtsc" : "=A" (v));
return v;
}
static inline uint32_t rdtscl(void)
{
uint32_t v;
asm volatile("rdtsc" : "=a" (v) : : "edx");
return v;
}
static inline uint32_t cpuid_eax(uint32_t level)
{
uint32_t v;
asm("cpuid" : "=a" (v) : "a" (level) : "ebx", "ecx", "edx");
return v;
}
static inline uint32_t cpuid_ebx(uint32_t level)
{
uint32_t v;
asm("cpuid" : "=b" (v), "+a" (level) : : "ecx", "edx");
return v;
}
static inline uint32_t cpuid_ecx(uint32_t level)
{
uint32_t v;
asm("cpuid" : "=c" (v), "+a" (level) : : "ebx", "edx");
return v;
}
static inline uint32_t cpuid_edx(uint32_t level)
{
uint32_t v;
asm("cpuid" : "=d" (v), "+a" (level) : : "ebx", "ecx");
return v;
}
static inline uint64_t rdmsr(uint32_t msr)
{
uint64_t v;
asm volatile("rdmsr" : "=A" (v) : "c" (msr));
return v;
}
static inline void wrmsr(uint64_t v, uint32_t msr)
{
asm volatile("wrmsr" : : "A" (v), "c" (msr));
}
static inline void cpu_relax(void)
{
asm volatile("rep ; nop");
}
/* These are local cli/sti; not SMP-safe!!! */
static inline void cli(void)
{
asm volatile("cli");
}
static inline void sti(void)
{
asm volatile("sti");
}
#endif

View File

@@ -0,0 +1,42 @@
#ifndef _SYS_IO_H
#define _SYS_IO_H
#include <inttypes.h>
static inline uint8_t inb(uint16_t p)
{
uint8_t v;
asm volatile("inb %1,%0" : "=a" (v) : "Nd" (p));
return v;
}
static inline uint16_t inw(uint16_t p)
{
uint16_t v;
asm volatile("inw %1,%0" : "=a" (v) : "Nd" (p));
return v;
}
static inline uint32_t inl(uint16_t p)
{
uint32_t v;
asm volatile("inl %1,%0" : "=a" (v) : "Nd" (p));
return v;
}
static inline void outb(uint8_t v, uint16_t p)
{
asm volatile("outb %0,%1" : : "a" (v), "Nd" (p));
}
static inline void outw(uint16_t v, uint16_t p)
{
asm volatile("outw %0,%1" : : "a" (v), "Nd" (p));
}
static inline void outl(uint32_t v, uint16_t p)
{
asm volatile("outl %0,%1" : : "a" (v), "Nd" (p));
}
#endif /* _SYS_IO_H */

View File

@@ -0,0 +1,31 @@
#ifndef _SYS_PCI_H
#define _SYS_PCI_H
#include <inttypes.h>
#include <sys/io.h>
typedef uint32_t pciaddr_t;
static inline pciaddr_t pci_mkaddr(uint32_t bus, uint32_t dev,
uint32_t func, uint32_t reg)
{
return 0x80000000 | ((bus & 0xff) << 16) | ((dev & 0x1f) << 11) |
((func & 0x07) << 8) | (reg & 0xff);
}
enum pci_config_type {
PCI_CFG_AUTO = 0, /* autodetect */
PCI_CFG_TYPE1 = 1,
PCI_CFG_TYPE2 = 2,
};
void pci_set_config_type(enum pci_config_type);
uint8_t pci_readb(pciaddr_t);
uint16_t pci_readw(pciaddr_t);
uint32_t pci_readl(pciaddr_t);
void pci_writeb(uint8_t, pciaddr_t);
void pci_writew(uint16_t, pciaddr_t);
void pci_writel(uint32_t, pciaddr_t);
#endif /* _SYS_PCI_H */

View File

@@ -0,0 +1,43 @@
/*
* sys/stat.h
*/
#ifndef _SYS_STAT_H
#define _SYS_STAT_H
#include <sys/types.h>
/* We don't use this, but it's there for compatibility */
#define S_IFMT 00170000
#define S_IFSOCK 0140000
#define S_IFLNK 0120000
#define S_IFREG 0100000
#define S_IFBLK 0060000
#define S_IFDIR 0040000
#define S_IFCHR 0020000
#define S_IFIFO 0010000
#define S_ISUID 0004000
#define S_ISGID 0002000
#define S_ISVTX 0001000
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
#define S_IRWXU 00700
#define S_IRUSR 00400
#define S_IWUSR 00200
#define S_IXUSR 00100
#define S_IRWXG 00070
#define S_IRGRP 00040
#define S_IWGRP 00020
#define S_IXGRP 00010
#define S_IRWXO 00007
#define S_IROTH 00004
#define S_IWOTH 00002
#define S_IXOTH 00001
#endif /* _SYS_STAT_H */

View File

@@ -0,0 +1,21 @@
/*
* sys/times.h
*/
#ifndef _SYS_TIMES_H
#define _SYS_TIMES_H
#include <stdint.h>
struct tms {
/* Empty */
};
#define HZ 18 /* Piddly resolution... */
#define CLK_TCK HZ
typedef uint16_t clock_t;
clock_t times(struct tms *);
#endif /* _SYS_TIMES_H */

View File

@@ -0,0 +1,16 @@
/*
* sys/types.h
*/
#ifndef _SYS_TYPES_H
#define _SYS_TYPES_H
#include <klibc/compiler.h>
#include <stddef.h>
#include <stdint.h>
typedef ptrdiff_t ssize_t;
typedef int mode_t;
typedef int64_t off_t;
#endif