Initial checkin for supermicro p4dc6

This also includes a bunch of my pending work including
- Updated serial code so we can compile in different serial port speeds
- Updates to the build system so that:
  - Makefile.settings holds all of the settings of the config variables
  - ldoptions and cpuflags are generated automatically with perl scripts
  - src/config/Config holds all of the architecture neutral make file settings
- Initial work on the P4 including how to use cache as ram
- Update to the ioapic code for the P4 because it delivers irqs on the system
  bus instead of an out of band bus
- Updated version of printf that doesn't need an intermediate buffer
  - logbuf_subr now handles the case when we want to use a log buffer
- video_subr handles the preliminary code for writing to a video device.
- Pending changes for the L440GX are merged in as well (hopefully I haven't
  messed then up since they were written).
This commit is contained in:
Eric W. Biederman 2001-11-03 02:11:49 +00:00
commit a8151ba2cd
53 changed files with 2071 additions and 351 deletions

View file

@ -36,6 +36,10 @@ EXT(_start): jmp _realstart
* at 0x18; these are Linux-compatible.
*/
#ifndef CACHE_RAM_BASE
#define CACHE_RAM_BASE 0
#endif
/** GDT. we have modified this from the original freebios to make it
* compatible with linux. This puts text at seg 0x10 and data at 0x18
*/
@ -46,16 +50,16 @@ EXT(gdtptr):
.long gdt /* we know the offset */
gdt:
.word 0x0000, 0x0000 /* dummy */
.byte 0x0, 0x0, 0x0, 0x0
.word 0x0000, 0x0000 /* dummy */
.byte 0x0, 0x0, 0x0, 0x0
.byte 0x00, 0x00, 0x00, 0x00
.word 0xffff, (CACHE_RAM_BASE & 0xffff) /* flat offset data segment */
.byte ((CACHE_RAM_BASE >> 16)& 0xff), 0x93, 0xcf, ((CACHE_RAM_BASE >> 24) & 0xff)
.word 0xffff, 0x0000 /* flat code segment */
.byte 0x0, 0x9b, 0xcf, 0x0
.byte 0x00, 0x9b, 0xcf, 0x00
.word 0xffff, 0x0000 /* flat data segment */
.byte 0x0, 0x93, 0xcf, 0x0
.byte 0x00, 0x93, 0xcf, 0x00
_realstart:

1
src/cpu/i786/Config Normal file
View file

@ -0,0 +1 @@
option i786

View file

@ -0,0 +1,39 @@
#if defined(CACHE_RAM_BASE) && defined(CACHE_RAM_SIZE)
/* Note: We cannot be running from simulated ram in
* this code. If we are evil things will happen.
*/
/* Disable the cache */
movl %cr0, %eax
orl $0x40000000, %eax
movl %eax, %cr0
/* Flush everything that is left in the cache,
* We don't want random writes to memory to occur later on.
*/
invd
/* Disable the cache ram mtrr */
movl $0x204, %ecx
xorl %eax, %eax
xorl %edx, %edx
wrmsr
movl $0x205, %ecx
xorl %eax, %eax
xorl %edx, %edx
wrmsr
/* Reenable the cache now that the mtrr is cleared */
movl %cr0, %eax
andl $0x9fffffff, %eax
movl %eax, %cr0
/* Reload the normal data segments */
movw $0x18, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
movw %ax, %fs
movw %ax, %gs
#endif

View file

@ -0,0 +1,42 @@
#if defined(CACHE_RAM_BASE) && defined(CACHE_RAM_SIZE)
/* Disable the cache while we set up the cache ram MTRR */
movl %cr0, %eax
orl $0x40000000, %eax
movl %eax, %cr0
/* Set up an mtrr in write-back mode over some arbitrary
* location. As long as we do not get a capacity miss,
* or a multiprocessor conflict miss this should allow us to
* function as if we have memory even when it hasn't been
* enabled yet.
*/
movl $0x204, %ecx /* mtrr[0] physical base register */
xorl %edx, %edx
movl $(CACHE_RAM_BASE | 0x006), %eax
wrmsr
movl $0x205, %ecx /* mtrr[0] physical mask register */
movl $0x0000000f, %edx
movl $(~(CACHE_RAM_SIZE - 1) | 0x800), %eax
wrmsr
/* Reenable the cache now that the mtrr is set up */
movl %cr0, %eax
andl $0x9fffffff, %eax
movl %eax, %cr0
/* Force cache ram area into cache */
movl $CACHE_RAM_BASE, %esi
movl $(CACHE_RAM_BASE + CACHE_RAM_SIZE), %edi
1: movl (%esi), %eax
addl $4, %esi
movl %eax, (%esi)
cmpl %esi, %edi
jnz 1b
/* Load a different set of data segments */
movw $0x08, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
#endif

View file

@ -0,0 +1,25 @@
/* copy data segment from FLASH ROM to CACHE */
movl $(EXT(_ldata) - CACHE_RAM_BASE), %esi
movl $EXT(_data), %edi
movl $(EXT(_eldata) - CACHE_RAM_BASE), %ecx
subl %esi, %ecx
jz 1f /* should not happen */
rep
movsb
1:
/** clear bss */
movl $EXT(_bss), %edi
movl $EXT(_ebss), %ecx
subl %edi, %ecx
jz 1f
xorl %eax, %eax
rep
stosb
1:
/* set new stack */
movl $(_stack + STACK_SIZE), %esp
call cache_ram_start

108
src/cpu/i786/earlymtrr.inc Normal file
View file

@ -0,0 +1,108 @@
#include <cpu/p6/mtrr.h>
/* The fixed and variable MTRRs are powered-up with random values, clear them to
* MTRR_TYPE_UNCACHABLE for safty reason
*/
earlymtrr_start:
xorl %eax, %eax # clear %eax and %edx
xorl %edx, %edx #
movl $fixed_mtrr_msr, %esi
clear_fixed_var_mtrr:
lodsl (%esi), %eax
testl %eax, %eax
jz clear_fixed_var_mtrr_out
movl %eax, %ecx
xorl %eax, %eax
wrmsr
jmp clear_fixed_var_mtrr
clear_fixed_var_mtrr_out:
#ifdef MEMORY_HOLE
set_fixed_mtrr:
/* enable Write Back Cache for 0-640KB */
movl $MTRRfix64K_00000_MSR, %ecx
rdmsr
movl $0x06060606, %edx
movl $0x06060606, %eax
wrmsr
movl $MTRRfix16K_80000_MSR, %ecx
rdmsr
movl $0x06060606, %edx
movl $0x06060606, %eax
wrmsr
#endif /* MEMORY_HOLE */
set_var_mtrr:
#if 0
/* enable caching for 0 - 128MB using variable mtrr */
movl $0x200, %ecx
rdmsr
andl $0xfffffff0, %edx
orl $0x00000000, %edx
andl $0x00000f00, %eax
orl $0x00000006, %eax
wrmsr
movl $0x201, %ecx
rdmsr
andl $0xfffffff0, %edx
orl $0x0000000f, %edx
andl $0x000007ff, %eax
orl $0xf0000800, %eax
wrmsr
#endif
#if defined(XIP_ROM_SIZE) && defined(XIP_ROM_BASE)
/* enable write protect caching so we can do execute in place
* on the flash rom.
*/
movl $0x202, %ecx
xorl %edx, %edx
movl $(XIP_ROM_BASE | 0x005), %eax
wrmsr
movl $0x203, %ecx
movl $0x0000000f, %edx
movl $(~(XIP_ROM_SIZE - 1) | 0x800), %eax
wrmsr
#endif /* XIP_ROM_SIZE && XIP_ROM_BASE */
enable_mtrr:
/* Set the default memory type and enable fixed and variable MTRRs */
movl $0x2ff, %ecx
xorl %edx, %edx
#ifdef MEMORY_HOLE
/* Enable Fixed and Variable MTRRs */
movl $0x00000c00, %eax
#else
/* Enable Variable MTRRs */
movl $0x00000800, %eax
#endif /* MEMORY_HOLE */
wrmsr
/* enable cache */
movl %cr0, %eax
andl $0x9fffffff,%eax
movl %eax, %cr0
jmp earlymtrr_end
fixed_mtrr_msr:
.long 0x250, 0x258, 0x259
.long 0x268, 0x269, 0x26A
.long 0x26B, 0x26C, 0x26D
.long 0x26E, 0x26F
var_mtrr_msr:
.long 0x200, 0x201, 0x202, 0x203
.long 0x204, 0x205, 0x206, 0x207
.long 0x208, 0x209, 0x20A, 0x20B
.long 0x20C, 0x20D, 0x20E, 0x20F
.long 0x000 /* NULL, end of table */
earlymtrr_end:

View file

@ -109,6 +109,7 @@ static unsigned char fixed_mtrr_values[][4] = {
{ROM, ROM, ROM, ROM}, {ROM, ROM, ROM, ROM},
};
#else
static unsigned char fixed_mtrr_values[][4] = {
/* MTRRfix64K_00000_MSR, defines memory range from 0KB to 512 KB, each byte cover 64KB area */
{RAM, RAM, RAM, RAM}, {RAM, RAM, RAM, RAM},
@ -143,6 +144,7 @@ static unsigned char fixed_mtrr_values[][4] = {
/* MTRRfix4K_F8000_MSR, defines memory range from F8000 to 100000, each byte cover 4KB area */
{ROM, ROM, ROM, ROM}, {ROM, ROM, ROM, ROM},
};
#endif
#undef FB