SlideShare a Scribd company logo
オープンソース開発と、
あるフレームバッファコンソールの話
~名古屋応用編~
えとみ なるあき
おやくそく
この資料は、
OSC名古屋 2015で青山さんが発表された
Using “C-bus” extension boards on LUNA-88K2 (at OSC 2015 Nagoya)
に対抗して作られました。
よって、事前に青山さんのスライドを一読しておくと、より楽しめる内容に
なっているよーな、なっていないよーな感じです…
(↓青山さんのスライドはこちら!)
http://www.slideshare.net/ao_kenji/osc2015-nagoya/
家にこんな本が有りまして
あっ
黒歴史に勝つにはどうすれば…
人が、安心して眠るためには!
なんか探すと…
Oxygen VX1がAlphaに刺さってました…
もっとなんか探すと…
ProFormance3が出てきました…
CPU黒歴史にはGPU黒歴史で対抗だ!
黒歴史とはいうものの…
PCI Macの世界では最速でしたhttp://clone.sevencolors.jp/mocw/enq/enq01.htm
OpenLDI
DVIに負けた規格?
OpenLDI
genfbで使えない…
ファームウェアの時点で画面が崩れてしまう…
が、MacOSだと問題無し!
NetBSD Advent Calendar 2014
話は変わって…
記事書いてみました
Permedia2なグラフィックカードを買ってみたら、
pm2fbではなくgenfbしかアタッチしなかったので、
色々調べて、パッチ書いて、投げて、議論して、取り込まれたというお話です。
ドライバを書く事に味を占める
仕様の公開されている
貴重なAlphaで動くPCIグラフィックカード
http://moon.hanya-n.org/comp/alpha/hct/graphics.html
AlphaのX?
/src/share/mk/bsd.own.mk
#
# Do we default to XFree86 or Xorg for this platform?
#
.if 
${MACHINE} == "acorn32" || 
${MACHINE} == "alpha" || 
${MACHINE} == "amiga" || 
${MACHINE} == "mac68k" || 
${MACHINE} == "pmax" || 
${MACHINE} == "sun3"
X11FLAVOUR?= XFree86
.else
X11FLAVOUR?= Xorg
.endif
NetBSD/luna68Kですら、Xorgなのに...
NetBSD/AlphaはXFree86…
AlphaのX?
# startx
auth: creating new authority file /root/.Xauthority
xauth: (argv):1: bad display name ":0" in "list" command
xauth: creating new authority file /root/.Xauthority
xauth: (stdin):1: bad display name ":0" in "add" command
xauth: creating new authority file /root/.Xauthority
xauth: (argv):1: bad display name ":0" in "list" command
xauth: creating new authority file /root/.Xauthority
xauth: (stdin):1: bad display name ":0" in "add" command
unable to get frame buffer info: Inappropriate ioctl for device
Fatal server error:
no screens found
X connection to :0.0 broken (explicit kill or server shutdown).
xauth: creating new authority file /root/.Xauthority
xauth: (argv):1: bad display name ":0" in "remove" command
xauth: (argv):1: bad display name ":0" in "remove" command
# ls -l X
lrwxr-xr-x 1 root wheel 25 May 16 2015 X -> /usr/X11R6/bin/XdecNetBSD
AlphaのX?
♪♪時の流れが止まって
ドライバ書いた!
アピールポイント
特になし!
強いてあげるならば…
何故表示が崩れるのか?
何故表示が崩れるのか?
おおしまさんのありがたいアドバイス!
J2000とは?
Appian Graphics
一枚でマルチモニタが実現できる
グラフィックカードの製造メーカー
J2000にはPermedia3が2個搭載されている!
Appian Graphics
/*
* Copyright 2000-2001 by Sven Luther <luther (at) dpt-info.u-strasbg.fr>.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Sven Luther not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Sven Luther makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* SVEN LUTHER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL SVEN LUTHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Sven Luther, <luther (at) dpt-info.u-strasbg.fr>
* Alan Hourihane, <alanh (at) fairlite.demon.co.uk>
*
* this work is sponsored by Appian Graphics.
*
* Permedia 3 accelerated options.
*/
/xfree/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c
XのPermedia3ドライバのスポンサー!
何故表示が崩れるのか?
J2000はPermedia3が2個搭載されているから
BIOSによってカードが初期化されないよ
何故表示が崩れるのか?
/*
* Some Power Mac G4 model could not initialize these registers,
* Power Mac G4 (Mirrored Drive Doors), for example
*/
#if defined(__powerpc__)
bus_space_write_4(sc->sc_memt, sc->sc_regh, PM3_LOCALMEMCAPS,
0x02e311B8);
bus_space_write_4(sc->sc_memt, sc->sc_regh, PM3_LOCALMEMTIMINGS,
0x07424905);
bus_space_write_4(sc->sc_memt, sc->sc_regh, PM3_LOCALMEMCONTROL,
0x0c000003);
#endif
My Power Mac G4 Mirrored Drive Doors could not initialize these registers.
(Display gets corrupted.)
レジスタを規定値で初期化したらうまくいきました!
64MBの罠
/*
* Permedia 3 always return 64MB fbsize
* 16 MB should be enough -- more just wastes map entries
*/
if (sc->sc_fbsize != 0)
sc->sc_fbsize = (16 << 20);
Permedia 3 always return 64MB frame buffer size.
The minimum frame buffer size is 16MB in Permedia 3 product lines.
I don't write frame buffer size check routine.
I think that's enough.
グラフィックメモリの容量を聞くと、
実際は16MBだったり、32MBだったりしても、
常に64MBと返してくる…
そこで製品ラインナップ最低の16MBを設定してみる
64MBの罠
Xではグラフィックメモリを読み書きして、
実際の容量を割り出しています、が、
8bppのフレームバッファコンソールで
こんな複雑な処���が必要か?と思いました
↓
製品ラインの最低限の16MB設定しとこ!
↓
pm3fb0: 16 MB aperture at 0x84000000
↓
16MBの表示いらないんじゃ←イマココ
(処理を書くのがメンドクサかった訳ではない)
xfree86/drivers/glint/pm3_dac.c
static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p,
int c, int yy, int xx)
PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */
(1 << 18) | /* BE */
1 | (asx << 1) | (asy << 4) | /* address select x/y */
(1 << 20)); /* OpaqueSpan */
if (fontwidth(p) <= 8) {
cdat = p->fontdata + (c & p->charmask) * fontheight(p);
} else {
cdat =
p->fontdata +
((c & p->charmask) * (fontheight(p) << 1));
}
PM3_WAIT(2 + fontheight(p));
for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */
if (fontwidth(p) <= 8) {
ldat = *cdat++;
} else { /* assume fontwidth <= 16 ATM */
ldat = ((*cdat++) << 8);
ldat |= *cdat++;
}
PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat);
}
フォント?
linux/drivers/video/pm3fb.c
Linuxでは
AreaStippleModeで描画
フォント?
static void
pm3fb_putchar(void *cookie, int row, int col, u_int c, long attr)
bus_space_write_4(sc->sc_memt, sc->sc_regh, PM3_RASTERIZER_MODE, mode);
…
bus_space_write_4(sc->sc_memt, sc->sc_regh,
PM3_SCISSORMINXY, ((y & 0x0fff) << 16) | (x & 0x0fff));
bus_space_write_4(sc->sc_memt, sc->sc_regh,
PM3_SCISSORMAXXY, (((y + he) & 0x0fff) << 16) | ((x + wi) & 0x0fff));
bus_space_write_4(sc->sc_memt, sc->sc_regh,
PM3_RECTANGLEPOSITION, (((y) & 0xffff)<<16) | ((x) & 0xffff));
…
pm3fb_wait(sc, he);
switch (ri->ri_font->stride) {
case 1: {
uint8_t *data8 = data;
uint32_t reg;
for (i = 0; i < he; i++) {
reg = *data8;
bus_space_write_4(sc->sc_memt,
sc->sc_regh,
PM3_BITMASKPATTERN, reg);
data8++;
}
break;
}
NetBSDでは
RASTERIZER_MODEで描画
フォントの描画が違うのだよ!
著作権?
著作権?
↑スポンサーが削られてる…
著作権?
書き直し
ソースの書き方?
NetBSD的なソースの書き方とは!?
The NetBSD source code style guide.
/src/share/misc/style
OpenBSDにもあるそうです!
(青山さん談)
manの書き方
.Dd January 1, 2015
.Dt PM3FB 4
.Os
.Sh NAME
.Nm pm3fb
.Nd 3Dlabs Permedia 3 / Oxygen VX1 / Proformance 3 framebuffer driver
.Sh SYNOPSIS
.Cd "pm3fb* at pci?"
.Cd "wsdisplay* at pm3fb?"
.Sh DESCRIPTION
The
.Nm
driver provides support for the 3Dlabs Permedia 3 / Oxygen VX1 / Proformance 3 series of
graphics cards and provides an interface for machine independent
.Xr wscons 4
driver.
.Pp
Currently
コピって作っていたが直感的でない…
ちょっと書いてbuild.sh -releaseで確認
効率が悪い
manの書き方
mandoc…だと…
manの書き方
PM3FB(4) Kernel Interfaces Manual PM3FB(4)
NAME
pm3fb -- 3Dlabs Permedia 3 / Oxygen VX1 / Proformance 3 framebuffer
driver
SYNOPSIS
pm3fb* at pci?
wsdisplay* at pm3fb?
DESCRIPTION
The pm3fb driver provides support for the 3Dlabs Permedia 3 / Oxygen VX1
/ Proformance 3 series of graphics cards and provides an interface for
machine independent wscons(4) driver.
Currently pm3fb does not support Anti-alias font rendering and OpenLDI
video interface. However, it is capable of changing the resolution and
uses DDC2 to pick an appropriate video mode.
A 2D graphics engine is used to accelerate scrolling, rectangle fills and
Bitmap font rendering.
SEE ALSO
pci(4), wscons(4), wsdisplay(4)
正月SEND-PR
正月SEND-PR
正月SEND-PR
正月SEND-PR
正月SEND-PR
x11
NetBSD 7で移行?
おっ?
何か動きが??
まとめ
pm2fbをまねて、デバイスに依存する所(Permedia 3依存の所)を書き換えるだけで、
ゆるふわにドライバを書く事が出来ました。(カーネル50回くらいしかコンパイルしてない)
/src/sys/dev/pci/files.pciに追記する所からはじめて、manを書くまで一通りやった事で
楽しく遊ぶ事が出来ましたし、やり遂げた感が得られました。
若い頃の憧れのデバイスに対するドライバを書くのは、なんというか大変良いです。
みなさんも、怪しげなデバイスをさがしてドライバを書きましょう。
あと、NetBSD 7楽しみですね!

More Related Content

オープンソース開発と、 あるフレームバッファコンソールの話 ~名古屋応用編~