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:
parent
be3ebbe61f
commit
a8151ba2cd
53 changed files with 2071 additions and 351 deletions
|
|
@ -2,7 +2,9 @@ object linuxbiosmain.o
|
|||
object linuxpci.o
|
||||
object newpci.o
|
||||
object printk.o
|
||||
object serial_subr.o
|
||||
object serial_subr.o SERIAL_CONSOLE
|
||||
object video_subr.o VIDEO_CONSOLE
|
||||
object logbuf_subr.o LOGBUF_CONSOLE
|
||||
object subr.o
|
||||
object vsprintf.o
|
||||
object memset.o
|
||||
|
|
|
|||
14
src/lib/logbuf_subr.c
Normal file
14
src/lib/logbuf_subr.c
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <logbuf_subr.h>
|
||||
|
||||
#define LOGBUF_SIZE = 1024;
|
||||
|
||||
// KEEP THIS GLOBAL.
|
||||
// I need the address so I can watch it with the ARIUM hardware. RGM.
|
||||
char logbuf[LOGBUF_SIZE];
|
||||
int logbuf_offset = 0;
|
||||
|
||||
void logbuf_tx_byte(unsigned char byte)
|
||||
{
|
||||
logbuf[logbuf_offset] = byte;
|
||||
logbuf_offset = (logbuf_offset +1) % LOGBUF_SIZE;
|
||||
}
|
||||
|
|
@ -750,9 +750,9 @@ void enable_resources(struct pci_bus *bus)
|
|||
u16 command;
|
||||
pci_read_config_word(curdev, PCI_COMMAND, &command);
|
||||
command |= curdev->command;
|
||||
pci_write_config_word(curdev, PCI_COMMAND, command);
|
||||
printk_debug("DEV Set command bus 0x%x devfn 0x%x to 0x%x\n",
|
||||
printk_debug("DEV Set command bus 0x%02x devfn 0x%02x to 0x%02x\n",
|
||||
curdev->bus->number, curdev->devfn, command);
|
||||
pci_write_config_word(curdev, PCI_COMMAND, command);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,12 +12,9 @@ static char rcsid[] = "$Id$";
|
|||
//typedef void * va_list;
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <subr.h>
|
||||
#include <smp/spinlock.h>
|
||||
|
||||
// KEEP THIS GLOBAL.
|
||||
// I need the address so I can watch it with the ARIUM hardware. RGM.
|
||||
char log_buf[1024];
|
||||
|
||||
/* printk's without a loglevel use this.. */
|
||||
#define DEFAULT_MESSAGE_LOGLEVEL 4 /* BIOS_WARNING */
|
||||
|
||||
|
|
@ -36,7 +33,7 @@ int minimum_console_loglevel = MINIMUM_CONSOLE_LOGLEVEL;
|
|||
int default_console_loglevel = DEFAULT_CONSOLE_LOGLEVEL;
|
||||
|
||||
void display(char*);
|
||||
extern int vsprintf(char *buf, const char *, va_list);
|
||||
extern int vtxprintf(void (*)(unsigned char), const char *, va_list);
|
||||
|
||||
spinlock_t console_lock = SPIN_LOCK_UNLOCKED;
|
||||
|
||||
|
|
@ -52,10 +49,10 @@ int do_printk(int msg_level, const char *fmt, ...)
|
|||
spin_lock(&console_lock);
|
||||
|
||||
va_start(args, fmt);
|
||||
i = vsprintf(log_buf, fmt, args); /* hopefully i < sizeof(log_buf)-4 */
|
||||
i = vtxprintf(display_tx_byte, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
display(log_buf);
|
||||
display_tx_break();
|
||||
|
||||
spin_unlock(&console_lock);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,14 @@ static char rcsid[] = "$Id$";
|
|||
|
||||
#define TTYS0_DIV (115200/TTYS0_BAUD)
|
||||
|
||||
/* Line Control Settings */
|
||||
#ifndef TTYS0_LCS
|
||||
/* Set 8bit, 1 stop bit, no parity */
|
||||
#define TTYS0_LCS 0x3
|
||||
#endif
|
||||
|
||||
#define UART_LCS TTYS0_LCS
|
||||
|
||||
/* Data */
|
||||
#define UART_RBR 0x00
|
||||
#define UART_TBR 0x00
|
||||
|
|
@ -36,10 +44,6 @@ static char rcsid[] = "$Id$";
|
|||
#define UART_MSR 0x06
|
||||
#define UART_SCR 0x07
|
||||
|
||||
#ifndef TTYS0_BAUD
|
||||
#define TTYS0_BAUD 115200
|
||||
#endif
|
||||
|
||||
static inline int uart_can_tx_byte(unsigned base_port)
|
||||
{
|
||||
return inb(base_port + UART_LSR) & 0x20;
|
||||
|
|
@ -141,10 +145,10 @@ inline void uart_init(unsigned base_port, unsigned divisor)
|
|||
/* enable fifo's */
|
||||
outb(0x01, base_port + UART_FCR);
|
||||
/* Set Baud Rate Divisor to 12 ==> 115200 Baud */
|
||||
outb(0x83, base_port + UART_LCR);
|
||||
outb(0x80 | UART_LCS, base_port + UART_LCR);
|
||||
outb(divisor & 0xFF, base_port + UART_DLL);
|
||||
outb((divisor >> 8) & 0xFF, base_port + UART_DLM);
|
||||
outb(0x03, base_port + UART_LCR);
|
||||
outb(UART_LCS, base_port + UART_LCR);
|
||||
}
|
||||
|
||||
void ttys0_init(void)
|
||||
|
|
|
|||
|
|
@ -18,63 +18,18 @@ static char rcsid[] = "$Id$";
|
|||
#ifdef SERIAL_CONSOLE
|
||||
#include <serial_subr.h>
|
||||
#endif
|
||||
#ifdef VIDEO_CONSOLE
|
||||
#include <video_subr.h>
|
||||
#endif
|
||||
#ifdef LOGBUF_CONSOLE
|
||||
#include <logbuf_subr.h>
|
||||
#endif
|
||||
|
||||
#ifdef VIDEO_BIOS_WORKS
|
||||
|
||||
# error the video display code has not been tested
|
||||
|
||||
// kludgy but this is only used here ...
|
||||
static char *vidmem; /* The video buffer, should be replaced by symbol in ldscript.ld */
|
||||
static int video_line, video_col;
|
||||
|
||||
#define LINES 25 /* Number of lines and */
|
||||
#define COLS 80 /* columns on display */
|
||||
#define VIDBUFFER 0x20000;
|
||||
|
||||
static void video_init(void)
|
||||
{
|
||||
video_line = 0;
|
||||
video_col = 0;
|
||||
vidmem = (char *) VIDBUFFER;
|
||||
memset(vidmem, 0, 64*1024);
|
||||
}
|
||||
static void video_scroll(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
memcpy(vidmem, vidmem + COLS * 2, (LINES - 1) * COLS * 2);
|
||||
for (i = (LINES - 1) * COLS * 2; i < LINES * COLS * 2; i += 2)
|
||||
vidmem[i] = ' ';
|
||||
}
|
||||
|
||||
static void video_tx_byte(unsigned char byte)
|
||||
{
|
||||
if (byte == '\n') {
|
||||
video_line++;
|
||||
}
|
||||
else if (byte == '\r') {
|
||||
video_col = 0;
|
||||
}
|
||||
else {
|
||||
videmem[((video_col + (video_line *COLS)) * 2)] = byte;
|
||||
videmem[((video_col + (video_line *COLS)) * 2) +1] = 0x07;
|
||||
video_col++;
|
||||
}
|
||||
if (video_col >= COLS) {
|
||||
video_line++;
|
||||
video_col = 0;
|
||||
}
|
||||
if (video_line >= LINES) {
|
||||
video_scroll();
|
||||
video_line--;
|
||||
}
|
||||
}
|
||||
#endif /* VIDEO_BIOS_WORKS */
|
||||
|
||||
// initialize the display
|
||||
void displayinit(void)
|
||||
{
|
||||
#ifdef VIDEO_BIOS_WORKS
|
||||
#ifdef VIDEO_CONSOLE
|
||||
video_init();
|
||||
#endif
|
||||
#ifdef SERIAL_CONSOLE
|
||||
|
|
@ -82,9 +37,9 @@ void displayinit(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void display_tx_byte(unsigned char byte)
|
||||
static void __display_tx_byte(unsigned char byte)
|
||||
{
|
||||
#ifdef VIDEO_BIOS_WORKS
|
||||
#ifdef VIDEO_CONSOLE
|
||||
video_tx_byte(byte);
|
||||
#endif
|
||||
#ifdef SERIAL_CONSOLE
|
||||
|
|
@ -93,17 +48,29 @@ void display_tx_byte(unsigned char byte)
|
|||
#ifdef SROM_CONSOLE
|
||||
srom_tx_byte(byte);
|
||||
#endif
|
||||
#ifdef LOGBUF_CONSOLE
|
||||
logbuf_tx_byte(byte);
|
||||
#endif
|
||||
}
|
||||
|
||||
void display_tx_break(void)
|
||||
{
|
||||
}
|
||||
|
||||
void display_tx_byte(unsigned char byte)
|
||||
{
|
||||
if (byte == '\n')
|
||||
__display_tx_byte('\r');
|
||||
__display_tx_byte(byte);
|
||||
}
|
||||
|
||||
void display(char *string)
|
||||
{
|
||||
while(*string) {
|
||||
if (*string == '\n') {
|
||||
display_tx_byte('\r');
|
||||
}
|
||||
display_tx_byte(*string);
|
||||
string++;
|
||||
}
|
||||
display_tx_break();
|
||||
}
|
||||
|
||||
void error(char errmsg[])
|
||||
|
|
|
|||
49
src/lib/video_subr.c
Normal file
49
src/lib/video_subr.c
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include <video_subr.h>
|
||||
# error the video display code has not been tested
|
||||
|
||||
// kludgy but this is only used here ...
|
||||
static char *vidmem; /* The video buffer, should be replaced by symbol in ldscript.ld */
|
||||
static int video_line, video_col;
|
||||
|
||||
#define LINES 25 /* Number of lines and */
|
||||
#define COLS 80 /* columns on display */
|
||||
#define VIDBUFFER 0x20000;
|
||||
|
||||
void video_init(void)
|
||||
{
|
||||
video_line = 0;
|
||||
video_col = 0;
|
||||
vidmem = (char *) VIDBUFFER;
|
||||
memset(vidmem, 0, 64*1024);
|
||||
}
|
||||
static void video_scroll(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
memcpy(vidmem, vidmem + COLS * 2, (LINES - 1) * COLS * 2);
|
||||
for (i = (LINES - 1) * COLS * 2; i < LINES * COLS * 2; i += 2)
|
||||
vidmem[i] = ' ';
|
||||
}
|
||||
|
||||
void video_tx_byte(unsigned char byte)
|
||||
{
|
||||
if (byte == '\n') {
|
||||
video_line++;
|
||||
}
|
||||
else if (byte == '\r') {
|
||||
video_col = 0;
|
||||
}
|
||||
else {
|
||||
videmem[((video_col + (video_line *COLS)) * 2)] = byte;
|
||||
videmem[((video_col + (video_line *COLS)) * 2) +1] = 0x07;
|
||||
video_col++;
|
||||
}
|
||||
if (video_col >= COLS) {
|
||||
video_line++;
|
||||
video_col = 0;
|
||||
}
|
||||
if (video_line >= LINES) {
|
||||
video_scroll();
|
||||
video_line--;
|
||||
}
|
||||
}
|
||||
|
|
@ -88,12 +88,13 @@ __res = ((unsigned long) n) % (unsigned) base; \
|
|||
n = ((unsigned long) n) / (unsigned) base; \
|
||||
__res; })
|
||||
|
||||
static char * number(char * str, long num, int base, int size, int precision
|
||||
static int number(void (*tx_byte)(unsigned char byte), long num, int base, int size, int precision
|
||||
,int type)
|
||||
{
|
||||
char c,sign,tmp[66];
|
||||
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
int i;
|
||||
int count = 0;
|
||||
|
||||
if (type & LARGE)
|
||||
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
|
@ -132,38 +133,35 @@ static char * number(char * str, long num, int base, int size, int precision
|
|||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT)))
|
||||
while(size-->0)
|
||||
*str++ = ' ';
|
||||
tx_byte(' '), count++;
|
||||
if (sign)
|
||||
*str++ = sign;
|
||||
tx_byte(sign), count++;
|
||||
if (type & SPECIAL) {
|
||||
if (base==8)
|
||||
*str++ = '0';
|
||||
tx_byte('0'), count++;
|
||||
else if (base==16) {
|
||||
*str++ = '0';
|
||||
*str++ = digits[33];
|
||||
tx_byte('0'), count++;
|
||||
tx_byte(digits[33]), count++;
|
||||
}
|
||||
}
|
||||
if (!(type & LEFT))
|
||||
while (size-- > 0)
|
||||
*str++ = c;
|
||||
tx_byte(c), count++;
|
||||
while (i < precision--)
|
||||
*str++ = '0';
|
||||
tx_byte('0'), count++;
|
||||
while (i-- > 0)
|
||||
*str++ = tmp[i];
|
||||
tx_byte(tmp[i]), count++;
|
||||
while (size-- > 0)
|
||||
*str++ = ' ';
|
||||
return str;
|
||||
tx_byte(' '), count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Forward decl. needed for IP address printing stuff... */
|
||||
int sprintf(char * buf, const char *fmt, ...);
|
||||
|
||||
int vsprintf(char *buf, const char *fmt, va_list args)
|
||||
int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args)
|
||||
{
|
||||
int len;
|
||||
unsigned long num;
|
||||
int i, base;
|
||||
char * str;
|
||||
const char *s;
|
||||
|
||||
int flags; /* flags to number() */
|
||||
|
|
@ -172,10 +170,12 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
|||
int precision; /* min. # of digits for integers; max
|
||||
number of chars for from string */
|
||||
int qualifier; /* 'h', 'l', or 'L' for integer fields */
|
||||
|
||||
int count;
|
||||
|
||||
for (str=buf ; *fmt ; ++fmt) {
|
||||
for (count=0; *fmt ; ++fmt) {
|
||||
if (*fmt != '%') {
|
||||
*str++ = *fmt;
|
||||
tx_byte(*fmt), count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -234,10 +234,10 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
|||
case 'c':
|
||||
if (!(flags & LEFT))
|
||||
while (--field_width > 0)
|
||||
*str++ = ' ';
|
||||
*str++ = (unsigned char) va_arg(args, int);
|
||||
tx_byte(' '), count++;
|
||||
tx_byte((unsigned char) va_arg(args, int)), count++;
|
||||
while (--field_width > 0)
|
||||
*str++ = ' ';
|
||||
tx_byte(' '), count++;
|
||||
continue;
|
||||
|
||||
case 's':
|
||||
|
|
@ -249,11 +249,11 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
|||
|
||||
if (!(flags & LEFT))
|
||||
while (len < field_width--)
|
||||
*str++ = ' ';
|
||||
tx_byte(' '), count++;
|
||||
for (i = 0; i < len; ++i)
|
||||
*str++ = *s++;
|
||||
tx_byte(*s++), count++;
|
||||
while (len < field_width--)
|
||||
*str++ = ' ';
|
||||
tx_byte(' '), count++;
|
||||
continue;
|
||||
|
||||
case 'p':
|
||||
|
|
@ -261,7 +261,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
|||
field_width = 2*sizeof(void *);
|
||||
flags |= ZEROPAD;
|
||||
}
|
||||
str = number(str,
|
||||
count += number(tx_byte,
|
||||
(unsigned long) va_arg(args, void *), 16,
|
||||
field_width, precision, flags);
|
||||
continue;
|
||||
|
|
@ -270,15 +270,15 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
|||
case 'n':
|
||||
if (qualifier == 'l') {
|
||||
long * ip = va_arg(args, long *);
|
||||
*ip = (str - buf);
|
||||
*ip = count;
|
||||
} else {
|
||||
int * ip = va_arg(args, int *);
|
||||
*ip = (str - buf);
|
||||
*ip = count;
|
||||
}
|
||||
continue;
|
||||
|
||||
case '%':
|
||||
*str++ = '%';
|
||||
tx_byte('%'), count++;
|
||||
continue;
|
||||
|
||||
/* integer number formats - set up the flags and "break" */
|
||||
|
|
@ -299,9 +299,9 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
|||
break;
|
||||
|
||||
default:
|
||||
*str++ = '%';
|
||||
tx_byte('%'), count++;
|
||||
if (*fmt)
|
||||
*str++ = *fmt;
|
||||
tx_byte(*fmt), count++;
|
||||
else
|
||||
--fmt;
|
||||
continue;
|
||||
|
|
@ -316,10 +316,27 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
|||
num = va_arg(args, int);
|
||||
else
|
||||
num = va_arg(args, unsigned int);
|
||||
str = number(str, num, base, field_width, precision, flags);
|
||||
count += number(tx_byte, num, base, field_width, precision, flags);
|
||||
}
|
||||
*str = '\0';
|
||||
return str-buf;
|
||||
return count;
|
||||
}
|
||||
|
||||
/* FIXME this global makes vsprintf non-reentrant
|
||||
*/
|
||||
static char *str_buf;
|
||||
static void str_tx_byte(char byte)
|
||||
{
|
||||
*str_buf = byte;
|
||||
str_buf++;
|
||||
}
|
||||
|
||||
int vsprintf(char * buf, const char *fmt, va_list args)
|
||||
{
|
||||
int i;
|
||||
str_buf = buf;
|
||||
i = vtxprintf(str_tx_byte, fmt, args);
|
||||
str_buf = 0;
|
||||
return i;
|
||||
}
|
||||
|
||||
int sprintf(char * buf, const char *fmt, ...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue