`
xiaoqiang6775
  • 浏览: 31535 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

OpenBSD内核编译

 
阅读更多

OpenBSD内核配置
http://www.loveunix.net/thread-43893-1-1.html 
默认安装情况下,OpenBSD是不安装源代码书和内核源代码的。你可以在安装完
成之后手工安装。

如果你的安装CDROM上有的话,那么可以直接拷贝sys.tar.gz;如果没有的话,可
以进入系统,然后连接Internet下载和安装官方网站上的当前版本源代码:

[omni^3]# ftp ftp://ftp.openbsd.org/pub/OpenBSD/`uname -r`/sys.tar.gz
[omni^3]# tar -C /usr/src -xzvf sys.tar.gz

OpenBSD的源代码树安装在/usr/src下,而内核源代码则是其中一个子目录
/usr/src/sys,同时他还有一个符号链接到 /sys 。后面的操作也都可以直接以/sys
为绝对目录路径。

OpenBSD的内核配置方法同样继承了BSD系列的传统方法:先修改适合你系统的
平文配置文件,然后通过config命令产生配置目录,最后编译内核。这里先写出
主要的命令步骤,之后再详细解释相关的配置文件和选项。

1. 修改通用配置文件
[omni^3]# cd /sys/conf
[omni^3]# cp GENERIC Genii
[omni^3]# vi Genii

(:编译内核是一件稍具挑战性的工作,对新手来说更是如此;而BSD内核一向采用
比较传统的手工配置方法,需要对内核本身各模块之间的结构有一定了解,出错
在所难免因此先做好各配置文件的备份,最好重新cp一个副本,作为自己的内核
配置文件基础修改。)

2. 修改平台配置文件
[omni^3]# cd /sys/arch/i386/conf
[omni^3]# cp GENERIC Genii
[omni^3]# vi Genii

(:OpenBSD与FreeBSD很大的差别就是OpenBSD支持多平台,同时更原始--接近
古典型BSD,所以它的配置文件也分为多个不同的部分)

3. 如果是SMP平台的话,修改MP配置文件
[omni^3]# vi /sys/arch/i386/conf/GENERIC.MP

(如果需要多处理器mp支持,还需要看一下这个)

4. config产生内核配置
[omni^3]# config Genii

(命令过程中可能会产生错误提示,这可能是因为你的模块关系没有理顺,遗漏
了某些模块,或误删模块所致,仔细检查内核配置)

5. 编译内核
[omni^3]# cd /sys/arch/i386/compile/Genii
[omni^3]# make clean
[omni^3]# make depend
[omni^3]# make

(如果一切没出错,那么最后你可以看见LD生成内核映像的提示,会显示出当前
内核可执行文件各部分的的size以及内核的文件大小。)

6. 安装内核
[omni^3]# cp /bsd /bsd.old
[omni^3]# cp ./bsd /bsd

(OpenBSD和NetBSD相对FreeBSD来说更原始,从管理和配置你都需要手工作更多
的工作,比如编译完成后需要你手工cp安装内核;另外,此处一定要记得备份默认
安装完成后你的通用内核哦。)

7. 引导和测试新内核
[omni^3]# reboot

如果一切正常,那么重新引导之后你就会用你的新内核了。也有可能因为各种因素
无法引导,或者发现丢失了一些驱动导致系统设备无法认出,那么这时候可能就只
能通过你的通用内核或原来稳定版本的内核重新引导系统,然后仔细检查dmesg信
息来重新配置你的内核了。

因为OpenBSD比FreeBSD支持更多的硬件平台,所以它的内核配置文件也不得不
分割为两个部分: 
通用配置部分(/sys/conf/GENERIC) 和 平台相关配置(/sys/arch/i386/conf/GENERIC)

此外,当支持SMP时,还有一个很小的配置部分/sys/arch/i386/conf/GENERIC.MP。
(老版本的配置略有不同,此处均以3.6版本为准)

所以现在根据我们的需求,裁减和定制一个适合自己硬件的内核至少要修改两个配置
文件。

先来看一下系统源代码树中默认的 通用配置 /sys/conf/GENERIC :
#####################################################################
# $OpenBSD: GENERIC,v 1.109 2004/07/31 21:27:31 brad Exp $
#
# Machine-independent option; used by all architectures for their
# GENERIC kernel

#--4.4 BSD内核安全选项,默认情况下为SECURE,boot时系统securelevel为0,
#--boot完成后自动提升为1;
#--如果取消注释启用此选项,则默认securelevel为-1
#--

#option INSECURE # default to secure

#--
#--内核全局特性,用于内核调试、性能分析和进程跟踪
#--非开发系统建议开启KTRACE和ACCOUNTING两项,其它全部关闭
#--

#option DDB # 启用内置内核调试器
#option DDB_SAFE_CONSOLE # 允许在引导过程中切入内核调试器
#makeoptions DEBUG="-g" # 编译内置内核符号表,允许内核调试
#makeoptions PROF="-pg" # 编译profiled kernel,允许性能调试
#option GPROF # kernel profiling, kgmon(8),内核性能监视器
#option DIAGNOSTIC # internal consistency checks
option KTRACE # 启用ktrace(1),可以使用ktrace跟踪用户进程的系统调用等信息
option ACCOUNTING # 启用acct(2),允许使用4.3BSD进程记帐
option KMEMSTATS # collect malloc(9) statistics
#option PTRACE # ptrace(2) ,允许ptrace跟踪和调试用户进程


#--内置加密模块
option CRYPTO # Cryptographic framework

#--
#--SYSV进程间通讯
#--
option SYSVMSG # System V-like message queues
option SYSVSEM # System V-like semaphores
option SYSVSHM # System V-like memory sharing

#--允许UVM内存管理系统加密SWAP页面
option UVM_SWAP_ENCRYPT# support encryption of pages going to swap

#--内核兼容特性,必须打开COMPAT_43
#option COMPAT_23 # Kernel compatibility with OpenBSD 2.3,
#option COMPAT_25 # 2.5,
option COMPAT_35 # 3.5,
option COMPAT_43 # and 4.3BSD
#option TCP_COMPAT_42 # TCP bug compatibility with 4.2BSD

#--允许可加载内核模块
#--在静态的生产服务器上,如果能够熟悉和精确编译所有驱动,处于安全原因
#--建议禁用LKM
option LKM # loadable kernel modules

#--文件系统支持
option FFS # UFS文件系统支持,必选项
option FFS_SOFTUPDATES # Soft updates支持,可提升文件系统性能
option UFS_DIRHASH # DIRHUSH支持,增加多文件查找性能
option QUOTA # UFS quotas
option EXT2FS # Second Extended Filesystem
option MFS # memory file system
option XFS # xfs filesystem

option CD9660 # ISO 9660 + Rock Ridge file system
option MSDOSFS # MS-DOS file system
option FDESC # /dev/fd
option FIFO # FIFOs; RECOMMENDED
option KERNFS # /kern
option PORTAL # dynamically created filesystem objects
option PROCFS # /proc

# layer filesystems
option NULLFS # loopback file system
option UMAPFS # NULLFS + uid and gid remapping
option UNION # union file system

#--TCP选项支持
option TCP_SACK # Selective Acknowledgements for TCP
option TCP_ECN # Explicit Congestion Notification for TCP
option TCP_SIGNATURE # TCP MD5 Signatures, for BGP routing sessions
#option TCP_FACK # Forward Acknowledgements for TCP

#--NFS支持
#option NFSCLIENT # 内核NFS客户端,作为无盘启动工作站时需要
#option NFSSERVER # NFS服务器

#--基本网络协议支持
option INET # IP + ICMP + TCP + UDP,必选
option ALTQ # ALTQ base,提供队列功能
#option INET6 # IPv6 支持
option IPSEC # IPsec 支持
#option KEY # PF_KEY (implied by IPSEC)
#option NS # XNS
#option NSIP # XNS tunneling over IP
#option IPX # IPX+SPX
#option IPXIP # IPX tunneling over IP
#option NETATALK # AppleTalk
#option CCITT,LLC,HDLC # X.25
option PPP_BSDCOMP # PPP BSD compression
option PPP_DEFLATE
#option MROUTING # Multicast router

#--伪设备
pseudo-device pf # pf防火墙设备
pseudo-device pflog # pf log设备
pseudo-device pfsync # pf sync if
#pseudo-device sppp 1 # Sync PPP/HDLC
pseudo-device enc 1 # option IPSEC needs the encapsulation interface
#pseudo-device strip 1 # Starmode Radio IP interface

pseudo-device pty 64 # 默认伪终端设备
#pseudo-device tb 1 # tablet line discipline
pseudo-device vnd 4 # vnd虚拟磁盘设备
pseudo-device ccd 4 # ccd设备,RAID必须
#pseudo-device ksyms 1 # 内核符号表
pseudo-device systrace 1 # systrace安全特性,允许对系统调用进行访问控制

#-- clonable devices
pseudo-device bpfilter # packet filter
pseudo-device bridge # network bridging support
#pseudo-device carp # CARP protocol support
#pseudo-device gif # IPv[46] over IPv[46] tunnel (RFC1933)
#pseudo-device gre # GRE encapsulation interface
pseudo-device loop # network loopback
pseudo-device ppp # PPP
#pseudo-device sl # CSLIP
pseudo-device tun # network tunneling over tty
pseudo-device vlan # IEEE 802.1Q VLAN 

#-- for IPv6
#pseudo-device faith 1 # IPv[46] tcp relay translation i/f

option BOOT_CONFIG # add support for boot -c
#####################################################################

在这里主要的段节和常用配置选项都已经加上了注解,而#注释掉的那些行则是
一般情况下较少会遇到的。

平台相关配置 /sys/arch/i386/conf/GENERIC :
#####################################################################
# $OpenBSD: GENERIC,v 1.376 2004/07/20 20:30:09 dhartmei Exp $
#
# GENERIC -- everything that's currently supported
#

machine i386 # 系统硬件体系,必选

include "../../../conf/Genii" #包含全局特性配置文件

#option I386_CPU # CPU classes; at least one is REQUIRED
option I686_CPU # 系统对应的CPU体系
#option GPL_MATH_EMULATE # 模拟数学协处理器

option USER_PCICONF # 用户PCI配置

#option VM86 # Virtual 8086 emulation
option USER_LDT # user-settable LDT; see i386_set_ldt(2)
option APERTURE # XFree86支持

#option KGDB # 内核GDB调试器,不兼容KDB,允许串口调试
#option "KGDB_DEVNAME=\"pccom\"",KGDBADDR=0x2f8,KGDBRATE=9600

option DUMMY_NOPS # speed hack; recommended

#--二进制可执行文件兼容特性
#--允许执行其他操作系统的可执行文件
#--在I386平台上分别支持Sco Unixware(SVR4), IBCS2(OpenServer), Linux, *BSD

#option COMPAT_SVR4 # binary compatibility with SVR4
#option COMPAT_IBCS2 # binary compatibility with SCO and ISC
option COMPAT_LINUX # binary compatibility with Linux
option COMPAT_FREEBSD # binary compatibility with FreeBSD
#option COMPAT_BSDOS # binary compatibility with BSD/OS
option COMPAT_AOUT # a.out binaries are emulated

#option NTFS # Experimental NTFS support

#-- maxusers参数,影响到进程表等一系列内核参数
maxusers 128 # estimated number of users

#-- 内核和引导设备配置,不用修改
config bsd swap generic

#-- 系统总线,必选
mainbus0 at root

#-- cpu, bios, 电源管理,PCI总线
cpu0 at mainbus? apid ?
bios0 at mainbus0 apid ?
apm0 at bios0 flags 0x0000 # flags 0x0101 to force protocol version 1.1
pcibios0 at bios0 flags 0x0000 # use 0x30 for a total verbose

#-- isa和pci总线
isa0 at mainbus0 # isa总线
isa0 at pcib?
isa0 at ichpcib? # Intel ICH芯片组
#isa0 at gscpcib? # NS Gende芯片组
eisa0 at mainbus0 # eisa总线
pci* at mainbus0 bus ? # pci总线

#-- 引导时显示设备冗余信息
option PCIVERBOSE
option EISAVERBOSE
option USBVERBOSE

#-- PCI设备
pchb* at pci? dev ? function ? # PCI-Host bridges
ppb* at pci? dev ? function ? # PCI-PCI bridges
pci* at ppb? bus ?
pci* at pchb? bus ?
pcib* at pci? dev ? function ? # PCI-ISA bridge
ichpcib* at pci? dev ? function ? # Intel ICHx/ICHx-M LPC bridges
#gscpcib* at pci? dev ? function ? # NS Geode SC1100 PCI-ISA bridge
#gpio* at gscpcib? # 禁用其他无用的主板类型支持

# 特殊硬件的电源管理设备
#amdpm* at pci? dev ? function ? # AMD768MPX
#elansc* at pci? dev ? function ? # AMD Elan SC520 System Controller
#gpio* at elansc?
#geodesc* at pci? dev ? function ? # Geode SC1100/SCx200 IAOC

# National Semiconductor LM7[89] 兼容设备
#lm0 at isa? port 0x290
#lm1 at isa? port 0x280
#lm2 at isa? port 0x310
#nsclpcsio* at isa? # NS PC87366 LPC Super I/O
#gpio* at nsclpcsio?
#gscsio* at isa? # NS Geode SC1100 Super I/O
#iic0 at gscsio? # ACCESS.bus 1
#iic1 at gscsio? # ACCESS.bus 2
#lmtemp0 at iic1 addr 0x48 # NS LM75/LM77 temperature sensor

#it0 at isa? port 0x290 # IT8705F, IT8712F and SiS970 hardware
# monitors
#viaenv* at pci? dev ? function ? # VIA VT82C686A hardware monitor

#-- PCMCIA类型设备支持,笔记本电脑和一些特殊的PCMCIA设备可能需要
#-- ISA PCMCIA 设备
#option PCMCIAVERBOSE
#pcic0 at isa? port 0x3e0 iomem 0xd0000 iosiz 0x10000
#pcic1 at isa? port 0x3e2 iomem 0xe0000 iosiz 0x4000
#pcic2 at isa? port 0x3e4 iomem 0xe0000 iosiz 0x4000
#tcic0 at isa? disable port 0x240 iomem 0xd0000 iosiz 0x10000

#-- ISA Plug-and-Play PCMCIA controllers
#option DEBUG_ISAPNP
#pcic* at isapnp?

#-- PCI PCMCIA 设备
#pcic* at pci? dev? function ?

#-- PCMCIA 总线支持
#pcmcia* at pcic? controller ? socket ?
#pcmcia* at tcic? controller ? socket ?

#-- CardBus 总线支持
#cardbus* at cardslot?
#pcmcia* at cardslot?
#cbb* at pci? dev ? function ?
#cardslot* at cbb?

# PCI USB 控制器
ehci* at pci? # Enhanced Host Controller 
uhci* at pci? # Universal Host Controller (Intel芯片组)
ohci* at pci? # Open Host Controller (Apple,VIA等其他芯片组)

# USB bus support
usb* at ehci?
usb* at uhci?
usb* at ohci?

# USB devices
uhub* at usb? # USB Hubs
uhub* at uhub? port ? configuration ? # USB Hubs

#-- 这一项是要的,U盘和移动硬盘的支持
umass* at uhub? port ? configuration ? # USB Mass Storage devices
scsibus* at umass? # USB存储设备需要模拟SCSI总线
# 因此使用这一项同时需要打开SCSI、
# SCSI磁盘和SCSI-IDE桥的支持

#-- USB 鼠标、键盘的支持;这一项需要wscons设备支持
uhidev* at uhub? port ? configuration ? interface ? # Human Interface Devices
ums* at uhidev? reportid ? # USB mouse
wsmouse* at ums? mux 0
ukbd* at uhidev? reportid ? # USB keyboard
wskbd* at ukbd? console ? mux 1
uhid* at uhidev? reportid ? # USB generic HID support

#-- 其他基本无用的USB设备
#umodem* at uhub? port ? configuration ? # USB Modems/Serial
#ucom* at umodem?
#uvisor* at uhub? port ? configuration ? # Handspring Visor
#ucom* at uvisor?
#uvscom* at uhub? port ? # SUNTAC Slipper U VS-10U serial
#ucom* at uvscom? portno ?
#ubsa* at uhub? port ? # Belkin serial adapter
#ucom* at ubsa? portno ?
#uftdi* at uhub? port ? # FTDI FT8U100AX serial adapter
#ucom* at uftdi? portno ?
#uplcom* at uhub? port ? # I/O DATA USB-RSAQ2 serial adapter
#ucom* at uplcom? portno ?
#umct* at uhub? port ? # MCT USB-RS232 serial adapter
#ucom* at umct? portno ?
#uaudio* at uhub? port ? configuration ? # USB Audio
#audio* at uaudio?
#umidi* at uhub? port ? configuration ? # USB MIDI
#midi* at umidi?
#ulpt* at uhub? port ? configuration ? # USB Printers


#-- USB网卡和无线网卡支持
#aue* at uhub? port ? # ADMtek AN986 Pegasus Ethernet
#axe* at uhub? port ? # ASIX Electronics AX88172 USB Ethernet
#cue* at uhub? port ? # CATC USB-EL1201A based Ethernet
#kue* at uhub? port ? # Kawasaki KL5KUSB101B based Ethernet
#cdce* at uhub? port ? # CDC Ethernet
#upl* at uhub? port ? # Prolific PL2301/PL2302 host-to-host `network'
#url* at uhub? port ? # Realtek RTL8150L based adapters
#wi* at uhub? port ? # WaveLAN IEEE 802.11DS
#urio* at uhub? port ? # Diamond Multimedia Rio 500
#uscanner* at uhub? port ? # USB Scanners
#usscanner* at uhub? port ? # USB SCSI scanners, e.g., HP5300
#scsibus* at usscanner?
#uyap* at uhub? port ? # Y@P firmware loader
#udsbr* at uhub? port ? # D-Link DSB-R100 radio
#radio* at udsbr? # USB radio
ugen* at uhub? port ? configuration ? # USB 通用设备

#-- FireWire 1394设备支持
#fwohci* at pci? dev ? function ? # PCI FireWire adapter
#fwohci* at cardbus? dev ? function ? # CardBus FireWire adapter

#fwnode* at fwbus? idhi ? idlo ?

#fwscsi* at fwnode? # SCSI over FireWire
#scsibus* at fwscsi?

#option FWOHCI_DEBUG
#option FWNODE_DEBUG
#option P1212_DEBUG
#option SBP2_DEBUG
#option FWSCSI_DEBUG

puc* at pci? # PCI "universal" communication device

#-- 数学协处理器,必选 (486DX以下系统此选项无效,需要打开GPL_MATH_EMULATE选项)
npx0 at isa? port 0xf0 irq 13 # math coprocessor
isadma0 at isa?
isapnp0 at isa?

#-- 控制台和虚拟终端设备
option WSDISPLAY_COMPAT_USL # VT handling
option WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes
option WSDISPLAY_DEFAULTSCREENS=6
option WSDISPLAY_COMPAT_PCVT # emulate some ioctls

#-- 键盘、鼠标和显示器
pckbc0 at isa? # PC keyboard controller
pckbd* at pckbc? # PC keyboard
pms* at pckbc? # PS/2 mouse for wsmouse
pmsi* at pckbc? # PS/2 "Intelli"mouse for wsmouse
vga0 at isa?
option PCIAGP # AGP设备支持
vga* at pci? dev ? function ?
pcdisplay0 at isa? # CGA, MDA, EGA, HGA
wsdisplay* at vga? console ?
wsdisplay* at pcdisplay? console ?
wskbd* at pckbd? console ?
wsmouse* at pms? mux 0
wsmouse* at pmsi? mux 0

#-- 系统扬声器设备
pcppi0 at isa?
sysbeep0 at pcppi?

#-- 串口
pccom0 at isa? port 0x3f8 irq 4 # standard PC serial ports
pccom1 at isa? port 0x2f8 irq 3
pccom2 at isa? port 0x3e8 irq 5
#pccom3 at isa? port 0x2e8 irq 9 # (conflicts with some video cards)
#ast0 at isa? port 0x1a0 irq 5 # AST 4-port serial card
#ast1 at isa? port 0x2a0 irq 6 # 2nd AST 4-port serial card
#pccom* at ast? slave ?
#boca0 at isa? port 0x100 irq 5 # BOCA 8-port serial cards
#pccom* at boca? slave ?
#addcom0 at isa? port 0x108 irq 5 # Addonics FlexPort
#pccom* at addcom? slave ?
#rtfps0 at isa? port 0x1230 irq 10 # RT 4-port serial cards
#pccom* at rtfps? slave ?
#hsq0 at isa? port 0x140 irq 10 # Hostess 4-port serial card
#pccom* at hsq? slave ?
#pccom* at pcmcia? function ? # PCMCIA modems/serial ports
#pccom* at isapnp?
#pccom* at puc? port ?

# option for using CD1400 handshaking for incoming data
# requires a special cable that exchanges the RTS and DTR lines
# options CY_HW_RTS
#cy0 at isa? iomem 0xd4000 irq 12 # ISA cyclom serial card
#cy* at pci? # PCI cyclom serial card
#cz* at pci? dev ? function ? # Cyclades-Z multi-port serial boards

#-- 并口
lpt0 at isa? port 0x378 irq 7 # standard PC parallel ports
#lpt1 at isa? port 0x278
#lpt2 at isa? port 0x3bc
#lpt* at puc? port ?

#-- 非标准协议的鼠标支持,LogitechBus和MicroSoft
#lms0 at isa? port 0x23c irq 5 # Logitech bus mouse
#lms1 at isa? port 0x238 irq 5
#mms0 at isa? port 0x23c irq 5 # Microsoft InPort mouse
#mms1 at isa? port 0x238 irq 5

#wsmouse* at lms? mux 0
#wsmouse* at mms? mux 0

#-- Buslogic SCSI适配器,Vmware需要
bha0 at isa? port 0x330 irq ? drq ? # BusLogic [57]4X SCSI controllers
bha1 at isa? disable port 0x334 irq ? drq ? # BusLogic [57]4X SCSI controllers
bha2 at isa? disable port ? irq ?
bha* at pci? dev ? function ?
#bha* at eisa? slot ? # XXX eisa still runs in isa-compat
scsibus* at bha?

#-- 其他SCSI和RAID卡的支持
#aha0 at isa? port 0x330 irq ? drq ? # Adaptec 154[02] SCSI controllers
#aha1 at isa? port 0x334 irq ? drq ? # Adaptec 154[02] SCSI controllers
#aha* at isapnp?
#scsibus* at aha?
#ahb* at eisa? slot ? # Adaptec 174[024] SCSI controllers
#scsibus* at ahb?
#ahc0 at isa? port ? irq ? # Adaptec 284x SCSI controllers
#ahc* at eisa? slot ? # Adaptec 274x, aic7770 SCSI controllers
#ahc* at pci? dev ? function ? # Adaptec 2940/3940/78?? SCSI controllers
#scsibus* at ahc?
#ahd* at pci? dev ? function ? # Adaptec 79?? SCSI controllers
#scsibus* at ahd?

#-- LSI SCSI适配器,Vmware需要
mpt* at pci? dev ? function ? # LSI Fusion-MPT SCSI/Fibre
scsibus* at mpt?

#-- 其他SCSI和RAID卡的支持
#dpt* at pci? dev ? function ? # DPT SmartCache/SmartRAID PCI
#dpt* at eisa? slot ? # DPT SmartCache/SmartRAID EISA
#scsibus* at dpt?
#gdt* at pci? dev ? function ? # ICP Vortex GDT RAID controllers
#scsibus* at gdt?
#twe* at pci? dev ? function ? # 3ware Escalade RAID controllers
#scsibus* at twe?
#aac* at pci? dev ? function ? # Adaptec FSA RAID controllers
#scsibus* at aac?
#ami* at pci? dev ? function ? # AMI MegaRAID controllers
#scsibus* at ami?
#cac* at pci? dev ? function ? # Compaq Smart ARRAY RAID controllers
#cac* at eisa? slot ?
#scsibus* at cac?
#iha* at pci? dev ? function ? # Initio Ultra/UltraWide SCSI controllers
#scsibus* at iha?
#isp* at pci? dev ? function ? # Qlogic ISP [12]0x0 SCSI/FibreChannel
#scsibus* at isp?
#aic0 at isa? port 0x340 irq 11 # Adaptec 152[02] SCSI controllers
#aic* at pcmcia? function ? # PCMCIA based aic SCSI controllers
#aic* at isapnp? # isapnp configured aic SCSI controllers
#scsibus* at aic?
#esp* at pcmcia? function ? # PCMCIA based NCR 53C9X SCSI
#scsibus* at esp?
#ncr* at pci? dev ? function ? # NCR 538XX SCSI controllers(old)
#scsibus* at ncr?
#siop* at pci? dev ? function ? # NCR 538XX SCSI controllers(new)
#scsibus* at siop?
#adv* at pci? dev ? function ? # AdvanSys 1200A/B and ULTRA SCSI
#scsibus* at adv?
#adw* at pci? dev ? function ? # AdvanSys ULTRA WIDE SCSI
#scsibus* at adw?
#pcscp* at pci? dev ? function ? # AMD 53c974 PCscsi-PCI SCSI
#scsibus* at pcscp?
#sea0 at isa? disable iomem 0xc8000 irq 5 # Seagate ST0[12] SCSI controllers
#scsibus* at sea?
#trm* at pci? dev ? function ? # Tekram DC-3x5U SCSI Controllers
#scsibus* at trm?
#uha0 at isa? port 0x330 irq ? drq ? # UltraStor [13]4f SCSI controllers
#uha1 at isa? disable port 0x334 irq ? drq ? # UltraStor [13]4f SCSI controllers
#uha* at eisa? slot ? # UltraStor 24f SCSI controllers
#scsibus* at uha?
#wds0 at isa? disable port 0x350 irq 15 drq 6 # WD7000 and TMC-7000 controllers
##wds1 at isa? port 0x358 irq 11 drq 5
#scsibus* at wds?

#-- SCSI设备支持
sd* at scsibus? target ? lun ? # SCSI disk drives,SCSI硬盘
#st* at scsibus? target ? lun ? # SCSI tape drives,SCSI磁带机
cd* at scsibus? target ? lun ? # SCSI CD-ROM drives,SCSI CDROM
#ch* at scsibus? target ? lun ? # SCSI autochangers,SCSI光盘塔?
#ss* at scsibus? target ? lun ? # SCSI scanners,SCSI扫描仪
uk* at scsibus? target ? lun ? # unknown SCSI,未知SCSI设备

#-- 软盘驱动器
fdc0 at isa? port 0x3f0 irq 6 drq 2 # standard PC floppy controllers
#fdc1 at isa? port 0x370 irq ? drq ?
fd* at fdc? drive ? flags 0x00

#-- 老式Mitsumi CDROM驱动
#mcd0 at isa? port 0x300 irq 10 # Mitsumi CD-ROM drives

#-- IDE 控制器
pciide* at pci ? dev ? function ? flags 0x0000

wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
#wdc* at pcmcia? function ? # PCMCIA硬盘,此行需注释
wdc* at isapnp?

#-- IDE 硬盘
wd* at wdc? channel ? drive ? flags 0x0000
wd* at pciide? channel ? drive ? flags 0x0000

# ATAPI<->SCSI 桥接模拟
atapiscsi* at wdc? channel ?
atapiscsi* at pciide? channel ?
scsibus* at atapiscsi?

#wt0 at isa? port 0x308 irq 5 drq 1 # Archive and Wangtek QIC tape drives

#-- 网络设备
#we0 at isa? port 0x280 iomem 0xd0000 irq 9 # WD/SMC 80x3 ethernet
#we1 at isa? port 0x300 iomem 0xcc000 irq 10 #
#we2 at isa? port 0x280 iomem 0xd0000 irq 3 # WD/SMC 80x3 ethernet
#we* at isapnp?
#ec0 at isa? port 0x250 iomem 0xd8000 irq 9 # ISA接口,3COM 3C503 ethernet
#ne0 at isa? port 0x240 irq 9 # *ISA接口,NE[12]000 ethernet
#ne1 at isa? port 0x300 irq 10 # *ISA接口,NE[12]000 ethernet
#ne2 at isa? port 0x280 irq 9 # ISA接口,NE[12]000 ethernet
#ne* at isapnp? # ISA接口,NE[12]000 PnP ethernet
#eg0 at isa? disable port 0x310 irq 5 # 3C505/Etherlink+ ethernet
#el0 at isa? disable port 0x300 irq 9 # 3C501 ethernet
#ep0 at isa? port ? irq ? # 3C509 ethernet
#ep* at isapnp? # *ISA接口,3C509 PnP ethernet
#ep* at isa? port ? irq ? # *ISA接口,3C509 ethernet
#ef* at isapnp? # 3C515 PnP ethernet
#ie0 at isa? port 0x360 iomem 0xd0000 irq 7 # StarLAN and 3C507
#ie1 at isa? port 0x300 irq 10 # EtherExpress
#lc0 at isa? port 0x200 irq ? # DEC EtherWorks
#lc1 at isa? port 0x280 irq ? # DEC EtherWorks
#le0 at isa? port 0x360 irq 15 drq 6 # IsoLan, NE2100, and DEPCA
#ex0 at isa? port 0x320 irq 5 # Intel EtherExpress PRO/10
#tr0 at isa? port 0xa20 iomem 0xd8000 irq ? # IBM TROPIC based Token-Ring
#tr1 at isa? port 0xa24 iomem 0xd0000 irq ? # IBM TROPIC based Token-Ring
#tr* at isa? port ? irq ? # 3COM TROPIC based Token-Ring
#ep0 at eisa? slot ?
#ep* at eisa? slot ? # 3C579 ethernet
#fea* at eisa? slot ? # DEC DEFEA FDDI
#lmc* at pci? dev ? function ? # Lan Media Corp SSI/T3/HSSI
#san* at pci? dev ? function ? # Sangoma PCI AFT card
le* at pci? dev ? function ? # *AMD PCNET32 网卡,Vmware需要
le* at isapnp?
#de* at pci? dev ? function ? # *PCI接口,DC21X4X 网卡,M$ VirtualPC需要
#fxp* at pci? dev ? function ? # *PCI接口,Intel EEpro10/100 (Intel 8255x芯片)
#fxp* at cardbus? dev ? function ? # *PCMCIA接口,Intel PRO/100 ethernet
#ne* at pci? dev ? function ? # *PCI接口,NE2000-compat ethernet
#ep0 at pci? dev ? function ? # 3C59x ethernet
#ep* at pci? dev ? function ? # 3C59x ethernet
#ne* at pcmcia? function ? # PCMCIA based NE2000 ethernet
#ep* at pcmcia? function ? # PCMCIA based 3C5xx ethernet
#sm* at pcmcia? function ? # PCMCIA based sm ethernet
#xe* at pcmcia? function ? # PCMCIA接口,Xircom ethernet
#fpa* at pci? dev ? function ? # DEC DEFPA FDDI
#xl* at pci? dev ? function ? # 3C9xx ethernet
#xl* at cardbus? dev ? function ? # 3C575/3C656 ethernet
#rl* at pci? dev ? function ? # *PCI接口,RealTek 81[23]9 ethernet
#rl* at cardbus? dev ? function ? # *PCI接口,RealTek 81[23]9 ethernet
#mtd* at pci? dev ? function ? # Myson MTD800/803/891
#tx* at pci? dev ? function ? # SMC 83C170 EPIC ethernet
#tl* at pci? dev ? function ? # Compaq Thunderlan ethernet
#vr* at pci? dev ? function ? # PCI接口,VIA Rhine(VIA 690*芯片) ethernet
#wb* at pci? dev ? function ? # Winbond W89C840F ethernet
#sf* at pci? dev ? function ? # Adaptec AIC-6915 ethernet
#sis* at pci? dev ? function ? # SiS 900/7016 ethernet
#ste* at pci? dev ? function ? # Sundance ST201 ethernet
#dc* at pci? dev ? function ? # PCI接口,DEC 21143, "tulip" clone ethernet
#dc* at cardbus? dev ? function ? # PCI接口,DEV 21143, "tulip" clone ethernet
#ti* at pci? dev ? function ? # Alteon Tigon 1Gb ethernet
#skc* at pci? dev ? function ? # SysKonnect GEnesis 984x
#sk* at skc? # each port of above
#em* at pci? dev ? function ? # *Intel Pro/1000 ethernet,Intel EEpro 1000
#txp* at pci? dev ? function ? # *3com 3CR990
#nge* at pci? dev ? function ? # NS DP83820/DP83821 GigE
#bge* at pci? dev ? function ? # *Broadcom BCM570x (aka Tigon3)
#re* at pci? dev ? function ? # *Realtek 8169/8169S/8110S
#stge* at pci? dev ? function ? # Sundance TC9021 GigE
#lge* at pci? dev ? function ? # Level1 LXT1001 GigE
#hme* at pci? dev ? function ? # Sun Happy Meal
#bce* at pci? dev ? function ? # Broadcom BCM4401

#-- 无线网卡
#atw* at pci? dev ? function ? # ADMtek ADM8211 (802.11)
#atw* at cardbus? dev ? function ? # ADMtek ADM8211 (802.11)
#wi* at pci? dev ? function ? # *WaveLAN IEEE 802.11DS
#wi* at pcmcia? function ? # *WaveLAN IEEE 802.11DS
#awi* at pcmcia? function ? # Bay Networks IEEE 802.11FH
#an* at pci? dev ? function ? # *Aironet IEEE 802.11DS
#an* at isapnp? # *Aironet IEEE 802.11DS
#an* at pcmcia? function ? # *Aironet IEEE 802.11DS
#cnw* at pcmcia? function ? # Xircom Netwave
#ray* at pcmcia? function ? # Raylink Aviator2.4/Pro 802.11FH

#-- MII类型网卡
#exphy* at mii? phy ? # 3Com internal PHYs
#inphy* at mii? phy ? # Intel 82555 PHYs
#iophy* at mii? phy ? # Intel 82553 PHYs
#icsphy* at mii? phy ? # ICS 1890 PHYs
#lxtphy* at mii? phy ? # Level1 LXT970 PHYs
#nsphy* at mii? phy ? # NS and compatible PHYs
#nsphyter* at mii? phy ? # NS and compatible PHYs
#qsphy* at mii? phy ? # Quality Semi QS6612 PHYs
#sqphy* at mii? phy ? # Seeq 8x220 PHYs
#rlphy* at mii? phy ? # RealTek 8139 internal PHYs
#mtdphy* at mii? phy ? # Myson MTD972 PHYs
#dcphy* at mii? phy ? # Digital Clone PHYs
#acphy* at mii? phy ? # Altima AC101 PHYs
#amphy* at mii? phy ? # AMD 79C873 PHYs
#tqphy* at mii? phy ? # TDK 78Q212x PHYs
#bmtphy* at mii? phy ? # Broadcom 10/100 PHYs
#brgphy* at mii? phy ? # Broadcom Gigabit PHYs
#eephy* at mii? phy ? # Marvell 88E1000 series PHY
#xmphy* at mii? phy ? # XaQti XMAC-II PHYs
#nsgphy* at mii? phy ? # NS gigabit PHYs
#urlphy* at mii? phy ? # Realtek RTL8150L internal PHY
#rgephy* at mii? phy ? # Realtek 8169S/8110S PHY
#ukphy* at mii? phy ? # "unknown" PHYs

#-- 声卡驱动支持
#pss0 at isa? port 0x220 irq 7 drq 6 # Personal Sound System
#sp0 at pss0 port 0x530 irq 10 drq 0 # sound port driver

#eap* at pci? dev ? function ? # Ensoniq AudioPCI S5016
#eso* at pci? dev ? function ? # ESS Solo-1 PCI AudioDrive
#sv* at pci? dev ? function ? # S3 SonicVibes (S3 617)
#neo* at pci? dev ? function ? # NeoMagic 256AV/ZX
#cmpci* at pci? dev ? function ? # C-Media CMI8338/8738
#auich* at pci? dev ? function ? flags 0x0000 # i82801 ICH AC'97 audio
#autri* at pci? dev ? function ? flags 0x0000 # Trident 4D WAVE
#auvia* at pci? dev ? function ? # VIA VT82C686A
#clcs* at pci? dev ? function ? # CS4280 CrystalClear audio
#clct* at pci? dev ? function ? # CS4281 CrystalClear audio
#fms* at pci? dev ? function ? # Forte Media FM801
#maestro* at pci? dev ? function ? # ESS Maestro PCI
#esa* at pci? dev ? function ? # ESS Maestro3 PCI
#yds* at pci? dev ? function ? flags 0x0000 # Yamaha YMF Audio
#emu* at pci? dev ? function ? # SB Live!
#sb0 at isa? port 0x220 irq 5 drq 1 # SoundBlaster
#sb* at isapnp?
#ess* at isapnp? # ESS Tech ES188[78], ES888
#wss0 at isa? port 0x530 irq 10 drq 0 # Windows Sound System
#wss* at isapnp?
#pas0 at isa? port 0x220 irq 7 drq 1 # ProAudio Spectrum
#gus0 at isa? port 0x220 irq 7 drq 1 drq2 6 # Gravis (drq2 is record drq)
#ym* at isapnp?
#mpu* at isapnp?
#mpu* at isa? port 0x300 # generic MPU, Yamaha SW60XG
##aria0 at isa? port 0x280 irq 10 drq 0 flags 0x1 # Prometheus Aria 16

# OPL[23] FM synthesizers
#opl0 at isa? port 0x388 # use only if not attached to sound card
#opl* at eso?
#opl* at sb?
#opl* at ess?
#opl* at yds?

# MIDI support
#midi* at pcppi? # MIDI interface to the PC speaker
#midi* at sb? # SB MPU401 port
#midi* at opl? # OPL FM synth
#midi* at ym?
#midi* at mpu?
#midi* at autri?

# The spkr driver provides a simple tone interface to the built in speaker.
#spkr0 at pcppi? # PC speaker

# Audio Support
#audio* at sb?
#audio* at gus?
#audio* at pas?
#audio* at sp?
#audio* at ess?
#audio* at wss?
#audio* at ym?
#audio* at eap?
#audio* at eso?
#audio* at sv?
#audio* at neo?
#audio* at cmpci?
#audio* at clcs?
#audio* at clct?
#audio* at auich?
#audio* at autri?
#audio* at auvia?
#audio* at fms?
#audio* at maestro?
#audio* at esa?
#audio* at yds?
#audio* at emu?

#bktr0 at pci? dev ? function ?

#-- FM-Radio无线电设备
#gtp* at pci? dev ? function ? # Gemtek/Guillemot Radio PCI Radio Card
#sfr0 at isa? port 0x384 # SoundForte RadioLink SF16-FMR FM Radio Card
#sf2r0 at isa? port 0x384 # SoundForte RadioLink SF16-FMR2 FM Radio Card
#az0 at isa? port 0x350 # Aztech/PackardBell FM Radio Card
#rt0 at isa? port 0x30c # AIMS Lab Radiotrack FM Radio Card
#rt* at isapnp?
#rtii0 at isa? port 0x30c # AIMS Lab Radiotrack II FM Radio Card

# FM-Radio support
#radio* at bktr?
#radio* at fms?
#radio* at gtp?
#radio* at sfr?
#radio* at sf2r?
#radio* at az?
#radio* at rt?
#radio* at rtii?

#-- 游戏杆设备
#joy0 at isa? port 0x201
#joy* at isapnp?

#wdt0 at pci? dev ? function ? # Ind Computer Source PCI-WDT50x driver

#-- 硬件加密卡设备
#hifn* at pci? dev ? function ? # Hi/fn 7751 crypto card
#lofn* at pci? dev ? function ? # Hi/fn 6500 crypto card
#nofn* at pci? dev ? function ? # Hi/fn 7814/7851/7854 crypto card
#ubsec* at pci? dev ? function ? # Bluesteel Networks 5xxx crypto card
#safe* at pci? dev ? function ? # SafeNet SafeXcel 1141/1741
#ises* at pci? dev ? function ? # Pijnenburg PCC-ISES

#-- I2O 设备
#iop* at pci? dev ? function ? # I2O
#ioprbs* at iop? tid ? # Random block storage
#scsibus* at ioprbs?

#-- 伪设备
#pseudo-device pctr 1
pseudo-device mtrr 1 # Memory range attributes control
#pseudo-device sequencer 1
#pseudo-device raid 4 # RAIDframe disk driver
pseudo-device bio 1 # ioctl multiplexing device
pseudo-device hotplug 1 # devices hot plugging

# mouse & keyboard multiplexor pseudo-devices
pseudo-device wsmux 2
pseudo-device crypto 1

#####################################################################

最后是MP支持部分 /sys/arch/i386/conf/GENERIC.MP
#####################################################################
# $OpenBSD: GENERIC.MP,v 1.4 2004/09/22 08:48:56 grange Exp $
#
# GENERIC.MP - sample multiprocessor kernel
#

include "arch/i386/conf/Genii" # 包含平台相关部分配置

option MULTIPROCESSOR # 多处理器支持

cpu* at mainbus?
ioapic* at mainbus?
#####################################################################

作为应用于网络最多的系统,一些国内常见的网卡类型的驱动用*号特别标了出来。

从这三个配置文件中include的部分可以看出它们的关系:
1. 如果是SMP环境,则使用/sys/arch/i386/conf/GENERIC.MP作为顶层配置文件;
2. 否则使用 /sys/arch/i386/conf/GENERIC 作为顶层配置文件;
3. 从 /sys/conf/GENERIC 中继承平台无关的内核配置。

在 平台无关配置 中,主要包含平台无关的内核基本架构,分为以下几个大段:
1. 内核 安全、性能、调试 节段
2. 内核全局特性、进程间通讯配置
3. 文件系统支持
4. 网络选项支持
5. 网络协议支持
6. 伪设备

在 平台相关配置 中,主要包含平台相关的各种设备驱动,分为以下几部分:
1. CPU及硬件体系
2. 平台相关的内核特性 和 内核参数
3. 总线和BIOS设备
4. ISA设备
5. PCI设备
6. USB设备
7. IDE设备
8. PCMCIA设备
9. 有线网络设备
10. 无线网络设备
11. 声卡
12. 其他外设
13. 显示器、鼠标、键盘
14. 系统板卡接口
15. 伪设备

在SMP配置文件中,只有简短的几行,提供了MP的支持,而且一般情况下是不用
修改了。

面对那么多的设备驱动,肯定不免会多出或遗漏些什么,这个时候记住一条规则,
就是所有的配置都是有线索可循的,下层的设备一定要依赖于上层设备的链,当
然这样的设备链偶尔会有交叉和继承,这时候就需要看经验了。 面向对象的编程
经验在这里很必要 ^^

一般的设备可以按照总线顺序来摸清他的线索,例如PCMCIA设备就一定要依赖于
PCMCIA控制器,PCMCIA控制器则需要ISA或PCI总线,PCI总线等最后就依赖于mainbus。

1. 第一层,mainbus
mainbus0 at root

2. 第二层,cpu、主板、pcibios、数学协处理器
cpu0 at mainbus? apid ?
bios0 at mainbus0 apid ?
apm0 at bios0 flags 0x0000 # flags 0x0101 to force protocol version 1.1
pcibios0 at bios0 flags 0x0000

npx0 at isa? port 0xf0 irq 13 # math coprocessor
isadma0 at isa?
isapnp0 at isa?

3. 第三层,设备总线,ISA、EISA、MCA和PCI
isa0 at mainbus0 # isa总线
isa0 at pcib?
isa0 at ichpcib? # Intel ICH芯片组
eisa0 at mainbus0 # eisa总线
pci* at mainbus0 bus ? # pci总线

这里的几个isa总线分别是isa的几种类型--集成于主板的、一些特殊芯片组的、
以及插在PCI槽中的PCI-ISA桥。

4. 第四层,总线控制器
>>PCI总线
pchb* at pci? dev ? function ? # PCI-Host bridges
ppb* at pci? dev ? function ? # PCI-PCI bridges
pci* at ppb? bus ?
pci* at pchb? bus ?
pcib* at pci? dev ? function ? # PCI-ISA bridge

>>PCMCIA和CardBus
#pcic* at pci? dev? function ?
#-- PCMCIA 总线支持
#pcmcia* at pcic? controller ? socket ?
#pcmcia* at tcic? controller ? socket ?
#-- CardBus 总线支持
#cardbus* at cardslot?
#pcmcia* at cardslot?
#cbb* at pci? dev ? function ?
#cardslot* at cbb?

>>USB总线
ehci* at pci? # Enhanced Host Controller 
uhci* at pci? # Universal Host Controller (Intel芯片组)
ohci* at pci? # Open Host Controller (Apple,VIA等其他芯片组)
# USB bus support
usb* at ehci?
usb* at uhci?
usb* at ohci?

5. 各种设备驱动
>>网络
le* at pci? dev ? function ? # AMD PCNET32 网卡,Vmware需要
le* at isapnp?

>>SCSI 适配器和设备
mpt* at pci? dev ? function ? # LSI Fusion-MPT SCSI/Fibre
scsibus* at mpt?

>>IDE
pciide* at pci ? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
wdc* at isapnp?

>>USB存储
umass* at uhub? port ? configuration ? # USB Mass Storage devices
scsibus* at umass? 

>>鼠标、键盘、显示器
pckbc0 at isa? # PC keyboard controller
pckbd* at pckbc? # PC keyboard
pms* at pckbc? # PS/2 mouse for wsmouse
pmsi* at pckbc? # PS/2 "Intelli"mouse for wsmouse
vga0 at isa?

>>其他接口
pccom0 at isa? port 0x3f8 irq 4 # standard PC serial ports
pccom1 at isa? port 0x2f8 irq 3
pccom2 at isa? port 0x3e8 irq 5
lpt0 at isa? port 0x378 irq 7 # standard PC parallel port

按这样的线索和结构来看配置文件,是不是就清晰多了?
当然偶尔还是会有一些可能会引起混杂的东西:

比如这个:
wdc* at pcmcia? function ? # PCMCIA硬盘
特殊类型的PCMCIA磁盘,就同时需要IDE设备、PCMCIA总线的支持;

另外更常遇到的一种设备,各种USB移动存储器需要UMASS驱动支持:
umass* at uhub? port ? configuration ? # USB Mass Storage devices
scsibus* at umass?

atapiscsi* at wdc? channel ?
atapiscsi* at pciide? channel ?
scsibus* at atapiscsi?

sd* at scsibus? target ? lun ?

UMASS驱动是模拟SCSI设备工作,因而就需要以上三个部分的支持,也就是
UMASS设备必须要SCSI-IDE桥、SCSI HD、IDE控制器三个驱动支持才能够运作。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics