090316

| | コメント(6)



レースウィークに入って中断していた、机の塗装を再開。3回まで塗ったところ
だった。ここでオービタルサンダーで#400で割と思いっきり削りました。3回塗
りといえども、壁面塗りなので塗膜厚さが稼げてなくてちょっと厳しい。ここ
からは仕上げ塗りということで刷毛目が出ないようにちょっと薄めて塗装しま
した。これはこれでタレるから難しい。

ちょっと思ったような塗面に仕上がってない。

ML115 G5を4.99.72のGENERICで起動してみました。後半キーボード、マウスで タイムアウトや、エラーが出てるのはXを起動した時のもの。このせいで立ちあ がるのに1分くらいかかる。立ちあがれば普通に使える。ML115のビデオはさす がの僕でも「これは使えない...」と思ったけれど、ML115 G5のビデオなら使え なくないレベル。それでもPower Edge T105より多少滲むかな。(今のデスクトッ プはT105)
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 4.99.72 (GENERIC) #0: Mon Mar 16 19:35:26 JST 2009
	uch@alexandrite:/usr/work/src-4.99.72/sys/arch/i386/compile/GENERIC
total memory = 511 MB
avail memory = 491 MB
timecounter: Timecounters tick every 10.000 msec
timecounter: Timecounter "i8254" frequency 1193182 Hz quality 100
HP ProLiant ML115 G5 (  )
mainbus0 (root)
cpu0 at mainbus0 apid 0: AMD 686-class, 2700MHz, id 0x70ff2
ioapic0 at mainbus0 apid 1: pa 0xfec00000, version 11, 24 pins
acpi0 at mainbus0: Intel ACPICA 20080321
acpi0: X/RSDT: OemId <HP    ,ProLiant,20080526>, AslId <FOXC,00000097>
acpi0: SCI interrupting at int 9
acpi0: fixed-feature power button present
timecounter: Timecounter "ACPI-Fast" frequency 3579545 Hz quality 1000
ACPI-Fast 24-bit timer
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
midi0 at pcppi1: PC speaker (CPU-intensive output)
sysbeep0 at pcppi1
npx1 at acpi0 (COPR, PNP0C04)
npx1: io 0xf0-0xff irq 13
npx1: reported by CPUID; using exception 16
UAR1 (PNP0501) at acpi0 not configured
hpet0 at acpi0 (HPET, PNP0103-0)
hpet0: mem 0xfed00000-0xfed00fff irq 0,8
timecounter: Timecounter "hpet0" frequency 25000000 Hz quality 2000
attimer1 at acpi0 (TMR, PNP0100): AT Timer
attimer1: io 0x40-0x43
acpibut0 at acpi0 (PWRB, PNP0C0C-170): ACPI Power Button
MI0 (IPI0001) ACPI Error (nsxfeval-0213): Incorrect return type [Buffer] requested [String] [20080321]
at acpi0 not configured
MI1 (HPI0002) ACPI Error (nsxfeval-0213): Incorrect return type [Buffer] requested [String] [20080321]
at acpi0 not configured
apm0 at acpi0: Power Management spec V1.2
attimer1: attached to pcppi1
pci0 at mainbus0 bus 0: configuration mode 1
pci0: i/o space, memory space enabled, rd/line, rd/mult, wr/inv ok
vendor 0x10de product 0x0369 (RAM memory, revision 0xa2) at pci0 dev 0 function 0 not configured
pcib0 at pci0 dev 1 function 0
pcib0: vendor 0x10de product 0x0360 (rev. 0xa3)
nfsmbc0 at pci0 dev 1 function 1: vendor 0x10de product 0x0368 (rev. 0xa3)
nfsmb0 at nfsmbc0 SMBus 1
iic0 at nfsmb0: I2C bus
nfsmb1 at nfsmbc0 SMBus 2
iic1 at nfsmb1: I2C bus
ohci0 at pci0 dev 2 function 0: vendor 0x10de product 0x036c (rev. 0xa1)
LUB0: Picked IRQ 21 with weight 0
ohci0: interrupting at ioapic0 pin 21
ohci0: OHCI version 1.0, legacy support
usb0 at ohci0: USB revision 1.0
ehci0 at pci0 dev 2 function 1: vendor 0x10de product 0x036d (rev. 0xa2)
LUB2: Picked IRQ 22 with weight 0
ehci0: interrupting at ioapic0 pin 22
ehci0: BIOS has given up ownership
ehci0: EHCI version 1.0
ehci0: companion controller, 10 ports each: ohci0
usb1 at ehci0: USB revision 2.0
viaide0 at pci0 dev 5 function 0
viaide0: NVIDIA MCP55 Serial ATA Controller (rev. 0xa3)
viaide0: bus-master DMA support present
viaide0: primary channel wired to native-PCI mode
LSA0: Picked IRQ 23 with weight 0
viaide0: using ioapic0 pin 23 for native-PCI interrupt
atabus0 at viaide0 channel 0
viaide0: secondary channel wired to native-PCI mode
atabus1 at viaide0 channel 1
viaide1 at pci0 dev 5 function 1
viaide1: NVIDIA MCP55 Serial ATA Controller (rev. 0xa3)
viaide1: bus-master DMA support present
viaide1: primary channel wired to native-PCI mode
LSA1: Picked IRQ 21 with weight 1
viaide1: using ioapic0 pin 21 for native-PCI interrupt
atabus2 at viaide1 channel 0
viaide1: secondary channel wired to native-PCI mode
atabus3 at viaide1 channel 1
viaide2 at pci0 dev 5 function 2
viaide2: NVIDIA MCP55 Serial ATA Controller (rev. 0xa3)
viaide2: bus-master DMA support present
viaide2: primary channel wired to native-PCI mode
LSA2: Picked IRQ 22 with weight 1
viaide2: using ioapic0 pin 22 for native-PCI interrupt
atabus4 at viaide2 channel 0
viaide2: secondary channel wired to native-PCI mode
atabus5 at viaide2 channel 1
ppb0 at pci0 dev 6 function 0: vendor 0x10de product 0x0370 (rev. 0xa2)
pci1 at ppb0 bus 1
pci1: no spaces enabled!
ppb1 at pci0 dev 10 function 0: vendor 0x10de product 0x0376 (rev. 0xa3)
pci2 at ppb1 bus 2
pci2: no spaces enabled!
ppb2 at pci0 dev 11 function 0: vendor 0x10de product 0x0374 (rev. 0xa3)
pci3 at ppb2 bus 3
pci3: no spaces enabled!
ppb3 at pci0 dev 12 function 0: vendor 0x10de product 0x0374 (rev. 0xa3)
pci4 at ppb3 bus 4
pci4: no spaces enabled!
ppb4 at pci0 dev 13 function 0: vendor 0x10de product 0x0378 (rev. 0xa3)
pci5 at ppb4 bus 16
pci5: i/o space, memory space enabled, rd/line, wr/inv ok
vga1 at pci5 dev 0 function 0: vendor 0x102b product 0x0522 (rev. 0x02)
wsdisplay0 at vga1 kbdmux 1: console (80x25, vt100 emulation)
wsmux1: connecting to wsdisplay0
drm at vga1 not configured
ppb5 at pci0 dev 14 function 0: vendor 0x10de product 0x0375 (rev. 0xa3)
pci6 at ppb5 bus 17
pci6: memory space enabled, rd/line, wr/inv ok
bge0 at pci6 dev 0 function 0: Broadcom BCM5722 Gigabit Ethernet
LNEC: Picked IRQ 16 with weight 0
bge0: interrupting at ioapic0 pin 16
bge0: ASIC BCM5755 C0 (0xa200), Ethernet address 00:23:7d:61:42:c1
bge0: setting short Tx thresholds
ukphy0 at bge0 phy 1: Generic IEEE 802.3u media interface
ukphy0: OUI 0x000af7, model 0x002d, rev. 0
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
ppb6 at pci0 dev 15 function 0: vendor 0x10de product 0x0377 (rev. 0xa3)
pci7 at ppb6 bus 18
pci7: no spaces enabled!
pchb0 at pci0 dev 24 function 0
pchb0: vendor 0x1022 product 0x1100 (rev. 0x00)
pchb1 at pci0 dev 24 function 1
pchb1: vendor 0x1022 product 0x1101 (rev. 0x00)
pchb2 at pci0 dev 24 function 2
pchb2: vendor 0x1022 product 0x1102 (rev. 0x00)
amdtemp0 at pci0 dev 24 function 3
amdtemp0: AMD CPU Temperature Sensors (K8: core rev DH-G2)
isa0 at pcib0
com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
pckbc0 at isa0 port 0x60-0x64
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pms0 mux 0
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
uhub0 at usb0: vendor 0x10de OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 10 ports with 10 removable, self powered
uhub1 at usb1: vendor 0x10de EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
uhub1: 10 ports with 10 removable, self powered
viaide0 port 0: device present, speed: 3.0Gb/s
viaide2 port 0: device present, speed: 1.5Gb/s
wd0 at atabus0 drive 0: <GB0160EAFJE>
wd0: drive supports 16-sector PIO transfers, LBA48 addressing
wd0: 149 GB, 310101 cyl, 16 head, 63 sec, 512 bytes/sect x 312581808 sectors
wd0: 32-bit data port
wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100)
wd0(viaide0:0:0): using PIO mode 4, Ultra-DMA mode 5 (Ultra/100) (using DMA)
atapibus0 at atabus4: 2 targets
cd0 at atapibus0 drive 0: <HL-DT-STDVD-ROM GDRH20N, , D8E4> cdrom removable
cd0: 32-bit data port
cd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100)
cd0(viaide2:0:0): using PIO mode 4, Ultra-DMA mode 5 (Ultra/100) (using DMA)
Kernelized RAIDframe activated
pad0: outputs: 44100Hz, 16-bit, stereo
audio0 at pad0: half duplex
boot device: bge0
root on bge0
nfs_boot: trying DHCP/BOOTP
uhidev0 at uhub0 port 5 configuration 1 interface 0
uhidev0: ServerEngines SE USB Device, rev 1.10/0.01, addr 2, iclass 3/1
ukbd0 at uhidev0
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0
uhidev1 at uhub0 port 5 configuration 1 interface 1
uhidev1: ServerEngines SE USB Device, rev 1.10/0.01, addr 2, iclass 3/1
ums0 at uhidev1: 8 buttons and Z dir.
wsmouse1 at ums0 mux 0
uhub2 at uhub0 port 8: Chicony Generic USB Hub, class 9/0, rev 1.10/1.00, addr 3
uhub2: 3 ports with 2 removable, bus powered
nfs_boot: DHCP next-server: 192.168.33.2
nfs_boot: my_name=sicklemoon
nfs_boot: my_domain=s.vnop.net
nfs_boot: my_addr=192.168.33.25
nfs_boot: my_mask=255.255.255.0
nfs_boot: gateway=192.168.33.1
uhidev2 at uhub2 port 1 configuration 1 interface 0
uhidev2: Chicony PFU-65 USB Keyboard, rev 1.10/1.00, addr 4, iclass 3/1
ukbd1 at uhidev2
wskbd2 at ukbd1 mux 1
wskbd2: connecting to wsdisplay0
root on 192.168.33.2:/usr/work/nfsroot/i386
root file system type: nfs
wsdisplay0: screen 1 added (80x25, vt100 emulation)
wsdisplay0: screen 2 added (80x25, vt100 emulation)
wsdisplay0: screen 3 added (80x25, vt100 emulation)
wsdisplay0: screen 4 added (80x25, vt100 emulation)
pckbport: command timeout
pckbport: command timeout
pckbport: command timeout
pckbport: command timeout
pms_enable: command error 35
pckbport: command timeout
pckbport: command timeout
pms_disable: command error
pckbport: command timeout
pckbport: command timeout
pckbport: command timeout
pckbport: command timeout
pms_enable: command error 35
pckbport: command timeout
pms_disable: command error
pckbport: command timeout
pms_enable: command error 35
pckbport: command timeout
pms_disable: command error
pckbport: command timeout
pckbport: command timeout
pckbport: command timeout
pckbport: command timeout
pms_enable: command error 35
x86続き。
セグメントの領域を設定するデスクリプタを生成するプログラム。

#include <sys/types.h>
#include <stdio.h>
#include <string.h>

typedef int8_t bool;

// Access byte (Lower attribute filed) defines.
#define	PRESENT			0x80

// DPL
#define	DPL_MASK		0x60

// S (Descriptor Type) bit
#define	SEGMENT_SYSTEM		0x00
#define	SEGMENT_APPLICATION	0x10

// Code/Text Segment.
#define	APP_CODE		0x08
#define	APP_DATA		0x00
/*
  Data:
  E Lower extension. (Stack)
  W Writable
  A Access
  Code:
  C Conforming (omit privileged level check.)
  R Readable
  A Access
*/
#define	DATA_R			0x00
#define	DATA_RW			0x02
#define	DATA_R_STACK		0x04
#define	DATA_RW_STACK		0x06

// C ... Conforming. omit privileged level check
#define	CODE_X			0x00
#define	CODE_RX			0x02
#define	CODE_XC			0x04
#define	CODE_RXC		0x06

#define	CODE_SEGMENT	(PRESENT | SEGMENT_APPLICATION | APP_CODE | CODE_RX)
#define	DATA_SEGMENT	(PRESENT | SEGMENT_APPLICATION | APP_DATA | DATA_RW)
#define	STACK_SEGMENT	(PRESENT | SEGMENT_APPLICATION | APP_DATA | DATA_RW_STACK)

// Upper Attribute field.
// Granularity bit
#define	SIZE_UNIT_4KB		0x80
#define	SIZE_UNIT_1B		0x00
// Default bit. application descriptor only.
#define	CODE_32			0x40
#define	CODE_16			0x00

// Type filed for System Segment.
#define	SYS_LDT			0x02
#define	SYS_TASKGATE		0x05
#define	SYS_TSS_AVAILABLE	0x09
#define	SYS_TSS_BUSY		0x0b

#define	SYS_TRAPGATE		0x0f
#define	SYS_INTRGATE		0x0e
#define	SYS_CALLGATE		0x0c

struct application_descriptor // including system descriptor
{
  uint16_t size_0_15;
  uint16_t base_0_15;
  uint8_t base_16_23;
  uint8_t access_byte;
  uint8_t size_16_19_GD;
  uint8_t base_24_31;
} __attribute ((packed));

/*
  System descriptor type filed.
  2 ... LDT
  5 ... Task gate
  9 ... 386TSS available
  b ... 386TSS busy.
  c ... 386call gate
  e ... 386intr gate
  f ... 386trap gate
 */

struct gate_descriptor // call gate, interrupt gate, trap gate.
{
  uint16_t offset_0_15;
  uint16_t selector;
  uint8_t parameter_0_4;// dword count.
  uint8_t access_byte;
  /*
    System:
    P DPL 0 1 1 1 1 trap gate
    P DPL 0 1 1 1 0 interrupt gate
    P DPL 0 1 1 0 0 call gate
    Application:
    P DPL 1 0 . . . data/stack
    P DPL 1 1 . . . code
   */
  uint16_t offset_16_31;
} __attribute ((packed));

struct gdt_config
{
  uint32_t base;
  uint32_t size;
  uint8_t unit;
  uint8_t mode;
  uint8_t type;
} gdt_config [] = {
  { 0x0,	0x200,	SIZE_UNIT_4KB, CODE_32, CODE_SEGMENT },
  { 0x0,	0x200,	SIZE_UNIT_4KB, CODE_32, DATA_SEGMENT },
  { 0x200000,	0x1,	SIZE_UNIT_4KB, CODE_32, STACK_SEGMENT },
};

struct lgdt_arg
{
  uint16_t limit;
  uint32_t base;
} __attribute ((packed));

main ()
{
  union
  {
    struct application_descriptor desc;
    struct gate_descriptor gate;
    uint16_t u[4];
  } descriptor;
  struct gdt_config *conf = gdt_config;
  struct application_descriptor *d = &descriptor.desc;
  int32_t limit;
  int i, j;

  printf ("\t.arch i486\n");

  // GDT
  printf ("\t.section .data\n\t.balign 4\n");
  printf ("\t.global _gdt\n_gdt:\n");

  // Null Descriptor #0
  for (j = 0; j < 4; j++)
    printf ("\t.short 0x0000\n");

  // Application Descriptor. (code, data, stack)
  for (i = 0; i < sizeof gdt_config / sizeof (gdt_config[0]); i++, conf++)
    {
      memset (d, 0, sizeof *d);
      d->access_byte = conf->type;
      d->base_0_15 = conf->base & 0xffff;
      d->base_16_23 = (conf->base >> 16) & 0xff;
      d->base_24_31 = (conf->base >> 24) & 0xff;
      limit = conf->size;
      if (conf->type == STACK_SEGMENT)
	{
	  limit = -limit;
	}
      limit--;

      d->size_0_15 = limit & 0xffff;
      d->size_16_19_GD = ((limit >> 16) & 0xf) | conf->unit | conf->mode;
      for (j = 0; j < 4; j++)
	printf ("\t.short 0x%04x\n", descriptor.u[j]);
    }

  return 0;
}

これを
	lgdt	lgdt_arg
	movl	%cr0,	%eax
	orl	$0x1,	%eax
	movl	%eax,	%cr0
	ljmp	$0x8,	$flush	// Load CS(0x08) with pipeline flush.
flush:	.code32
	// Load DS(0x10),ES,FS,GS
	movw	$0x10,	%ax
	movw	%ax,	%ds
	movw	%ax,	%es
	movw	%ax,	%fs
	movw	%ax,	%gs
	// Load SS
	movw	$0x18,	%ax
	movw	%ax,	%ss

	call	c_main
infinite_loop:
	jmp	infinite_loop

で保護モードに移行。これでCでプログラムが書けるようになる。(A20はまだだけど)

LMSW, SMSW (load/store machine status word)命令は286との互換性のために
残してある。IA-32では使ってはいけない。MOV命令を使ってCR0にアクセスする
こと。

リアルモードのうちに

	movb	$0x00,	%ah
	movb	$0x13,	%al	// 320x240 8bit color VRAM 0xa0000 - 0xafa00
	int	$0x10

のBIOSコールでグラフィックモードにしておいて、

void
c_main ()
{
  uint8_t f[] = {
/* code 52 (R) */    0x7e,0x41,0x41,0x7e,0x44,0x42,0x41,0x00,
  };
  uint8_t (*p)[320] = (void *)0xa0000;
  int x, y;

  for (y = 0; y < 8; y++)
    {
      for (x = 0; x < 8; x++)
	{
	  p[y][x] = (f[y] & (1 << (7-x))) ? 7 : 6;
/* 0 black, 1 blue, 2 green, 3 cyan, 4 red, 5 magenta, 6 orange, 7 white, 8 grey, 9 skyblue */
	}
    }
}

qemu  -serial stdio -std-vga -hda boot1

これで画面に"R"(BGオレンジ、FG白)の文字が書かれる。
ここでついにブートセクタの510byteを使いきってしまった。これからはどこか らかロードしないといけない。歴史的に、パーティションはシリンダ境界から とることになっている。なので最初のシリンダは先頭のブートセクタ以降は使 われていない。ちょっと大きなブートローダーはこの領域を使っている。
今日日、設定としてのセクタ/トラックは大抵63なのであと31KB(512byte/ セク タ)はブートローダとしてに使えそうな場所。
わかってはいたことだけど、お膳立てが長い...。

コメント(6)

uchさん

ご無沙汰しております。ytakeuchです。
現在、PCIe基板上で動作するメディアプロセッサを作成しています。
uchさんの方で*BSD向けのドライバを書いていただくなんてお願いできますでしょうか?

以上、今後ともよろしくお願い申し上げます。

お久しぶりです。
NetBSDのなら書けるかもしれないです。最近いじってないのでちょっと不安ですが...

よろしくお願いします。
ただまだ私のところにはPCが無いんですよね。
HPのPC安いですね。

デルとHPの激安サーバはいいですよ。おすすめです。

メールが出せなかったので、こちらで失礼します。
PCがようやく到着しました。同時に2台(笑)
PCIeのドライバ開発用マシンにNetBSDをインストールしようとしているのですが、
バージョンは何が良いでしょうか?
4.0.1で問題ないですか?

4.0.1だとドライバが最近のマシンに追従してないかもしれません。-currentでいいと思います。
今なら落ちついてる感じ。