archive-org.com » ORG » N » NETBSD.ORG

Total: 1243

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • <TMPL_VAR NAME=raw_title>
    duration Duration estimate TMPL VAR NAME raw duration TMPL IF TMPL IF NAME funded Funded by TMPL VAR NAME funded TMPL IF TMPL IF NAME done by IMPORTANT This project was completed by TMPL VAR NAME raw done by You may still contact the people above for details but please do not submit an application for this project TMPL ELSE TMPL IF TMPL VAR NAME description TMPL IF NAME category TMPL IF TMPL IF NAME difficulty TMPL IF TMPL IF NAME funded TMPL IF TMPL ELSE Project template description The project template provides a consistent set of variables and tags to define a project proposal and or specification The following parameters are supported title required contact required done by optional set to the name of the person that completed the project This adds a note to the project mentioning that it has been completed and removes it from the indexes Do not move project pages or delete them by setting this tag the URL will remain valid mentors optional category required one of filesystems kernel misc networking pkgsrc ports or userland difficulty required one of easy medium or hard funded optional set to the name of the organization or individual

    Original URL path: http://wiki.netbsd.org/templates/project/ (2016-02-01)
    Open archived version from archive


  • project-test
    Packages Browse packages Release engineering Wiki Home Edit Comment Source History New RecentChanges NetBSD Wiki templates project test TMPL IF NAME title TMPL VAR NAME title contact TMPL VAR NAME contact mentors TMPL VAR NAME mentors TMPL VAR NAME description requirements TMPL VAR NAME requirements deliverables TMPL VAR NAME deliverables expected duration TMPL VAR NAME duration TMPL ELSE Description This template will make a standard project proposal page It takes

    Original URL path: http://wiki.netbsd.org/templates/project-test/ (2016-02-01)
    Open archived version from archive

  • ...BSDCon 20... NetBSD Summit
    guide Report a bug Query bug database Security Community Blogs Mailing lists List archives Developers Browse source Cross reference Release engineering Projects list Ports History Emulators Packages Browse packages Release engineering Wiki Home Edit Comment Source History New RecentChanges NetBSD Wiki templates BSDCon 20 NetBSD Summit Details add description here NetBSD Dinner more description Planning to attend table Error empty data Planning to present something Speaker Title login Very Interesting

    Original URL path: http://wiki.netbsd.org/templates/summit/ (2016-02-01)
    Open archived version from archive

  • the netbsd system manager's manual
    apply a security patch Securing the NetBSD Operating System Determine the system s security level See the value of kern securelevel cf sysctl 8 sysctl kern securelevel kern securelevel 1 Recognize basic recommended access methods Configure an SSH server according to a set of requirements Edit etc ssh sshd config When all seems fine relaunch sshd 8 daemon with etc rc d sshd restart If you are working remotely via an SSH connexion don t worry with privileges separation as default your working connexion won t be claused Configure an SSH server to use a key pair for authentication In etc ssh sshd config uncomment lines PasswordAuthentication no PermitEmptyPasswords no If you want to connect as root don t do this at least use keys with PermitRootLogin without password Don t forget to relaunch daemon Preserve existing SSH host keys during a system upgrade The SSH keys live under etc ssh Just tar 1 up all key files and extract the archive on the new system Recognize alternate authentication mechanisms Recognize alternate authorization schemes Recognize firewalls and rulesets To see input rules ipfstat hin o instead of i option gives output rules 6 option manipulates IPv6 rules n display groups and rules numbers useful when searching from logs IPNAT rules can be listed with ipnat l Recognize utilities that shape traffic or control bandwidth Recognize mechanisms for encrypting devices man cgd Recognize methods for verifying the validity of binaries By default etc daily launch etc security which uses mtree 8 To check if veriexec 4 is up sysctl kern veriexec strict kern veriexec strict 1 Read veriexec chapter from NetBSD Guide for more information Enable exploit mitigation Follow advices in security 8 man page Recognize methods for restraining a service chroot 8 systrace 1 Xen Modify the system banner Edit etc motd You can also add a banner before SSH connexion to do that add Banner etc ssh issue in etc ssh sshd config and put what you want to be displayed before SSH auth in file etc ssh issue Files Filesystems and Disks Mount or unmount local filesystems To mount a file system use the mount 8 command The general syntax is mount options device node mount point The available options may be found in the man page Typically it will be necessary to at least use the t command to specify the type of filesystem to be mounted For example to mount a CD ROM device specify the ISO 9660 format with a command like the following mount t cd9660 dev cd0d mnt cdrom To unmount a mounted filesystem use the umount 8 command To unmount the mounted filesystem mnt cdrom simply execute umount mnt cdrom Note that unmounting a filesystem will fail if any running process has a directory in that filesystem as its present working directory For example mount t cd9660 dev cd0d mnt cdrom cd mnt cdrom umount mnt cdrom umount mnt cdrom Device busy cd umount mnt cdrom Configure data to be available through NFS Let s share export data Create the file etc exports as cat etc exports export data maproot nobody ro network 192 168 1 0 mask 255 255 255 0 Here the file system will be read only option ro available only for clients from 192 168 1 0 24 and root access from clients will be mapped as nobody access on server we don t have confidence with our clients The syntax and options are documented in exports 5 We have to start rpcbind 8 mountd 8 rpc lockd 8 nfsd 8 and rpc statd 8 In order to do that edit etc rc conf and set rpcbind YES rpcbind flags l mountd YES nfs server YES statd YES lockd YES The flag l tells rpcbind 8 to use libwrap hosts options 5 Edit the etc hosts access and set rpcbind 192 168 1 0 255 255 255 0 ALLOW to allow clients to connect to the server On the clients we have to start rpcbind 8 rpc statd 8 and rpc lockd 8 edit etc rc conf and set rpcbind YES rpcbind flags l nfs client YES statd YES lockd YES Now lets mount the file system on the client mount o ro server export data data mount grep data server export data on data type nfs read only Don t forget to add a line in etc fstab fstab 5 server export data data nfs ro 0 0 to mount the file system at boot time That s all See the NetBSD Guide 1 http www netbsd org docs guide en chap net misc html chap net misc nfs for more details Determine which filesystems are currently mounted and which will be mounted at system boot A list of currently mounted filesystems can be obtained by running the mount 8 command without any arguments The file fstab 5 in etc contains information about which files are mounted at system boot and what options they are mounted with whether they should be fsck 8 ed and if so in what order etc Determine disk capacity and which files are consuming the most disk space Disk capacity df h Find the size of files in a directory du sk Report by file size du k sort n Create and view symbolic or hard links Symbolic link ln s sourcefile targetfile Hard link ln sourcefile targetfile View file permissions and modify them using either symbolic or octal mode View file permissions ls l filename Change file permissions chmod 644 filename Modify a file s owner or group The chown 8 command can be used to modify a file s owner or group To change the owner of the file somefile to the user someuser execute chown someuser somefile Similarly to change the group of the file somefile to the group somegroup execute chown somegroup somefile If you like can change both the group and owner of a file with a single command To implement both of the modifications made by the two commands above execute chown someuser somegroup somefile Note that there is also a chgrp 1 command to change the group of a file To change the group of the file somefile to the group somegroup execute chgrp somegroup somefile Backup and restore a specified set of files and directories to local disk or tape Create your compressed archive with tar cvfz backup tgz somedirectory c option create the archive z option compress the archive whith gzip 1 f option output to a file if you miss this option tar 1 will output archive to dev st0 default tape v option verbose output ie files added to archive will be displayed To restore use tar xzpf backup tgz x option extract the archive p option preserve ownership See also pax 1 and cpio 1 Backup and restore a file system dump 0f cd altroot retore rf See dump 8 and restore 8 Backup using ffs snapshots Snapshots allows to work with an atomic file system copy taken at a the time of the snapshot This is very useful to for instance backup a file system on which there may be running database applications such as PostgreSQL without the need to stop and restart the database application See fssconfig 8 and fss 4 for more details Here for the sake of an example we will suppose that we want to backup a live file system using rsync to a backup file system Let s first create the atomic snapshot of the file system fssconfig cx fss0 tmp back We now have configured the device dev fss0 to be a snapshot mirror of the file system using a temporary log of tmp back to which new writes will be added for as long as the snapshot device is configured This file will be automatically deleted at device unconfiguration because of the optional x switch You may now use that device with the dump command or mount it and use other backup commands such as pax tar or rsync as you wish mount o ro dev fss0 mnt We have now mounted the atomic copy of the file system to mnt Let s update our backup file system from it rsync vaHx delete mnt backup So our atomic live backup is done and we now no longer need our snapshot umount mnt fssconfig u fss0 Determine the directory structure of a system Manually run the file system checker and repair tool For FFS filesystems example in this case is the first slice on your first IDE hard disk fsck dev rwd0a The y option should be added with caution fsck 8 assumes yes as the default answer for all its questions Use it at your own risks View and modify file flags use chflags to modify file flags for example chflag uchange pkgsrc tar gz ls lo pkgsrc tar gz rw r r 1 zafer users uchg 32072480 May 19 09 12 pkgsrc tar gz Monitor the virtual memory system Users and Accounts Management Protect authentication data Create modify and remove user accounts create useradd m johndoe delete userdel johndoe modify usermod m d home foo johndoe Create a system account Control which files are copied to a new user s home directory during account creation The k option of the useradd 8 command can be used to specify a skeleton directory The contents of the specified skeleton directory will be copied to the new user s home directory If no skeleton directory is specified with k the default of usr skel is used Change a password The passwd 1 command can be used to change a password Executing passwd with no arguments will change the password of the executing user The existing password must be supplied before changes can be made The new password must be entered identically twice to ensure the password is not set to a misspelling of the intended password The process looks something like this note that passwords do not echo passwd Changing local password for user Old password New password Retype new password The superuser may change the password of an arbitrary user by supplying that user s name as the only argument to passwd Root does not need to supply the user s existing password and may simply supply a new one The process looks something like this passwd user Changing local password for user New password Retype new password Force the user to change their password upon next login usermod F johndoe Change the encryption algorithm used to encrypt the password database The encryption algorithm or algorithms used to encrypt the password database are specified in the passwd conf 5 file in etc The syntax of the file is straightforward and is made clear by the following example taken from the man page Use MD5 as the local cipher and old style DES as the YP cipher Use blowfish with 2 5 rounds for root default localcipher md5 ypcipher old root localcipher blowfish 5 The algorithm choices are old newsalt md5 sha1 and blowfish Consult the man page for details on allowable round parameters Change a user s default shell Make your market in etc shells file and pick up one For example we want to change the shell of johndoe to bin ksh chsh s bin ksh johndoe or chpass s bin ksh johndoe See chsh 1 for mor details Lock a user account or reset a locked user account Lock usermod C yes johndoe Unlock usermod C no johndoe Determine identity and group membership id Determine who is currently on the system or the last time a user was on the system Enter w to determine who is currently on the system Enter last to determine the last time a user was on the system Enable accounting and view system usage statistics Basic System Administration Determine which process are consuming the most CPU The top 1 command displays and regularly updates a list of top CPU consuming processes The list includes details such as the command used to create the process the user who ran that command the process PID what state the process is currently in and how much memory and CPU time the process is consuming View and send signals to active processes The ps 1 command can be used to view a list of names and details such as PID currently active processes Exactly which processes and what details about them are displayed can be customised using the options described in the man page To get the default details of all processes execute ps ax Sending signals to processes is done using the kill 1 command The signal to be sent may be specified either by name e g HUP INT QUIT ABRT KILL ALRM TERM see also kill l output or by an integer code as specified in the man page The simplest syntax for kill 1 is kill signal name or code pid where pid is the PID of the process to be killed Note that if no signal name or code is specified i e just kill pid is used then a TERM signal is sent by default Note that it is not typical to immediately know the PID of a process one wants to signal One can either use the ps 1 command as described above to find the pid perhaps with the assistance of grep 1 or one can use the pkill 1 command which works like kill 1 except that it accepts a process name rather than a PID Use an rc 8 script to determine if a service is running and start restart or stop it as required To see if a service is running execute that service s rc 8 script with an argument of status The output will indicate if that service is running Not all rc scripts have a status option For example etc rc d sshd status sshd is not running etc rc d sshd start etc rc d sshd status sshd is running as pid 383 etc rc d sshd stop Note that while every script in etc rc d is supposed to accept the status argument many do not If a service is not running it can be started by executing its rc 8 script with an argument of start Once a service is running it can be restarted or stopped in a similar manner using the arguments restart and stop Note that an rc script can not launch a service if this service is not marked as runable in etc rc conf via service YES entry Configure a service to start at boot time Add or copy the rc skript to etc rc d and then add the service to your etc rc conf View and configure system hardware View pci bus use pci0 2 pcictl dev pci0 list View load or unload a kernel module View modstat Load modload file Unload modunload i id See the manual page for lkm conf 5 for information on how to automatically load modules at boot time Please note that for this to work lkm YES must be set in etc rc conf Also note the critical filesystems local setting in rc conf 5 which may be required for bootloaded modules located under usr if usr is on a separate partition than Modify a kernel parameter on the fly sysctl w variable value View the status of a software RAID mirror or stripe Verify parity raidctl p raid0 dev rraid0c Parity status clean View configuration and state raidctl s raid0 raidctl 8 man page is very useful don t miss it Configure system logging Verify that syslogd 8 is running If not enable it in etc rc conf and launch it etc rc d syslogd start The logging daemon is configured with etc syslog conf see syslog conf 5 When you have modified this file you have to tell to the daemon to reread it pkill HUP syslogd by sending a SIGHUP If you add files in etc syslog conf don t forget to configure rotation in etc newsyslog conf newsyslog conf 5 If the original daemon s filtering features are too poor for you try sysutils syslog ng package To log signals sent to processes sysctl w kern logsigexit 1 Review log files to troubleshoot and monitor system behavior tail f var log messages grep daemon Try also these packages misc root tail or misc xtail if you use X11 misc colortail or misc mail if you want colors sysutils wtail or misc multitail to view multiples files Determine which MTA is being used on the system less etc mailer conf Create or modify email aliases for Sendmail or Postfix View the Sendmail or Postfix mail queue mailq Read mail on the local system mail Understand basic printer troubleshooting Halt reboot or bring the system to single user mode to halt enter shutdown h now to reboot enter either reboot or shutdown r now to bring the system to single user mode press any key during boot countdown and then enter boot s From multi user mode you should kill TERM 1 to return to single user mode Recognize the difference between hard and soft limits and modify existing resource limits Recognize common possibly third party server configuration files Configure the scripts that run periodically to perform various system maintenance tasks Determine the last system boot time and the workload on the system uptime or w Monitor disk input output iostat w 1 Deal with busy devices Determine information regarding the operating system uname a Understand the advantages of using a BSD license Network Administration Determine the current TCP IP settings on a system First see the interfaces which are connected ifconfig ls wm0 wm1 wm2 wm3 wm4 lo0 pflog0 vlan0 vlan1 vlan2 vlan3 To see the IP adress of an interface ifconfig vlan3 vlan3 flags 8843 UP BROADCAST RUNNING SIMPLEX MULTICAST mtu 1500 vlan 847 parent wm4 address 00 04 23 af f1 e4 inet 172

    Original URL path: http://wiki.netbsd.org/the_netbsd_system_manager__39__s_manual/ (2016-02-01)
    Open archived version from archive

  • tracking current
    module files at all If you would just like to test new features of a new kernel without updating kernel modules using MONOLITHIC kernel is easier way for the first and quick trial It s also a good idea to put an old MONOLITHIC kernel into root directory for emergency and recovery because if newer modules have some fatal issue there is no easy way to specify an alternative path of old module files to a modular ized kernel and you can t rename directories without a working kernel Warning The infrastructure of kernel module files mentioned here is still under discussion on current development It could be changed at some point before the next 6 0 release and in that case the description in this section will be obsolete Again check src UPDATING and currenet users mailing list for updated information There is a possible alternative structure for kernel modules which was proposed on May 2009 but we have not got any conclusion yet This would be because most current users build their own custom kernels from sources but kernel modules might be rather useful for users who don t want to bother to compile their own kernels from sources to just try to use optinal functions Anyway any feedback about this brandnew kernel modules is quite appreciated Reboot machine with the new kernel shutdown r now Make sure the new kernel boots and works properly If your new kernel has any trouble you can recover it by loading the renamed old one If you are using modular ized GENERIC kernel mentioned above you might also have to restore old kernel module files Extract the matching base and any other desirable feature sets except etc cd tar zxpf base tgz tar zxpf comp tgz Don t forget to specify p option preserve permissions on tar 1 command otherwise setuid ed commands like su 1 won t work Warning Extracting etc tgz on the installed system will overwrite your local settings Update etc as the last step postinstall 8 will first check and fix most things that can be automated and etcupdate 8 in the second step will ask on what to merge usr sbin postinstall s etc tgz check usr sbin postinstall s etc tgz fix usr sbin etcupdate s etc tgz shutdown r now If you have the X sets installed xbase you can repeat the postinstall and etcupdate steps with xetc tgz as argument before rebooting At this point you are relatively current and ready to build your own current source Downloading current source See the Obtaining the sources section in the NetBSD Guide Building a release from source See the Crosscompiling NetBSD section in the NetBSD Guide Updating an existing system from source See the Updating an existing system from sources section in the NetBSD Guide Updating the configuration and startup files See the More details about the updating of configuration and startup files section in the NetBSD Guide What if I get an error If you try to build current either from a snapshot or an earlier current and it doesn t work don t panic Try these steps Read the src UPDATING file from the release you re trying to build Read the current users archive for hints Update again You may have caught the repository in the middle of a commit to several related files or the problem might have already been fixed If all else fails send email to current users explaining the problem Include the date time and method you used to get your current sources as well as any local changes you ve made Then put in a short script that includes the error messages you re getting Somebody will probably fix the problem momentarily Tracking NetBSD current with anoncvs See the Fetching by CVS section in the NetBSD Guide To check out the sources from a certain date cvs checkout D 20020501 UTC src To check out the sources from a certain branch cvs checkout rnetbsd 5 0 src See src doc BRANCHES for a description of the branches in the CVS repository Useful hints Do not use the cvs z flag The data stream gets out of sync leading to corruption on the client or causing the client to hang completely The additional load is also hard on the cvs server If you want to check out a certain branch of the tree you may want to take caution not to overwrite any existing directories by creating a new directory for this branch cd parent dir to checkout into mkdir NewName temp cd NewName temp cvs checkout src mv src NewName cd rmdir NewName temp You will have to use objdirs in order for cvs updates to work correctly If you happen to get errors from cvs saying things like cvs update aborted could not chdir to gnu usr bin gdb gdb Not a directory You should do a make cleandir and try again Make sure to run make obj after the cvs update You can put switches for specific commands in a cvsrc in your home directory and they will be automatically used A sample cvsrc would be update dP checkout P diff u Importing and merging sources Sources are imported as follows cvs d misc cvsrep import I I CVS netbsd netbsd current date date is replaced by the date of the SUP for tracking purposes The I I CVS options ensure that no file in the source tree is ignored except CVS directories This is because some NetBSD source files have extensions which are normally ignored by CVS If there are any conflicts with local patches the import command will report them and will describe a command to merge the conflicts something like cvs checkout jnetbsd yesterday jnetbsd netbsd This merge command will correctly merge the imported NetBSD sources but it will not handle the removal of files locally which have already been removed by the SUP process To do this the merge command would

    Original URL path: http://wiki.netbsd.org/tracking_current/ (2016-02-01)
    Open archived version from archive

  • altqd traffic shaping example
    conf We have a 5mbit link to our ISP over a fiber ethernet connection interface bge0 bandwidth 5M priq Create a class for important traffic class priq bge0 high class NULL priority 2 We raise the priority of all UDP traffic The only significant type we will see is VoIP and that should be fine filter bge0 high class 0 0 0 0 17 All other traffic is lower priority than VoIP class priq bge0 low class NULL priority 0 default What the config file meant Okay let s face it The configuration is somewhat less than straightforward So let s break down what we did interface bge0 bandwidth 5M priq This line says that we intend on using a the first broadcom ethernet interaface as the outgoing WAN interface to shape the traffic on In order for for ALTQ algorithms to work most of them need to know how much bandwidth that line has Even though that interface is capable of 1000mbit it s a gigabit copper port it s connected to a fiber optic media converter which is connected to my ISP The ISP only gives me the capability to transmit at 5mbit So I don t want ALTQ to assume we are dealing with a gigabit link here Otherwise I suspect our shaping rules wouldn t work at all Also you ll notice that I keep talking about this being the WAN interface Shaping traffic on the LAN interface of this firewall it does NAT using IP filter might work as well However I prefer to shape it at the last possible moment before it leaves my control The authors of the altq conf 4 man page seem to agree with this approach class priq bge0 high class NULL priority 2 This line says that we want to create a new parent class for ALTQ The parent class tells ALTQ what kind of shaping we ll be doing In this case it s priq which is shorthand for priority queuing This algorithm makes sure that network buffers with my chosen type of traffic will be separated out by using filters and the ones with higher priorities will be emptied first Moving on we see that the class applies to the interface bge0 which is good since we just defined that above Next is a simple user defined label for this class I chose the string high class so it would be clear You can call it anything you want I could have chose voip class or udp traffic It doesn t matter You ll notice the next item is NULL That s because this class is a parent class and thus it has no parent class of it s own The man page was helpful enough to tell me what to use there The last two items priority 2 are pretty clear I m simply telling this class what priority it is The higher the value the more priority it has In most cases I believe you

    Original URL path: http://wiki.netbsd.org/tutorials/altqd_traffic_shaping_example/ (2016-02-01)
    Open archived version from archive

  • Creating atf-based tests for NetBSD src
    the directory using the templates below Edit the parent Makefile to recurse into the new subdirectory Edit src etc mtree NetBSD dist tests to register the new subdirectory Your test will be installed under usr tests Edit src distrib sets lists tests mi to register the new test program Do not forget to add debug entries if your test program is a C C binary Makefile template Follow this template to create your Makefile include bsd own mk This must always be defined TESTSDIR TESTSBASE bin ls These correspond to the test programs you have in the directory TESTS C c1 test c2 test Correspond to c1 test c and c2 test c TESTS SH sh1 test sh2 test Correspond to sh1 test c and sh2 test c Define only if your tests need any data files FILESDIR TESTSDIR FILES testdata1 txt testdata2 bin Any necessary data files include bsd test mk Atffile template Atffiles are automatically generated by bsd test mk so in general you will not have to deal with them What is an Atffile An Atffile is the atf run counterpart of a Makefile Given that atf tests do not rely on a toolchain they cannot use make 1 to script their execution as the old tests in src regress did The Atffiles in general just provide a list of test programs in a particular directory and the list of the subdirectories to descend into If you have to provide an Atffile explicitly because the automatic generation does not suit your needs follow this format Content Type application X atf atffile version 1 prop test suite NetBSD tp first test tp second test tp glob optional test tp subdir1 tp subdir2 C test programs Template The following code snippet provides a C test program with two test cases The specific details as to how this works follow later include atf c h ATF TC tc my test case ATF TC HEAD tc my test case atf tc set md var tc descr This test case ensures that ATF TC BODY tc my test case ATF CHECK true Success continue execution ATF CHECK false Failure continue execution ATF CHECK EQ 5 2 2 Failure continue execution ATF REQUIRE EQ 5 2 2 Failure abort execution if condition atf tc fail Condition not met Abort execution ATF TC tc another test case ATF TC HEAD tc another test case atf tc set md var tc descr This test case ensures that ATF TC BODY tc another test case Do more tests here ATF TP ADD TCS tp ATF TP ADD TC tp my test case ATF TP ADD TC tp another test case This program needs to be built with the Makefile shown below Once built the program automatically gains a main method that provides a consistent user interface to all test programs You are simply not intended to provide your own main method nor to deal with the command line of the invocation How to build To build a C test program append the name of the test program without the c extension to the TESTS C variable in the Makefile For example include bsd own mk TESTSDIR TESTSBASE bin ls TESTS C fs test ui test include bsd test mk Common functions The following functions are commonly used from within a test case body ATF REQUIRE boolean expression Checks if the given boolean expression is true and if not aborts execution and marks the test as failed Similarly ATF CHECK performs the same test but does not abort execution it records the failure but keeps processing the test case For an explanation on when to use which refer to the FAQ question below ATF REQUIRE EQ expected expression actual expression Checks if the two expressions match and if not aborts marking the test as failed Similarly ATF CHECK EQ records the error but does not abort execution ATF REQUIRE STREQ expected string actual string Same as ATF REQUIRE EQ but performs string comparisons with strcmp atf tc skip const char format Marks the test case as skipped with the provided reason and exits atf tc fail const char format Marks the test case as failed with the provided reason and exits atf tc pass void Explicitly marks the test case as passed This is implied when the test case function ends so you should not use this in general atf expect fail const char format Tells the atf runtime that the code following this call is expected to raise one or more failures be it with atf tc fail ATF REQUIRE etc Use this to mark a block of code that is known to be broken e g a test that reproduces a known bug Use the string parameter to provide an explanation about why the code is broken if possible provide a PR number Lastly to terminate the expected failure code block and reset the runtime to the default functionality use the atf expect pass function atf expect death const char format Same as atf expect fail but expects an abrupt termination of the test case be it due to a call to exit or to the reception of a signal atf expect exit int exitcode const char format Same as atf expect fail but expects the test case to exit with a specific exitcode Provide 1 to indicate any exit code atf expect signal int signo const char format Same as atf expect fail but expects the test case to receive a specific signal Provide 1 to indicate any signal atf expect timeout const char reason Same as atf expect fail but expects the test case to get stuck and time out atf tc get config var srcdir Returns the path to the directory containing the test program binary This must be used to locate any data auxiliary files stored alongside the binary RL integer expression integer Used to evaluate a call to a libc function that updates errno when it returns an error and

    Original URL path: http://wiki.netbsd.org/tutorials/atf/ (2016-02-01)
    Open archived version from archive

  • bus space tutorial
    bit registers 16 bytes Other configuration registers irrelevant Our hardware technical details memory mapped register set Advanced Addition Acceleration registers Register Name Offset Description COMMAND 0x4 Register used to issue commands to the engine DATA 0x8 Register used to load data to internal engine registers RESULT 0xC Register used to store the result of arithmetic operation COMMAND register Bit R W Description 0 W Execute ADD operation on values loaded into internal register A and B 1 R W Select internal register A for access through DATA register 2 R W Select internal register B for access through DATA register Selecting internal register A and B at the same time will lead to undefined behaviour Our hardware technical details memory mapped register set DATA register Bit R W Description 0 31 R W Read write the value in internal engine register RESULT register Bit R W Description 0 31 R Holds the result of last ADD operation Our hardware technical details operation algorithm Select the internal register A for access write 0x2 into COMMAND register Write the first number into DATA register Select the internal register B for access write 0x4 into COMMAND register Write the second number into DATA register Issue the ADD operation write 0x1 into COMMAND register Read the result from RESULT register Adding a new driver to the NetBSD kernel We ll discuss the steps needed to add a new MI PCI device driver to the NetBSD kernel Add the vendor and device ID to the database of PCI IDs Create a set of the driver source files in src sys dev BUSNAME Add the new driver to src sys dev BUSNAME BUSNAME files file Add the new driver to DEVNAMES file Required if you are NetBSD developer optional otherwise Modifying the PCI device database unmatched vendor 0xfabc product 0x0001 Co processor processor revision 0x01 at pci0 dev 12 function 0 not configured The kernel does not know anything about this vendor and device Add it to the PCI device database src sys dev pci pcidevs vendor VENDORNAME 0xVENDORID Long Vendor Name product VENDORNAME PRODUCTNAME 0xPRODUCTID Long Product Name To regenerate pcidevs h run awk f devlist2h awk pcidevs or Makefile pcidevs if you re on NetBSD Modifying the PCI device database example pcidevs 29 Sep 2012 10 26 14 0000 1 1139 pcidevs 5 Oct 2012 08 52 59 0000 669 6 669 7 vendor CHRYSALIS 0xcafe Chrysalis ITS vendor MIDDLE DIGITAL 0xdeaf Middle Digital vendor ARC 0xedd8 ARC Logic vendor FAKECARDS 0xfabc Fake Cards vendor INVALID 0xffff INVALID VENDOR ID 2120 6 2121 9 Eumitcom products product EUMITCOM WL11000P 0x1100 WL11000P PCI WaveLAN IEEE 802 11 FakeCards products product FAKECARDS AAA 0x0001 Advanced Addition Accelerator O2 Micro product O2MICRO 00F7 0x00f7 Integrated OHCI IEEE 1394 Host Controller product O2MICRO OZ6729 0x6729 OZ6729 PCI PCMCIA Bridge Modifying the PCI device database example Fake Cards Advanced Addition Accelerator Co processor processor revision 0x01 at pci0 dev 12 function 0 not configured Now the kernel knows the vendor and product ID But there s still no driver for this device Adding the new PCI driver Choose a name short easy to remember avoid numbers faa looks like a good name but you can choose any name you like Create a set of new files in src sys dev pci faa c main driver code faareg h register definitions Might not exist if the driver is only a simple passthrough from a specific bus to another MI driver faavar h driver structures and functions used in other parts of the kernel Omitted if not needed Modify driver definitions src sys dev pci files pci src sys dev DEVNAMES Configure the kernel to use the newly added driver src sys arch PORTNAME conf GENERIC Adding the new PCI driver main driver Kernel includes are at the beginning followed by machine specific and bus specific includes Should also include faareg h and faavar h files A minimal driver needs just two functions faa match or faa probe for some buses faa attach The CFATTACH DECL NEW macro plugs the above functions into autoconf 9 mechanism Adding the new PCI driver main driver static int faa match device t parent cfdata t match void aux Check if the driver should attach to a given device for example in case of PCI bus it will be used to check vendor and product ID parent pointer to parent s driver device structure match pointer to autoconf 9 details structure aux despite the name the most important argument usually contains bus specific structure describing device details static void faa attach device t parent device t self void aux Attach the driver to a given device parent same as with match function self pointer to driver s device structure aux same as with match function See definitions of these functions in the driver 9 man page Adding the new PCI driver main driver cont d CFATTACH DECL NEW faa sizeof struct faa softc faa match faa attach NULL NULL driver name size of softc structure containing state of driver s instance match probe function attach function detach function activate function The NEW name is unfortunate Pass NULL for unimplemented functions We won t cover detach and activate now as they are not needed for a simple driver Adding the new PCI driver main driver example src sys dev pci faa c include sys cdefs h KERNEL RCSID 0 NetBSD bus space tutorial mdwn v 1 12 2013 06 29 12 41 13 ryoon Exp include sys param h include sys device h include dev pci pcivar h include dev pci pcidevs h include dev pci faareg h include dev pci faavar h static int faa match device t cfdata t void static void faa attach device t device t void CFATTACH DECL NEW faa sizeof struct faa softc faa match faa attach NULL NULL static int faa match device t parent cfdata t match void aux return 0 static void faa attach device t parent device t self void aux Adding the new PCI driver auxiliary includes src sys dev pci faareg h ifndef FAAREG H define FAAREG H Registers are defined using preprocessor define FAA REGNAME 0x0 We ll add them later let s leave it empty for now endif FAAREG H src sys dev pci faavar h ifndef FAAVAR H define FAAVAR H sc dev is an absolute minimum we ll add more later struct faa softc device t sc dev endif FAAVAR H Adding the new PCI driver registering the driver courtesy src sys dev DEVNAMES DEVNAMES 1 Sep 2012 11 19 58 0000 1 279 DEVNAMES 6 Oct 2012 19 59 06 0000 436 6 436 7 ex MI exphy MI ezload MI Attribute faa MI fb luna68k fb news68k fb newsmips Adding the new PCI driver registering the driver See config 5 src sys dev pci files pci pci files pci 2 Aug 2012 00 17 44 0000 1 360 pci files pci 6 Oct 2012 19 59 10 0000 1122 3 1122 9 device tdvfb wsemuldisplaydev rasops8 vcons videomode attach tdvfb at pci file dev pci tdvfb c tdvfb FakeCards Advanced Addition Accelerator device faa attach faa at pci file dev pci faa c faa Adding the new PCI driver to the kernel configuration src sys arch cobalt conf GENERIC GENERIC 10 Mar 2012 21 51 50 0000 1 134 GENERIC 6 Oct 2012 20 12 37 0000 302 6 302 9 fms at pci dev function Forte Media FM801 sv at pci dev function S3 SonicVibes Fake Cards Advanced Addition Accelerator faa at pci dev function Audio support audio at audiobus The above definition means that an instance of faa may be attached to any PCI bus any device any function The exact position of the rule in the configuration file is not important in this case See config 5 for a description of the device definition language Adding the new PCI driver example The driver should compile now The driver s match function will check if the driver is able to work with a given device Since it is not implemented the kernel will not attach the driver Matching the PCI device Modify the faa match function to match the specified PCI device Use PCI VENDOR and PCI PRODUCT macros to obtain the IDs static int faa match device t parent cfdata t match void aux const struct pci attach args pa const struct pci attach args aux if PCI VENDOR pa pa id PCI VENDOR FAKECARDS PCI PRODUCT pa pa id PCI PRODUCT FAKECARDS AAA return 1 return 0 Attaching to the PCI device faa0 at pci0 dev 12 function 0 The driver has successfully matched and attached to the PCI device but still is not doing anything useful Let s fill the attach function and actually program the hardware Variable types used with bus space bus space tag t type used to describe a particular bus usually passed to the driver from MI bus structures bus space handle t used to describe a mapped range of bus space usually created with the bus space map function bus addr t address on the bus bus size t an amount of space on the bus Contents of these types are MD so avoid modifying from within the driver although you ll often have to use bus size t Why do we need to map the resources The bus space must be mapped before it can be used and should be unmapped when it is no longer needed It s a machine dependent process but it s also conveniently hidden from the programmer by the bus space framework Mapping the hardware resources The generic bus space 9 way to map space bus space map bus space tag t space bus addr t address bus size t size int flags bus space handle t handlep bus space map creates a mapping from the physical address to a kernel virtual address space represents the bus on which the mapping will be created address typically represents the physical address for which a mapping will be created size describes the amount of bus space to be mapped handlep pointer to mapped space filled after successful mapping Separate space and address Mapping the hardware resources The PCI specific way to map space pci mapreg map const struct pci attach args pa int reg pcireg t type int busflags bus space tag t tagp bus space handle t handlep bus addr t basep bus size t sizep pci mapreg map creates mapping from physical address present in specified BAR register to kernel virtual address pa struct describing PCI attachment details passed through aux reg BAR register number type Select mapping type I O memory busflags Passed to bbus space map flags argument tagp pointer to bus space tag handlep pointer to a mapped space basep address of a mapped space sizep size of mapped space equivalent to BAR size The last four parameters are filled after successful mapping Mapping the registers using BAR adding auxiliary includes src sys dev pci faareg h define FAA MMREG BAR 0x10 src sys dev pci faavar h struct faa softc device t sc dev bus space tag t sc regt bus space handle t sc regh bus addr t sc reg pa Mapping the registers using BAR main driver code src sys dev pci faa c static void faa attach device t parent device t self void aux struct faa softc sc device private self const struct pci attach args pa aux sc sc dev self pci aprint devinfo pa NULL if pci mapreg map pa FAA MMREG BAR PCI MAPREG TYPE MEM 0 sc sc regt sc sc regh sc sc reg pa 0 0 aprint error dev sc sc dev can t map the BAR n return aprint normal dev sc sc dev regs at 0x 08x n uint32 t sc sc reg pa Accessing the hardware registers The bus space read and bus space write functions are basic methods of reading and writing the hardware registers uintX t bus space read X bus space tag t space bus space handle t handle bus size t offset void bus space write X bus space tag t space bus space handle t handle bus size t offset uintX t value space tag describing the bus handle describes the exact location on the bus where read write should occur this handle is obtained by bus space map offset offset from handle location The read function returns the data read from the specified location while write has an argument value which should be filled with data to be written Variants of bus space read and bus space write Data Read function Write function 8 bitb bus space read 1 bus space write 1 16 bit bus space read 2 bus space write 2 32 bit bus space read 4 bus space write 4 64 bit bus space read 8 bus space write 8 There are many more variants of read and write functions and they are useful in certain situations see the bus space 9 man page Accessing the hardware registers example Create a function that will write a value into the DATA register of our device then read it back and check if the value is the same as written Define the DATA register in the driver src sys dev pci faareg h define FAA DATA 0x8 define FAA COMMAND 0x4 define FAA COMMAND STORE A BIT 1 Define the new function in main driver code static bool faa check struct faa softc sc Accessing the hardware registers example src sys dev pci faa c static void faa attach device t parent device t self void aux if faa check sc aprint error dev sc sc dev hardware not responding n return static bool faa check struct faa softc sc uint32 t testval 0xff11ee22 bus space write 4 sc sc regt sc sc regh FAA COMMAND FAA COMMAND STORE A bus space write 4 sc sc regt sc sc regh FAA DATA testval if bus space read 4 sc sc regt sc sc regh FAA DATA testval return true return false Accessing the hardware registers running the example Update the kernel binary and run it again Check the GXemul log faa COMMAND register 0x4 WRITE value 0x2 faa DATA register 0x8 WRITE value 0xff11ee22 faa DATA register 0x8 READ value 0xff11ee22 GXemul will conveniently display all accesses to our device The faa driver still does attach without error which means that the check function is working properly faa0 at pci0 dev 12 function 0 Fake Cards Advanced Addition Accelerator rev 0x01 faa0 registers at 0x10110000 Implementing addition using the hardware The basic principle of device operation should be laid out in the data sheet We need to implement an algorithm based on this description Writing such an algorithm is often not needed since the NetBSD kernel already has frameworks for common device types such as atabus wd for IDE and SATA hard disk controllers wsdisplay wscons for frame buffers etc Implementing addition using the hardware Define all registers src sys dev pci faareg h define FAA STATUS 0x0 define FAA COMMAND 0x4 define FAA COMMAND ADD BIT 0 define FAA COMMAND STORE A BIT 1 define FAA COMMAND STORE B BIT 2 define FAA DATA 0x8 define FAA RESULT 0xC Implementing addition using the hardware Add a new function to the main driver code src sys dev pci faa c static void faa attach device t parent device t self void aux aprint normal dev sc sc dev just checking 1 2 d n faa add sc 1 2 static uint32 t faa add struct faa softc sc uint32 t a uint32 t b bus space write 4 sc sc regt sc sc regh FAA COMMAND FAA COMMAND STORE A bus space write 4 sc sc regt sc sc regh FAA DATA a bus space write 4 sc sc regt sc sc regh FAA COMMAND FAA COMMAND STORE B bus space write 4 sc sc regt sc sc regh FAA DATA b bus space write 4 sc sc regt sc sc regh FAA COMMAND FAA COMMAND ADD return bus space read 4 sc sc regt sc sc regh FAA RESULT Implementing addition using the hardware running the example Update the kernel binary and run it again Check GXemul log faa COMMAND register 0x4 WRITE value 0x2 faa DATA register 0x8 WRITE value 0x1 faa COMMAND register 0x4 WRITE value 0x4 faa DATA register 0x8 WRITE value 0x2 faa COMMAND register 0x4 WRITE value 0x1 faa RESULT register 0xC READ value 0x3 Looks like it worked faa0 at pci0 dev 12 function 0 Fake Cards Advanced Addition Accelerator rev 0x01 faa0 registers at 0x10110000 faa0 just checking 1 2 3 Interacting with userspace The kernel user space interface Now that the core functionality of the kernel driver is working it should be exposed to user space The interface between kernel driver and userspace can be designed in many different ways The classic UNIX way of interfacing between the kernel and user space is a device file Even when using device files there is no single interfacing method that fits all use cases It s up to the programmer to define the communication protocol Device files crw r 1 root wheel 101 1 Aug 12 21 53 dev file The kernel identifies which driver should service the request to this file by using major and minor numbers 101 and 1 in the example above The major number identifies the driver The minor number usually identifies the driver instance although the driver is free to use it in any other way In NetBSD device files are created statically By the MAKEDEV script during installation or boot Manually by using the mknod utility Operations on device files open 2 and close 2 read 2 and write 2 ioctl 2 poll 2 mmap 2 and more Any mix of the above system calls

    Original URL path: http://wiki.netbsd.org/tutorials/bus_space_tutorial/ (2016-02-01)
    Open archived version from archive