//boot loader
//Part of the boot sector ,along with bootasm.S which calls bootmain(),
//bootasm.S has put the processor into protected 32 -bits mode.
//bootmain() loads an ELF kernel image from the disk starting at
//sector 1 and then jump to the kernel entry routine;
#include "type.h"
#include"x86.h"
#define CRTPORT 0x3d4
#define LPTPORT 0x378
#define BACKSPACE 0x100
static ushort *crt =(ushort*)0xb8000;
static char*message="This is an xv6 bootloader";
//copy console output to parallel port ,which you can tell .bochsrc to copy to the stdout
//parport1:enabled=1;file ="/dev/stdout"
static void
lpt_putc(int c)
for(i=0;!(inb (LPTPORT+1)&0x80)&&i<12800;i++)
;
if(c==BACKSPACE)
c='/b';
outb(LPTPORT+0,c);
outb(LPTPORT+2,0x08|0x04|0x01);
outb(LPTPORT+2,0x08);
}
static void
cga_putc(int c)
{
int pos;
static void
cga_putc(int c)
{
int pos;
// Cursor position: col + 80*row.
outb(CRTPORT, 14);
pos = inb(CRTPORT+1) << 8;
outb(CRTPORT, 15);
pos |= inb(CRTPORT+1);
if(c == '/n')
pos += 80 - pos%80;
else if(c == BACKSPACE){
if(pos > 0)
crt[--pos] = ' ' | 0x0700;
} else
crt[pos++] = (c&0xff) | 0x0700; // black on white
outb(CRTPORT, 14);
outb(CRTPORT+1, pos>>8);
outb(CRTPORT, 15);
outb(CRTPORT+1, pos);
crt[pos] = ' ' | 0x0700;
}
void
cons_putc(int c)
{
lpt_putc(c);
cga_putc(c);
}
void
bootmain(void)
{
int i;
for(i=0;i<25;i++)
cons_putc(message[i]);
for(;;)
;
}
dataregister(baseaddress +0)=0x378
stautsregister(baseadddress+1)=0x379
controlregister(baseaddress+2)=0x3a0
这个表格是并口的管脚说明;下面是英文的说明:
Pin No (D-Type 25) | SPP Signal | Direction In/out | Register.bit |
1* | nStrobe | In/Out | Control.0 |
2 | Data 0 | In/Out | Data.0 |
3 | Data 1 | In/Out | Data.1 |
4 | Data 2 | In/Out | Data.2 |
5 | Data 3 | In/Out | Data.3 |
6 | Data 4 | In/Out | Data.4 |
7 | Data 5 | In/Out | Data.5 |
8 | Data 6 | In/Out | Data.6 |
9 | Data 7 | In/Out | Data.7 |
10 | nAck | In | Status.6 |
11* | Busy | In | Status.7 |
12 | Paper-Out / Paper-End | In | Status.5 |
13 | Select | In | Status.4 |
14* | nAuto-Linefeed | In/Out | Control.1 |
15 | nError / nFault | In | Status.3 |
16 | nInitialize | In/Out | Control.2 |
17* | nSelect-Printer/ nSelect-In | In/Out | Control.3 |
18 - 25 | Ground | Gnd |
|