Code reorg
This commit is contained in:
parent
96fa389618
commit
69e023b385
16 changed files with 2313 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#include "intel_conf.h"
|
||||
#include "intel_subr.h"
|
||||
#include "printk.h"
|
||||
|
||||
#include <pciconf.h>
|
||||
#include <subr.h>
|
||||
#include <printk.h>
|
||||
#include <cpu/p5/cpuid.h>
|
||||
#ifdef i586
|
||||
#include <asm/msr.h>
|
||||
#endif
|
||||
|
|
|
|||
25
src/include/cpu/p5/cpuid.h
Normal file
25
src/include/cpu/p5/cpuid.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef _INTEL_CPUID_H_
|
||||
#define _INTEL_CPUID_H_
|
||||
|
||||
#ifdef i586
|
||||
int intel_mtrr_check(void);
|
||||
#endif
|
||||
void intel_display_cpuid(void);
|
||||
|
||||
/*
|
||||
* Generic CPUID function. copied from Linux kernel headers
|
||||
*/
|
||||
|
||||
extern inline void intel_cpuid(int op, int *eax, int *ebx, int *ecx, int *edx)
|
||||
{
|
||||
__asm__("cpuid"
|
||||
: "=a" (*eax),
|
||||
"=b" (*ebx),
|
||||
"=c" (*ecx),
|
||||
"=d" (*edx)
|
||||
: "a" (op)
|
||||
: "cc");
|
||||
}
|
||||
|
||||
|
||||
#endif /* _INTEL_CPUID_H_ */
|
||||
197
src/include/cpu/p5/io.h
Normal file
197
src/include/cpu/p5/io.h
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
#ifndef _ASM_IO_H
|
||||
#define _ASM_IO_H
|
||||
|
||||
/*
|
||||
* This file contains the definitions for the x86 IO instructions
|
||||
* inb/inw/inl/outb/outw/outl and the "string versions" of the same
|
||||
* (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
|
||||
* versions of the single-IO instructions (inb_p/inw_p/..).
|
||||
*
|
||||
* This file is not meant to be obfuscating: it's just complicated
|
||||
* to (a) handle it all in a way that makes gcc able to optimize it
|
||||
* as well as possible and (b) trying to avoid writing the same thing
|
||||
* over and over again with slight variations and possibly making a
|
||||
* mistake somewhere.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Thanks to James van Artsdalen for a better timing-fix than
|
||||
* the two short jumps: using outb's to a nonexistent port seems
|
||||
* to guarantee better timings even on fast machines.
|
||||
*
|
||||
* On the other hand, I'd like to be sure of a non-existent port:
|
||||
* I feel a bit unsafe about using 0x80 (should be safe, though)
|
||||
*
|
||||
* Linus
|
||||
*/
|
||||
|
||||
/*
|
||||
* Bit simplified and optimized by Jan Hubicka
|
||||
* Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
|
||||
*/
|
||||
|
||||
#ifdef SLOW_IO_BY_JUMPING
|
||||
#define __SLOW_DOWN_IO "\njmp 1f\n1:\tjmp 1f\n1:"
|
||||
#else
|
||||
#define __SLOW_DOWN_IO "\noutb %%al,$0x80"
|
||||
#endif
|
||||
|
||||
#ifdef REALLY_SLOW_IO
|
||||
#define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO
|
||||
#else
|
||||
#define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Talk about misusing macros..
|
||||
*/
|
||||
#define __OUT1(s,x) \
|
||||
extern inline void out##s(unsigned x value, unsigned short port) {
|
||||
|
||||
#define __OUT2(s,s1,s2) \
|
||||
__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
|
||||
|
||||
#define __OUT(s,s1,x) \
|
||||
__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "Nd" (port)); } \
|
||||
__OUT1(s##_p,x) __OUT2(s,s1,"w") __FULL_SLOW_DOWN_IO : : "a" (value), "Nd" (port));} \
|
||||
|
||||
#define __IN1(s) \
|
||||
extern inline RETURN_TYPE in##s(unsigned short port) { RETURN_TYPE _v;
|
||||
|
||||
#define __IN2(s,s1,s2) \
|
||||
__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
|
||||
|
||||
#define __IN(s,s1,i...) \
|
||||
__IN1(s) __IN2(s,s1,"w") : "=a" (_v) : "Nd" (port) ,##i ); return _v; } \
|
||||
__IN1(s##_p) __IN2(s,s1,"w") __FULL_SLOW_DOWN_IO : "=a" (_v) : "Nd" (port) ,##i ); return _v; } \
|
||||
|
||||
#define __INS(s) \
|
||||
extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
|
||||
{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
|
||||
: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
|
||||
|
||||
#define __OUTS(s) \
|
||||
extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
|
||||
{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
|
||||
: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
|
||||
|
||||
#define RETURN_TYPE unsigned char
|
||||
__IN(b,"")
|
||||
#undef RETURN_TYPE
|
||||
#define RETURN_TYPE unsigned short
|
||||
__IN(w,"")
|
||||
#undef RETURN_TYPE
|
||||
#define RETURN_TYPE unsigned int
|
||||
__IN(l,"")
|
||||
#undef RETURN_TYPE
|
||||
|
||||
__OUT(b,"b",char)
|
||||
__OUT(w,"w",short)
|
||||
__OUT(l,,int)
|
||||
|
||||
__INS(b)
|
||||
__INS(w)
|
||||
__INS(l)
|
||||
|
||||
__OUTS(b)
|
||||
__OUTS(w)
|
||||
__OUTS(l)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
#include <linux/vmalloc.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
#define __io_virt(x) ((void *)(PAGE_OFFSET | (unsigned long)(x)))
|
||||
#define __io_phys(x) ((unsigned long)(x) & ~PAGE_OFFSET)
|
||||
/*
|
||||
* Change virtual addresses to physical addresses and vv.
|
||||
* These are pretty trivial
|
||||
*/
|
||||
extern inline unsigned long virt_to_phys(volatile void * address)
|
||||
{
|
||||
#ifdef CONFIG_BIGMEM
|
||||
return __pa(address);
|
||||
#else
|
||||
return __io_phys(address);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern inline void * phys_to_virt(unsigned long address)
|
||||
{
|
||||
#ifdef CONFIG_BIGMEM
|
||||
return __va(address);
|
||||
#else
|
||||
return __io_virt(address);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
|
||||
|
||||
extern inline void * ioremap (unsigned long offset, unsigned long size)
|
||||
{
|
||||
return __ioremap(offset, size, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* This one maps high address device memory and turns off caching for that area.
|
||||
* it's useful if some control registers are in such an area and write combining
|
||||
* or read caching is not desirable:
|
||||
*/
|
||||
extern inline void * ioremap_nocache (unsigned long offset, unsigned long size)
|
||||
{
|
||||
return __ioremap(offset, size, _PAGE_PCD);
|
||||
}
|
||||
|
||||
extern void iounmap(void *addr);
|
||||
|
||||
/*
|
||||
* IO bus memory addresses are also 1:1 with the physical address
|
||||
*/
|
||||
#define virt_to_bus virt_to_phys
|
||||
#define bus_to_virt phys_to_virt
|
||||
|
||||
/*
|
||||
* readX/writeX() are used to access memory mapped devices. On some
|
||||
* architectures the memory mapped IO stuff needs to be accessed
|
||||
* differently. On the x86 architecture, we just read/write the
|
||||
* memory location directly.
|
||||
*/
|
||||
|
||||
#define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
|
||||
#define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
|
||||
#define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
|
||||
|
||||
#define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
|
||||
#define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
|
||||
#define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
|
||||
|
||||
#define memset_io(a,b,c) __memset_generic(__io_virt(a),(b),(c))
|
||||
#define memcpy_fromio(a,b,c) __memcpy((a),__io_virt(b),(c))
|
||||
#define memcpy_toio(a,b,c) __memcpy(__io_virt(a),(b),(c))
|
||||
|
||||
/*
|
||||
* Again, i386 does not require mem IO specific function.
|
||||
*/
|
||||
|
||||
#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),__io_virt(b),(c),(d))
|
||||
|
||||
static inline int check_signature(unsigned long io_addr,
|
||||
const unsigned char *signature, int length)
|
||||
{
|
||||
int retval = 0;
|
||||
do {
|
||||
if (readb(io_addr) != *signature)
|
||||
goto out;
|
||||
io_addr++;
|
||||
signature++;
|
||||
length--;
|
||||
} while (length);
|
||||
retval = 1;
|
||||
out:
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif
|
||||
369
src/include/cpu/p5/macros.h
Normal file
369
src/include/cpu/p5/macros.h
Normal file
|
|
@ -0,0 +1,369 @@
|
|||
/*
|
||||
This software and ancillary information (herein called SOFTWARE )
|
||||
called LinuxBIOS is made available under the terms described
|
||||
here. The SOFTWARE has been approved for release with associated
|
||||
LA-CC Number 00-34 . Unless otherwise indicated, this SOFTWARE has
|
||||
been authored by an employee or employees of the University of
|
||||
California, operator of the Los Alamos National Laboratory under
|
||||
Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The
|
||||
U.S. Government has rights to use, reproduce, and distribute this
|
||||
SOFTWARE. The public may copy, distribute, prepare derivative works
|
||||
and publicly display this SOFTWARE without charge, provided that this
|
||||
Notice and any statement of authorship are reproduced on all copies.
|
||||
Neither the Government nor the University makes any warranty, express
|
||||
or implied, or assumes any liability or responsibility for the use of
|
||||
this SOFTWARE. If SOFTWARE is modified to produce derivative works,
|
||||
such modified SOFTWARE should be clearly marked, so as not to confuse
|
||||
it with the version available from LANL.
|
||||
*/
|
||||
/* Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
|
||||
* rminnich@lanl.gov
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ROM_INTEL_H
|
||||
#define ROM_INTEL_H
|
||||
|
||||
/*
|
||||
* Bootstrap code for the Intel
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Config registers.
|
||||
*/
|
||||
/* yeah, yeah, I know these are macros, which is bad. Don't forget:
|
||||
* we have almost no assembly, so I am not worrying just yet about this.
|
||||
* we'll fix it someday if we care. My guess is we won't.
|
||||
*/
|
||||
|
||||
/* well we want functions. But first we want to see it work at all. */
|
||||
#undef FUNCTIONS
|
||||
#ifndef FUNCTIONS
|
||||
|
||||
#define RET_LABEL(label) \
|
||||
jmp label##_done
|
||||
|
||||
#define CALL_LABEL(label) \
|
||||
jmp label ;\
|
||||
label##_done:
|
||||
|
||||
#define CALLSP(func) \
|
||||
lea 0f, %esp ; \
|
||||
jmp func ; \
|
||||
0:
|
||||
|
||||
#define RETSP \
|
||||
jmp *%esp
|
||||
|
||||
|
||||
#define DELAY(x) mov x, %ecx ;\
|
||||
1: loop 1b ;\
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Macro: PCI_WRITE_CONFIG_BYTE
|
||||
* Arguments: %eax address to write to (includes bus, device, function, &offset)
|
||||
* %dl byte to write
|
||||
*
|
||||
* Results: none
|
||||
*
|
||||
* Trashed: %eax, %edx
|
||||
* Effects: writes a single byte to pci config space
|
||||
*
|
||||
* Notes: This routine is optimized for minimal register usage.
|
||||
* And the tricks it does cannot scale beyond writing a single byte.
|
||||
*
|
||||
* What it does is almost simple.
|
||||
* It preserves %eax (baring special bits) until it is written
|
||||
* out to the appropriate port. And hides the data byte
|
||||
* in the high half of edx.
|
||||
*
|
||||
* In %edx[3] it stores the byte to write.
|
||||
* In %edx[2] it stores the lower three bits of the address.
|
||||
*/
|
||||
|
||||
|
||||
#define PCI_WRITE_CONFIG_BYTE \
|
||||
shll $8, %edx ; \
|
||||
movb %al, %dl ; \
|
||||
andb $0x3, %dl ; \
|
||||
shll $16, %edx ; \
|
||||
\
|
||||
orl $0x80000000, %eax ; \
|
||||
andl $0xfffffffc, %eax ; \
|
||||
movw $0xcf8, %dx ; \
|
||||
outl %eax, %dx ; \
|
||||
\
|
||||
shrl $16, %edx ; \
|
||||
movb %dh, %al ; \
|
||||
movb $0, %dh ; \
|
||||
addl $0xcfc, %edx ; \
|
||||
outb %al, %dx
|
||||
|
||||
|
||||
/*
|
||||
* Macro: PCI_WRITE_CONFIG_WORD
|
||||
* Arguments: %eax address to write to (includes bus, device, function, &offset)
|
||||
* %ecx word to write
|
||||
*
|
||||
* Results: none
|
||||
*
|
||||
* Trashed: %eax, %edx
|
||||
* Preserved: %ecx
|
||||
* Effects: writes a single byte to pci config space
|
||||
*
|
||||
* Notes: This routine is optimized for minimal register usage.
|
||||
*
|
||||
* What it does is almost simple.
|
||||
* It preserves %eax (baring special bits) until it is written
|
||||
* out to the appropriate port. And hides the least significant
|
||||
* bits of the address in the high half of edx.
|
||||
*
|
||||
* In %edx[2] it stores the lower three bits of the address.
|
||||
*/
|
||||
|
||||
|
||||
#define PCI_WRITE_CONFIG_WORD \
|
||||
movb %al, %dl ; \
|
||||
andl $0x3, %edx ; \
|
||||
shll $16, %edx ; \
|
||||
\
|
||||
orl $0x80000000, %eax ; \
|
||||
andl $0xfffffffc, %eax ; \
|
||||
movw $0xcf8, %dx ; \
|
||||
outl %eax, %dx ; \
|
||||
\
|
||||
shrl $16, %edx ; \
|
||||
movl %ecx, %eax ; \
|
||||
addl $0xcfc, %edx ; \
|
||||
outw %ax, %dx
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Macro: PCI_WRITE_CONFIG_DWORD
|
||||
* Arguments: %eax address to write to (includes bus, device, function, &offset)
|
||||
* %ecx dword to write
|
||||
*
|
||||
* Results: none
|
||||
*
|
||||
* Trashed: %eax, %edx
|
||||
* Preserved: %ecx
|
||||
* Effects: writes a single byte to pci config space
|
||||
*
|
||||
* Notes: This routine is optimized for minimal register usage.
|
||||
*
|
||||
* What it does is almost simple.
|
||||
* It preserves %eax (baring special bits) until it is written
|
||||
* out to the appropriate port. And hides the least significant
|
||||
* bits of the address in the high half of edx.
|
||||
*
|
||||
* In %edx[2] it stores the lower three bits of the address.
|
||||
*/
|
||||
|
||||
|
||||
#define PCI_WRITE_CONFIG_DWORD \
|
||||
movb %al, %dl ; \
|
||||
andl $0x3, %edx ; \
|
||||
shll $16, %edx ; \
|
||||
\
|
||||
orl $0x80000000, %eax ; \
|
||||
andl $0xfffffffc, %eax ; \
|
||||
movw $0xcf8, %dx ; \
|
||||
outl %eax, %dx ; \
|
||||
\
|
||||
shrl $16, %edx ; \
|
||||
movl %ecx, %eax ; \
|
||||
addl $0xcfc, %edx ; \
|
||||
outl %eax, %dx
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Macro: PCI_READ_CONFIG_BYTE
|
||||
* Arguments: %eax address to read from (includes bus, device, function, &offset)
|
||||
*
|
||||
* Results: %al Byte read
|
||||
*
|
||||
* Trashed: %eax, %edx
|
||||
* Effects: reads a single byte from pci config space
|
||||
*
|
||||
* Notes: This routine is optimized for minimal register usage.
|
||||
*
|
||||
* What it does is almost simple.
|
||||
* It preserves %eax (baring special bits) until it is written
|
||||
* out to the appropriate port. And hides the least significant
|
||||
* bits of the address in the high half of edx.
|
||||
*
|
||||
* In %edx[2] it stores the lower three bits of the address.
|
||||
*/
|
||||
|
||||
|
||||
#define PCI_READ_CONFIG_BYTE \
|
||||
movb %al, %dl ; \
|
||||
andl $0x3, %edx ; \
|
||||
shll $16, %edx ; \
|
||||
\
|
||||
orl $0x80000000, %eax ; \
|
||||
andl $0xfffffffc, %eax ; \
|
||||
movw $0xcf8, %dx ; \
|
||||
outl %eax, %dx ; \
|
||||
\
|
||||
shrl $16, %edx ; \
|
||||
addl $0xcfc, %edx ; \
|
||||
inb %dx, %al
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Macro: PCI_READ_CONFIG_WORD
|
||||
* Arguments: %eax address to read from (includes bus, device, function, &offset)
|
||||
*
|
||||
* Results: %ax word read
|
||||
*
|
||||
* Trashed: %eax, %edx
|
||||
* Effects: reads a 2 bytes from pci config space
|
||||
*
|
||||
* Notes: This routine is optimized for minimal register usage.
|
||||
*
|
||||
* What it does is almost simple.
|
||||
* It preserves %eax (baring special bits) until it is written
|
||||
* out to the appropriate port. And hides the least significant
|
||||
* bits of the address in the high half of edx.
|
||||
*
|
||||
* In %edx[2] it stores the lower three bits of the address.
|
||||
*/
|
||||
|
||||
|
||||
#define PCI_READ_CONFIG_WORD \
|
||||
movb %al, %dl ; \
|
||||
andl $0x3, %edx ; \
|
||||
shll $16, %edx ; \
|
||||
\
|
||||
orl $0x80000000, %eax ; \
|
||||
andl $0xfffffffc, %eax ; \
|
||||
movw $0xcf8, %dx ; \
|
||||
outl %eax, %dx ; \
|
||||
\
|
||||
shrl $16, %edx ; \
|
||||
addl $0xcfc, %edx ; \
|
||||
inw %dx, %ax
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Macro: PCI_READ_CONFIG_DWORD
|
||||
* Arguments: %eax address to read from (includes bus, device, function, &offset)
|
||||
*
|
||||
* Results: %eax
|
||||
*
|
||||
* Trashed: %edx
|
||||
* Effects: reads 4 bytes from pci config space
|
||||
*
|
||||
* Notes: This routine is optimized for minimal register usage.
|
||||
*
|
||||
* What it does is almost simple.
|
||||
* It preserves %eax (baring special bits) until it is written
|
||||
* out to the appropriate port. And hides the least significant
|
||||
* bits of the address in the high half of edx.
|
||||
*
|
||||
* In %edx[2] it stores the lower three bits of the address.
|
||||
*/
|
||||
|
||||
|
||||
#define PCI_READ_CONFIG_DWORD \
|
||||
movb %al, %dl ; \
|
||||
andl $0x3, %edx ; \
|
||||
shll $16, %edx ; \
|
||||
\
|
||||
orl $0x80000000, %eax ; \
|
||||
andl $0xfffffffc, %eax ; \
|
||||
movw $0xcf8, %dx ; \
|
||||
outl %eax, %dx ; \
|
||||
\
|
||||
shrl $16, %edx ; \
|
||||
addl $0xcfc, %edx ; \
|
||||
inl %dx, %eax
|
||||
|
||||
|
||||
|
||||
|
||||
#define CS_READ(which) \
|
||||
mov $0x80000000,%eax ; \
|
||||
mov which,%ax ; \
|
||||
and $0xfc,%al /* clear bits 1-0 */ ; \
|
||||
mov $0xcf8,%dx /* port 0xcf8 ?*/ ; \
|
||||
outl %eax,%dx /* open up CS config */ ; \
|
||||
add $0x4,%dl /* 0xcfc data port 0 */ ; \
|
||||
mov which,%al ; \
|
||||
and $0x3,%al /* only bits 1-0 */ ; \
|
||||
add %al,%dl ; \
|
||||
inb %dx,%al /* read */ ; \
|
||||
|
||||
|
||||
#define CS_WRITE(which, data) \
|
||||
mov $0x80000000,%eax /* 32bit word with bit 31 set */ ; \
|
||||
mov which,%ax /* put the reg# in the low part */ ; \
|
||||
and $0xfc,%al /* dword align the reg# */ ; \
|
||||
mov $0xcf8,%dx /* enable port */ ; \
|
||||
outl %eax,%dx ; \
|
||||
add $0x4,%dl /* 1st data port */ ; \
|
||||
mov which,%ax /* register# */ ; \
|
||||
and $0x3,%ax ; \
|
||||
add %al,%dl ; \
|
||||
mov data, %al ; \
|
||||
outb %al,%dx /* write to reg */
|
||||
|
||||
#define REGBIS(which, bis) \
|
||||
CS_READ(which) ;\
|
||||
movb bis, %cl ;\
|
||||
orb %al, %cl ;\
|
||||
CS_WRITE(which, %cl)
|
||||
|
||||
#define REGBIC(which, bic) \
|
||||
CS_READ(which) ;\
|
||||
movb bic, %cl ;\
|
||||
notb %cl ;\
|
||||
andb %al, %cl ;\
|
||||
CS_WRITE(which, %cl)
|
||||
|
||||
|
||||
/* macro to BIC and BIS a reg. calls read a reg,
|
||||
* does a BIC and then a BIS on it.
|
||||
* to clear no bits, make BIC 0.
|
||||
* to set no bits, make BIS 0
|
||||
*/
|
||||
#define REGBICBIS(which, bic, bis) \
|
||||
CS_READ(which) ;\
|
||||
movb bic, %cl ;\
|
||||
notb %cl ;\
|
||||
andb %cl, %al ;\
|
||||
movb bis, %cl ;\
|
||||
orb %al, %cl ;\
|
||||
CS_WRITE(which, %cl)
|
||||
|
||||
#else
|
||||
NO FUNCTIONS YET!
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* originally this macro was from STPC BIOS */
|
||||
#define intel_chip_post_macro(value) \
|
||||
movb $value, %al ; \
|
||||
outb %al, $0x80
|
||||
|
||||
#define INTEL_PDATA_MAGIC 0xdeadbeef
|
||||
|
||||
/* SLOW_DOWN_IO is a delay we can use that is roughly cpu neutral,
|
||||
* and can be used before memory or timer chips come up.
|
||||
* Since this hits the isa bus it's roughly
|
||||
*/
|
||||
#define SLOW_DOWN_IO inb $0x80, %al
|
||||
|
||||
#endif /* ROM_INTEL_H */
|
||||
30
src/include/cpu/p6/msr.h
Normal file
30
src/include/cpu/p6/msr.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Access to machine-specific registers (available on 586 and better only)
|
||||
* Note: the rd* operations modify the parameters directly (without using
|
||||
* pointer indirection), this allows gcc to optimize better
|
||||
*/
|
||||
|
||||
#define rdmsr(msr,val1,val2) \
|
||||
__asm__ __volatile__("rdmsr" \
|
||||
: "=a" (val1), "=d" (val2) \
|
||||
: "c" (msr))
|
||||
|
||||
#define wrmsr(msr,val1,val2) \
|
||||
__asm__ __volatile__("wrmsr" \
|
||||
: /* no outputs */ \
|
||||
: "c" (msr), "a" (val1), "d" (val2))
|
||||
|
||||
#define rdtsc(low,high) \
|
||||
__asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
|
||||
|
||||
#define rdtscl(low) \
|
||||
__asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
|
||||
|
||||
#define rdtscll(val) \
|
||||
__asm__ __volatile__ ("rdtsc" : "=A" (val))
|
||||
|
||||
#define rdpmc(counter,low,high) \
|
||||
__asm__ __volatile__("rdpmc" \
|
||||
: "=a" (low), "=d" (high) \
|
||||
: "c" (counter))
|
||||
|
||||
33
src/include/cpu/p6/mtrr.h
Normal file
33
src/include/cpu/p6/mtrr.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef __LINUXBIOS_MTRR_H
|
||||
#define __LINUXBIOS_MTRR_H
|
||||
|
||||
/* These are the region types */
|
||||
#define MTRR_TYPE_UNCACHABLE 0
|
||||
#define MTRR_TYPE_WRCOMB 1
|
||||
/*#define MTRR_TYPE_ 2*/
|
||||
/*#define MTRR_TYPE_ 3*/
|
||||
#define MTRR_TYPE_WRTHROUGH 4
|
||||
#define MTRR_TYPE_WRPROT 5
|
||||
#define MTRR_TYPE_WRBACK 6
|
||||
#define MTRR_NUM_TYPES 7
|
||||
|
||||
#define MTRRcap_MSR 0x0fe
|
||||
#define MTRRdefType_MSR 0x2ff
|
||||
|
||||
#define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
|
||||
#define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)
|
||||
|
||||
#define NUM_FIXED_RANGES 88
|
||||
#define MTRRfix64K_00000_MSR 0x250
|
||||
#define MTRRfix16K_80000_MSR 0x258
|
||||
#define MTRRfix16K_A0000_MSR 0x259
|
||||
#define MTRRfix4K_C0000_MSR 0x268
|
||||
#define MTRRfix4K_C8000_MSR 0x269
|
||||
#define MTRRfix4K_D0000_MSR 0x26a
|
||||
#define MTRRfix4K_D8000_MSR 0x26b
|
||||
#define MTRRfix4K_E0000_MSR 0x26c
|
||||
#define MTRRfix4K_E8000_MSR 0x26d
|
||||
#define MTRRfix4K_F0000_MSR 0x26e
|
||||
#define MTRRfix4K_F8000_MSR 0x26f
|
||||
|
||||
#endif /* __LINUXBIOS_MTRR_H */
|
||||
40
src/include/linux/asm-i386/e820.h
Normal file
40
src/include/linux/asm-i386/e820.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* structures and definitions for the int 15, ax=e820 memory map
|
||||
* scheme.
|
||||
*
|
||||
* In a nutshell, arch/i386/boot/setup.S populates a scratch table
|
||||
* in the empty_zero_block that contains a list of usable address/size
|
||||
* duples. In arch/i386/kernel/setup.c, this information is
|
||||
* transferred into the e820map, and in arch/i386/mm/init.c, that
|
||||
* new information is used to mark pages reserved or not.
|
||||
*
|
||||
*/
|
||||
#ifndef __E820_HEADER
|
||||
#define __E820_HEADER
|
||||
|
||||
#define E820MAP 0x2d0 /* our map */
|
||||
#define E820MAX 32 /* number of entries in E820MAP */
|
||||
#define E820NR 0x1e8 /* # entries in E820MAP */
|
||||
|
||||
#define E820_RAM 1
|
||||
#define E820_RESERVED 2
|
||||
#define E820_ACPI 3 /* usable as RAM once ACPI tables have been read */
|
||||
#define E820_NVS 4
|
||||
|
||||
#define HIGH_MEMORY (1024*1024)
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
struct e820map {
|
||||
int nr_map;
|
||||
struct {
|
||||
long long addr; /* start of memory segment */
|
||||
long long size; /* size of memory segment */
|
||||
long type; /* type of memory segment */
|
||||
} map[E820MAX];
|
||||
};
|
||||
|
||||
extern struct e820map e820;
|
||||
#endif/*!__ASSEMBLY__*/
|
||||
|
||||
#endif/*__E820_HEADER*/
|
||||
10
src/include/params.h
Normal file
10
src/include/params.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/* ../lib/params.c */
|
||||
void init_params(unsigned char *empty_zero_page);
|
||||
void set_memory_size(unsigned char *empty_zero_page,
|
||||
unsigned long ext_memory_size,
|
||||
unsigned long alt_memory_size);
|
||||
void set_root_rdonly(unsigned char *empty_zero_page);
|
||||
void set_command_line(unsigned char *empty_zero_page,
|
||||
unsigned char *cmdline);
|
||||
unsigned char *get_empty_zero_page(void);
|
||||
void set_display(unsigned char *empty_zero_page, int rows, int cols);
|
||||
1
src/include/pc80/keyboard.h
Normal file
1
src/include/pc80/keyboard.h
Normal file
|
|
@ -0,0 +1 @@
|
|||
void pc_keyboard_init(void);
|
||||
73
src/include/pci-i386.h
Normal file
73
src/include/pci-i386.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* This file was copied verbatim from Linux-2.4.0-test4 sources.
|
||||
*
|
||||
* Low-Level PCI Access for i386 machines.
|
||||
*
|
||||
* (c) 1999 Martin Mares <mj@ucw.cz>
|
||||
*/
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DBG(x...) printk(x)
|
||||
#else
|
||||
#define DBG(x...)
|
||||
#endif
|
||||
|
||||
#define PCI_PROBE_BIOS 1
|
||||
#define PCI_PROBE_CONF1 2
|
||||
#define PCI_PROBE_CONF2 4
|
||||
#define PCI_NO_SORT 0x100
|
||||
#define PCI_BIOS_SORT 0x200
|
||||
#define PCI_NO_CHECKS 0x400
|
||||
#define PCI_ASSIGN_ROMS 0x1000
|
||||
#define PCI_BIOS_IRQ_SCAN 0x2000
|
||||
|
||||
extern unsigned int pci_probe;
|
||||
|
||||
/* pci-i386.c */
|
||||
|
||||
extern unsigned int pcibios_max_latency;
|
||||
|
||||
void pcibios_resource_survey(void);
|
||||
int pcibios_enable_resources(struct pci_dev *);
|
||||
|
||||
/* pci-pc.c */
|
||||
|
||||
extern int pcibios_last_bus;
|
||||
extern struct pci_bus *pci_root_bus;
|
||||
extern struct pci_ops *pci_root_ops;
|
||||
|
||||
struct irq_routing_table *pcibios_get_irq_routing_table(void);
|
||||
int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
|
||||
|
||||
/* pci-irq.c */
|
||||
|
||||
struct irq_info {
|
||||
u8 bus, devfn; /* Bus, device and function */
|
||||
struct {
|
||||
u8 link; /* IRQ line ID, chipset dependent, 0=not routed */
|
||||
u16 bitmap; /* Available IRQs */
|
||||
} __attribute__((packed)) irq[4];
|
||||
u8 slot; /* Slot number, 0=onboard */
|
||||
u8 rfu;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct irq_routing_table {
|
||||
u32 signature; /* PIRQ_SIGNATURE should be here */
|
||||
u16 version; /* PIRQ_VERSION */
|
||||
u16 size; /* Table size in bytes */
|
||||
u8 rtr_bus, rtr_devfn; /* Where the interrupt router lies */
|
||||
u16 exclusive_irqs; /* IRQs devoted exclusively to PCI usage */
|
||||
u16 rtr_vendor, rtr_device; /* Vendor and device ID of interrupt router */
|
||||
u32 miniport_data; /* Crap */
|
||||
u8 rfu[11];
|
||||
u8 checksum; /* Modulo 256 checksum must give zero */
|
||||
struct irq_info slots[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
extern unsigned int pcibios_irq_mask;
|
||||
|
||||
void pcibios_irq_init(void);
|
||||
void pcibios_fixup_irqs(void);
|
||||
void pcibios_enable_irq(struct pci_dev *dev);
|
||||
1422
src/include/pci.h
Normal file
1422
src/include/pci.h
Normal file
File diff suppressed because it is too large
Load diff
6
src/include/pciconf.h
Normal file
6
src/include/pciconf.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef PCI_CONF_REG_INDEX
|
||||
// These are defined in the PCI spec, and hence are theoretically
|
||||
// inclusive of ANYTHING that uses a PCI bus.
|
||||
#define PCI_CONF_REG_INDEX 0xcf8
|
||||
#define PCI_CONF_REG_DATA 0xcfc
|
||||
#endif
|
||||
18
src/include/printk.h
Normal file
18
src/include/printk.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef PRINTK_H
|
||||
#define PRINTK_H
|
||||
|
||||
/* These defines copied from linux/include/linux/kernel.h */
|
||||
|
||||
#define KERN_EMERG "<0>" /* system is unusable */
|
||||
#define KERN_ALERT "<1>" /* action must be taken immediately */
|
||||
#define KERN_CRIT "<2>" /* critical conditions */
|
||||
#define KERN_ERR "<3>" /* error conditions */
|
||||
#define KERN_WARNING "<4>" /* warning conditions */
|
||||
#define KERN_NOTICE "<5>" /* normal but significant condition */
|
||||
#define KERN_INFO "<6>" /* informational */
|
||||
#define KERN_DEBUG "<7>" /* debug-level messages */
|
||||
|
||||
extern int console_loglevel;
|
||||
int printk(const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
10
src/include/serial_subr.h
Normal file
10
src/include/serial_subr.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef _SERIAL_SUBR_H_
|
||||
#define _SERIAL_SUBR_H_
|
||||
|
||||
void ttys0_tx_char(char data);
|
||||
void ttys0_tx_string(char *data);
|
||||
void ttys0_tx_hex_digit(char data);
|
||||
void ttys0_tx_hex(unsigned int data, int digits);
|
||||
void ttys0_tx_int(int data);
|
||||
|
||||
#endif /* _SERIAL_SUBR_H_ */
|
||||
51
src/include/subr.h
Normal file
51
src/include/subr.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef SUBR_H_
|
||||
#define SUBR_H_
|
||||
|
||||
/*
|
||||
* Read/Write the special configuration registers on the INTEL
|
||||
*/
|
||||
// TODO: split this thing up. Delete the intel_ names
|
||||
// that really are not intel-specific, e.g. intel_conf_readb should
|
||||
// be conf_readb -- those addresses are defined in the PCI spec.
|
||||
unsigned char intel_conf_readb(unsigned long port);
|
||||
void intel_conf_writeb(unsigned long port, unsigned char value);
|
||||
|
||||
void intel_keyboard_on();
|
||||
void intel_smpblock(void *v);
|
||||
void intel_nvram_on();
|
||||
|
||||
void displayinit(void);
|
||||
void display(char msg[]);
|
||||
void printnibl(unsigned long nibl);
|
||||
void printchar(unsigned char x);
|
||||
void printint(unsigned long x);
|
||||
void error(char errmsg[]);
|
||||
void intel_post(char value);
|
||||
void intel_conf_writeb(unsigned long port, unsigned char value);
|
||||
unsigned char intel_conf_readb(unsigned long port);
|
||||
void intel_cache_on(unsigned long base, unsigned long totalram);
|
||||
void intel_interrupts_on(void);
|
||||
void pc_keyboard_init(void);
|
||||
void intel_mainboard_fixup(void);
|
||||
unsigned long sizeram(void);
|
||||
|
||||
#ifdef INTEL_PPRO_MTRR
|
||||
void intel_set_mtrr(unsigned long rambase, unsigned long ramsizeK);
|
||||
#endif
|
||||
|
||||
#ifdef NEWPCI /* IRQ routing stuff */
|
||||
|
||||
#include <pci.h>
|
||||
#include <pci-i386.h>
|
||||
|
||||
#define PIRQ_SIGNATURE (('$' << 0) + ('P' << 8) + ('I' << 16) + ('R' << 24))
|
||||
#define PIRQ_VERSION 0x0100
|
||||
|
||||
extern const struct irq_routing_table intel_irq_routing_table;
|
||||
|
||||
void intel_zero_irq_settings(void);
|
||||
void intel_check_irq_routing_table(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* SUBR_H_ */
|
||||
|
|
@ -34,6 +34,30 @@
|
|||
#define PCI_MEM_START 0x80000000
|
||||
#define PCI_IO_START 0x1000
|
||||
|
||||
// historical functions, sometimes very useful.
|
||||
/*
|
||||
* Write the special configuration registers on the INTEL
|
||||
*/
|
||||
void intel_conf_writeb(unsigned long port, unsigned char value)
|
||||
{
|
||||
unsigned char whichbyte = port & 3;
|
||||
port &= (~3);
|
||||
outl(port, PCI_CONF_REG_INDEX);
|
||||
outb(value, PCI_CONF_REG_DATA + whichbyte);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the special configuration registers on the INTEL
|
||||
*/
|
||||
unsigned char intel_conf_readb(unsigned long port)
|
||||
{
|
||||
unsigned char whichbyte = port & 3;
|
||||
port &= (~3);
|
||||
outl(port, PCI_CONF_REG_INDEX);
|
||||
return inb(PCI_CONF_REG_DATA + whichbyte);
|
||||
}
|
||||
|
||||
|
||||
static const struct pci_ops *conf;
|
||||
|
||||
struct pci_ops {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue