xv6的lab1中的proj1的bootmain.c

//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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值