diff --git a/en_US.ISO8859-1/books/arch-handbook/book.sgml b/en_US.ISO8859-1/books/arch-handbook/book.sgml index 6cbec1dd1c..4e64f19df1 100644 --- a/en_US.ISO8859-1/books/arch-handbook/book.sgml +++ b/en_US.ISO8859-1/books/arch-handbook/book.sgml @@ -1,725 +1,515 @@ %bookinfo; %chapters; ]> FreeBSD Developers' Handbook The FreeBSD Documentation Project
doc@FreeBSD.org
August 2000 2000 The FreeBSD Documentation Project &bookinfo.legalnotice; Welcome to the Developers' Handbook.
Introduction Developing on FreeBSD This will need to discuss FreeBSD as a development platform, the vision of BSD, architectural overview, layout of /usr/src, history, etc. Thank you for considering FreeBSD as your development platform! We hope it will not let you down. The BSD Vision Architectural Overview The Layout of /usr/src The complete source code to FreeBSD is available from our public CVS repository. The source code is normally installed in /usr/src which contains the following subdirectories. Directory Description bin/ Source for files in /bin contrib/ Source for files from contribued software. crypto/ DES source etc/ Source for files in /etc games/ Source for files in /usr/games gnu/ Utilities covered by the GNU Public License include/ Source for files in /usr/include kerberosIV/ Source for Kerbereros version IV kerberos5/ Source for Kerbereros version 5 lib/ Source for files in /usr/lib libexec/ Source for files in /usr/libexec release/ Files required to produce a FreeBSD release sbin/ Source for files in /sbin secure/ FreeSec sources share/ Source for files in /sbin sys/ Kernel source files tools/ Tools used for maintenance and testing of FreeBSD usr.bin/ Source for files in /usr/bin usr.sbin/ Source for files in /usr/sbin Basics &chap.tools; &chap.secure; Kernel History of the Unix Kernel Some history of the Unix/BSD kernel, system calls, how do processes work, blocking, scheduling, threads (kernel), context switching, signals, interrupts, modules, etc. Memory and Virtual Memory Virtual Memory VM, paging, swapping, allocating memory, testing for memory leaks, mmap, vnodes, etc. I/O System UFS UFS, FFS, Ext2FS, JFS, inodes, buffer cache, labeling, locking, metadata, soft-updates, LFS, portalfs, procfs, vnodes, memory sharing, memory objects, TLBs, caching Interprocess Communication Signals Signals, pipes, semaphores, message queues, shared memory, ports, sockets, doors Networking Sockets Sockets, bpf, IP, TCP, UDP, ICMP, OSI, bridging, firewalling, NAT, switching, etc Network Filesystems AFS AFS, NFS, SANs etc] Terminal Handling Syscons Syscons, tty, PCVT, serial console, screen savers, etc Sound OSS OSS, waveforms, etc Device Drivers &chap.driverbasics; - - - PCI Devices - - This chapter will talk about the FreeBSD mechanisms for - writing a device driver for a device on a PCI bus. - - Probe and Attach - - Information here about how the PCI bus code iterates - through the unattached devices and see if a newly loaded kld - will attach to any of them. - -/* - * Simple KLD to play with the PCI functions. - * - * Murray Stokely - */ - -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) - -#include <sys/types.h> -#include <sys/module.h> -#include <sys/systm.h> /* uprintf */ -#include <sys/errno.h> -#include <sys/param.h> /* defines used in kernel.h */ -#include <sys/kernel.h> /* types used in module initialization */ -#include <sys/conf.h> /* cdevsw struct */ -#include <sys/uio.h> /* uio struct */ -#include <sys/malloc.h> -#include <sys/bus.h> /* structs, prototypes for pci bus stuff */ - -#include <pci/pcivar.h> /* For get_pci macros! */ - -/* Function prototypes */ -d_open_t mypci_open; -d_close_t mypci_close; -d_read_t mypci_read; -d_write_t mypci_write; - -/* Character device entry points */ - -static struct cdevsw mypci_cdevsw = { - mypci_open, - mypci_close, - mypci_read, - mypci_write, - noioctl, - nopoll, - nommap, - nostrategy, - "mypci", - 36, /* reserved for lkms - /usr/src/sys/conf/majors */ - nodump, - nopsize, - D_TTY, - -1 -}; - -/* vars */ -static dev_t sdev; - -/* We're more interested in probe/attach than with - open/close/read/write at this point */ - -int -mypci_open(dev_t dev, int oflags, int devtype, struct proc *p) -{ - int err = 0; - - uprintf("Opened device \"mypci\" successfully.\n"); - return(err); -} - -int -mypci_close(dev_t dev, int fflag, int devtype, struct proc *p) -{ - int err=0; - - uprintf("Closing device \"mypci.\"\n"); - return(err); -} - -int -mypci_read(dev_t dev, struct uio *uio, int ioflag) -{ - int err = 0; - - uprintf("mypci read!\n"); - return err; -} - -int -mypci_write(dev_t dev, struct uio *uio, int ioflag) -{ - int err = 0; - - uprintf("mypci write!\n"); - return(err); -} - -/* PCI Support Functions */ - -/* - * Return identification string if this is device is ours. - */ -static int -mypci_probe(device_t dev) -{ - uprintf("MyPCI Probe\n" - "Vendor ID : 0x%x\n" - "Device ID : 0x%x\n",pci_get_vendor(dev),pci_get_device(dev)); - - if (pci_get_vendor(dev) == 0x11c1) { - uprintf("We've got the Winmodem, probe successful!\n"); - return 0; - } - - return ENXIO; -} - -/* Attach function is only called if the probe is successful */ - -static int -mypci_attach(device_t dev) -{ - uprintf("MyPCI Attach for : deviceID : 0x%x\n",pci_get_vendor(dev)); - sdev = make_dev(&mypci_cdevsw, - 0, - UID_ROOT, - GID_WHEEL, - 0600, - "mypci"); - uprintf("Mypci device loaded.\n"); - return ENXIO; -} - -/* Detach device. */ - -static int -mypci_detach(device_t dev) -{ - uprintf("Mypci detach!\n"); - return 0; -} - -/* Called during system shutdown after sync. */ - -static int -mypci_shutdown(device_t dev) -{ - uprintf("Mypci shutdown!\n"); - return 0; -} - -/* - * Device suspend routine. - */ -static int -mypci_suspend(device_t dev) -{ - uprintf("Mypci suspend!\n"); - return 0; -} - -/* - * Device resume routine. - */ - -static int -mypci_resume(device_t dev) -{ - uprintf("Mypci resume!\n"); - return 0; -} - -static device_method_t mypci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, mypci_probe), - DEVMETHOD(device_attach, mypci_attach), - DEVMETHOD(device_detach, mypci_detach), - DEVMETHOD(device_shutdown, mypci_shutdown), - DEVMETHOD(device_suspend, mypci_suspend), - DEVMETHOD(device_resume, mypci_resume), - - { 0, 0 } -}; - -static driver_t mypci_driver = { - "mypci", - mypci_methods, - 0, - /* sizeof(struct mypci_softc), */ -}; - -static devclass_t mypci_devclass; - -DRIVER_MODULE(mypci, pci, mypci_driver, mypci_devclass, 0, 0); - - - Additional Resources - - PCI Special Interest - Group - PCI System Architecture, Fourth Edition by - Tom Shanley, et al. - - - - + &chap.pci; USB Devices This chapter will talk about the FreeBSD mechanisms for writing a device driver for a device on a USB bus. NewBus This chapter will talk about the FreeBSD NewBus architecture. Architectures IA-32 Talk about the architectural specifics of FreeBSD/x86. Alpha Talk about the architectural specifics of FreeBSD/alpha. Explanation of allignment errors, how to fix, how to ignore. Example assembly language code for FreeBSD/alpha. IA-64 Talk about the architectural specifics of FreeBSD/ia64. Debugging Truss various descriptions on how to debug certain aspects of the system using truss, ktrace, gdb, kgdb, etc Compatibility Layers Linux Linux, SVR4, etc Appendices Dave A Patterson John L Hennessy 1998Morgan Kaufmann Publishers, Inc. 1-55860-428-6 Morgan Kaufmann Publishers, Inc. Computer Organization and Design The Hardware / Software Interface 1-2 W. Richard Stevens 1993Addison Wesley Longman, Inc. 0-201-56317-7 Addison Wesley Longman, Inc. Advanced Programming in the Unix Environment 1-2 Marshall Kirk McKusick Keith Bostic Michael J Karels John S Quarterman 1996Addison-Wesley Publishing Company, Inc. 0-201-54979-4 Addison-Wesley Publishing Company, Inc. The Design and Implementation of the 4.4 BSD Operating System 1-2 Aleph One Phrack 49; "Smashing the Stack for Fun and Profit" Chrispin Cowan Calton Pu Dave Maier StackGuard; Automatic Adaptive Detection and Prevention of Buffer-Overflow Attacks Todd Miller Theo de Raadt strlcpy and strlcat -- consistent, safe string copy and concatenation.
diff --git a/en_US.ISO8859-1/books/arch-handbook/pci/chapter.sgml b/en_US.ISO8859-1/books/arch-handbook/pci/chapter.sgml new file mode 100644 index 0000000000..50c2cc81ca --- /dev/null +++ b/en_US.ISO8859-1/books/arch-handbook/pci/chapter.sgml @@ -0,0 +1,218 @@ + + + + PCI Devices + + This chapter will talk about the FreeBSD mechanisms for + writing a device driver for a device on a PCI bus. + + Probe and Attach + + Information here about how the PCI bus code iterates + through the unattached devices and see if a newly loaded kld + will attach to any of them. + +/* + * Simple KLD to play with the PCI functions. + * + * Murray Stokely + */ + +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) + +#include <sys/types.h> +#include <sys/module.h> +#include <sys/systm.h> /* uprintf */ +#include <sys/errno.h> +#include <sys/param.h> /* defines used in kernel.h */ +#include <sys/kernel.h> /* types used in module initialization */ +#include <sys/conf.h> /* cdevsw struct */ +#include <sys/uio.h> /* uio struct */ +#include <sys/malloc.h> +#include <sys/bus.h> /* structs, prototypes for pci bus stuff */ + +#include <pci/pcivar.h> /* For get_pci macros! */ + +/* Function prototypes */ +d_open_t mypci_open; +d_close_t mypci_close; +d_read_t mypci_read; +d_write_t mypci_write; + +/* Character device entry points */ + +static struct cdevsw mypci_cdevsw = { + mypci_open, + mypci_close, + mypci_read, + mypci_write, + noioctl, + nopoll, + nommap, + nostrategy, + "mypci", + 36, /* reserved for lkms - /usr/src/sys/conf/majors */ + nodump, + nopsize, + D_TTY, + -1 +}; + +/* vars */ +static dev_t sdev; + +/* We're more interested in probe/attach than with + open/close/read/write at this point */ + +int +mypci_open(dev_t dev, int oflags, int devtype, struct proc *p) +{ + int err = 0; + + uprintf("Opened device \"mypci\" successfully.\n"); + return(err); +} + +int +mypci_close(dev_t dev, int fflag, int devtype, struct proc *p) +{ + int err=0; + + uprintf("Closing device \"mypci.\"\n"); + return(err); +} + +int +mypci_read(dev_t dev, struct uio *uio, int ioflag) +{ + int err = 0; + + uprintf("mypci read!\n"); + return err; +} + +int +mypci_write(dev_t dev, struct uio *uio, int ioflag) +{ + int err = 0; + + uprintf("mypci write!\n"); + return(err); +} + +/* PCI Support Functions */ + +/* + * Return identification string if this is device is ours. + */ +static int +mypci_probe(device_t dev) +{ + uprintf("MyPCI Probe\n" + "Vendor ID : 0x%x\n" + "Device ID : 0x%x\n",pci_get_vendor(dev),pci_get_device(dev)); + + if (pci_get_vendor(dev) == 0x11c1) { + uprintf("We've got the Winmodem, probe successful!\n"); + return 0; + } + + return ENXIO; +} + +/* Attach function is only called if the probe is successful */ + +static int +mypci_attach(device_t dev) +{ + uprintf("MyPCI Attach for : deviceID : 0x%x\n",pci_get_vendor(dev)); + sdev = make_dev(&mypci_cdevsw, + 0, + UID_ROOT, + GID_WHEEL, + 0600, + "mypci"); + uprintf("Mypci device loaded.\n"); + return ENXIO; +} + +/* Detach device. */ + +static int +mypci_detach(device_t dev) +{ + uprintf("Mypci detach!\n"); + return 0; +} + +/* Called during system shutdown after sync. */ + +static int +mypci_shutdown(device_t dev) +{ + uprintf("Mypci shutdown!\n"); + return 0; +} + +/* + * Device suspend routine. + */ +static int +mypci_suspend(device_t dev) +{ + uprintf("Mypci suspend!\n"); + return 0; +} + +/* + * Device resume routine. + */ + +static int +mypci_resume(device_t dev) +{ + uprintf("Mypci resume!\n"); + return 0; +} + +static device_method_t mypci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, mypci_probe), + DEVMETHOD(device_attach, mypci_attach), + DEVMETHOD(device_detach, mypci_detach), + DEVMETHOD(device_shutdown, mypci_shutdown), + DEVMETHOD(device_suspend, mypci_suspend), + DEVMETHOD(device_resume, mypci_resume), + + { 0, 0 } +}; + +static driver_t mypci_driver = { + "mypci", + mypci_methods, + 0, + /* sizeof(struct mypci_softc), */ +}; + +static devclass_t mypci_devclass; + +DRIVER_MODULE(mypci, pci, mypci_driver, mypci_devclass, 0, 0); + + + Additional Resources + + PCI Special Interest + Group + PCI System Architecture, Fourth Edition by + Tom Shanley, et al. + + + + + + diff --git a/en_US.ISO8859-1/books/developers-handbook/book.sgml b/en_US.ISO8859-1/books/developers-handbook/book.sgml index 6cbec1dd1c..4e64f19df1 100644 --- a/en_US.ISO8859-1/books/developers-handbook/book.sgml +++ b/en_US.ISO8859-1/books/developers-handbook/book.sgml @@ -1,725 +1,515 @@ %bookinfo; %chapters; ]> FreeBSD Developers' Handbook The FreeBSD Documentation Project
doc@FreeBSD.org
August 2000 2000 The FreeBSD Documentation Project &bookinfo.legalnotice; Welcome to the Developers' Handbook.
Introduction Developing on FreeBSD This will need to discuss FreeBSD as a development platform, the vision of BSD, architectural overview, layout of /usr/src, history, etc. Thank you for considering FreeBSD as your development platform! We hope it will not let you down. The BSD Vision Architectural Overview The Layout of /usr/src The complete source code to FreeBSD is available from our public CVS repository. The source code is normally installed in /usr/src which contains the following subdirectories. Directory Description bin/ Source for files in /bin contrib/ Source for files from contribued software. crypto/ DES source etc/ Source for files in /etc games/ Source for files in /usr/games gnu/ Utilities covered by the GNU Public License include/ Source for files in /usr/include kerberosIV/ Source for Kerbereros version IV kerberos5/ Source for Kerbereros version 5 lib/ Source for files in /usr/lib libexec/ Source for files in /usr/libexec release/ Files required to produce a FreeBSD release sbin/ Source for files in /sbin secure/ FreeSec sources share/ Source for files in /sbin sys/ Kernel source files tools/ Tools used for maintenance and testing of FreeBSD usr.bin/ Source for files in /usr/bin usr.sbin/ Source for files in /usr/sbin Basics &chap.tools; &chap.secure; Kernel History of the Unix Kernel Some history of the Unix/BSD kernel, system calls, how do processes work, blocking, scheduling, threads (kernel), context switching, signals, interrupts, modules, etc. Memory and Virtual Memory Virtual Memory VM, paging, swapping, allocating memory, testing for memory leaks, mmap, vnodes, etc. I/O System UFS UFS, FFS, Ext2FS, JFS, inodes, buffer cache, labeling, locking, metadata, soft-updates, LFS, portalfs, procfs, vnodes, memory sharing, memory objects, TLBs, caching Interprocess Communication Signals Signals, pipes, semaphores, message queues, shared memory, ports, sockets, doors Networking Sockets Sockets, bpf, IP, TCP, UDP, ICMP, OSI, bridging, firewalling, NAT, switching, etc Network Filesystems AFS AFS, NFS, SANs etc] Terminal Handling Syscons Syscons, tty, PCVT, serial console, screen savers, etc Sound OSS OSS, waveforms, etc Device Drivers &chap.driverbasics; - - - PCI Devices - - This chapter will talk about the FreeBSD mechanisms for - writing a device driver for a device on a PCI bus. - - Probe and Attach - - Information here about how the PCI bus code iterates - through the unattached devices and see if a newly loaded kld - will attach to any of them. - -/* - * Simple KLD to play with the PCI functions. - * - * Murray Stokely - */ - -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) - -#include <sys/types.h> -#include <sys/module.h> -#include <sys/systm.h> /* uprintf */ -#include <sys/errno.h> -#include <sys/param.h> /* defines used in kernel.h */ -#include <sys/kernel.h> /* types used in module initialization */ -#include <sys/conf.h> /* cdevsw struct */ -#include <sys/uio.h> /* uio struct */ -#include <sys/malloc.h> -#include <sys/bus.h> /* structs, prototypes for pci bus stuff */ - -#include <pci/pcivar.h> /* For get_pci macros! */ - -/* Function prototypes */ -d_open_t mypci_open; -d_close_t mypci_close; -d_read_t mypci_read; -d_write_t mypci_write; - -/* Character device entry points */ - -static struct cdevsw mypci_cdevsw = { - mypci_open, - mypci_close, - mypci_read, - mypci_write, - noioctl, - nopoll, - nommap, - nostrategy, - "mypci", - 36, /* reserved for lkms - /usr/src/sys/conf/majors */ - nodump, - nopsize, - D_TTY, - -1 -}; - -/* vars */ -static dev_t sdev; - -/* We're more interested in probe/attach than with - open/close/read/write at this point */ - -int -mypci_open(dev_t dev, int oflags, int devtype, struct proc *p) -{ - int err = 0; - - uprintf("Opened device \"mypci\" successfully.\n"); - return(err); -} - -int -mypci_close(dev_t dev, int fflag, int devtype, struct proc *p) -{ - int err=0; - - uprintf("Closing device \"mypci.\"\n"); - return(err); -} - -int -mypci_read(dev_t dev, struct uio *uio, int ioflag) -{ - int err = 0; - - uprintf("mypci read!\n"); - return err; -} - -int -mypci_write(dev_t dev, struct uio *uio, int ioflag) -{ - int err = 0; - - uprintf("mypci write!\n"); - return(err); -} - -/* PCI Support Functions */ - -/* - * Return identification string if this is device is ours. - */ -static int -mypci_probe(device_t dev) -{ - uprintf("MyPCI Probe\n" - "Vendor ID : 0x%x\n" - "Device ID : 0x%x\n",pci_get_vendor(dev),pci_get_device(dev)); - - if (pci_get_vendor(dev) == 0x11c1) { - uprintf("We've got the Winmodem, probe successful!\n"); - return 0; - } - - return ENXIO; -} - -/* Attach function is only called if the probe is successful */ - -static int -mypci_attach(device_t dev) -{ - uprintf("MyPCI Attach for : deviceID : 0x%x\n",pci_get_vendor(dev)); - sdev = make_dev(&mypci_cdevsw, - 0, - UID_ROOT, - GID_WHEEL, - 0600, - "mypci"); - uprintf("Mypci device loaded.\n"); - return ENXIO; -} - -/* Detach device. */ - -static int -mypci_detach(device_t dev) -{ - uprintf("Mypci detach!\n"); - return 0; -} - -/* Called during system shutdown after sync. */ - -static int -mypci_shutdown(device_t dev) -{ - uprintf("Mypci shutdown!\n"); - return 0; -} - -/* - * Device suspend routine. - */ -static int -mypci_suspend(device_t dev) -{ - uprintf("Mypci suspend!\n"); - return 0; -} - -/* - * Device resume routine. - */ - -static int -mypci_resume(device_t dev) -{ - uprintf("Mypci resume!\n"); - return 0; -} - -static device_method_t mypci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, mypci_probe), - DEVMETHOD(device_attach, mypci_attach), - DEVMETHOD(device_detach, mypci_detach), - DEVMETHOD(device_shutdown, mypci_shutdown), - DEVMETHOD(device_suspend, mypci_suspend), - DEVMETHOD(device_resume, mypci_resume), - - { 0, 0 } -}; - -static driver_t mypci_driver = { - "mypci", - mypci_methods, - 0, - /* sizeof(struct mypci_softc), */ -}; - -static devclass_t mypci_devclass; - -DRIVER_MODULE(mypci, pci, mypci_driver, mypci_devclass, 0, 0); - - - Additional Resources - - PCI Special Interest - Group - PCI System Architecture, Fourth Edition by - Tom Shanley, et al. - - - - + &chap.pci; USB Devices This chapter will talk about the FreeBSD mechanisms for writing a device driver for a device on a USB bus. NewBus This chapter will talk about the FreeBSD NewBus architecture. Architectures IA-32 Talk about the architectural specifics of FreeBSD/x86. Alpha Talk about the architectural specifics of FreeBSD/alpha. Explanation of allignment errors, how to fix, how to ignore. Example assembly language code for FreeBSD/alpha. IA-64 Talk about the architectural specifics of FreeBSD/ia64. Debugging Truss various descriptions on how to debug certain aspects of the system using truss, ktrace, gdb, kgdb, etc Compatibility Layers Linux Linux, SVR4, etc Appendices Dave A Patterson John L Hennessy 1998Morgan Kaufmann Publishers, Inc. 1-55860-428-6 Morgan Kaufmann Publishers, Inc. Computer Organization and Design The Hardware / Software Interface 1-2 W. Richard Stevens 1993Addison Wesley Longman, Inc. 0-201-56317-7 Addison Wesley Longman, Inc. Advanced Programming in the Unix Environment 1-2 Marshall Kirk McKusick Keith Bostic Michael J Karels John S Quarterman 1996Addison-Wesley Publishing Company, Inc. 0-201-54979-4 Addison-Wesley Publishing Company, Inc. The Design and Implementation of the 4.4 BSD Operating System 1-2 Aleph One Phrack 49; "Smashing the Stack for Fun and Profit" Chrispin Cowan Calton Pu Dave Maier StackGuard; Automatic Adaptive Detection and Prevention of Buffer-Overflow Attacks Todd Miller Theo de Raadt strlcpy and strlcat -- consistent, safe string copy and concatenation.
diff --git a/en_US.ISO8859-1/books/developers-handbook/pci/chapter.sgml b/en_US.ISO8859-1/books/developers-handbook/pci/chapter.sgml new file mode 100644 index 0000000000..50c2cc81ca --- /dev/null +++ b/en_US.ISO8859-1/books/developers-handbook/pci/chapter.sgml @@ -0,0 +1,218 @@ + + + + PCI Devices + + This chapter will talk about the FreeBSD mechanisms for + writing a device driver for a device on a PCI bus. + + Probe and Attach + + Information here about how the PCI bus code iterates + through the unattached devices and see if a newly loaded kld + will attach to any of them. + +/* + * Simple KLD to play with the PCI functions. + * + * Murray Stokely + */ + +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) + +#include <sys/types.h> +#include <sys/module.h> +#include <sys/systm.h> /* uprintf */ +#include <sys/errno.h> +#include <sys/param.h> /* defines used in kernel.h */ +#include <sys/kernel.h> /* types used in module initialization */ +#include <sys/conf.h> /* cdevsw struct */ +#include <sys/uio.h> /* uio struct */ +#include <sys/malloc.h> +#include <sys/bus.h> /* structs, prototypes for pci bus stuff */ + +#include <pci/pcivar.h> /* For get_pci macros! */ + +/* Function prototypes */ +d_open_t mypci_open; +d_close_t mypci_close; +d_read_t mypci_read; +d_write_t mypci_write; + +/* Character device entry points */ + +static struct cdevsw mypci_cdevsw = { + mypci_open, + mypci_close, + mypci_read, + mypci_write, + noioctl, + nopoll, + nommap, + nostrategy, + "mypci", + 36, /* reserved for lkms - /usr/src/sys/conf/majors */ + nodump, + nopsize, + D_TTY, + -1 +}; + +/* vars */ +static dev_t sdev; + +/* We're more interested in probe/attach than with + open/close/read/write at this point */ + +int +mypci_open(dev_t dev, int oflags, int devtype, struct proc *p) +{ + int err = 0; + + uprintf("Opened device \"mypci\" successfully.\n"); + return(err); +} + +int +mypci_close(dev_t dev, int fflag, int devtype, struct proc *p) +{ + int err=0; + + uprintf("Closing device \"mypci.\"\n"); + return(err); +} + +int +mypci_read(dev_t dev, struct uio *uio, int ioflag) +{ + int err = 0; + + uprintf("mypci read!\n"); + return err; +} + +int +mypci_write(dev_t dev, struct uio *uio, int ioflag) +{ + int err = 0; + + uprintf("mypci write!\n"); + return(err); +} + +/* PCI Support Functions */ + +/* + * Return identification string if this is device is ours. + */ +static int +mypci_probe(device_t dev) +{ + uprintf("MyPCI Probe\n" + "Vendor ID : 0x%x\n" + "Device ID : 0x%x\n",pci_get_vendor(dev),pci_get_device(dev)); + + if (pci_get_vendor(dev) == 0x11c1) { + uprintf("We've got the Winmodem, probe successful!\n"); + return 0; + } + + return ENXIO; +} + +/* Attach function is only called if the probe is successful */ + +static int +mypci_attach(device_t dev) +{ + uprintf("MyPCI Attach for : deviceID : 0x%x\n",pci_get_vendor(dev)); + sdev = make_dev(&mypci_cdevsw, + 0, + UID_ROOT, + GID_WHEEL, + 0600, + "mypci"); + uprintf("Mypci device loaded.\n"); + return ENXIO; +} + +/* Detach device. */ + +static int +mypci_detach(device_t dev) +{ + uprintf("Mypci detach!\n"); + return 0; +} + +/* Called during system shutdown after sync. */ + +static int +mypci_shutdown(device_t dev) +{ + uprintf("Mypci shutdown!\n"); + return 0; +} + +/* + * Device suspend routine. + */ +static int +mypci_suspend(device_t dev) +{ + uprintf("Mypci suspend!\n"); + return 0; +} + +/* + * Device resume routine. + */ + +static int +mypci_resume(device_t dev) +{ + uprintf("Mypci resume!\n"); + return 0; +} + +static device_method_t mypci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, mypci_probe), + DEVMETHOD(device_attach, mypci_attach), + DEVMETHOD(device_detach, mypci_detach), + DEVMETHOD(device_shutdown, mypci_shutdown), + DEVMETHOD(device_suspend, mypci_suspend), + DEVMETHOD(device_resume, mypci_resume), + + { 0, 0 } +}; + +static driver_t mypci_driver = { + "mypci", + mypci_methods, + 0, + /* sizeof(struct mypci_softc), */ +}; + +static devclass_t mypci_devclass; + +DRIVER_MODULE(mypci, pci, mypci_driver, mypci_devclass, 0, 0); + + + Additional Resources + + PCI Special Interest + Group + PCI System Architecture, Fourth Edition by + Tom Shanley, et al. + + + + + + diff --git a/en_US.ISO_8859-1/books/developers-handbook/book.sgml b/en_US.ISO_8859-1/books/developers-handbook/book.sgml index 6cbec1dd1c..4e64f19df1 100644 --- a/en_US.ISO_8859-1/books/developers-handbook/book.sgml +++ b/en_US.ISO_8859-1/books/developers-handbook/book.sgml @@ -1,725 +1,515 @@ %bookinfo; %chapters; ]> FreeBSD Developers' Handbook The FreeBSD Documentation Project
doc@FreeBSD.org
August 2000 2000 The FreeBSD Documentation Project &bookinfo.legalnotice; Welcome to the Developers' Handbook.
Introduction Developing on FreeBSD This will need to discuss FreeBSD as a development platform, the vision of BSD, architectural overview, layout of /usr/src, history, etc. Thank you for considering FreeBSD as your development platform! We hope it will not let you down. The BSD Vision Architectural Overview The Layout of /usr/src The complete source code to FreeBSD is available from our public CVS repository. The source code is normally installed in /usr/src which contains the following subdirectories. Directory Description bin/ Source for files in /bin contrib/ Source for files from contribued software. crypto/ DES source etc/ Source for files in /etc games/ Source for files in /usr/games gnu/ Utilities covered by the GNU Public License include/ Source for files in /usr/include kerberosIV/ Source for Kerbereros version IV kerberos5/ Source for Kerbereros version 5 lib/ Source for files in /usr/lib libexec/ Source for files in /usr/libexec release/ Files required to produce a FreeBSD release sbin/ Source for files in /sbin secure/ FreeSec sources share/ Source for files in /sbin sys/ Kernel source files tools/ Tools used for maintenance and testing of FreeBSD usr.bin/ Source for files in /usr/bin usr.sbin/ Source for files in /usr/sbin Basics &chap.tools; &chap.secure; Kernel History of the Unix Kernel Some history of the Unix/BSD kernel, system calls, how do processes work, blocking, scheduling, threads (kernel), context switching, signals, interrupts, modules, etc. Memory and Virtual Memory Virtual Memory VM, paging, swapping, allocating memory, testing for memory leaks, mmap, vnodes, etc. I/O System UFS UFS, FFS, Ext2FS, JFS, inodes, buffer cache, labeling, locking, metadata, soft-updates, LFS, portalfs, procfs, vnodes, memory sharing, memory objects, TLBs, caching Interprocess Communication Signals Signals, pipes, semaphores, message queues, shared memory, ports, sockets, doors Networking Sockets Sockets, bpf, IP, TCP, UDP, ICMP, OSI, bridging, firewalling, NAT, switching, etc Network Filesystems AFS AFS, NFS, SANs etc] Terminal Handling Syscons Syscons, tty, PCVT, serial console, screen savers, etc Sound OSS OSS, waveforms, etc Device Drivers &chap.driverbasics; - - - PCI Devices - - This chapter will talk about the FreeBSD mechanisms for - writing a device driver for a device on a PCI bus. - - Probe and Attach - - Information here about how the PCI bus code iterates - through the unattached devices and see if a newly loaded kld - will attach to any of them. - -/* - * Simple KLD to play with the PCI functions. - * - * Murray Stokely - */ - -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) - -#include <sys/types.h> -#include <sys/module.h> -#include <sys/systm.h> /* uprintf */ -#include <sys/errno.h> -#include <sys/param.h> /* defines used in kernel.h */ -#include <sys/kernel.h> /* types used in module initialization */ -#include <sys/conf.h> /* cdevsw struct */ -#include <sys/uio.h> /* uio struct */ -#include <sys/malloc.h> -#include <sys/bus.h> /* structs, prototypes for pci bus stuff */ - -#include <pci/pcivar.h> /* For get_pci macros! */ - -/* Function prototypes */ -d_open_t mypci_open; -d_close_t mypci_close; -d_read_t mypci_read; -d_write_t mypci_write; - -/* Character device entry points */ - -static struct cdevsw mypci_cdevsw = { - mypci_open, - mypci_close, - mypci_read, - mypci_write, - noioctl, - nopoll, - nommap, - nostrategy, - "mypci", - 36, /* reserved for lkms - /usr/src/sys/conf/majors */ - nodump, - nopsize, - D_TTY, - -1 -}; - -/* vars */ -static dev_t sdev; - -/* We're more interested in probe/attach than with - open/close/read/write at this point */ - -int -mypci_open(dev_t dev, int oflags, int devtype, struct proc *p) -{ - int err = 0; - - uprintf("Opened device \"mypci\" successfully.\n"); - return(err); -} - -int -mypci_close(dev_t dev, int fflag, int devtype, struct proc *p) -{ - int err=0; - - uprintf("Closing device \"mypci.\"\n"); - return(err); -} - -int -mypci_read(dev_t dev, struct uio *uio, int ioflag) -{ - int err = 0; - - uprintf("mypci read!\n"); - return err; -} - -int -mypci_write(dev_t dev, struct uio *uio, int ioflag) -{ - int err = 0; - - uprintf("mypci write!\n"); - return(err); -} - -/* PCI Support Functions */ - -/* - * Return identification string if this is device is ours. - */ -static int -mypci_probe(device_t dev) -{ - uprintf("MyPCI Probe\n" - "Vendor ID : 0x%x\n" - "Device ID : 0x%x\n",pci_get_vendor(dev),pci_get_device(dev)); - - if (pci_get_vendor(dev) == 0x11c1) { - uprintf("We've got the Winmodem, probe successful!\n"); - return 0; - } - - return ENXIO; -} - -/* Attach function is only called if the probe is successful */ - -static int -mypci_attach(device_t dev) -{ - uprintf("MyPCI Attach for : deviceID : 0x%x\n",pci_get_vendor(dev)); - sdev = make_dev(&mypci_cdevsw, - 0, - UID_ROOT, - GID_WHEEL, - 0600, - "mypci"); - uprintf("Mypci device loaded.\n"); - return ENXIO; -} - -/* Detach device. */ - -static int -mypci_detach(device_t dev) -{ - uprintf("Mypci detach!\n"); - return 0; -} - -/* Called during system shutdown after sync. */ - -static int -mypci_shutdown(device_t dev) -{ - uprintf("Mypci shutdown!\n"); - return 0; -} - -/* - * Device suspend routine. - */ -static int -mypci_suspend(device_t dev) -{ - uprintf("Mypci suspend!\n"); - return 0; -} - -/* - * Device resume routine. - */ - -static int -mypci_resume(device_t dev) -{ - uprintf("Mypci resume!\n"); - return 0; -} - -static device_method_t mypci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, mypci_probe), - DEVMETHOD(device_attach, mypci_attach), - DEVMETHOD(device_detach, mypci_detach), - DEVMETHOD(device_shutdown, mypci_shutdown), - DEVMETHOD(device_suspend, mypci_suspend), - DEVMETHOD(device_resume, mypci_resume), - - { 0, 0 } -}; - -static driver_t mypci_driver = { - "mypci", - mypci_methods, - 0, - /* sizeof(struct mypci_softc), */ -}; - -static devclass_t mypci_devclass; - -DRIVER_MODULE(mypci, pci, mypci_driver, mypci_devclass, 0, 0); - - - Additional Resources - - PCI Special Interest - Group - PCI System Architecture, Fourth Edition by - Tom Shanley, et al. - - - - + &chap.pci; USB Devices This chapter will talk about the FreeBSD mechanisms for writing a device driver for a device on a USB bus. NewBus This chapter will talk about the FreeBSD NewBus architecture. Architectures IA-32 Talk about the architectural specifics of FreeBSD/x86. Alpha Talk about the architectural specifics of FreeBSD/alpha. Explanation of allignment errors, how to fix, how to ignore. Example assembly language code for FreeBSD/alpha. IA-64 Talk about the architectural specifics of FreeBSD/ia64. Debugging Truss various descriptions on how to debug certain aspects of the system using truss, ktrace, gdb, kgdb, etc Compatibility Layers Linux Linux, SVR4, etc Appendices Dave A Patterson John L Hennessy 1998Morgan Kaufmann Publishers, Inc. 1-55860-428-6 Morgan Kaufmann Publishers, Inc. Computer Organization and Design The Hardware / Software Interface 1-2 W. Richard Stevens 1993Addison Wesley Longman, Inc. 0-201-56317-7 Addison Wesley Longman, Inc. Advanced Programming in the Unix Environment 1-2 Marshall Kirk McKusick Keith Bostic Michael J Karels John S Quarterman 1996Addison-Wesley Publishing Company, Inc. 0-201-54979-4 Addison-Wesley Publishing Company, Inc. The Design and Implementation of the 4.4 BSD Operating System 1-2 Aleph One Phrack 49; "Smashing the Stack for Fun and Profit" Chrispin Cowan Calton Pu Dave Maier StackGuard; Automatic Adaptive Detection and Prevention of Buffer-Overflow Attacks Todd Miller Theo de Raadt strlcpy and strlcat -- consistent, safe string copy and concatenation.
diff --git a/en_US.ISO_8859-1/books/developers-handbook/pci/chapter.sgml b/en_US.ISO_8859-1/books/developers-handbook/pci/chapter.sgml new file mode 100644 index 0000000000..50c2cc81ca --- /dev/null +++ b/en_US.ISO_8859-1/books/developers-handbook/pci/chapter.sgml @@ -0,0 +1,218 @@ + + + + PCI Devices + + This chapter will talk about the FreeBSD mechanisms for + writing a device driver for a device on a PCI bus. + + Probe and Attach + + Information here about how the PCI bus code iterates + through the unattached devices and see if a newly loaded kld + will attach to any of them. + +/* + * Simple KLD to play with the PCI functions. + * + * Murray Stokely + */ + +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) + +#include <sys/types.h> +#include <sys/module.h> +#include <sys/systm.h> /* uprintf */ +#include <sys/errno.h> +#include <sys/param.h> /* defines used in kernel.h */ +#include <sys/kernel.h> /* types used in module initialization */ +#include <sys/conf.h> /* cdevsw struct */ +#include <sys/uio.h> /* uio struct */ +#include <sys/malloc.h> +#include <sys/bus.h> /* structs, prototypes for pci bus stuff */ + +#include <pci/pcivar.h> /* For get_pci macros! */ + +/* Function prototypes */ +d_open_t mypci_open; +d_close_t mypci_close; +d_read_t mypci_read; +d_write_t mypci_write; + +/* Character device entry points */ + +static struct cdevsw mypci_cdevsw = { + mypci_open, + mypci_close, + mypci_read, + mypci_write, + noioctl, + nopoll, + nommap, + nostrategy, + "mypci", + 36, /* reserved for lkms - /usr/src/sys/conf/majors */ + nodump, + nopsize, + D_TTY, + -1 +}; + +/* vars */ +static dev_t sdev; + +/* We're more interested in probe/attach than with + open/close/read/write at this point */ + +int +mypci_open(dev_t dev, int oflags, int devtype, struct proc *p) +{ + int err = 0; + + uprintf("Opened device \"mypci\" successfully.\n"); + return(err); +} + +int +mypci_close(dev_t dev, int fflag, int devtype, struct proc *p) +{ + int err=0; + + uprintf("Closing device \"mypci.\"\n"); + return(err); +} + +int +mypci_read(dev_t dev, struct uio *uio, int ioflag) +{ + int err = 0; + + uprintf("mypci read!\n"); + return err; +} + +int +mypci_write(dev_t dev, struct uio *uio, int ioflag) +{ + int err = 0; + + uprintf("mypci write!\n"); + return(err); +} + +/* PCI Support Functions */ + +/* + * Return identification string if this is device is ours. + */ +static int +mypci_probe(device_t dev) +{ + uprintf("MyPCI Probe\n" + "Vendor ID : 0x%x\n" + "Device ID : 0x%x\n",pci_get_vendor(dev),pci_get_device(dev)); + + if (pci_get_vendor(dev) == 0x11c1) { + uprintf("We've got the Winmodem, probe successful!\n"); + return 0; + } + + return ENXIO; +} + +/* Attach function is only called if the probe is successful */ + +static int +mypci_attach(device_t dev) +{ + uprintf("MyPCI Attach for : deviceID : 0x%x\n",pci_get_vendor(dev)); + sdev = make_dev(&mypci_cdevsw, + 0, + UID_ROOT, + GID_WHEEL, + 0600, + "mypci"); + uprintf("Mypci device loaded.\n"); + return ENXIO; +} + +/* Detach device. */ + +static int +mypci_detach(device_t dev) +{ + uprintf("Mypci detach!\n"); + return 0; +} + +/* Called during system shutdown after sync. */ + +static int +mypci_shutdown(device_t dev) +{ + uprintf("Mypci shutdown!\n"); + return 0; +} + +/* + * Device suspend routine. + */ +static int +mypci_suspend(device_t dev) +{ + uprintf("Mypci suspend!\n"); + return 0; +} + +/* + * Device resume routine. + */ + +static int +mypci_resume(device_t dev) +{ + uprintf("Mypci resume!\n"); + return 0; +} + +static device_method_t mypci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, mypci_probe), + DEVMETHOD(device_attach, mypci_attach), + DEVMETHOD(device_detach, mypci_detach), + DEVMETHOD(device_shutdown, mypci_shutdown), + DEVMETHOD(device_suspend, mypci_suspend), + DEVMETHOD(device_resume, mypci_resume), + + { 0, 0 } +}; + +static driver_t mypci_driver = { + "mypci", + mypci_methods, + 0, + /* sizeof(struct mypci_softc), */ +}; + +static devclass_t mypci_devclass; + +DRIVER_MODULE(mypci, pci, mypci_driver, mypci_devclass, 0, 0); + + + Additional Resources + + PCI Special Interest + Group + PCI System Architecture, Fourth Edition by + Tom Shanley, et al. + + + + + +