brickos-0.9.0/0000775000175000017500000000000010517714033010711 5ustar cbcbbrickos-0.9.0/README0000644000175000017500000000306510173101721011563 0ustar cbcbHello, this is brickOS-0.9.0 This software will run on Linux and Windows (using the Cygwin tool suite.) To start with brickOS: - Type ./configure. Environment should be autodetected (hopefully). - Type make. Utilities, libraries, a default kernel and some demos will be made. - Pre-packaged binaries have been discontinued. - Be sure to add brickOS-0.9.0/util to your PATH. Set RCXTTY if you use a non- standard port for the IR tower. Use firmdl3 to download boot/brickOS.srec to your RCX. - Type "dll demo/helloworld.lx". If all is well, it should be automatically relocated and transmitted to program slot 1. Press the RUN key to run. The program stops automatically. - Type "dll -p2 demo/rover.lx" to transmit another demo to program slot 2. Use the PRGM key to select the desired program. Try RUN. - Stop your program with the RUN or ON/OFF key. Programs are preserved over ON/OFF. Press ON/OFF and PRGM simultaneously to erase brickOS. If things don't quite work, work at it. For your own projects, - Make a directory in the brickOS root directory. - Copy Makefile from the demo directory. - Put your main routine into myproject.c. (.C if using C++) - If you need more source files, add them in the Makefile. - "make myproject.lx && dll myproject.lx". In case anyone is wondering, dll is short for dynamic linker and loader. For more documentation, see in docs on the web at http://brickOS.sourceforge.net/HOWTO/ ------------------------------------------------------------------------ legOS/brickOS Copyright (C) 1998-2005 by Markus L. Noga brickos-0.9.0/ChangeLog0000644000175000017500000004140210173101721012452 0ustar cbcb2005-01-17 Stephen M Moraco * Releasing current state as 0.9.0 - coincident with a lnpd-0.9.0 release. Both of these for eval. prior to official 1.0.0 release. Things needing to be fixed in 0.9.0 will be fixed in order to create v1.0.0 * Updated Doxygen control file with current release number * Added README.usb describing Linux USB IR Tower use 2004-11-17 Stephen M Moraco * Finished USB Tower support on Linux (dll, firmdl3) (See built-in help on each utility.) 2004-02-16 Stephen M Moraco * Added new index.html page to installed docs * Fixed generation of installed Makefile.common had to adjust filter removing all:: target so does not check for ensure configured (add of depend to all caused this target to no-longer be removed, is now) 2004-02-15 Stephen M Moraco * fixed lib/float/divsf3.s (Univ. submittal, see source file) 2004-01-25 Henner Zeller * add new form of new/delete operators (gcc-3.x caused this). * disable c++ RTTI and Exception Handling via compile directives 2004-01-25 Stephen M Moraco * Applied Patch: #747434 - configure now uses sh vs. bash * Applied Patch: #766164 - cast away asm 'const' for gcc-3.x * Fixed Bug #612161 - adjusted tid_t to signed return value * Adjusted configure to work with new Debian Tool-chain * Removed ^M's from demo sources, corrected warning messages * Removed multi-line use in #error in boot/config.h 2004-01-02 Henner Zeller * Fixed Bug #835433 - install problem: multiline asm vs. new gcc * Fixed Bug #766169 - kernel/systime.c spurious ^Ms * Fixed Bug #766168 - kernel_critsec_count volatility * Implement Feature Request #686495 - added on/off sound * add sem_timedwait() * externalized atomic counting in atomic.[hc]; introduce new type atomic_t * semaphores and critical sections make use of atomic_t * do some cleanup in unistd.h: not all functions were available if !CONF_TM 2003-03-02 Paolo Masetti * Fixed util\makefile(s). Now "make strip" works. * Revised doc/INSTALL-cygwin.sgml to reflect actual release. * Added ./configure step in README. * Changed filename in comments for demo/rover.c. 2003-02-24 Stephen M Moraco * Adjusted motor direction display on LCD (fix brake display) 2003-02-16 Mark Riley * Improvements to high memory Patch 638513 * Improved motor handler to allow full speed operation. Previously, every 256ms the outputs would float for 1ms when setting the motor speed to maximum: motor_a_speed(MAX_SPEED) * Moved motor handler to high memory 2003-02-13 Stephen M Moraco * Applied Patches. For more detail on each, see the closed patches still on file at the brickOS sourceforge project web * Applied Patch 638513: Make use of high memory (Mech. only) (the patch moved mm routines to high mem. This is not yet decided, so no routines are moved, yet.) * Applied Patch 651692: Add setjmp/longjmp (ANSI C support) * Applied Patch 668115: Make brickOS work with up-to-date binutils * Applied Patch 673995: Patch brickos 0.2.6.09 for *BSD * Fixed bug 666378: Motors still running when RCX turned off (applied fix described in bug report at site.) 2003-01-11 Ed Manlove * Modified makedepend to $(MAKEDEPEND) in lib/*/Makefiles 2002-12-13 Joseph A Woolley * Update system time so that motor controller is called every 1ms as in previous version 2002-11-07 Stephen M Moraco * Adjusted configure to prevent false detect of directory as compiler 2002-10-22 Stephen M Moraco * Converted Makefile.common and rest of makefiles to support the new ./configure utility * Use of ./configure is now required 2002-10-16 Stephen M Moraco * Move Makefile.kernel into boot/Makefile (was only consumer) * Finish install targets, add uninstall target * Generate & install installed forms of included and demo makefiles (generate by filtering existing then installing) 2002-10-15 Stephen M Moraco * 2nd pass at cleaning up Makefiles - added build/install of all docs as targets separate from normal brickOS build/install - enabled 'make tag' from top Makefile * Install of headers and brickOS itself is all that remains to be done in next make update * Merge util/Makefile.common into top Makefile.common - rework util/ Makefiles to use top Makefile.common 2002-10-11 Joseph A Woolley * Added locked_increment and locked_decrement to inc/dec an unsigned char value; interrupt safe. Added locked_check_and_increment function; used by enter_critical_section. * Added critsec.c, critsec.h and sys/critsec.h to implement critical sections. * Added a 'kernel critical section' that can be used in the kernel to keep the task swapper from switching tasks. This is a simple and 'cost effective' way to manage critical resources. This prevents a task from being killed while in a critical region of code. It also keeps two tasks from modifying kernel structures at the same time. This replaces the use of semaphores which don't support nesting and cannot be used while in the task manager while swapping. A task should never yield, sleep or exit while in a critical section; whether kernel or user level. * Replaced semaphore in task manager with critical section. * Replaced semaphore in memory manager with critical section. * Added definitions for the Control Status Register (CSR) for the Watch Dog Timer (WDT) and the Counter Register (CNT) for the WDT. * Seperated sys_time increment code from the systime_handler and attached sys_time clock to the WDT. This is configured to use the NMI, so clock should be more accurate. Named sys_time handler 'clock_handler'. * Seperated sub-systems from task switcher in systime.c and called sub-system handler 'subsystem_handler'. The sub-system handler will call the task switcher handler * Named the task switcher handler 'task_switch_handler'. * Attached task switcher handler to OCA of the 16 bit timer and subsystem handler to OCB of the 16 bit timer. The OCA and OCB interrupts can be configured at different intervals, however, they are linked. The timer will reset on A, so B will be delayed until A is reached, then the timer is reset and B can be reached again. B must be less than A or B will never be reached. Currenty, A and B alternate every msec. * Adjusted the lnp_timeout_counter, auto_shutoff_counter, vis_refresh_counter and lcd_refresh_counter; (cut in half) since the subsystem_handler is only called once every two msecs. * The task switcher is checked every msec since direct modification of the timeslice counter can be used to tweak task wake-up. msleep currently does this to allow wakeup to interrupt lower priority tasks mid-slice. * Removed another static buffer used by LNP. Instead, I Added code to malloc and free the memory as needed. Added #ifdef blocks to resort back to static buffers if CONF_MM is not defined. 2002-10-11 Stephen M Moraco * First pass at cleaning up Makefiles by normalizing subdirectory handling, and adding install targets. * There are a couple more Makefiles to update before thie is done. 2002-09-25 Stephen M Moraco * Awakened API doc for Kernel Developers * Added Demo pages to each API set * Upgraded control files to New Doxygen Version 2002-09-23 Joseph A Woolley * Removed static buffer in program.c that is used to copy lnp packets. Instead, malloc and free buffer as needed. 2002-09-22 Stephen M Moraco * NEW add LEGO Lamp support for C++ * NEW added demo/c++/lampTest.C as example * 2nd wave of API documentation updates 2002-09-20 Joseph A Woolley * Added support for "safe-shutdown" of tasks. Updated tm, mm, program, semaphore and a few others. Updated demos. * Look in demo programs for examples of new code usage. 2002-09-04 Stephen M Moraco * First wave of internal comment updates for Doxygen extraction of API documentation This round included (1) upgrade of Doxygen control files (2) revision of file brief descriptions, and (3) excluding of __asm__ code blocks from the generated HTML API docs. 2002-09-01 Stephen M Moraco * Remove legOS from Makefiles and doxygen files * Add Linux/Debian support to Makefile.common * Prep as 1st brickos test release 2002-08-28 Joseph Woolley * Updated comments, code and data structures to refer to tasks instead of threads and processes. * Added menu choice for modifying LNP Host Address at run-time. * Added menu choice to delete current program. * Added low priority task to animate man (while program running) and to show/hide the battery low indicator. * Updated execi and tm_switcher to keep a tally of the number of kernel tasks at run-time. This value is used to determine if any user tasks are running. * Updated comments from LegOS to BrickOS and from LegOS Network Protocol to Link Network Protocol (unofficial) * Fixed minor bug in mm_try_join for "end-of-memory" condition. Previously unchecked, the pointer would wrap around into kernel memory; producing undefined behaviour. * Updated killall so only user tasks or all tasks are killed. * Added T_IDLE flag to indicate which task is the idle task. Removed now-unnecessary idle_task global variable. * Modified tm_sleep_wakeup so tasks will interupt lower priority tasks when wakeup time is between time-slices. 2002-08-21 Stephen M Moraco * Changes to loader utils to support new internal name * Changes to .lx image to contain brickos vs. legos * Makefile changes to generate brickos files vs. legos 2002-08-21 Ted Hess * Allow setting LNP Host address at build or load-time - Specify LNP_HOSTADDR=n on make command-line (0 .. N) - Use dll option --node={hostaddress} or -n{hostaddress} Note: CONF_LNP_HOSTADDR in config.h is now a small integer instead of shifted mask * fix LEGOS_ROOT macro to work in sub-directory (makefile) * added $CDEFINES macro for compile-time defines (makefile) * minor fixes for various config option combinations to build properly * added CMDsethost to dll protocol to set host addrs * use Win32 device name for USB tower on Win32 * updated man page for new dll options 2002-05-05 Stephen M Moraco * Applied Patch #552135: RCX Remote control support + misc fixes: animated figure (doesn't fidget anymore), dll Program numbers now consistent (1 - 8), LCD display of motor dir during braking now correct, cputc_native_xxx macros now allow expression as arg, and dll now allows delete of program. * small adjustments to two demos * This effectively removes the prior IR Remote implementation as it is now a blend of the two patched approaches * Added new config settings: CONF_RCX_PROTOCOL // RCX protocol handler (lnp) CONF_LR_HANDLER // Remote control button event dispatcher CONF_RCX_MESSAGE // Standard firmare message functions Which replaced the following settings: CONF_REMOTE_CTRL // remote control CONF_RKEY_HANDLER // remote control keys handler CONF_RKEY_MOTOR // remote control motor CONF_MESSAGE // standard firmware message 2002-04-28 Stephen M Moraco * Added Motor control to complete implementation of Patch #475185: Remote Control & Standard Message Patch * Cleaned up Makefile.user targets (much more to do) 2002-04-26 Paolo Masetti * demo/c++: Added .cvsignore file 2002-04-23 Stephen M Moraco * Apply Patch #475185: Remote Control & Standard Message Patch * Move from NUM_SYSTEM_THREADS to NUM_SYSTEM_TASKS 2002-04-22 Stephen M Moraco * Apply Patch #403527: LNP checksum optimizations * Apply Patch #403728: LNP optimizations versus CVS * Apply Patch #545860: race conditions fix in LNP 2002-04-19 Stephen M Moraco * Version number bump to 0.2.6 - Official Release * Moved some ChangeLog content to NEWS, updates in NEWS * Updated CONTRIBUTERS * Removed some old text from TODO, added new 2002-04-17 Stephen M Moraco * Version number bump to 0.2.5.3 - next release candidate * README: added version number to directory name in instru. * Makefile: Added cygwin on WinXP detection (in util dir) * Makefile: added remove of dll-src/.depend on clean 2002-04-17 Paolo Masetti * Makefile: Added cygwin on WinXP detection * lnp.c: fixed a problem vs lnp.h * dsensor.c: fixed a badly formatted comment/syntax error 2002-04-11 Stephen M Moraco * Makefile: Added TODO to list of files in distribution (missed it on first attempt) * Add HOWTO source to complete addition of docs for this release * Version number bump to 0.2.5.2 - next release candidate 2002-04-08 Paolo Masetti * rcxtty.c: Parity patch by Michael Obenland 2002-04-04 Stephen M Moraco * Makefile.Common: Added HMSTOOLDIR so Debian GNU/Linux users can build the code with: export HMSTOOLDIR=/usr;make -e * TODO, NEWS, README, VERSION updating in prep for release 2002-04-01 Paolo Masetti * Makefile.Common: Using $(shell uname) if $OSTYPE is undefined * Cygwin B-20 / Cygwin 1.x: Added support for both environment with some limitation for B-20 (printf.c) * utils: Changed Makefile avoiding duplicate generation of executables * firmdl3 / dll: Added USB support (WIN32) Patches by Hary D. Mahesan 09/27/01 Edited & CVS merged by paolom 2002-03-30 Stephen M Moraco * THIS IS A COLLECTION OF ALL CHANGES IN CVS since 0.2.5 it therefore does not reflect who did the work and when in the future we will -Stephen * Fix BUG #228723: makelx out-of-bounds check bad on c++ * Fix BUG #226789: Remove -u use to fix build on BSD * Added Manpage source files dll.1 & firmdl3.1 * Add C++ TemperatureSensor Class * Add 3 new C++ demos: rotation.velocity.Sensor.C temperatureSensor.C touch.pressed.Sensor.C * dll: add default of /dev/ttyb for Sun (serial port B) * dll: added -d switch to display sizes during run * util/dll-src/Makefile: remove need for symlink in tarball (symlinks not supported in Packaging for Debian) also simplify compile rules * Add cmpsi2.c/ucmpsi2.c to lib/mint/Makefile, version the new files * Add printf.c to lib/c/Makefile, version printf.c source file * In kernel/program.c: Added free memory and batter life display Press "view" repeatedly while no programs are running to see * Add NUM_SYSTEM_THREADS def & mod files to use DEF vs. literal * In sys/mm.c/h: add int mm_free_mem(void); function * TouchSensor class: added pressed() member * RotationSensor.H: added CONF_DSENSOR_VELOCITY wraps * C++: motorPair.C/H methods renamed to lower case, demos adjusted * C++: motor.C/H methods renamed to lower case, demos adjusted * Minor changes to internal comments containing source file name * .PHONEY and c++ make targets added to demo/Makefile * .PHONEY and c++ make targets added to Makefile * README was updated to 0.2.5 after release (oops) * Added Cygwin 1.1 make target support * DOXYGEN: Added API generation support using Doxygen Added doxygen API docs build/clean make-targets to Makefile Updated Doxygen files to work with newer Doxygen version Revise insternal comments for c/C++ classes so API reads better Add DOXYGEN_SHOULD_SKIP_INTERNALS flags to misc source Add C and C++ Doxygen control files 2002-03-29 Stephen M Moraco * creating this file after 0.2.5 release -- $Id: ChangeLog,v 1.41 2005/01/18 03:34:41 stephmo Exp $ brickos-0.9.0/CONTRIBUTORS0000644000175000017500000001210710014036331012556 0ustar cbcbbrickOS contributors -------------------- V{next-release} we're building this list as we go... _________ Bernardo Dal Seno (dibbe@users.sourceforge.net) Patch optimizing checksum calcs for LNP (Original work and final cleanup) Patch fixing race conditions in LNP Ryan Cumming (bodnar42@users.sourceforge.net) Rediff of LNP checksum patch against 0.2.5 Zhengrong Zang (mikezang@users.sourceforge.net) Remote Control & Standard Message Patch Additional LNP Protocol Description Ross Crawford (roscohead@users.sourceforge.net) Remote control patch Ted Hess (thess@users.sourceforge.net) Blended the best of each of the Remote Control and LNP Messaging patches resulting in our current implementation. Also, LCD status fixes Joseph Woolley (jawoolley@users.sourceforge.net) Various kernel/task code and comment changes. Minor bug fix in mm_try_join. Added kernel tasks to animate man and show/hide battery indicator. Stephen M Moraco (stephen@debian.org) Rewrite make system to handle installs and document builds. Upgrade inline documentation in support of our always publishing brickOS API docs to our website. Evgeni Krimer Roman Barsky (while at Israel Institute of Technology Computer Science Department) Fixes to lib/float/divsf3: Floating point divide single precision routines and many people testing and submitting fix requests including (but not limited to): Michael Obenland, Joseph Woolley, Max Bowsher, and... V0.2.6 _________ Hary D. Mahesan (hdmahesa@engmail.uwaterloo.ca) Patches enabling USB-IR tower support on Windows Paolo Masetti (paolo.masetti@itlug.org) Added/Updated Cygwin support (B-20 and 1.x) Stephen M Moraco (stephen@debian.org) Small makelx c++ fix (ctor/dtor alloc), created manpages for dll(1) and firmdl3(1), added inline API documentation extractable by Doxygen and many people testing and submitting fix requests including (but not limited to): Michael Obenland, Joseph Woolley, Max Bowsher, Kingsley Gifford, Mathias N. Kjrgaard, Steve Hassenplug V0.2.5 _________ Jochen Hoenicke (Jochen.Hoenicke@Informatik.Uni-Oldenburg.DE) Added VELOCITY_X to do velocity sensing with rotation sensors. Pat Welch (legOS@mousebrains.com) Added full blown C++ support, including all sensors. Stig Neilsson (spiff@rhk.dk) Extremely thorough kernel documentation. John Markus Bjorndalen (johnm@cs.uit.no) Small makelx fix for gcc 2.96 (RH 7.0). V0.2.4 --------- Lars Berntzon Added a missing wrapper to the C++ support. Luis Villa (luis.villa@duke.edu) HOWTO (again), lots of very small fixes. Ross Crawford (rcrawford@csi.com) Some assembler fixes to finally allow use of gcc 2.95. Eddie C. Dost (ecd@skynet.be) Fixed bss alignment bug and improved lcd_refresh() Paolo Masetti (paolo.masetti@itlug.org) Assortment of fixes and adds to dll, dsensor.h, firmdl3 and battery.h. More details in NEWS file. Rossz Vamos-Wentworth (rossz2@home.com) Work on DJGPP port. V0.2.3 --------- Frank Cremer Better handling of re-sent packets in program downloads. Martin Cornelius Fixed collision handling in lnp-logical.c. Initiated a useful sound driver at last. V0.2.2 --------- Frank Cremer Patch to shutdown motor/sensor/networking with the RUN button. Found typing inconsistency in sensor code. Reported hanging lnp_logical_write call. Reported never ending story (rotation sensor problems) V0.2.1 -------- Sergey Ivanyuk Found ON/OFF button bug in program module. Dave Found naming inconsistency in dsound.h Kekoa Proudfoot Floating point math V0.2.0 -------- Mark Falco Mario Ferrari Rotation sensor fixes Frank Mueller Touch sensor values Kekoa Proudfoot IR carrier setup Snapshot -------- Tom Emerson PDF documentation Lou Sortman Motor speed patch Priority chain task model Luis Villa HOWTO V0.1.7 ------ Lou Sortman Optimized rotation sensor code with compile-time shifts David Van Wagner Found inconsistencies in conditional defines Pointed out problems with defines in assembler statements For an example how to use those correctly, see systime.c Kekoa Proudfoot Integer math routines. V0.1.6 ------ Michael Nielsen Fixed sound driver IRQ bug Chris Dearman Fixed the ugly volatile problem in the IR code Eric Habnerfeller Fixed rotation sensors with window-based approach V0.1.0 ------ Ben Laurie Added Priority-based scheduler brickos-0.9.0/LICENSE0000644000175000017500000004643007530330673011730 0ustar cbcb MOZILLA PUBLIC LICENSE Version 1.0 ---------------- 1. Definitions. 1.1. ``Contributor'' means each entity that creates or contributes to the creation of Modifications. 1.2. ``Contributor Version'' means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. 1.3. ``Covered Code'' means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. 1.4. ``Electronic Distribution Mechanism'' means a mechanism generally accepted in the software development community for the electronic transfer of data. 1.5. ``Executable'' means Covered Code in any form other than Source Code. 1.6. ``Initial Developer'' means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. 1.7. ``Larger Work'' means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. 1.8. ``License'' means this document. 1.9. ``Modifications'' means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is: A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. B. Any new file that contains any part of the Original Code or previous Modifications. 1.10. ``Original Code'' means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. 1.11. ``Source Code'' means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or a list of source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. 1.12. ``You'' means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, ``You'' includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, ``control'' means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of fifty percent (50%) or more of the outstanding shares or beneficial ownership of such entity. 2. Source Code License. 2.1. The Initial Developer Grant. The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: (a) to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, or as part of a Larger Work; and (b) under patents now or hereafter owned or controlled by Initial Developer, to make, have made, use and sell (``Utilize'') the Original Code (or portions thereof), but solely to the extent that any such patent is reasonably necessary to enable You to Utilize the Original Code (or portions thereof) and not to any greater extent that may be necessary to Utilize further Modifications or combinations. 2.2. Contributor Grant. Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: (a) to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code or as part of a Larger Work; and (b) under patents now or hereafter owned or controlled by Contributor, to Utilize the Contributor Version (or portions thereof), but solely to the extent that any such patent is reasonably necessary to enable You to Utilize the Contributor Version (or portions thereof), and not to any greater extent that may be necessary to Utilize further Modifications or combinations. 3. Distribution Obligations. 3.1. Application of License. The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. 3.2. Availability of Source Code. Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. 3.3. Description of Modifications. You must cause all Covered Code to which you contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. 3.4. Intellectual Property Matters (a) Third Party Claims. If You have knowledge that a party claims an intellectual property right in particular functionality or code (or its utilization under this License), you must include a text file with the source code distribution titled ``LEGAL'' which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If you obtain such knowledge after You make Your Modification available as described in Section 3.2, You shall promptly modify the LEGAL file in all copies You make available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. (b) Contributor APIs. If Your Modification is an application programming interface and You own or control patents which are reasonably necessary to implement that API, you must also include this information in the LEGAL file. 3.5. Required Notices. You must duplicate the notice in Exhibit A in each file of the Source Code, and this License in any documentation for the Source Code, where You describe recipients' rights relating to Covered Code. If You created one or more Modification(s), You may add your name as a Contributor to the notice described in Exhibit A. If it is not possible to put such notice in a particular Source Code file due to its structure, then you must include such notice in a location (such as a relevant directory file) where a user would be likely to look for such a notice. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. 3.6. Distribution of Executable Versions. You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. 3.7. Larger Works. You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. 4. Inability to Comply Due to Statute or Regulation. If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Application of this License. This License applies to code to which the Initial Developer has attached the notice in Exhibit A, and to related Covered Code. 6. Versions of the License. 6.1. New Versions. Netscape Communications Corporation (``Netscape'') may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. 6.2. Effect of New Versions. Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Netscape. No one other than Netscape has the right to modify the terms applicable to Covered Code created under this License. 6.3. Derivative Works. If you create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), you must (a) rename Your license so that the phrases ``Mozilla'', ``MOZILLAPL'', ``MOZPL'', ``Netscape'', ``NPL'' or any confusingly similar phrase do not appear anywhere in your license and (b) otherwise make it clear that your version of the license contains terms which differ from the Mozilla Public License and Netscape Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) 7. DISCLAIMER OF WARRANTY. COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN ``AS IS'' BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 8. TERMINATION. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. 9. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. 10. U.S. GOVERNMENT END USERS. The Covered Code is a ``commercial item,'' as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of ``commercial computer software'' and ``commercial computer software documentation,'' as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. 11. MISCELLANEOUS. This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in, the United States of America: (a) unless otherwise agreed in writing, all disputes relating to this License (excepting any dispute relating to intellectual property rights) shall be subject to final and binding arbitration, with the losing party paying all costs of arbitration; (b) any arbitration relating to this Agreement shall be held in Santa Clara County, California, under the auspices of JAMS/EndDispute; and (c) any litigation relating to this Agreement shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. 12. RESPONSIBILITY FOR CLAIMS. Except in cases where another Contributor has failed to comply with Section 3.4, You are responsible for damages arising, directly or indirectly, out of Your utilization of rights under this License, based on the number of copies of Covered Code you made available, the revenues you received from utilizing such rights, and other relevant factors. You agree to work with affected parties to distribute responsibility on an equitable basis. EXHIBIT A. ``The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is legOS code, released October 17, 1999. The Initial Developer of the Original Code is Markus L. Noga. Portions created by Markus L. Noga are Copyright (C) 1999 Markus L. Noga. All Rights Reserved. Contributor(s): see CONTRIBUTORS_________________________________.'' brickos-0.9.0/VERSION0000644000175000017500000000000610173101721011743 0ustar cbcb0.9.0 brickos-0.9.0/Makefile0000644000175000017500000001700010173102440012334 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.20 2004/02/17 01:39:07 stephmo Exp $ ### FILE: Makefile - make all parts of the brickOS distribution ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- ### (This is the top-level Makefile. All actions are performed from here) # distribution name (all lower-case by convention) PACKAGE = brickos # version of this release, let's use the verision from our VERSION file VERSION = $(shell cat VERSION) # set this once to accommodate our new dir name export BRICKOS_ROOT=$(shell cd . && pwd)/ # ------------------------------------------------------------ # No user customization below here... # ------------------------------------------------------------ # # makefile to build the brickOS operating system and demo files # SUBDIRS=util lib boot demo doc # if new configuration tool installed force it to be used once all:: @if [ configure -nt .configured.flg ]; then \ rm -f .configured.flg; \ fi all install:: @for i in $(SUBDIRS) ; do $(MAKE) $(MFLAGS) -C $$i $@ || exit 2 ; done depend tag clean realclean uninstall:: @for i in $(SUBDIRS) ; do $(MAKE) $(MFLAGS) NODEPS=yes -C $$i $@ || exit 2 ; done realclean:: clean rm -f tags TAGS *.bak docs-build docs-install:: $(MAKE) $(MFLAGS) -C doc $@ # API generation support using Doxygen # # when we get a new version of doxygen, run this target once # upgrade-doxygen: doxygen -u Doxyfile-c doxygen -u Doxyfile-c++ doxygen -u Doxyfile # # doc/html-c subdirectory: make C docs # pkghtmldir = /usr/local/share/doc/brickos/html html-c: Doxyfile-c-report realclean:: rm -rf doc/html-c doc/rtf-c rm -f -- Doxyfile-c.log Doxyfile-c.rpt .Doxyfile-c-doneflag *.out brickos-html-c-dist.tar.gz: html-c cd doc;tar --gzip -cf $@ html-c;mv $@ ..;cd - html-c-dist: brickos-html-c-dist.tar.gz html-c-install: html-c cp -r doc/html-c ${pkghtmldir} Doxyfile-c.log: Doxyfile-c doxygen $? >$@ 2>&1 Doxyfile-c.rpt: Doxyfile-c.log @grep Warn $? | sed -e 's/^.*brickos\///' | cut -f1 -d: | sort | \ uniq -c | sort -rn | tee $@ .Doxyfile-c-doneflag: Doxyfile-c.rpt @for FIL in `cat $? | cut -c9-99`; do \ OUTFILE=`echo $$FIL | sed -e 's/[\/\.]/-/g'`.out; \ echo "# FILE: $$OUTFILE" >$$OUTFILE; \ grep "$$FIL" $? >>$$OUTFILE; \ grep "$$FIL" Doxyfile-c.log | grep Warn >>$$OUTFILE; \ done @touch $@ Doxyfile-c-report: .Doxyfile-c-doneflag -ls -ltr *.out 2>/dev/null # # doc/html-c++ subdirectory: make C++ docs # html-c++: Doxyfile-c++-report realclean:: rm -rf doc/html-c++ doc/rtf-c++ rm -f -- Doxyfile-c++.log Doxyfile-c++.rpt .Doxyfile-c++-doneflag *.out brickos-html-c++-dist.tar.gz: html-c++ cd doc;tar --gzip -cf $@ html-c++;mv $@ ..;cd - html-c++-dist: brickos-html-c++-dist.tar.gz html-c++-install: html-c++ cp -r doc/html-c++ ${pkghtmldir} Doxyfile-c++.log: doxygen Doxyfile-c++ >$@ 2>&1 Doxyfile-c++.rpt: Doxyfile-c++.log @grep Warn $? | sed -e 's/^.*brickos\///' | cut -f1 -d: | sort | \ uniq -c | sort -rn | tee $@ .Doxyfile-c++-doneflag: Doxyfile-c++.rpt @for FIL in `cat Doxyfile-c++.rpt | cut -c9-99`; do \ OUTFILE=`echo $$FIL | sed -e 's/[\/\.]/-/g'`.out; \ echo "# FILE: $$OUTFILE" >$$OUTFILE; \ grep "$$FIL" Doxyfile-c++.rpt >>$$OUTFILE; \ grep "$$FIL" Doxyfile-c++.log | grep Warn >>$$OUTFILE; \ done @touch $@ Doxyfile-c++-report: .Doxyfile-c++-doneflag -ls -ltr *.out 2>/dev/null # # doc/html-kern subdirectory: make kernel developer docs # html-kern: Doxyfile-kern-report realclean:: rm -rf doc/html-kern doc/rtf-kern rm -f -- Doxyfile-kern.log Doxyfile-kern.rpt .Doxyfile-kern-doneflag *.out brickos-html-kern-dist.tar.gz: html-kern cd doc;tar --gzip -cf $@ html-kern;mv $@ ..;cd - html-kern-dist: brickos-html-kern-dist.tar.gz html-kern-install: html-kern cp -r doc/html-kern ${pkghtmldir} Doxyfile-kern.log: doxygen Doxyfile >$@ 2>&1 Doxyfile-kern.rpt: Doxyfile-kern.log @grep Warn $? | sed -e 's/^.*brickos\///' | cut -f1 -d: | sort | \ uniq -c | sort -rn | tee $@ .Doxyfile-kern-doneflag: Doxyfile-kern.rpt @for FIL in `cat Doxyfile-kern.rpt | cut -c9-99`; do \ OUTFILE=`echo $$FIL | sed -e 's/[\/\.]/-/g'`.out; \ echo "# FILE: $$OUTFILE" >$$OUTFILE; \ grep "$$FIL" Doxyfile-kern.rpt >>$$OUTFILE; \ grep "$$FIL" Doxyfile-kern.log | grep Warn >>$$OUTFILE; \ done @touch $@ Doxyfile-kern-report: .Doxyfile-kern-doneflag -ls -ltr *.out 2>/dev/null # # make all API documentation # api-docs-build: html-c html-c++ html-kern docs: docs-build api-docs-build # # make distribution files for all API documentation # api-dist: html-c-dist html-c++-dist html-kern-dist # # install all API documentation # docs-install:: html-c-install html-c++-install html-kern-install # NOTE: --format=1 is not supported on Linux ([ce]tags in emacs2[01] packages) # please set in your own environment tag:: -ctags kernel/*.c include/*.h include/*/*.h -etags kernel/*.c include/*.h include/*/*.h .PHONY: all depend tag clean realclean html tag c++ html html-c html-c++ html-kern html-dist # ------------------------------------------------------------ # Components of this release to be packaged # ------------------------------------------------------------ # SOURCES = boot demo kernel lib util HEADERS = include EXTRA_DIST = Doxy* doc h8300.rcx configure DIST_COMMON = README ChangeLog CONTRIBUTORS LICENSE VERSION Makefile* NEWS TODO README.use README.usb # # The following 'dist' target code is taken from a makefile # generated by the auto* tools # SHELL = /bin/sh DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) # locations for this package build effort SRC_ROOTDIR = . DISTDIR = $(PACKAGE)-$(VERSION) # tools we use to make distribution image TAR = tar GZIP_ENV = --best # make our distribution tarball dist: notinsourcetree distdir -chmod -R a+r $(DISTDIR) GZIP=$(GZIP_ENV) $(TAR) chozf $(DISTDIR).tar.gz $(DISTDIR) -rm -rf $(DISTDIR) @echo "---------------------------------------------------------" @echo " MD5 sum for $(PACKAGE) v$(VERSION)" @md5sum $(DISTDIR).tar.gz @echo "---------------------------------------------------------" # check for target being run in CVS source tree... bail if is... notinsourcetree: @if [ -d $(SRC_ROOTDIR)/CVS ]; then \ echo ""; \ echo "---------------------------------------------------------"; \ echo " make: target 'dist' not for use in source tree"; \ echo "---------------------------------------------------------"; \ echo ""; \ exit 2; \ fi # build a copy of the source tree which can be zipped up and then deleted distdir: $(DISTFILES) -rm -rf $(DISTDIR) mkdir $(DISTDIR) -chmod 777 $(DISTDIR) # DISTDIR=`cd $(DISTDIR) && pwd`; @for file in $(DISTFILES); do \ d=$(SRC_ROOTDIR); \ if test -d $$d/$$file; then \ cp -pr $$d/$$file $(DISTDIR)/$$file; \ else \ test -f $(DISTDIR)/$$file \ || ln $$d/$$file $(DISTDIR)/$$file 2> /dev/null \ || cp -p $$d/$$file $(DISTDIR)/$$file || :; \ fi; \ done # cleanup files which should not make it into any release @find $(DISTDIR) -type d -depth -name 'CVS' -exec rm -rf {} \; @find $(DISTDIR) -type f -name '.cvs*' -exec rm -f {} \; @find $(DISTDIR) -type f -name '.dep*' -exec rm -f {} \; include Makefile.common # for the ocnfiguration check ### -------------------------------------------------------------------------- ### End of top-level brickOS Makefile ### ========================================================================== brickos-0.9.0/Makefile.common0000644000175000017500000001034210014270273013631 0ustar cbcb### ========================================================================== ### $Id: Makefile.common,v 1.23 2004/02/17 01:39:07 stephmo Exp $ ### FILE: Makefile.common - definitions common to most brickOS Makefiles ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- ### (this file is included by other brickOS Makefiles) # # Define our default install locations (overridden by packaging systems) # prefix = /usr/local exec_prefix = ${prefix} PACKAGE = brickos inst_prefix = ${prefix} bindir = ${exec_prefix}/bin sbindir = ${exec_prefix}/sbin libexecdir = ${exec_prefix}/lib datadir = ${prefix}/share docdir = ${prefix}/share/doc sysconfdir = ${prefix}/etc sharedstatedir = ${prefix}/com localstatedir = ${prefix}/var libdir = ${exec_prefix}/lib mandir = ${prefix}/man includedir = ${prefix}/include instbindir = ${inst_prefix}/bin instincdir = ${inst_prefix}/include/${PACKAGE} instlibdir = ${inst_prefix}/lib/${PACKAGE} pkgdatadir = $(datadir)/${PACKAGE} pkgdocdir = $(docdir)/${PACKAGE} pkgexampledir = $(pkgdocdir)/examples pkgincludedir = $(includedir)/${PACKAGE} pkghtmldir = $(pkgdocdir)/html pkglibdir = $(libdir)/${PACKAGE} # # BEGIN-configuration insert (do not remove this line) # ------------------------------------------------------- TOOLPREFIX= SED_SFLAG= EXT= CC=cc CFLAGS=-O2 -Wall MAKEDEPEND=$(CC) -M BRICKOS_ROOT= # ------------------------------------------------------- # END-configuration insert (do not remove this line) # # # test to ensure that user has run configure before building # all depend:: ensureConfigured ensureConfigured: @if [ ! -f $(BRICKOS_ROOT)/.configured.flg ]; then \ echo "" >&2; \ echo "ERROR- brickOS builds are not yet configured..." >&2; \ echo " Please run ./configure then try to build again." >&2; \ echo "" >&2; \ exit 2; \ fi # # select purpose based on building hosted utilities or brickOS and demos # ifdef BUILDING_HOST_UTILS # ---------------------------------------------------------------------------- # defines for build of native compiled utilities # ---------------------------------------------------------------------------- CFLAGS+=-O2 -Wall else # ifndef BUILDING_HOST_UTILS # ---------------------------------------------------------------------------- # defines for build of cross-compiled parts: brickOS, demos # ---------------------------------------------------------------------------- # options COPT =-O2 -fno-builtin -fomit-frame-pointer CWARN =-Wall # # 2000.03.12 - Paolo Masetti # # - Added -I$(BRICKOS_ROOT)/include/lnp in respect of # Martin Corneluis (cornelius@csd.de) fix for lnp includes # see http://www.lugnet.com/robotics/rcx/legos/?n=498 for details # CINC =-I$(BRICKOS_ROOT)/include -I$(BRICKOS_ROOT)/include/lnp -I. CFLAGS=$(COPT) $(CWARN) $(CINC) $(CDEFINES) CXXFLAGS=-DCXX -fno-rtti -fno-exceptions $(CFLAGS) ## ## older options ## # do we need to pad the srec file with zeros? #NEED_ZERO_PADDING=--pad-to 0xC000 # how to disassemble ODFLAGS = --disassemble-all --no-show-raw-insn -m h8300 # which firmware version to act upon FIRMVERS=firm0309 ## ## no user servicable parts below ## AS=$(TOOLPREFIX)as AR=$(TOOLPREFIX)ar LD=$(TOOLPREFIX)ld NM=$(TOOLPREFIX)nm OBJCOPY=$(TOOLPREFIX)objcopy OBJDUMP=$(TOOLPREFIX)objdump CC=$(TOOLPREFIX)gcc CXX=$(TOOLPREFIX)g++ MERGEMAP =$(BRICKOS_ROOT)/util/merge-map GENLDS =$(BRICKOS_ROOT)/util/genlds FIXDEPS =$(BRICKOS_ROOT)/util/fixdeps MAKELX =$(BRICKOS_ROOT)/util/makelx MAKEDEPEND =$(CC) -M $(CINC) ### ### generic rules ### # how to assemble %.o: %.s $(AS) $< -o $@ # how to compile C source %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ # how to compile C kernel sources %.o: $(BRICKOS_ROOT)/kernel/%.c $(CC) $(CFLAGS) -c $< -o $@ # how to generate an assembly listing of a kernel source %.s: $(BRICKOS_ROOT)/kernel/%.c $(CC) $(CFLAGS) -c $< -S # how to compile C++ source %.o: %.cpp $(CXX) $(CXXFLAGS) -c $< -o $@ %.o: %.C $(CXX) $(CXXFLAGS) -c $< -o $@ # # endif # ifndef BUILDING_HOST_UTILS ### -------------------------------------------------------------------------- ### End of FILE: Makefile.common ### ========================================================================== brickos-0.9.0/Makefile.user0000644000175000017500000000437307623101501013325 0ustar cbcb### ========================================================================== ### $Id: Makefile.user,v 1.9 2003/02/14 05:48:49 stephmo Exp $ ### FILE: Makefile.user - support for building programs run under brickOS ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- ### (this file is included by the demo/ and demo/c++ Makefiles) # User application libraries. Comment out if linking # them statically to kernel in Makefile.kernel. LIBS = -lc -lmint -lfloat -lc++ # Linker command files dynamic executables. DYNAMIC_LDS = $(KERNEL).lds DLDFLAGS = -T $(DYNAMIC_LDS) -relax -L$(BRICKOS_ROOT)/lib # Base addresses to determine relocation info. BASE1 = 0xb000 BASE2 = 0xb210 # Add config.h to include path CINC += -I$(BRICKOS_ROOT)/boot # Allow setting LNP Host Address on command line ifdef LNP_HOSTADDR CDEFINES = -DCONF_LNP_HOSTADDR=$(LNP_HOSTADDR) endif ############ new dynamic executables stuff # How to build executables dynamically linked to the kernel # Set DYNAMIC_TEXT, DOBJECTS, DYNAMIC_LDS appropriately. %.dcoff: %.o $(DOBJECTS) $(DYNAMIC_LDS) $(LD) $(DLDFLAGS) $*.o $(DOBJECTS) $(LIBS) -o $@ -Ttext $(BASE1) --oformat coff-h8300 # How to make barebones dymanic executable map files %.dmap: %.dcoff $(NM) $< | sort > $@ # How to disassemble coff kernel %.dis: %.dcoff $(OBJDUMP) $(ODFLAGS) $*.dcoff > $@ # How to merge map files with symbols %.dis2: %.dmap %.dis $(MERGEMAP) $*.dmap $*.dis > $@ # How to make coff files of dynamic executables (twice, for makelx) %.dc1: %.o $(DOBJECTS) $(DYNAMIC_LDS) $(LD) $(DLDFLAGS) $*.o $(DOBJECTS) $(LIBS) -o $@ --oformat coff-h8300 -Ttext $(BASE1) %.dc2: %.o $(DOBJECTS) $(DYNAMIC_LDS) $(LD) $(DLDFLAGS) $*.o $(DOBJECTS) $(LIBS) -o $@ --oformat coff-h8300 -Ttext $(BASE2) # How to make srec files from coff files (twice, for makelx) %.ds2: %.dc2 $(OBJCOPY) -I coff-h8300 -O symbolsrec $< $@ %.ds1: %.dc1 $(OBJCOPY) -I coff-h8300 -O symbolsrec $< $@ %.lx: %.ds1 %.ds2 $(MAKELX) $*.ds1 $*.ds2 $@ ### -------------------------------------------------------------------------- ### End of FILE: Makefile.user ### ========================================================================== brickos-0.9.0/NEWS0000644000175000017500000001333410173101721011402 0ustar cbcbOur Next Releases (work pending): -------------------------------- * we are moving source to gcc-3.4 compatibility * working on remaining reported issues * we are updating our HOWTO News for brickos-0.9.0: ------------------------- * USB tower on Linux works (See README.usb) * Install/uninstall targets added to Makefiles * Many patches filed to date, now applied * API doc generation now in Makefiles * LNP Parser for RCX firmware protocol op-codes based on work fm Zhengrong Zang * dll: NEW -dn or --delete=n option deletes a program from memory * dll: default program is 1. zero no longer exists from dll point of view * New added full support for LEGO Remote Control * Reawakened the RCX to RCX simple messaging * Applied all known LNP patches (improving LNP communication) * Added (optional, compile-in and Macro) support for 3rd party sensors News for legOS-0.2.6: ----------------------- * WIN32 ONLY: Support for USB IR tower For firmdl3: firmdl3 --tty=usb For dll: dll --tty=usb NOTEs: - 'fast' mode is not supported for the USB tower. - as usual, you must delete legOS from your RCX before reloading it. * Updated Cygwin toolchain support legOS built and tested on Win9x, WinNT, Win2k, WinXP using cygwin tools. See install docs at legOS website http://legos.sourceforge.net (Docs section) * New C++ support for Temperature Sensor * New pressed() method in C++ TouchSensor class * Manpages for dll(1) and firmdl3(1) utilities * Fixed BUG #228723: makelx out-of-bounds check bad on c++ * Fixed BUG #226789: Remove -u use to fix build on BSD * Added a ChangeLog file tracking changes in more detail News for legOS-0.2.5: --------------------- * New CONF_AUTOSHUTOFF for RCX self autoshutdown if no activity detected. * New VELOCITY_X variable that tracks speed of a rotation sensor attached to X. * Complete C++ support. Check out c++ in the demo/ directory for an example. Be aware that this requires use of gcc 2.95 to build correctly. * Small floating point changes to make the library more IEEE compliant. * Very slight firmdl3 update; useful mainly only if you use firmdl for other projects. News for legOS-0.2.4: --------------------- * Toolchain fixes to eliminate crashes due to memory misalignment. * Ability to make variables persistent. (see include/persistent.h) * Kernel will now build correctly with gcc 2.95. * New random number generator, random() and srandom() now work without libiberty.a. * Support for C++: new, delete and virtual methods work. Refrain from exceptions and RTTI, though. * Perl only required for backannotated dissassembly now. Linker skripts are generated with C programs now. * Makefile improvements: All tools (including dll and firmdl3) should now build cleanly under Linux and Cygwin. DJGPP currently a work in progress. * New settling code in dsensor.c to increase reliability of sensor readings. * Now RCX signal when battery is low via lcd battery low indicator * New battery.h module to get mV scaled (get_battery_mv()). * Now RCX IR can works both in near and in far mode handled via a simple option of dll. RCX lcd signals when it's near or far. * You can run a program after download via dll -e option. * Predefined constants for touch sensors: TOUCH(x) and TOUCH_1, TOUCH_2 ... * Paolo Masetti and Luis Villa are now serving as co-maintainers. News for legOS-0.2.3: --------------------- * Better rotation sensor handling via state tables. * Sound driver to play sequences of notes. * Improved packet retransmit handling for program downloads. * Another collision detection bug fixed (char -> volatile signed char). * Prebuilt standard kernel in distribution. News for legOS-0.2.2: --------------------- * .lx files now generated in three steps instead of six through the use of symbolsrec files. makelx is a standalone C program now. Perl is no longer required to build user apps. * experimental new motor driver. old driver used PWM with movement and off states. new driver uses PWM with movement and brake states. better speed control, but strange sound. enable in boot/config.h. * Stopping programs with the RUN button now stops motors and active sensors and resets network handlers. Programs stopping on their own need to perform this themselves. This way, direct control of the RCX with on-the-fly compilation is still possible, but regular user programs react as expected when stopped. * The collision bug that occasionally caused the RCX to hang upon sending has been adressed. News for legOS-0.2.1: --------------------- * .lx relocatable file format for legOS executables * dll is a stand-alone C program now, should be possible to compile under windows? * boot/ directory for compiled kernel image / linker map * sensor activation visualization * better program number display * ON/OFF always works now. * user programs survive ON/OFF now. * Kekoa's single precision floating point library integrated. Check Makefile.kernel / Makefile.user if you want to link libraries statically to your kernel. * use cls() to clear user screen only. News for legOS-0.2: ------------------- * legOS networking protocol. addressing, ports, timeouts, ... * loading and linking of dynamic executables * new project directory structure * per-project configuration management (maybe obsolete with dynamic loading) * new debounced key driver: try getchar() * automatic lcd_refresh * lots of little optimizations: cputs, cputw, ... * linker script for on-chip modules (relaxation -> 8-bit access) * support for patched egcs for better IRQ handling * workarounds for buggy GNU assembler (hint: avoid local labels) * improved backannotated assembly (push/pop, register names, on-chip modules) * new and improved 8kHz/8bit sound driver (still a little quiet) brickos-0.9.0/TODO0000644000175000017500000000165310173101721011374 0ustar cbcbNOTE: this list is old and will be reworked in an upcoming release - improve sensor detection.response times (see: priority patch, dat4 project) - add assignment of HOSTID for LNP at download time (firmdl3) - timeout handling needs improvement. if the RCX transmits data, the IR tower will shutdown more quickly. - Fix DJGPP support. Should mainly be a matter of compiling new tools. - maybe switch loader.c from getopt_long (GNU only) to getopt (POSIX compliant) for easier porting. Many, many ideas from the mailing list, mainly from Eddie & Paolo: - Redo sensor handling code. Eddie and Paolo will take care of this. - Implement event queues? - Implement a timer function? - Debug functions via LNP. Paolo already has a prototype. Wishlist: - Standardize all platforms on gcc 2.95 for compatibility. - PHP-based web compiler hosted at sourceforge. - Finally, the PHP-based documentation commentary system Luis keeps promising. brickos-0.9.0/README.use0000644000175000017500000000644607555444044012406 0ustar cbcbbrickOS README.use - easiest forms of interaction with source Updated: 16 Oct 2002 ------------------------------------------------------------------------------ The brickOS make system is written to accommodate the following styles of use: (s1) A person who is only interested in writing code for robots which are running a pre-built brickOS. (s2a) A person who wants to reconfigure the brickOS operating system to enable devices or services not normally enabled in the default build. (s2b) A person who wants to experiment with the brickOS operating system directly, modifying and testing it (s3) A person who wants to do all of these from time to time. ------------------------------------------------------------------------------ [s1] You want to get right to progranmming your creations and don't want to experiment with modifying brickOS at this time. Get started by locating a pre-built environment if one exists. Install it and then off you go to create programs for your creations If a pre-built environment doesn't exist get the latest source .tar.gz file. unpack it then build and install it. After install, you are ready to start. Rather than our describing how to do this let's walk thru a quick example... To start with a prebuilt brickOS: - Utilities, libraries, legOS kernel and demos have all been installed. - Copy the /usr/[local/]share/doc/brickos/examples/demo/ directory contents to a directory of your choosing. (If you wish to use c++ copy the files from the demo/c++ subdirectory, instead.) - Type 'make' in this new directory to compile the demos. - The utilities are already in your PATH. Set RCXTTY if you use a non- standard port for the IR tower. [example: 'export RCXTTY=/dev/ttyS1'] - Use firmdl3 to download /usr/[local/]lib/brickos/brickOS.srec to your RCX. - Type "dll demo/helloworld.lx" (where demo is the directory in which you just made the demos). If all is well, it should be automatically relocated and downloaded into program slot 0. Press the RUN key to run. The program stops automatically. - Type "dll -p1 demo/rover.lx" to transmit another demo to program slot 1. Use the PRGM key to select the desired program. Try RUN. - NOTE: A 'make realclean' will remove all built files. - Stop your program with the RUN or ON/OFF key. Programs are preserved over ON/OFF now. Press ON/OFF and PRGM simultaneously to erase legOS. For your own projects, - Make a directory in a location of your choosing (you may wish to make a ~/brickOS directory and place your projects below there). - Copy 'Makefile' from the /usr/[local/]share/doc/brickos/examples directory to this new directory. - Put your main routine into myproject.c. (or myproject.C if using C++) - If you need more source files, add them in the Makefile. - type "make myproject.lx && dll myproject.lx" to build and then download your new code. (Remember to use -pN to select specific program slot) In case you are wondering, dll is short for dynamic linker and loader. You can get good help at: http://lugnet.com/robotics/rcx/legos/ should you need to. ------------------------------------------------------------------------------ End of FILE: README.use ------------------------------------------------------------------------------ brickos-0.9.0/README.usb0000644000175000017500000000364410173101721012356 0ustar cbcbUSB support on Linux for brickOS-0.9.0 -------------------------------------- USB support for IR Towers is now working for Linux and Windows (using the Cygwin tool suite.) This file describes the Linux environment setup Recognition of the LEGO USB Infrared Tower is now built into the 2.6.x Linux Kernels. When you plug the USB IR Tower into a USB port the device will automatically be connected. I have usbutils installed which provides 'lsusb'. In my case lsusb shows the following when I have the IR Tower connected: $ lsusb Bus 004 Device 001: ID 0000:0000 Bus 003 Device 001: ID 0000:0000 Bus 002 Device 001: ID 0000:0000 Bus 001 Device 002: ID 0694:0001 Lego Group Mindstorms Tower Bus 001 Device 001: ID 0000:0000 I had to create my device file with something like: sudo mknod /dev/usb/legotower0 c 180 160 sudo chmod 666 /dev/usb/legotower0 To use the Tower then, I set RCXTTY to point to it: export RCXTTY=/dev/usb/legotower0 And then I use firmdl3 and dll just as before. - to load brickos - reset RCX removing prior brickOS firmware (press and hold [Prgm] and simultaneously press [On-Off] to turn the power off and then press [On-Off] to turn the power back on. You should hear the two startup beeps indicating that you are now running original firmware, not brickOS.) - run the OS downloader $ firmdl3 /usr/local/lib/brickos/brickOS.srec - to load a program into slot 2 - assuming you build the demos in the current directory, run $ dll -p2 sound.lx you should see the standing-man and 2 indicating that the download was successful. Now press [Run] to play the song... I hope this works for you. Please report issues with the USB support per the instructions found at http://brickos.sourceforge.net/rptrvwbugs.htm ------------------------------------------------------------------------ Stephen M Moraco (stephen@debian.org) - Mon, 17 Jan 2005 20:18:52 -0700 brickos-0.9.0/boot/0000755000175000017500000000000010173102444011645 5ustar cbcbbrickos-0.9.0/boot/Makefile0000644000175000017500000001562210014270273013313 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.20 2004/02/17 01:39:07 stephmo Exp $ ### FILE: boot/Makefile - make the brickOS kernel ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # brickOS kernel used (w/o extension) KERNEL=brickOS # kernel source files KSOURCES=kmain.c mm.c systime.c tm.c semaphore.c conio.c lcd.c \ lnp-logical.c lnp.c remote.c program.c vis.c battery.c\ timeout.c dkey.c dmotor.c dsensor.c dsound.c swmux.c\ atomic.c critsec.c setjmp.c KERNEL_TARGETS = $(KERNEL).srec \ $(KERNEL).lds # # NOTE: uncomment out the first line if you need a kernel disassembly file. # This will not work on Windows unless you have perl installed. # #all: $(KERNEL).srec $(KERNEL).dis2 $(KERNEL).lds all:: $(KERNEL_TARGETS) include ../Makefile.common .depend: $(BRICKOS_ROOT)/kernel/*.c $(MAKEDEPEND) $(BRICKOS_ROOT)/kernel/*.c > .depend depend:: .depend install: install-stamp @# nothing to do here but do it silently install-stamp: ${pkgincludedir} ${pkgexampledir} ${pkglibdir} \ ../include/* ../demo/Makefile ../demo/*.c ../demo/c++/*.C \ config.h $(KERNEL_TARGETS) ../Makefile.user ../Makefile.common cp -r ../include/* ${pkgincludedir} @find ${pkgincludedir} -type d -name 'CVS' -depth -exec rm -rf {} \; cp -r ../demo ${pkgexampledir} @cat ../demo/Makefile | sed -e 's/\.\.\/Makefile/$$\(LIBDIR\)\/Makefile/g' | \ sed -e 's/\.\.\/include/$$\(INCDIR\)/g' | \ sed -e 's:KERNEL\=\.\..boot.brickOS:KERNEL = $$\(LIBDIR\)/brickOS:' | \ sed -e 's:\# \#LIBDIR\#.*:LIBDIR \= ${instlibdir}:' | \ sed -e 's/.BRICKOS_ROOT..util/(LIBDIR)/g' >../demo/Makefile.dist @cat ../demo/c++/Makefile | sed -e 's/\.\..\.\..Makefile/$$\(LIBDIR\)\/Makefile/g' | \ sed -e 's/..BRICKOS_ROOT..include/$$\(INCDIR\)/g' | \ sed -e 's:KERNEL \= .*:KERNEL = $$\(LIBDIR\)/brickOS:' | \ sed -e 's:\# \#LIBDIR\#.*:LIBDIR \= ${instlibdir}:' | \ sed -e 's/..ROOTDIR.util/(LIBDIR)/g' >../demo/c++/Makefile.dist cp -f ../demo/Makefile.dist ${pkgexampledir}/demo/Makefile cp -f ../demo/Makefile.dist ${pkgexampledir}/Makefile cp -f ../demo/c++/Makefile.dist ${pkgexampledir}/demo/c++/Makefile @find ${pkgexampledir} -type f -name '*.dist' -exec rm -f {} \; @find ${pkgexampledir} -type f -name '*.lx' -exec rm -f {} \; @find ${pkgexampledir} -type d -name 'CVS' -depth -exec rm -rf {} \; @find ${pkgexampledir} -type f -name '*.o' -depth -exec rm -f {} \; @find ${pkgexampledir} -type f -name '*.ref' -depth -exec rm -f {} \; cp -f $(KERNEL_TARGETS) ${pkglibdir} @echo "/* WARNING: INSTALLED config.h: do not change this file without re-building brickOS kernel! */" >config.h.dist @cat config.h >>config.h.dist cp -f config.h.dist ${pkgincludedir}/config.h @cat ../Makefile.common | sed -e 's/.BRICKOS_ROOT..lib/(LIBDIR)/g' | \ sed -e 's/^all.depend:.*//' | \ sed -e 's/.BRICKOS_ROOT..include/(INCDIR)/g' | \ sed -e 's/^BRICKOS_ROOT=.*/BRICKOS_ROOT="not used when installed"/g' | \ sed -e 's/.BRICKOS_ROOT..util/(LIBDIR)/g' >../Makefile.common.dist @cat ../Makefile.user | sed -e 's/.BRICKOS_ROOT..lib/(LIBDIR)/g' | \ sed -e 's/.BRICKOS_ROOT..include/(INCDIR)/g' | \ sed -e 's/.BRICKOS_ROOT..boot/(INCDIR)/g' | \ sed -e 's/.BRICKOS_ROOT..util/(LIBDIR)/g' >../Makefile.user.dist cp -f ../Makefile.user.dist ${pkglibdir}/Makefile.user @echo "" >>../Makefile.common.dist @echo "INCDIR = ${instincdir}" >>../Makefile.common.dist @echo "BINDIR = ${instbindir}" >>../Makefile.common.dist @echo "LIBDIR = ${instlibdir}" >>../Makefile.common.dist @echo "" >>../Makefile.common.dist @echo "### --------------------------------------------------------------------------" >>../Makefile.common.dist @echo "### 'Installed copy' end of FILE: Makefile.common" >>../Makefile.common.dist @echo "### ==========================================================================" >>../Makefile.common.dist cp -f ../Makefile.common.dist ${pkglibdir}/Makefile.common @find ${pkgexampledir} -type f -exec chmod 444 {} \; @touch $@ clean:: rm -f ../Makefile.user.dist ../Makefile.common.dist ../demo/Makefile.dist ../demo/c++/Makefile.dist config.h.dist #!/bin/bash -p ${pkgincludedir} ${pkgexampledir} ${pkglibdir}: mkdir -p $@ uninstall: rm -rf ${pkglibdir} ${pkgincludedir} ${pkgdocdir} install-stamp tag: @# nothing to do here but do it silently clean:: rm -f *.srec *.o *.lds *.dis *.coff *.map *.dis2 realclean: rm -rf .depend* *.o *.dis *~ *.bak *.tgz *.s tags *.dcoff *.dmap *.dsrec *.dis2 rm -f *.srec *.map *.coff *.lds install-stamp .PHONY: all tag clean realclean depend ## ## no user servicable parts below ## # kernel object files KOBJECTS=$(KSOURCES:.c=.o) # Kernel libraries. Use second version to link all # libraries statically to kernel. Change Makefile.user, too. LIBS=-lc -lmint #LIBS=--whole-archive -lc -lmint -lfloat # linker command files for kernel LDFLAGS=-T $(BRICKOS_ROOT)/h8300.rcx -relax -L$(BRICKOS_ROOT)/lib # # 2002.05.12 - Ted Hess # # - Allow setting LNP Host Address on command line ifdef LNP_HOSTADDR CDEFINES =-DCONF_LNP_HOSTADDR=$(LNP_HOSTADDR) endif ############ kernel stuff # how to build coff kernel (for symbols, disassembly etc) $(KERNEL).coff: $(KOBJECTS) $(LD) $(LDFLAGS) $(KOBJECTS) $(LIBS) -o $@ chmod a-x $@ # how to build srec kernel (for download) %.srec: %.coff %.map $(OBJCOPY) -I coff-h8300 -O srec $(NEED_ZERO_PADDING) $*.coff $*.srec chmod a-x $*.srec # how to make map files %.map: %.coff $(NM) $*.coff | sort -u > $*.map # how to build linker script for dynamic executables %.lds: %.map $(GENLDS) $* < $*.map > $*.lds # how to disassemble coff kernel %.dis: %.coff $(OBJDUMP) $(ODFLAGS) $*.coff > $*.dis # how to merge map files with symbols %.dis2: %.map %.dis $(MERGEMAP) $*.map $*.dis > $*.dis2 # how to disassemble srec kernel (don't do this.) %.dis: %.srec $(OBJDUMP) $(ODFLAGS) $*.srec > $*.dis ############ original firmware stuff # how to disassemble original firmware file %.dis: %.lgo $(OBJDUMP) $(ODFLAGS) $*.lgo > $*.dis # how to merge labels etc into disassembly %.s: %.fix $(FIRMVERS).dis ./fixfirm.pl $*.fix $(FIRMVERS).dis > $*.s # how to reassemble new firmware file %.srec: %.s $(AS) $*.s -o $*.o $(LD) -Ttext=0x8000 $*.o -o $*.out $(OBJCOPY) -O srec $*.out $*.srec rm -f $*.o $*.out chmod -x $*.srec # dependencies ifndef NODEPS include .depend endif ### -------------------------------------------------------------------------- ### End of FILE: boot/Makefile ### ========================================================================== brickos-0.9.0/boot/config.h0000644000175000017500000001254510004643451013273 0ustar cbcb/*! \file boot/config.h \brief kernel configuration file \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __config_h__ #define __config_h__ // compilation environment // // #define CONF_RCX_COMPILER //!< a special RCX compiler is used. // core system services // #define CONF_TIME //!< system time #define CONF_MM //!< memory management #define CONF_TM //!< task management #define CONF_AUTOSHUTOFF //!< power down after x min of inactivity //#define CONF_TM_DEBUG //!< view key shows current instruction pointer #define CONF_SETJMP //!< non local goto #define CONF_ATOMIC //!< atomic counters #define CONF_SEMAPHORES //!< POSIX semaphores #define CONF_CRITICAL_SECTIONS //!< Critical Section support #define CONF_PROGRAM //!< dynamic program loading support #define CONF_VIS //!< generic visualization. //#define CONF_ROM_MEMCPY //!< Use the ROM memcpy routine // networking services // #define CONF_LNP //!< link networking protocol // #define CONF_LNP_FAST //!< enable 4800 bps LNP // Can override with compile-time option #if !defined(CONF_LNP_HOSTADDR) #define CONF_LNP_HOSTADDR 0 //!< LNP host address #endif // 16 nodes x 16 ports (affects size of lnp_addressing_handler[] table) #define CONF_LNP_HOSTMASK 0xf0 //!< LNP host mask // remote control services // #define CONF_RCX_PROTOCOL //!< RCX protocol handler #define CONF_LR_HANDLER //!< remote control keys handler service #define CONF_RCX_MESSAGE //!< standard firmware message service // drivers // #define CONF_DKEY //!< debounced key driver #define CONF_BATTERY_INDICATOR //!< automatic update of lcd battery indicator #define CONF_LCD_REFRESH //!< automatic display updates #define CONF_CONIO //!< console #define CONF_ASCII //!< ascii console #define CONF_DSOUND //!< direct sound #define CONF_ON_OFF_SOUND //!< sound on switch on/off #define CONF_DMOTOR //!< direct motor // #define CONF_DMOTOR_HOLD //!< experimental: use hold mode PWM instead of coast mode. #define CONF_DSENSOR //!< direct sensor #define CONF_DSENSOR_ROTATION //!< rotation sensor //#define CONF_DSENSOR_VELOCITY //!< rotation sensor velocity //#define CONF_DSENSOR_MUX //!< sensor multiplexor //#define CONF_DSENSOR_SWMUX //!< techno-stuff swmux sensor // dependencies // #if defined(CONF_ASCII) && !defined(CONF_CONIO) #error "Ascii needs console IO" #endif #if defined(CONF_DKEY) && !defined(CONF_TIME) #error "Key debouncing needs system time." #endif #if defined(CONF_TM) && !defined(CONF_TIME) #error "Task management needs system time." #endif #if defined(CONF_TM) && !defined(CONF_MM) #error "Task management needs memory management." #endif #if defined(CONF_TM) && !defined(CONF_ATOMIC) #error "Task management needs atomic counters for kernel lock" #endif #if defined(CONF_LNP) && defined(CONF_TM) && !defined(CONF_SEMAPHORES) #error "Tasksafe networking needs semaphores." #endif #if defined(CONF_SEMAPHORES) && !defined(CONF_ATOMIC) #error "Semphores need atomic counters" #endif #if defined(CONF_CRITICAL_SECTIONS) && !defined(CONF_ATOMIC) #error "Critical sections need atomic counters" #endif #if defined(CONF_RCX_PROTOCOL) && !defined(CONF_LNP) #error "RCX protocol needs networking." #endif #if defined(CONF_LR_HANDLER) && !defined(CONF_RCX_PROTOCOL) #error "Remote control handler needs remote control protocol." #endif #if defined(CONF_RCX_MESSAGE) && !defined(CONF_LNP) #error "Standard firmware message needs networking." #endif #if defined(CONF_LR_HANDLER) && !defined(CONF_TM) #error "Remote support needs task managment" #endif #if defined(CONF_PROGRAM) && (!defined(CONF_TM) || !defined(CONF_LNP) || !defined(CONF_DKEY) || !defined(CONF_ASCII)) #error "Program support needs task management, networking, key debouncing, and ASCII." #endif #if defined(CONF_DSENSOR_ROTATION) && !defined(CONF_DSENSOR) #error "Rotation sensor needs general sensor code." #endif #if defined(CONF_DSENSOR_VELOCITY) && !defined(CONF_DSENSOR_ROTATION) #error "Velocity sensor needs rotation sensor code." #endif //! macro used to put some legOS function in high memory area. #define __TEXT_HI__ __attribute__ ((__section__ (".text.hi"))) #endif // __config_h__ brickos-0.9.0/demo/0000755000175000017500000000000010173102444011626 5ustar cbcbbrickos-0.9.0/demo/c++/0000755000175000017500000000000010173102444012176 5ustar cbcbbrickos-0.9.0/demo/c++/Makefile0000644000175000017500000000321107555557624013663 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.9 2002/10/23 17:42:44 stephmo Exp $ ### FILE: demo/c++/Makefile - make the C++ Language Demo Programs ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # #LIBDIR# ### DO NOT REMOVE THIS LINE ### KERNEL = $(BRICKOS_ROOT)/boot/brickOS PROGRAMS = \ rover.lx \ batt.lx sensor.lx lightSensor.lx \ rotationSensor.lx \ rotation.velocity.Sensor.lx \ touchSensor.lx \ touch.pressed.Sensor.lx \ motor.lx sound.lx activeSensor.lx temperatureSensor.lx \ raceTrack.lx lampTest.lx # extra dynamic sources DOBJECTS= include ../../Makefile.common include ../../Makefile.user all:: $(PROGRAMS) @# nothing to do here but do it silently .depend: *.[cC] $(MAKEDEPEND) *.[cC] > .depend depend:: .depend @# nothing to do here but do it silently # NOTE: --format=1 is not supported on Linux ([ce]tags from emacs2[01] packages) # please set in your own environment tag: -ctags *.[cC] $(BRICKOS_ROOT)/include/*.h $(BRICKOS_ROOT)/include/*/*.h -etags *.[cC] $(BRICKOS_ROOT)/include/*.h $(BRICKOS_ROOT)/include/*/*.h clean: rm -f *.o *.dis *.dis2 *~ *.bak *.tgz *.s *.ds1 *.ds2 *.dmap *.dcoff rm -f *.srec *.map *.coff realclean: clean rm -f *.lx .depend tags TAGS .PHONY: all depend tag clean realclean # depencencies # ifndef NODEPS -include .depend endif ### -------------------------------------------------------------------------- ### End of FILE: demo/c++/Makefile ### ========================================================================== brickos-0.9.0/demo/c++/activeSensor.C0000644000175000017500000000222207544402045014755 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DSENSOR) #include #include #include #include // This program reads the sensor and displays the hex value on /// the display every 10 ms int main(int argc, char **argv) { Sensor s(Sensor::S2, true); while (!shutdown_requested()) { cputw(s.get()); delay(10); } return 0; } #else // CONF_DSENSOR #warning activeSensor.C requires CONF_DSENSOR #warning activeSensor demo will do nothing int main(int argc, char **argv) { return 0; } #endif // CONF_DSENSOR brickos-0.9.0/demo/c++/batt.C0000644000175000017500000000220210005106344013225 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DSENSOR) #include #include #include #include // This program reads the sensor and displays the hex value on /// the display every 10 ms int main(int argc, char **argv) { Battery b; while (!shutdown_requested()) { cputs("batt"); sleep(1); lcd_int(b.get()); sleep(1); } return 0; } #else #warning batt.C requires CONF_DSENSOR #warning batt demo will do nothing int main(int argc, char *argv[]) { return 0; } #endif // CONF_DSENSOR brickos-0.9.0/demo/c++/lampTest.C0000644000175000017500000000231610005106344014072 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) // This program beeps once a second #include #if defined(CONF_DMOTOR) #include // for the sleep() func. #include // for the shutdown_requested() func. #include int main(int argc, char **argv) { Lamp myLite(Lamp::B); int power = 0; myLite.on(); while (power < 255 && !shutdown_requested()) { myLite.brightness(power); sleep(1); power += (256/8); } myLite.off(); return 0; } #else // CONF_DMOTOR #warning lampTest.C requires CONF_DMOTOR #warning lamp demo will do nothing int main(int argc, char **argv) { return 0; } #endif // CONF_DMOTOR brickos-0.9.0/demo/c++/lightSensor.C0000644000175000017500000000224210005106344014600 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DSENSOR) #include #include #include #include // This program reads the light sensor and displays the hex value on /// the display every 10 ms int main(int argc, char **argv) { LightSensor l(LightSensor::S2); while (!shutdown_requested()) { cputw(l.get()); delay(10); } return 0; } #else // CONF_DSENSOR #warning lightSensor.C requires CONF_DSENSOR #warning lightSensor demo will do nothing int main(int argc, char **argv) { return 0; } #endif // CONF_DSENSOR brickos-0.9.0/demo/c++/motor.C0000644000175000017500000000265110005106344013443 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DMOTOR) #include #include #include #include // This is a simple example of using a single motor, which runs forward // at the fastest speed for 1 second, then goes in reverse at 1/2 speed // for 1 second, and then runs a minimum speed for 1 second. int main(int argc, char **argv) { Motor m(Motor::A); m.forward(); cputs ("Fast"); m.speed(m.max); sleep(1); cputs ("Med"); m.speed((m.max + m.min) / 2); m.reverse(); #ifdef CONF_DSOUND Sound::beep(); #endif // CONF_DSOUND sleep(1); cputs ("Slow"); m.speed(m.min); sleep(1); cls(); return 0; } #else // CONF_DMOTOR #warning motor.C requires CONF_DMOTOR #warning motor demo will do nothing int main(int argc, char **argv) { return 0; } #endif // CONF_DMOTOR brickos-0.9.0/demo/c++/raceTrack.C0000644000175000017500000000331310005106344014176 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DMOTOR) && defined(CONF_DSENSOR) #include #include #include #include #include // // This is a naive example of a rover which follows a dark line // int main(int argc, char **argv) { MotorPair m(Motor::A, Motor::C); LightSensor l(LightSensor::S2); const int speed = (m.max + m.min) / 3; m.off(); unsigned int lightLevel(l.sample()); unsigned int threshold(lightLevel + 5); cputw (lightLevel); sleep(2); while (!shutdown_requested()) { m.forward(speed); while (1) { const unsigned int value(l.get()); cputw(value); if (value > threshold) break; } m.brake(100); m.left(m.max); while (1) { const unsigned int value(l.get()); cputw(value); if (value < threshold) break; } m.brake(100); } return 0; } #else // CONF_DMOTOR && CONF_DSENSOR #warning raceTrack.C requires CONF_DMOTOR and CONF_DSENSOR #warning raceTrack demo will do nothing int main(int argc, char **argv) { return 0; } #endif // CONF_DMOTOR && CONF_DSENSOR brickos-0.9.0/demo/c++/rotation.velocity.Sensor.C0000644000175000017500000000252310005106344017245 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DSENSOR) && defined(CONF_DSENSOR_VELOCITY) #include #include #include // This program reads the rotation sensor and displays the hex value on /// the display every 10 ms int main(int argc, char **argv) { RotationSensor r(RotationSensor::S2, 0); while (!shutdown_requested()) { #ifdef CONF_DSENSOR_VELOCITY cputw(r.velocity()); #else cputw(0xffff); #endif delay(1000); } return 0; } #else #warning rotation.velocity.Sensor.C requires CONF_DSENSOR and CONF_DSENSOR_VELOCITY #warning rotation.velocity.Sensor.C demo will do nothing. int main(int argc, char **argv) { return 0; } #endif // defined(CONF_DSENSOR) && defined(CONF_DSENSOR_VELOCITY) brickos-0.9.0/demo/c++/rotationSensor.C0000644000175000017500000000241510005106344015332 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DSENSOR) && defined(CONF_DSENSOR_ROTATION) #include #include #include #include // This program reads the rotation sensor and displays the hex value on /// the display every 10 ms int main(int argc, char **argv) { RotationSensor r(RotationSensor::S2, 0); while (!shutdown_requested()) { cputw(r.pos()); delay(10); } return 0; } #else #warning rotationSensor.C requires CONF_DSENSOR and CONF_DSENSOR_ROTATION #warning rotationSensor.C demo will do nothing. int main(int argc, char **argv) { return 0; } #endif // defined(CONF_DSENSOR) && defined(CONF_DSENSOR_ROTATION) brickos-0.9.0/demo/c++/rover.C0000644000175000017500000000263707544402045013457 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #include #include #include #include // // This is a simple example of a two motor rover which moves forward for // 5 seconds, then goes in reverse for 5 seconds. It does this cycle // 5 times. // #if defined(CONF_DMOTOR) int main(int argc, char **argv) { MotorPair m(Motor::A, Motor::C); for (int i = 0; i < 10 && !shutdown_requested(); ++i) { if (i % 2) { m.forward(); #ifdef CONF_DSOUND Sound::beep(); #endif // CONF_DSOUND cputs ("FWD"); } else { m.reverse(); cputs ("REV"); } m.speed(m.max); sleep(5); } m.off(); cls(); return 0; } #else #warning rover.C requires CONF_DMOTOR #warning rover demo will do nothing int main(int argc, char *argv[]) { return 0; } #endif // CONF_DMOTOR brickos-0.9.0/demo/c++/sensor.C0000644000175000017500000000220110005106344013603 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DSENSOR) #include #include #include #include // This program reads the sensor and displays the hex value on /// the display every 10 ms int main(int argc, char **argv) { Sensor s(Sensor::S2); while (!shutdown_requested()) { cputw(s.get()); delay(10); } return 0; } #else // CONF_DSENSOR #warning sensor.C requires CONF_DSENSOR #warning sensor demo will do nothing int main(int argc, char **argv) { return 0; } #endif // CONF_DSENSOR brickos-0.9.0/demo/c++/sound.C0000644000175000017500000000212310005106344013425 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) // This program beeps once a second #include #if defined(CONF_DSOUND) #include #include #include #include int main(int argc, char **argv) { while (!shutdown_requested()) { Sound::beep(); cputs ("Beep"); sleep(1); cls(); } cls(); return 0; } #else // CONF_DSOUND #warning sound.C requires CONF_DSOUND #warning sound demo will do nothing int main(int argc, char **argv) { return 0; } #endif // CONF_DSOUND brickos-0.9.0/demo/c++/temperatureSensor.C0000644000175000017500000000232110005106344016024 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DSENSOR) #include #include #include #include // This program reads the temperature sensor and displays the hex value on /// the display every 100 ms int main(int argc, char **argv) { TemperatureSensor t(Sensor::S2); while (!shutdown_requested()) { const int a(t.tenths()); cputw(a); delay(100); } return 0; } #else // CONF_DSENSOR #warning temperatureSensor.C requires CONF_DSENSOR #warning temperatureSensor demo will do nothing int main(int argc, char **argv) { return 0; } #endif // CONF_DSENSOR brickos-0.9.0/demo/c++/touch.pressed.Sensor.C0000644000175000017500000000226710005106344016344 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DSENSOR) #include #include #include #include // This program reads the touch sensor and displays the hex value on /// the display every 10 ms int main(int argc, char **argv) { TouchSensor t(TouchSensor::S2); while (!shutdown_requested()) { cputw(t.pressed()); delay(10); } return 0; } #else // CONF_DSENSOR #warning touch.pressed.Sensor.C requires CONF_DSENSOR #warning touch.pressed.Sensor demo will do nothing int main(int argc, char **argv) { return 0; } #endif // CONF_DSENSOR brickos-0.9.0/demo/c++/touchSensor.C0000644000175000017500000000224010005106344014611 0ustar cbcb// // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #include #if defined(CONF_DSENSOR) #include #include #include #include // This program reads the touch sensor and displays the hex value on /// the display every 10 ms int main(int argc, char **argv) { TouchSensor t(TouchSensor::S2); while (!shutdown_requested()) { cputw(t.get()); delay(10); } return 0; } #else // CONF_DSENSOR #warning touchSensor.C requires CONF_DSENSOR #warning touchSensor demo will do nothing int main(int argc, char **argv) { return 0; } #endif // CONF_DSENSOR brickos-0.9.0/demo/Makefile0000644000175000017500000000277507553442444013320 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.7 2002/10/17 05:05:40 stephmo Exp $ ### FILE: demo/Makefile - make the C Language Demo Programs ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # name for the brickOS kernel # #LIBDIR# ### DO NOT REMOVE THIS LINE ### KERNEL=../boot/brickOS PROGRAMS=helloworld.lx rover.lx linetrack.lx robots.lx c++.lx sound.lx trailerbot.lx # extra dynamic sources DOBJECTS= all:: $(PROGRAMS) include ../Makefile.common include ../Makefile.user # for these targets, pass them on to C++ dir, too all clean realclean depend:: $(MAKE) -C c++ $@ .depend: *.c $(MAKEDEPEND) *.c > .depend depend:: .depend install uninstall: @# nothing to do here but do it silently # NOTE: --format=1 is not supported on Linux ([ce]tags in emacs2[01] packages) # please set in your own environment tag: -ctags *.c ../include/*.h ../include/*/*.h -etags *.c ../include/*.h ../include/*/*.h clean:: rm -f *.o *.dis *.dis2 *~ *.bak *.tgz *.s *.ds1 *.ds2 *.dmap *.dcoff rm -f *.srec *.map *.coff realclean:: clean rm -f *.lx .depend tags TAGS .PHONY: all depend tag clean realclean # depencencies # ifndef NODEPS include .depend endif ### -------------------------------------------------------------------------- ### End of FILE: demo/Makefile ### ========================================================================== brickos-0.9.0/demo/c++.cpp0000644000175000017500000000424607534555046012731 0ustar cbcb/*! \file c++.cpp \brief Demonstrates inheritance, virtual methods and new/delete. \author Markus L. Noga A StateChanger interface class is introduced. Two subclasses implement different behaviours with virtual methods, adressing display and beeper, respectively. main() successively generates StateChanger objects. Their virtual methods are are invoked via interface wrappers onOff() and setState(s). */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include #include #include //! An interface class. class StateChanger { public: virtual void setState(bool state) { if(state) enable(); else disable(); } virtual void enable() = 0; virtual void disable() = 0; void onOff(); }; //! An implementation using the display. class DisplayState : public StateChanger { public: void enable() { cputs("on"); } void disable() { cls(); } }; #ifdef CONF_DSOUND //! An implementation using sound. class SoundState : public StateChanger { public: void enable() { dsound_system(DSOUND_BEEP); } void disable() { } }; #endif // CONF_DSOUND void StateChanger::onOff() { setState(1); sleep(1); setState(0); sleep(1); } int main(int argc, char **argv) { StateChanger *s; s=new DisplayState; s->onOff(); delete s; #ifdef CONF_DSOUND s=new SoundState; s->onOff(); delete s; #endif // CONF_DSOUND return 0; } brickos-0.9.0/demo/helloworld.c0000644000175000017500000000024007530340563014152 0ustar cbcb#include #include int main(int argc, char **argv) { cputs("hello"); sleep(1); cputs("world"); sleep(1); cls(); return 0; } brickos-0.9.0/demo/linetrack.c0000644000175000017500000000531310005105607013746 0ustar cbcb/*! \file linetrack.c \brief A simple line tracker demo \author Markus L. Noga A simple line tracker demo. Lines are assumed to curve to the right, and initially encountered from the right (for example, from the inside of the test pad). Straight line tracking needs to define STRAIGHT_LINE. Assumes motors on A,C, light sensors on port 2 */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include #if defined(CONF_DSENSOR) && defined(CONF_DMOTOR) #include #include #include #include #include #define LIGHTSENS SENSOR_2 #define DARK_THRESH 0x40 #define BRIGHT_THRESH 0x48 #define NORMAL_SPEED (2*MAX_SPEED/3) #define TURN_SPEED (MAX_SPEED) // #define STRAIGHT_LINE static wakeup_t dark_found(wakeup_t data) { return LIGHT(LIGHTSENS)<(unsigned short)data; } static wakeup_t bright_found(wakeup_t data) { return LIGHT(LIGHTSENS)>(unsigned short)data; } static void locate_line() { motor_a_speed(NORMAL_SPEED); motor_c_speed(NORMAL_SPEED); motor_a_dir(fwd); motor_c_dir(fwd); wait_event(dark_found,DARK_THRESH); } static void follow_line() { int dir=0; while (!shutdown_requested()) { motor_a_speed(NORMAL_SPEED); motor_c_speed(NORMAL_SPEED); motor_a_dir(fwd); motor_c_dir(fwd); if (wait_event(bright_found,BRIGHT_THRESH) != 0) { if(dir==0) motor_a_dir(rev); else motor_c_dir(rev); #ifdef STRAIGHT_LINE dir=!dir; #endif motor_a_speed(TURN_SPEED); motor_c_speed(TURN_SPEED); wait_event(dark_found,DARK_THRESH); } } } int main(int argc, char *argv[]) { ds_active(&LIGHTSENS); locate_line(); follow_line(); return 0; } #else #warning linetrack.c requires CONF_DSENSOR and CONF_DMOTOR #warning linetrack demo will do nothing int main(int argc, char *argv[]) { return 0; } #endif // defined(CONF_DSENSOR) && defined(CONF_DMOTOR) brickos-0.9.0/demo/robots.c0000644000175000017500000000141307775246560013327 0ustar cbcb// Plays "wir sind die roboter" theme by Kraftwerk. #include #if defined(CONF_DSOUND) #include #include //! "wir sind die roboter" theme by Kraftwerk static const note_t robots[] = { { PITCH_D4, 2 } , { PITCH_C4, 1 } , { PITCH_D4, 1 }, { PITCH_F4, 1 } , { PITCH_D4, 1 } , { PITCH_D4, 2 }, { PITCH_F4, 2 } , { PITCH_G4, 1 } , { PITCH_C5, 1 }, { PITCH_A4, 2 } , { PITCH_D4, 2 } , { PITCH_END, 0 } }; int main(int argc,char *argv[]) { while (!shutdown_requested()) { if (wait_event(dsound_finished,0) != 0) dsound_play(robots); } return 0; } #else // CONF_DSOUND #warning robots.c requires CONF_DSOUND #warning robots demo will do nothing int main(int argc, char *argv[]) { return 0; } #endif // CONF_DSOUND brickos-0.9.0/demo/rover.c0000644000175000017500000000463210005105607013132 0ustar cbcb/*! \file rover.c \brief A simple rover demo \author Markus L. Noga a simple rover that evades obstacles. assumes motors on A,C, touch sensors on port 1,3 */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include #if defined(CONF_DSENSOR) && defined(CONF_DMOTOR) #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// wakeup_t sensor_press_wakeup(wakeup_t data); // the rover driver // int main(int argc, char *argv[]) { int dir=0; while (!shutdown_requested()) { motor_a_speed(2*MAX_SPEED/3); // go! motor_c_speed(2*MAX_SPEED/3); motor_a_dir(fwd); motor_c_dir(fwd); cputs("fwwd "); if (wait_event(&sensor_press_wakeup, 0) != 0) { if(SENSOR_1<0xf000) // keep in mind. dir=0; else dir=1; // back up // motor_a_dir(rev); motor_c_dir(rev); cputs("rev "); msleep(500); motor_a_speed(MAX_SPEED); // go! motor_c_speed(MAX_SPEED); if(dir==1) { motor_c_dir(fwd); cputs("left "); } else { motor_a_dir(fwd); cputs("right"); } msleep(500); } } return 0; } wakeup_t sensor_press_wakeup(wakeup_t data) { lcd_refresh(); return (SENSOR_1<0xf000) || (SENSOR_3<0xf000); } #else #warning rover.c requires CONF_DMOTOR and CONF_DSENSOR #warning rover demo will do nothing int main(int argc, char *argv[]) { return 0; } #endif // CONF_DSENSOR, CONF_DMOTOR brickos-0.9.0/demo/sound.c0000644000175000017500000000320510005105373013120 0ustar cbcb/*sound.c*/ #include #if defined(CONF_DSOUND) #include #include /*array of notes that make up the refrain*/ /*of Devil with a Blue Dress*/ static const note_t devil[] = { { PITCH_G4, QUARTER }, { PITCH_G4, QUARTER }, { PITCH_G4, QUARTER }, { PITCH_G4, QUARTER }, { PITCH_G4, HALF }, { PITCH_G4, HALF }, { PITCH_G4, HALF }, { PITCH_G4, HALF }, { PITCH_G4, HALF }, { PITCH_G4, HALF }, { PITCH_F4, QUARTER }, { PITCH_F4, QUARTER }, { PITCH_F4, QUARTER }, { PITCH_F4, QUARTER }, { PITCH_F4, HALF }, { PITCH_F4, HALF }, { PITCH_F4, HALF }, { PITCH_PAUSE, HALF }, { PITCH_PAUSE, HALF }, { PITCH_PAUSE, HALF }, { PITCH_E4, QUARTER }, { PITCH_E4, QUARTER }, { PITCH_E4, QUARTER }, { PITCH_E4, QUARTER }, { PITCH_F4, HALF }, { PITCH_F4, HALF }, { PITCH_E4, HALF }, { PITCH_E4, HALF }, { PITCH_F4, HALF }, { PITCH_F4, HALF }, { PITCH_E4, QUARTER }, { PITCH_E4, QUARTER }, { PITCH_E4, QUARTER }, { PITCH_E4, QUARTER }, { PITCH_F4, HALF }, { PITCH_F4, HALF }, { PITCH_E4, HALF }, { PITCH_PAUSE, HALF }, { PITCH_PAUSE, HALF }, { PITCH_PAUSE, HALF }, { PITCH_END, 0 } }; int main(int argc,char *argv[]) { /*The default makes this a really, really slow song*/ /*So, we speed it up a little bit.*/ dsound_set_duration(40); /*now, we play it*/ while (!shutdown_requested()) { if (wait_event(dsound_finished,0) != 0) dsound_play(devil); sleep(1); } return 0; } #else #warning sound.c requires CONF_DSOUND which is not set #warning sound demo will do nothing int main(int argc, char *argv[]) { return 0; } #endif // CONF_DSOUND brickos-0.9.0/demo/trailerbot.c0000644000175000017500000003015610005105607014144 0ustar cbcb/* trailerbot.c */ /* learns to "back up" a trailer without jack-knifing.*/ #include #if defined(CONF_DMOTOR) && defined(CONF_DSENSOR) && defined(CONF_DSENSOR_ROTATION) #include #include #include #include #include #include /* * Physical characteristics of the robot. * Increasing these increases the number of calculations * that must be done, but also the accuracy of the behavior of the robot. * Keep in mind that these should be congruent with the "real world." * I.e., by default, the "ANGLES" matches the accuracy of the rotation sensor * and the # of movements matches the number of motor commands * (hard/soft left/right, forward, and back, totalling 6) */ #define ANGLES 6 #define MOVEMENTS 6 /* * We use these to define the range of the angles. * Basically, these should be the jacknifed states. */ #define FAR_RIGHT 0 #define FAR_LEFT 4 /* * In order to encourage the robot to explore, we add a heaven state. * This state has a high reward, to "fool" the robot into looking for it. * Once the robot has tried (and failed) to reach it, the probability * of reaching HEAVEN will decline and the robot will ignore it. * The higher HEAVEN_REWARD is, the longer the robot will look for it. */ #define HEAVEN 5 #define HEAVEN_REWARD 20 /* * We need to be able to adjust the length of time that the robot moves * for. This will vary based on surface, structure, etc. * Adjust this so that a reverse backs the robot up all the way from a jackknife. * In my experience, 7 works reasonably well on carpet and 4 on wood floors. * This is also heavily dependent on battery power- lower this * if you have new batteries. */ #define TURN_MULTIPLIER 2 /* * Calculation variables. * These variables mainly affect the probability calculations done * by the robot. */ /* * EPSILON: How randomly do we move? * We start at EPSILON_MAX, and then after every move reduce EPSILON_CURRENT * by EPSILON_DECAY. * The higher EPSILON_MAX is, the more randomly we start. * The higher EPSILON_DECAY is, the quicker we get boring. * The lower EPSILON_MIN is, the more stable we are when we are done. */ #define EPSILON_MAX .60 #define EPSILON_MIN .10 #define EPSILON_DECAY .02 double EPSILON_CURRENT = EPSILON_MAX; /* * ALPHA: How quickly do we adjust the steering results? * The larger, the more impact an individual measurement can have. * If this is large, we can learn faster but one abberation will hurt * us longer. */ #define ALPHA .20 /* GAMMA: How important is the future v. the present? */ /* The larger, the more important the future is. */ #define GAMMA .90 /* KAPPA: How thoroughly do we update the Q values?*/ #define KAPPA 10 /* * Movement enum: what does each MOVEMENT int mean? * Enumerate clockwise from hard left. */ enum movement { HARD_LEFT, SOFT_LEFT, FORWARD, SOFT_RIGHT, HARD_RIGHT, REVERSE }; /* * Data arrays. * * steering_results stores the probability of the results of movements: * i.e., if we are in angle A and take movement B, what is the probability * that we end up at angle C? Range should be 0-1. * * q_score stores the "Q value" of an action. * i.e., given that we are at angle A, how "good" is the outcome of * the movement? Range should be 0-1. * * These are initialized in array_initialization(), called from main(). */ double steering_results[ANGLES][MOVEMENTS][ANGLES]; double q_score[ANGLES][MOVEMENTS]; /* * function to convert random from 0-2^31-1 to 0-1. */ double norm_random() { double temp; temp = random(); temp /= 2147483647; return temp; } /* * Function to convert rotation from 0-19 * to a more manageable 0-4 */ int norm_rotation(int real_value) { switch(real_value) { /*right jack-knife*/ case -1: case 0: case 1: case 2: return 0; /*leaning toward the right*/ case 3: case 4: case 5: case 6: return 1; /*centered!*/ case 7: case 8: case 9: case 10: case 11: case 12: return 2; /*leaning towards the left*/ case 13: case 14: case 15: case 16: return 3; /*left jack-knife*/ case 17: case 18: case 19: case 20: return 4; /*if none of these, big error*/ default: /*to be easily visible on LCD*/ cputs("ERROR"); sleep(1); return -1; } /*to get rid of compiler warning*/ return 0; } /* * Functions to initialize the data arrays. */ void array_initialization() { int i, j, k; /* * Make all steering possibilities the same; * All states stay the same until we "learn." * Probability is: 1/ANGLES */ for(i=0; i EPSILON_CURRENT) { /*We are doing what the table tells us to.*/ cputs("real "); msleep(500); for(i=0; i max_q_score) { max_q_score = q_score[initial_angle][i]; next_movement = i; } } } else { double temp; /*We are just picking something at random.*/ cputs("rand "); msleep(500); /*pick one. Any one.*/ temp = norm_random(); next_movement = temp*MOVEMENTS; /*show what we do next*/ lcd_int(next_movement); sleep(1); } /*what happens if next_movement never gets changed?*/ /*we'd hate to do HARD_LEFT over and over again*/ /*so we choose randomly*/ if(-1==next_movement) { double temp; temp = norm_random(); next_movement = temp*MOVEMENTS; } /*having chosen a movement, lets do it*/ switch(next_movement) { case HARD_LEFT: cputs("HL "); hard_left(); break; case SOFT_LEFT: cputs("SL "); soft_left(); break; case FORWARD: cputs("FWD "); go_forward(); break; case SOFT_RIGHT: cputs("SR "); soft_right(); break; case HARD_RIGHT: cputs("HR "); hard_right(); break; case REVERSE: cputs("REV "); go_back(); break; default: /*this is an error and should never be reached*/ cputs("ERROR"); sleep(1); stop_motors(); break; } /*Once we've started, we'd better stop*/ stop_motors(); /*Allows us to read direction*/ msleep(500); /*This is here just to make the next function cleaner*/ new_angle = norm_rotation(ROTATION_2); /*Where are we now?*/ cputs("NEW "); msleep(200); lcd_int(new_angle); msleep(500); /* * Since we know that "next_movement" took us from "initial_angle" * to new_angle (ROTATION_2), we store that increased probability. */ steering_results[initial_angle][next_movement][new_angle] += ALPHA; /*here we re-norm so that the sum of the probabilities is still 1*/ for(i=0; i EPSILON_MIN) { EPSILON_CURRENT-=EPSILON_DECAY; } } /* * This function updates the q_score table. * q_score is essentially the "expected" value of a move: * i.e., if I'm in angle A and do movement B, what can I expect? * Something good? Bad? */ void q_score_update() { /*loop variables. Lots of them.*/ int i, j, k, l; /*three variables for later*/ float reward; float q_sum; float max_q_score; for(i=0; i=FAR_LEFT)||(i<=FAR_RIGHT)||(REVERSE==j)) { reward = 0; } /*are we in "heaven?"*/ else if(HEAVEN==i) { reward = HEAVEN_REWARD; } /*if not, we get rewarded normally*/ else { reward = 1; } /* * This code "looks ahead" to see two things: * 1) What possibility do we have of getting to * all possible angles? * 2) Once we get to those angles, what is the best * possible outcome? * These two pieces of information are combined and * stored in q_sum. */ q_sum = 0; for(k=0; k max_q_score) { max_q_score = q_score[k][l]; } } q_sum += (steering_results[i][j][k]*max_q_score); } /*store the new expected q_score*/ q_score[i][j] = reward+(GAMMA*q_sum); } } } /* * main */ int main(int argc, char **argv) { int k; /*seed the random number generator*/ /*would be better to get a number from the environment here*/ ds_active(&SENSOR_1); msleep(100); srandom(LIGHT_1); ds_passive(&SENSOR_1); /*initialize rotation sensor*/ ds_active(&SENSOR_2); ds_rotation_on(&SENSOR_2); /*could initialize for left and right here*/ /*Have to make sure that the rotation sensor is correctly calibrated*/ cputs("start"); msleep(500); cputs("at "); msleep(500); cputs("right"); sleep(2); /*to ensure calibration, start against the right side*/ ds_rotation_set(&SENSOR_2, FAR_RIGHT); msleep(50); cputs("now "); msleep(500); cputs("centr"); sleep(1); /*We have to fill the probability arrays with "correct" information*/ array_initialization(); while (!shutdown_requested()) { /*We are going.*/ cputs("move"); msleep(500); move(); /*We are now calculating q-scores.*/ cputs("score"); for(k=0; k #ifdef CONF_ATOMIC /** * increment atomic counter without interruption. * locks interrupts except NMI, increments count * then restores interrupts. * @param counter the counter resource to be incremented * @see atomic_dec */ void atomic_inc(atomic_t* counter); __asm__("\n\ .text\n\ .globl _atomic_inc\n\ _atomic_inc:\n\ stc ccr, r1h ; save flags\n\ orc #0x80, ccr ; disable all but NMI\n\ mov.b @r0, r1l\n\ inc r1l\n\ mov.b r1l, @r0\n\ ldc r1h, ccr ; restore flags\n\ rts\n\ "); /** * decrement atomic counter without interruption. * locks interrupts except NMI, decrements count * then restores interrupts. * @param counter the counter resource to be decremented * @see atomic_inc */ void atomic_dec(atomic_t* counter); __asm__("\n\ .text\n\ .globl _atomic_dec\n\ _atomic_dec:\n\ stc ccr, r1h\n\ orc #0x80, ccr\n\ mov.b @r0, r1l\n\ dec r1l\n\ mov.b r1l, @r0\n\ ldc r1h, ccr\n\ rts\n\ "); #endif brickos-0.9.0/kernel/battery.c0000644000175000017500000000457107541267663014033 0ustar cbcb/*! \file battery.c \brief Inplementation: battery functions and low battery LCD indicator handling \author Paolo Masetti */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Paolo Masetti */ #include #include #include #include /////////////////////////////////////////////////////////////////////// // // Global Variables // /////////////////////////////////////////////////////////////////////// #ifdef CONF_BATTERY_INDICATOR unsigned int battery_refresh_counter = 0; //!< counter for lcd refresh in ms unsigned int battery_refresh_period = 2000; //!< LCD refresh period in ms #endif /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! return the approximate battery voltage (in milliVolts) #if defined(CONF_DSENSOR) int get_battery_mv() { long b = ds_scale(BATTERY) * 0xABD4L; return (int)(b / 0x618L); } #endif // CONF_DSENSOR #ifdef CONF_BATTERY_INDICATOR // battery indicator handed by kernel task when CONF_TM #ifndef CONF_TM //! battery indicator handler, called from system timer interrupt #ifdef CONF_RCX_COMPILER void battery_refresh(void) { #else // CONF_RCX_COMPILER HANDLER_WRAPPER("battery_refresh","battery_refresh_core"); void battery_refresh_core(void) { #endif // CONF_RCX_COMPILER int bmv = get_battery_mv(); if (bmv > BATTERY_NORMAL_THRESHOLD_MV) dlcd_hide(LCD_BATTERY_X); else if (bmv > BATTERY_LOW_THRESHOLD_MV) dlcd_show(LCD_BATTERY_X); } #endif // CONF_TM #endif // CONF_BATTERY_INDICATOR brickos-0.9.0/kernel/conio.c0000644000175000017500000002214007775246560013462 0ustar cbcb/*! \file conio.c \brief Implementation: console input / output \author Markus L. Noga \warning If CONF_LCD_REFRESH is set in config.h, the kernel will refresh the display automatically every 100ms. Otherwise, display updates are realized exclusively by lcd_refresh(). \par Display positions Digit display positions are denumerated from right to left, starting with 0 for the digit right to the running man. Digit 5 is only partially present on the RCXs display. \par Native segment masks In these bitmasks, bit 0 toggles the middle segment. Bit 1 toggles the top right segment, and the remaining segments are denumerated counterclockwise. The dot isn't encoded because it is desirable to seperate its positioning from the number display code. */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include #include #ifdef CONF_CONIO /////////////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////////////// //! hex display codes // const char hex_display_codes[] = { 0x7e, // 0 0x42, // 1 0x37, // 2 0x67, // 3 0x4b, // 4 0x6d, // 5 0x7d, // 6 0x46, // 7 0x7f, // 8 0x6f, // 9 0x5f, // A 0x79, // b 0x31, // c 0x73, // d 0x3d, // E 0x1d, // F }; #ifdef CONF_ASCII //! ASCII display codes /*! This is a 7-bit ASCII table only. */ const char ascii_display_codes[] = { 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // non-printables 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // -> underscore 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // except 0x00. 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, // 32 ' ' 0x42, // 33 ! 1 0x0a, // 34 " 0x7b, // 35 # 0x6d, // 36 $ 5 S Z 0x13, // 37 % / 0x7d, // 38 & 6 0x08, // 39 ' alt: ` 0x3c, // 40 ( C [ { 0x66, // 41 ) ] } 0x5b, // 42 * H K X 0x43, // 43 + alt: 0x19 (worse) 0x10, // 44 , . alt: 0x40 0x01, // 45 - 0x10, // 46 . alt: 0x40 0x13, // 47 / 0x7e, // 48 0 0 0x42, // 49 1 0x37, // 50 2 0x67, // 51 3 0x4b, // 52 4 0x6d, // 53 5 0x7d, // 54 6 0x46, // 55 7 0x7f, // 56 8 0x6f, // 57 9 0x21, // 58 : ; = alt:0x5 (worse) 0x21, // 59 ; 0x31, // 60 < c alt:0xd (worse) 0x21, // 61 = 0x61, // 62 > alt: 0x7 (worse) 0x17, // 63 ? 0x3f, // 64 @ alt: e 0x5f, // 65 A 0x79, // 66 b 0x3c, // 67 C 0x73, // 68 d 0x3d, // 69 E 0x1d, // 70 F 0x7c, // 71 G 0x5b, // 72 H 0x42, // 73 I 1 0x62, // 74 J 0x5b, // 75 K 0x38, // 76 L 0x5e, // 77 M N 0x5e, // 78 N 0x7e, // 79 O alt: o 0x1f, // 80 P 0x4f, // 81 Q 0x11, // 82 r 0x6d, // 83 S 0x46, // 84 T alt: t 0x7a, // 85 U V W 0x7a, // 86 V 0x7a, // 87 W 0x5b, // 88 X 0x6b, // 89 Y 0x37, // 90 Z 0x3c, // 91 [ 0x49, // 92 '\\' 0x66, // 93 ] 0x0e, // 94 ^ ~ 0x20, // 95 _ 0x02, // 96 ` alt: ' 0x5f, // 97 A R 0x79, // 98 b 0x31, // 99 c 0x73, // 100 d 0x3d, // 101 E 0x1d, // 102 F 0x7c, // 103 G 0x59, // 104 h 0x42, // 105 I 1 0x62, // 106 J alt 0x60 (worse) 0x5b, // 107 K alt h (worse?) 0x38, // 108 L 0x51, // 109 m n 0x51, // 110 n 0x71, // 111 o 0x1f, // 112 P 0x4f, // 113 q 0x11, // 114 r 0x6d, // 115 S 0x39, // 116 t 0x70, // 117 u v w 0x70, // 118 v 0x70, // 119 w 0x5b, // 120 X 0x6b, // 121 Y 0x37, // 122 Z 0x3c, // 123 { 0x18, // 124 | (left) alt: 1 (worse) 0x66, // 125 } 0x0e, // 126 ~ 0x00 // 127 "" 127 empty }; #endif // CONF_ASCII /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// #endif // CONF_CONIO //! uncalibrated delay loop /*! \param ms approximate time in ms */ void delay(unsigned ms) { unsigned i; while (ms-- > 0) for (i = 0; i < 600; i++) // not well calibrated. ; } #ifdef CONF_CONIO //! display native mode segment mask /*! \param mask the segment mask. \param pos the desired display position. this is a dispatcher for the fixed position routines. */ void cputc_native(char mask, int pos) { switch (pos) { case 0: cputc_native_0(mask); break; case 1: cputc_native_1(mask); break; case 2: cputc_native_2(mask); break; case 3: cputc_native_3(mask); break; case 4: cputc_native_4(mask); break; case 5: cputc_native_5(mask); } } //! display native mode segment mask at display position 0 /*! \param mask the mask to display */ void cputc_native_0(char mask) { // gcc is stupid // doesn't re-use constant values in registers. // re-ordered stores to help him. bit_load(mask, 0x2); dlcd_store(LCD_0_TOP); bit_load(mask, 0x0); dlcd_store(LCD_0_MID); bit_load(mask, 0x5); dlcd_store(LCD_0_BOT); bit_load(mask, 0x1); dlcd_store(LCD_0_TOPR); bit_load(mask, 0x6); dlcd_store(LCD_0_BOTR); bit_load(mask, 0x3); dlcd_store(LCD_0_TOPL); bit_load(mask, 0x4); dlcd_store(LCD_0_BOTL); } //! display native mode segment mask at display position 1 /*! \param mask the mask to display */ void cputc_native_1(char mask) { bit_load(mask, 0x2); dlcd_store(LCD_1_TOP); bit_load(mask, 0x0); dlcd_store(LCD_1_MID); bit_load(mask, 0x5); dlcd_store(LCD_1_BOT); bit_load(mask, 0x1); dlcd_store(LCD_1_TOPR); bit_load(mask, 0x6); dlcd_store(LCD_1_BOTR); bit_load(mask, 0x3); dlcd_store(LCD_1_TOPL); bit_load(mask, 0x4); dlcd_store(LCD_1_BOTL); } //! display native mode segment mask at display position 2 /*! \param mask the mask to display */ void cputc_native_2(char mask) { bit_load(mask, 0x2); dlcd_store(LCD_2_TOP); bit_load(mask, 0x0); dlcd_store(LCD_2_MID); bit_load(mask, 0x5); dlcd_store(LCD_2_BOT); dlcd_hide(LCD_2_DOT); bit_load(mask, 0x1); dlcd_store(LCD_2_TOPR); bit_load(mask, 0x6); dlcd_store(LCD_2_BOTR); bit_load(mask, 0x3); dlcd_store(LCD_2_TOPL); bit_load(mask, 0x4); dlcd_store(LCD_2_BOTL); } //! display native mode segment mask at display position 3 /*! \param mask the mask to display */ void cputc_native_3(char mask) { dlcd_hide(LCD_3_DOT); bit_load(mask, 0x2); dlcd_store(LCD_3_TOP); bit_load(mask, 0x0); dlcd_store(LCD_3_MID); bit_load(mask, 0x5); dlcd_store(LCD_3_BOT); bit_load(mask, 0x1); dlcd_store(LCD_3_TOPR); bit_load(mask, 0x6); dlcd_store(LCD_3_BOTR); bit_load(mask, 0x3); dlcd_store(LCD_3_TOPL); bit_load(mask, 0x4); dlcd_store(LCD_3_BOTL); } //! display native mode segment mask at display position 4 /*! \param mask the mask to display */ void cputc_native_4(char mask) { dlcd_hide(LCD_4_DOT); bit_load(mask, 0x2); dlcd_store(LCD_4_TOP); bit_load(mask, 0x0); dlcd_store(LCD_4_MID); bit_load(mask, 0x5); dlcd_store(LCD_4_BOT); bit_load(mask, 0x1); dlcd_store(LCD_4_TOPR); bit_load(mask, 0x6); dlcd_store(LCD_4_BOTR); bit_load(mask, 0x3); dlcd_store(LCD_4_TOPL); bit_load(mask, 0x4); dlcd_store(LCD_4_BOTL); } //! display native mode segment mask at display position 5 /*! \param mask the mask to display. only the middle segment is present on the display. */ void cputc_native_5(char mask) { bit_load(mask, 0x0); dlcd_store(LCD_5_MID); } //! display a hexword in the four leftmost positions. /*! \param word the hexword position 0 is unaffected by this call. */ void cputw(unsigned word) { int i; cputc_native(0, 5); for (i = 1; i <= 4; i++) { cputc_hex(word & 0x0f, i); word >>= 4; } #if !defined(CONF_LCD_REFRESH) lcd_refresh(); #endif } #ifdef CONF_ASCII //! display an ASCIIZ string /*! \param s the string only the first 5 characters will be displayed. if there are less than 5 characters, the remaining display positions will be cleared. */ void cputs(char *s) { int i; cputc_native(0, 5); for (i = 4; (*s) && (i >= 0);) cputc(*(s++), i--); while (i >= 1) cputc_native(0, i--); #if !defined(CONF_LCD_REFRESH) lcd_refresh(); #endif } //! clear user portion of screen void cls() { cputs(" "); } #endif // CONF_ASCII #endif // CONF_CONIO brickos-0.9.0/kernel/critsec.c0000644000175000017500000000556707777403630014020 0ustar cbcb #include "config.h" #include #include #include #if defined(CONF_TM) #include #include //! critical section counter for kernel/task manager /*! when the critical section counter is Zero, task swapping is allowed. when greater than zero, task swapping is not allowed. This is checked in the task_switch_handler() in systime.c */ atomic_t kernel_critsec_count; #if defined(CONF_CRITICAL_SECTIONS) //! check and increment counter, without interruptions /*! increments counter if count is already zero, or if this is the same task as the one that made it one. used to enter a normal critical section. \param counter pointer to counter to be incremented \param tid pointer to pointer to receive task pointer of the task that has locked the resource \return 0xffff if failure, 0 if successful \sa locked_decrement */ int locked_check_and_increment(atomic_t* counter, tdata_t** tid); __asm__("\n\ .text\n\ .global _locked_check_and_increment\n\ _locked_check_and_increment:\n\ push.w r4\n\ stc ccr, r4h\n\ orc #0x80, ccr\n\ mov.b @r0, r4l\n\ beq lci_get_lock\n\ \n\ push.w r2\n\ push.w r3\n\ mov.w @_ctid, r2\n\ mov.w @r1, r3\n\ sub.w r3, r2\n\ bne lci_cant_lock\n\ \n\ pop.w r3\n\ pop.w r2\n\ bra lci_get_lock\n\ \n\ lci_cant_lock:\n\ pop.w r3\n\ pop.w r2\n\ mov.w #0xffff, r0\n\ bra lci_done\n\ \n\ lci_get_lock:\n\ inc r4l\n\ mov.b r4l, @r0\n\ mov.w @_ctid, r0 \n\ mov.w r0, @r1 \n\ sub.w r0, r0\n\ \n\ lci_done:\n\ ldc r4h, ccr\n\ pop.w r4\n\ rts\n\ "); //! wakeup when critical section is available /*! wakeup function used to detect when a critical section is available. called while processing an interrupt, so interrupts are already disabled. */ wakeup_t wait_critical_section(wakeup_t data) { critsec_t* cs = (critsec_t*)((unsigned)data); if (locked_check_and_increment(&cs->count, &cs->task) == 0xffff) return 0; else return 1; } //! lock a critical section, or wait until it is available. /*! check and lock critical section if it is available; otherwise, wait until it is available, then lock it. \param cs pointer to critical section (critsec_t) \return 1 if successful, 0 upon failure \sa initialize_critical_section \sa leave_critical_section \sa destroy_critical_section */ int enter_critical_section(critsec_t* cs) { if (locked_check_and_increment(&cs->count, &cs->task) == 0xffff) return wait_event(&wait_critical_section, (wakeup_t)((unsigned)cs)); return 1; } #endif // CONF_CRITICAL_SECTIONS #endif // CONF_TM brickos-0.9.0/kernel/dkey.c0000644000175000017500000000661107777403630013307 0ustar cbcb/*! \file dkey.c \brief Implementation: debounced key driver \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include #ifdef CONF_DKEY #include #include #ifdef CONF_AUTOSHUTOFF #include #endif /////////////////////////////////////////////////////////////////////////////// // // Global Variables // /////////////////////////////////////////////////////////////////////////////// volatile unsigned char dkey_multi; //! multi-key state volatile unsigned char dkey; //! single key state /////////////////////////////////////////////////////////////////////////////// // // Internal Variables // /////////////////////////////////////////////////////////////////////////////// char dkey_timer __attribute__ ((unused)); //! debouncing timer /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 1\n\ .global _dkey_handler\n\ _dkey_handler:\n\ mov.b @_dkey_timer,r6l ; check debouncing timer==0\n\ beq dkey_check\n\ \n\ dec r6l\n\ mov.b r6l,@_dkey_timer\n\ rts\n\ \n\ dkey_check:\n\ sub.b r6l,r6l ; generate button codes\n\ ; from PORT4/PORT7 in r6l\n\ mov.b @_PORT4,r6h\n\ bld #1,r6h\n\ bist #0,r6l\n\ bld #2,r6h\n\ bist #1,r6l\n\ \n\ mov.b @_PORT7,r6h\n\ bld #6,r6h\n\ bist #2,r6l\n\ bld #7,r6h\n\ bist #3,r6l\n\ \n\ mov.b @_dkey_multi,r6h\n\ xor.b r6l,r6h ; create mask of changed positions in r6h\n\ beq dkey_same\n\ \n\ mov.b r6l,@_dkey_multi\n\ \n\ and.b r6h,r6l ; mask out unchanged positions\n\ mov.b r6l,@_dkey\n\ \n\ mov.b #100,r6l ; set debouncing timer\n\ mov.b r6l,@_dkey_timer\n\ \n\ dkey_same:\n\ rts\n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS //! wakeup if any of the given keys is pressed. // wakeup_t dkey_pressed(wakeup_t data) { #ifdef CONF_AUTOSHUTOFF if (idle_powerdown) { // if idle too long, say the OFF key was pressed dkey = KEY_ONOFF; return KEY_ONOFF; } #endif return (dkey & (unsigned char)data); } //! wakeup if all of the given keys are released. // wakeup_t dkey_released(wakeup_t data) { return ! (dkey & (unsigned char)data); } //! get and return a single key press, after waiting for it to arrive // int getchar(void) { wait_event(dkey_released,KEY_ANY); #ifdef CONF_AUTOSHUTOFF shutoff_restart(); #endif wait_event(dkey_pressed ,KEY_ANY); return dkey; } #endif // CONF_DKEY brickos-0.9.0/kernel/dmotor.c0000644000175000017500000001241607777403630013657 0ustar cbcb/*! \file dmotor.c \brief Implementation: direct motor control \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Lou Sortman */ #include #include #ifdef CONF_DMOTOR #include #include /////////////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////////////// //! motor drive patterns /*! to be indexed with MotorDirections \sa MotorDirections */ #ifdef CONF_DMOTOR_HOLD const unsigned char dm_a_pattern[]={0xc0,0x40,0x80,0x00}, dm_b_pattern[]={0x0c,0x04,0x08,0x00}, dm_c_pattern[]={0x03,0x01,0x02,0x00}; #else const unsigned char dm_a_pattern[]={0x00,0x80,0x40,0xc0}, dm_b_pattern[]={0x00,0x08,0x04,0x0c}, dm_c_pattern[]={0x00,0x02,0x01,0x03}; #endif MotorState dm_a, //!< motor A state dm_b, //!< motor B state dm_c; //!< motor C state /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// //! direct motor output handler /*! called by system timer in the 16bit timer OCIA irq */ extern void dm_handler(void); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .section .text.hi\n\ .align 1\n\ .global _dm_handler\n\ _dm_handler:\n\ ; r6 saved by ROM\n\ ; r0 saved by systime_handler\n\ " #ifdef CONF_DMOTOR_HOLD " mov.b #0xcf,r6l ; r6l is output\n" #else " sub.w r6,r6 ; r6l is output\n" #endif " ; we simultaneously load delta (r0h) and sum (r0l)\n\ ; this depends on byte order, but the H8 will stay MSB\n\ ; and the resulting code is efficient and compact.\n\ \n\ ; motor A\n\ \n\ mov.w @_dm_a,r0\n\ add.b #1,r0h ; maps 255 to 256\n\ dec.b r0h\n\ addx.b r0h,r0l ; add delta to sum\n\ bcc dm0 ; sum overflow?\n\ mov.b @_dm_a+2,r6h ; -> output drive pattern\n\ xor.b r6h,r6l\n\ dm0:mov.b r0l,@_dm_a+1 ; save sum\n\ \n\ ; motor B\n\ \n\ mov.w @_dm_b,r0\n\ add.b #1,r0h ; maps 255 to 256\n\ dec.b r0h\n\ addx.b r0h,r0l ; add delta to sum\n\ bcc dm1 ; sum overflow?\n\ mov.b @_dm_b+2,r6h ; -> output drive pattern\n\ xor.b r6h,r6l\n\ dm1:mov.b r0l,@_dm_b+1 ; save sum\n\ \n\ ; motor C\n\ \n\ mov.w @_dm_c,r0\n\ add.b #1,r0h ; maps 255 to 256\n\ dec.b r0h\n\ addx.b r0h,r0l ; add delta to sum\n\ bcc dm2 ; sum overflow?\n\ mov.b @_dm_c+2,r6h ; -> output drive pattern\n\ xor.b r6h,r6l\n\ dm2:mov.b r0l,@_dm_c+1 ; save sum\n\ \n\ ; driver chip\n\ \n\ mov.b r6l,@_motor_controller:8 ; output motor waveform\n\ \n\ rts \n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS //! initialize motors // void dm_init(void) { dm_shutdown(); // shutdown hardware } //! shutdown motors // void dm_shutdown(void) { motor_a_dir(off); // initialize driver data motor_b_dir(off); motor_c_dir(off); motor_a_speed(MAX_SPEED); motor_b_speed(MAX_SPEED); motor_c_speed(MAX_SPEED); motor_controller=0x00; // shutdown hardware } #ifdef CONF_VIS /* ** Define non-inline versions to display arrows */ void motor_a_dir(MotorDirection dir) { dm_a.dir = dm_a_pattern[dir]; dlcd_hide(LCD_A_LEFT); dlcd_hide(LCD_A_RIGHT); if (dir == fwd || dir == brake) dlcd_show(LCD_A_RIGHT); if (dir == rev || dir == brake) dlcd_show(LCD_A_LEFT); } void motor_b_dir(MotorDirection dir) { dm_b.dir = dm_b_pattern[dir]; dlcd_hide(LCD_B_LEFT); dlcd_hide(LCD_B_RIGHT); if (dir == fwd || dir == brake) dlcd_show(LCD_B_RIGHT); if (dir == rev || dir == brake) dlcd_show(LCD_B_LEFT); } void motor_c_dir(MotorDirection dir) { dm_c.dir = dm_c_pattern[dir]; dlcd_hide(LCD_C_LEFT); dlcd_hide(LCD_C_RIGHT); if (dir == fwd || dir == brake) dlcd_show(LCD_C_RIGHT); if (dir == rev || dir == brake) dlcd_show(LCD_C_LEFT); } #endif // ifdef CONF_VIS #endif // CONF_DMOTOR brickos-0.9.0/kernel/dsensor.c0000644000175000017500000003773307777403630014041 0ustar cbcb/*! \file dsensor.c \brief Implementation: direct sensor access \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Eric Habnerfeller * Lou Sortman */ /* * 2000.03.11 - Paolo Masetti * * - Included a fix for rotation sensor posted by "Ben Jackson" * on lugnet.robotics.rcx.legos * * 2000.04.30 - Paolo Masetti * * - ISR Reading routine fix to make read values stable. * - Fixed rotation sensor status table values to avoid offset problems. * * 2000.09.06 - Jochen Hoenicke * * - Added velocity calculation for rotation sensor. */ #include #ifdef CONF_DSENSOR #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////////////// #define DS_ALL_ACTIVE 0x07 //!< all sensors active mode #define DS_ALL_PASSIVE (~DS_ALL_ACTIVE) //!< all sensors passive mode /////////////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////////////// volatile unsigned char ds_channel; //!< current A/D channel unsigned char ds_activation; //!< channel bitmask. 1-> active #ifdef CONF_DSENSOR_ROTATION unsigned char ds_rotation; //!< channel bitmask. 1-> rotation volatile int ds_rotations[3]; //!< sensor revolutions * 16 static signed char rotation_state[3]; //!< rotation state static signed char rotation_new_state[3]; //!< proposed rotation state static unsigned int state_duration[3]; //!< proposed rotation state duration #ifdef CONF_DSENSOR_VELOCITY volatile int ds_velocities[3]; //!< sensor velocity static unsigned int last_rotation[3]; //!< last time of rotation signal static unsigned int next_rotation[3]; //!< rough upper estimatation of next signal time static signed char rotation_dir[3]; //!< direction of last rotation #endif //! convert a/d values to rotation states /*! Indexed with (value>>12). Invalid values yield negative states. */ static const signed char ad2state[16]={ // 0 1 2 3 4 5 6 7 8 9 a b c d e f // (sensor value>>12) -1,-1,-1,-1,-1, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 0 // New values to be used // with delayed read // -1,-1,-1,-1,-1,-1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 0 // Old values: biased for // non-delayed read }; //! convert state difference to revolution count change /*! Indexed with (newstate-state)+3. Invalid differences yield zero change. Differences of magnitude two could have been acheived in either rotational sense, so their expected value is zero. */ static const signed char diff2change[7]={ //-3 -2 -1 0 1 2 3 // newstate-state 1, 0,-1, 0, 1, 0,-1 }; /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// //! set rotation to an absolute value /*! \param sensor the sensor address, can be &SENSOR_1, &SENSOR_2 or &SENSOR_3 \param pos desired absolute position axis should be inert during the function call */ void ds_rotation_set(volatile unsigned *sensor,int pos) { if(sensor>=&AD_A && sensor<=&AD_C) { // catch range violations unsigned channel=(unsigned) (sensor-&AD_A); signed char state=ad2state[(*sensor)>>12]; if(state<0) state=0; rotation_state[channel]=state; rotation_new_state[channel] = -1; state_duration[channel]=0; ds_rotations[channel]=pos; // reset counter } } //! process rotation sensor on current A/D channel /*! \sa ds_channel current channel (global input value) */ void ds_rotation_handler() { unsigned channel =ds_channel; unsigned raw =(*((&AD_A)+channel)); signed char newstate=ad2state[raw>>12]; if (newstate < 0) return; if (newstate == rotation_new_state[channel]) { if (++state_duration[channel] == 2) { signed char change = diff2change[newstate - rotation_state[channel] + 3]; ds_rotations[channel] += change; #ifdef CONF_DSENSOR_VELOCITY { /* We only take the lowest 16 bits of sys_time. We have to be * a bit careful with wraparounds, but this is handled here. */ unsigned int time = (unsigned int) sys_time; if (change != rotation_dir[channel]) { rotation_dir[channel] = change; ds_velocities[channel] = 0; last_rotation[channel] = time; next_rotation[channel] = time + 1000; } else { if (time == last_rotation[channel]) ds_velocities[channel] = 1000 * change; else { unsigned int time_diff = (time - last_rotation[channel]); if (time_diff > 1000) { rotation_dir[channel] = 0; ds_velocities[channel] = 0; } else { int speed = 1000 / time_diff; ds_velocities[channel] = change > 0 ? speed : -speed; last_rotation[channel] = time; next_rotation[channel] = time + time_diff * 3 / 2; } } } } #endif rotation_state[channel] = newstate; rotation_new_state[channel] = -1; } } else if (newstate != rotation_state[channel]) { rotation_new_state[channel] = newstate; state_duration[channel] = 1; #ifdef CONF_DSENSOR_VELOCITY } else { /* No rotation change, check if velocity measure timeouts. */ unsigned int time = (unsigned int) sys_time; if (rotation_dir[channel] && ((signed int) (time - next_rotation[channel])) >= 0) { unsigned int time_diff = (time - last_rotation[channel]); if (time_diff > 1000) { rotation_dir[channel] = 0; ds_velocities[channel] = 0; } else { int speed = 1000 / time_diff; ds_velocities[channel] = rotation_dir[channel] > 0 ? speed : -speed; next_rotation[channel] = time + time_diff / 2; } } #endif } } #endif // CONF_DSENSOR_ROTATION #ifdef CONF_DSENSOR_MUX unsigned char ds_mux; //!< mux bitmask volatile int ds_muxs[3][3]; //!< mux ch values //width of each mux pulse #define DS_MUX_PULSE_TM_MS 10 typedef struct { unsigned long nextTm; //timestamp for next pulse char remainingEdges; //edges left in pulse train char channel; //current mux sub channel (0,1,2) unsigned int attached[3];//what channels are sensors attached to //this also defines the number of ms //to wait before reading the value enum {ds_mux_prepRead, ds_mux_read, ds_mux_pulse_low, ds_mux_pulse_high} action; //specify next action } ds_mux_data_t; ds_mux_data_t ds_mux_data[3]; //data on mux #endif //CONF_DSENSOR_MUX static inline void ds_power_on(unsigned channel) { switch(channel) { case 0: bit_set(&PORT6,0); break; case 1: bit_set(&PORT6,1); break; case 2: bit_set(&PORT6,2); break; default: //bad break; } }//endof ds_power_on static inline void ds_power_off(unsigned channel) { switch(channel) { case 0: bit_clear(&PORT6,0); break; case 1: bit_clear(&PORT6,1); break; case 2: bit_clear(&PORT6,2); break; default: //bad break; } }//endof ds_power_off #ifdef CONF_DSENSOR_MUX //! start multiplexing void ds_mux_on(volatile unsigned *sensor, unsigned int ch1, unsigned int ch2, unsigned int ch3) { unsigned char i,j; ds_passive(sensor);//powered, but not active in legOS sense if(ch1==0 && ch2==0 && ch3==0) { //umm this is useless //avoid endless cycling ds_mux_off(sensor); return; } if (sensor == &SENSOR_3) { i=0; } else if (sensor == &SENSOR_2) { i=1; } else if (sensor == &SENSOR_1) { i=2; } else { //bad return; } ds_mux_data[i].attached[0]=ch1; ds_mux_data[i].attached[1]=ch2; ds_mux_data[i].attached[2]=ch3; //add extended time based on the channel //this is required by the mux //the user supplies extra time based on the //type of sensor they hook up //these defaults give enough time to read //a light sensor and should be ok for most //sensors if(ch1) ds_mux_data[i].attached[0]+=160; if(ch2) ds_mux_data[i].attached[1]+=135; if(ch3) ds_mux_data[i].attached[2]+=25; //check if we're just adjusting the ports //if so we can return here if(i==0 && ds_mux&1) return; if(i==1 && ds_mux&2) return; if(i==2 && ds_mux&4) return; //starting up mux //power up ds_power_on(i); //schedule first event //find first attached sensor for(j=0;j<3 && ds_mux_data[i].attached[j]==0;j++); ds_mux_data[i].channel=j; ds_mux_data[i].remainingEdges=((j+1)*2); ds_mux_data[i].action=ds_mux_pulse_low; ds_mux_data[i].nextTm=sys_time+DS_MUX_PULSE_TM_MS; if (sensor == &SENSOR_3) { bit_set(&ds_mux, 0); } else if (sensor == &SENSOR_2) { bit_set(&ds_mux, 1); } else if (sensor == &SENSOR_1) { bit_set(&ds_mux, 2); } else { //bad return; } }//endof ds_mux_on void ds_mux_handler() { unsigned sen=ds_channel; if(ds_mux_data[sen].nextTm <= sys_time) { //we've reached our next scheduled step //lcd_int(sys_time-ds_mux_data[sen].nextTm); switch(ds_mux_data[sen].action) { case ds_mux_prepRead: ds_power_off(sen);//power down for read ds_mux_data[sen].action=ds_mux_read; ds_mux_data[sen].nextTm=sys_time;//do it ASAP, but not now break; case ds_mux_read: //read data switch(sen) { case 0: ds_muxs[sen][(int)ds_mux_data[sen].channel]=SENSOR_3; break; case 1: ds_muxs[sen][(int)ds_mux_data[sen].channel]=SENSOR_2; break; case 2: ds_muxs[sen][(int)ds_mux_data[sen].channel]=SENSOR_1; break; default: //bad } //change channel do { ds_mux_data[sen].channel++; if(ds_mux_data[sen].channel>2/*max chan*/) { ds_mux_data[sen].channel=0; } //make sure selected channel is marked attached //don't worry about an endless loop ds_mux_on makes //sure at least one channel is attached } while( (ds_mux_data[sen].attached [(int)ds_mux_data[sen].channel])==0); //use this low pulse as the first low pulse of next train ds_mux_data[sen].remainingEdges= ((ds_mux_data[sen].channel+1)*2)-1; //schedule next high pulse ds_mux_data[sen].action=ds_mux_pulse_high; ds_mux_data[sen].nextTm=sys_time+DS_MUX_PULSE_TM_MS; break; case ds_mux_pulse_low: //go low ds_power_off(sen); //schedule next high pulse ds_mux_data[sen].nextTm=sys_time+DS_MUX_PULSE_TM_MS; ds_mux_data[sen].remainingEdges--; ds_mux_data[sen].action=ds_mux_pulse_high; break; case ds_mux_pulse_high: //go high ds_power_on(sen); ds_mux_data[sen].remainingEdges--; if(ds_mux_data[sen].remainingEdges==0) { //done with train //schedule prepRead ds_mux_data[sen].action=ds_mux_prepRead; //schedule enough time for the mux to make the switch //this is scaled because the timeout the mux uses starts //when the first pulse comes in, it is around 70ms, so //when switching to sensor 1 we must want an additional //amount of time before it mux reacts, we wait less for 2 //and not at all for 3 //then we wait a little bit before reading the sensor //this give the sensor time to power up ds_mux_data[sen].nextTm=sys_time+ ds_mux_data[sen].attached[(int)ds_mux_data[sen].channel]; //lcd_int(ds_mux_data[sen].channel+1); break; } else { //schedule next low pulse ds_mux_data[sen].action=ds_mux_pulse_low; ds_mux_data[sen].nextTm=sys_time+DS_MUX_PULSE_TM_MS; } break; default: //bad } } }//endof ds_mux_handler #endif //CONF_DSENSOR_MUX //! sensor A/D conversion IRQ handler // extern void ds_handler(void); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 1\n\ _ds_handler:\n\ ; r6 saved by ROM\n\ \n\ mov.b @_ds_channel,r6l ; r6l = current channel\n\ \n\ mov.b @_ds_activation,r6h ; r6h = activation bitmask\n\ btst r6l,r6h ; activate output?\n\ beq ds_noset\n\ bset r6l,@_PORT6:8 ; activate output of last port scanned\n\ ds_noset:\n\ " #ifdef CONF_DSENSOR_ROTATION "\n\ mov.b @_ds_rotation,r6h ; r6h = rotation bitmask\n\ btst r6l,r6h ; process rotation sensor?\n\ beq ds_norot\n\ \n\ push r0 ; save r0..r3\n\ push r1\n\ push r2\n\ push r3 ; r4..r6 saved by gcc if necessary\n\ \n\ jsr _ds_rotation_handler ; process rotation sensor\n\ \n\ pop r3\n\ pop r2\n\ pop r1\n\ pop r0\n\ ds_norot:\n\ " #endif #ifdef CONF_DSENSOR_MUX "\n\ mov.b @_ds_mux,r6h ; r6h = mux bitmask\n\ btst r6l,r6h ; process mux sensor?\n\ beq ds_nomux\n\ \n\ push r0 ; save r0..r3\n\ push r1\n\ push r2\n\ push r3 ; r4..r6 saved by gcc if necessary\n\ \n\ jsr _ds_mux_handler ; process mux sensor\n\ \n\ pop r3\n\ pop r2\n\ pop r1\n\ pop r0\n\ ds_nomux:\n\ " #endif "\n\ inc r6l ; next channel\n\ and #0x03,r6l ; limit to 0-3\n\ \n\ mov.b @_ds_activation,r6h ; r6h = activation bitmask\n\ btst r6l,r6h ; activate output?\n\ beq ds_nounset\n\ bclr r6l,@_PORT6:8 ; set output inactive for reading\n\ ds_nounset:\n\ \n\ ; The settle time for reading the value from active sensor start here\n\ \n\ ; moved here for helping timing problems\n\ mov.b r6l,@_ds_channel ; store next channel\n\ \n\ ; Added a delay loop for sensor settle time\n\ \n\ mov.b #0x04, r6h ; delay loop\n\ settle:\n\ nop ; each nop is a 2 state clock delay\n\ dec.b r6h ; 2 states ?\n\ bne settle ; 4 states\n\ \n\ ; Total loop delay 32 states (?)\n\ \n\ mov.b @_AD_CSR:8,r6h ; r6h = A/D CSR\n\ and.b #0x7c,r6h ; reset scanmode and channel num\n\ or.b r6l,r6h ; scan next channel\n\ mov.b r6h,@_AD_CSR:8 ; put r6h back on A/D CSR\n\ \n\ ; The settle time for reading the value from active sensor finish here\n\ \n\ bset #0x5,@_AD_CSR:8 ; go!\n\ \n\ rts\n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS //! initialize sensor a/d conversion /*! all sensors set to passive mode rotation tracking disabled */ void ds_init(void) { rom_port6_ddr|=DS_ALL_ACTIVE; // notify ROM we are using PORT6_DDR =rom_port6_ddr; // PORT6 bit 0..2 as outputs ds_activation=0; // all sensors passive ds_channel =0; // start on channel 0 #ifdef CONF_DSENSOR_ROTATION ds_rotation =0; // rotation tracking disabled #endif #ifdef CONF_DSENSOR_MUX ds_mux=0; // muxing disabled #endif ad_vector=&ds_handler; // setup IRQ handler AD_CR &=~ADCR_EXTERN; AD_CSR =ADCSR_TIME_266 | ADCSR_GROUP_0 | ADCSR_AN_0 | ADCSR_ENABLE_IRQ | ADCSR_START; #ifdef CONF_CONIO delay(10); // wait for initial A/D #else # warning "Rotation initialization might fail." #endif } //! shutdown sensor a/d conversion /*! all sensors set to passive mode */ void ds_shutdown(void) { AD_CSR=0x00; PORT6 &=DS_ALL_PASSIVE; rom_port6_ddr&=DS_ALL_PASSIVE; PORT6_DDR =rom_port6_ddr; } #endif // CONF_DSENSOR brickos-0.9.0/kernel/dsound.c0000644000175000017500000001273007775657433013660 0ustar cbcb/*! \file dsound.c \brief Implementation: direct sound control \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Michael Nielsen * Kyosuke Ishikawa * Martin Cornelius */ #include #ifdef CONF_DSOUND #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////////////// //! note pitch -> frequency generator lookup table, index 0 ^= A0 static const unsigned pitch2freq[]={ 0x8d03, 0x8603, 0x7d03, 0x7703, 0x7003, 0x6a03, 0x6303, 0x5e03, 0x5903, 0x5403, 0x4f03, 0x4a03, 0x4603, 0x4203, 0xfd83, 0xee83, 0xe083, 0xd483, 0xc783, 0xbc83, 0xb283, 0xa883, 0x9e83, 0x9583, 0x8d83, 0x8583, 0x7e83, 0x7683, 0x7083, 0x6983, 0x6383, 0x5e83, 0x5983, 0x5383, 0x4f83, 0x4a83, 0x4683, 0x4283, 0xfc02, 0xee02, 0xe102, 0xd402, 0xc802, 0xbd02, 0xb202, 0xa802, 0x9e02, 0x9502, 0x8d02, 0x8502, 0xfc82, 0xee82, 0xe082, 0xd482, 0xc882, 0xbd82, 0xb282, 0xa882, 0x9e82, 0x9682, 0x8d82, 0x8582, 0x7e82, 0x7682, 0x7082, 0x6982, 0x6382, 0x5e82, 0x5882, 0x5382, 0x4f82, 0x4a82, 0x4682, 0x4282, 0xfc01, 0xee01, 0xe001, 0xd401, 0xc801, 0xbd01, 0xb201, 0xa801, 0x9e01, 0x9501, 0x8d01, 0x8501, 0x7e01, 0x7601, 0x7001, 0x6901, 0x6301, 0x5e01, 0x5801, 0x5301, 0x4f01, 0x4a01, 0x4601 }; //! single beep static const note_t sys_beep[]={ {PITCH_A4 , 1}, {PITCH_END, 0} }; //! system sound data const note_t *dsound_system_sounds[]={ sys_beep }; unsigned dsound_16th_ms; //!< length of 1/16 note in ms unsigned dsound_internote_ms; //!< length of internote spacing in ms volatile note_t *dsound_next_note; //!< pointer to current note volatile time_t dsound_next_time; //!< when to play next note static volatile int internote; //!< internote delay flag ////////////////////////////////////////////////////////////////////////////// // // Internal Functions // /////////////////////////////////////////////////////////////////////////////// //! start playing a given frequency static inline void play_freq(unsigned freq) { unsigned char CKSmask = freq & 0xff; unsigned char match = freq >> 8; T0_CR = 0x00; // timer off T0_CNT = 0x00; // counter reset #if 0 bit_load(CKSmask,0x7); // set ICKS0 bit_store(&STCR,0x0); #else if (CKSmask & 0x80) STCR |= 0x01; // ICKS0 = 1 else STCR &= ~0x01; // ICKS0 = 0 #endif T0_CORA = match; // set compare match A T0_CR = CR_CLEAR_ON_A | (CKSmask &0x3); } //! start playing a pause (aka stop playing freq) static inline void play_pause() { T0_CR = 0x00; // timer 0 off } ////////////////////////////////////////////////////////////////////////////// // // System functions // /////////////////////////////////////////////////////////////////////////////// //! sound handler, called from system timer interrupt #ifdef CONF_RCX_COMPILER void dsound_handler(void) { #else HANDLER_WRAPPER("dsound_handler","dsound_core"); //! sound core, called from ???? void dsound_core(void) { #endif if (get_system_up_time() >= dsound_next_time) { if(internote) { play_pause(); dsound_next_time = get_system_up_time() + dsound_internote_ms; internote=0; return; } if(dsound_next_note) { unsigned char pitch =dsound_next_note->pitch; if(pitchlength - dsound_internote_ms; dsound_next_note++; internote=1; return; } } dsound_stop(); } } //! initialize sound driver void dsound_init() { dsound_16th_ms=DSOUND_DEFAULT_16th_ms; dsound_internote_ms=DSOUND_DEFAULT_internote_ms; dsound_stop(); T0_CSR = CSR_TOGGLE_ON_A; // Output toggles on compare Match A } //! shutdown sound driver void dsound_shutdown() { dsound_stop(); } ////////////////////////////////////////////////////////////////////////////// // // User functions // /////////////////////////////////////////////////////////////////////////////// //! stop playing sound void dsound_stop(void) { play_pause(); dsound_next_note=0; dsound_next_time=0xffffffff; internote=0; } //! sound finished event wakeup function wakeup_t dsound_finished(wakeup_t data) { return !dsound_playing(); } #endif // CONF_DSOUND brickos-0.9.0/kernel/kmain.c0000644000175000017500000001314407777403630013451 0ustar cbcb/*! \file kmain.c \brief Implementaion: Main kernel loop \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Kekoa Proudfoot * Lou Sortman */ #include #include #include #include #include #include #include #include #include #include #include #ifdef CONF_AUTOSHUTOFF #include #endif #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////////////// //! firmware recognition string /*! the ROM checks for this string when validating new firmware */ unsigned char *firmware_string = "Do you byte, when I knock?"; extern char __bss; //!< the start of the uninitialized data segment extern char __bss_end; //!< the end of the uninitialized data segment //! the high memory segment extern char __text_hi, __etext_hi; #if defined(CONF_DSOUND) && defined(CONF_ON_OFF_SOUND) static const note_t on_sound[]={{PITCH_G4, 1}, {PITCH_G5, 1}, {PITCH_END, 0}}; static const note_t off_sound[]={{PITCH_C4, 1}, {PITCH_C3, 1}, {PITCH_END, 0}}; #endif /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// extern int main(int argc, char **argv); //!< the user main() #if defined(CONF_DSOUND) && defined(CONF_ON_OFF_SOUND) static void onOffSound(const note_t *snd) { dsound_set_duration(40); dsound_play(snd); } #endif //! show ON string extern inline void show_on(void) { cls(); #ifdef CONF_ASCII cputs("ON"); #else #ifdef CONF_CONIO cputc_native_4(0x38); cputc_native_3(0x3d); cputc_native_2(0x7c); cputc_native_1(0x7e); cputc_native_0(0x6d); #else lcd_digit(1); #endif #endif #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif #if defined(CONF_DSOUND) && defined(CONF_ON_OFF_SOUND) onOffSound(on_sound); #endif delay(250); #if defined(CONF_DSOUND) && defined(CONF_ON_OFF_SOUND) dsound_set_duration(DSOUND_DEFAULT_16th_ms); #endif } //! show OFF string extern inline void show_off(void) { cls(); #ifdef CONF_ASCII cputs("OFF"); #else #ifdef CONF_CONIO cputc_native_4(0x7e); cputc_native_3(0x1d); cputc_native_2(0x1d); #else lcd_digit(0); #endif #endif #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif #if defined(CONF_DSOUND) && defined(CONF_ON_OFF_SOUND) onOffSound(off_sound); #endif } //! the beginning of everything /*! initially called by ROM */ void kmain(void) __attribute__((noreturn)); void kmain(void) { int reset_after_shutdown=0; #ifdef CONF_DKEY int c; #endif /* Install the text.hi segment in the correct place. The * firmware loader puts it in the bss segment, we copy it * to it's final location. */ memcpy(&__text_hi, &__bss, &__etext_hi - &__text_hi); reset_vector = rom_reset_vector; /* Turn off motor, since writing to hitext manipulates motors */ motor_controller = 0; memset(&__bss, 0, &__bss_end - &__bss); #ifdef CONF_MM mm_init(); #endif while (1) { power_init(); #ifdef CONF_AUTOSHUTOFF shutoff_init(); #endif lcd_init(); #ifdef CONF_DSOUND dsound_init(); #endif #ifdef CONF_TIME systime_init(); #endif #ifdef CONF_DSENSOR ds_init(); #endif #ifdef CONF_DMOTOR dm_init(); #endif #ifdef CONF_LNP lnp_init(); lnp_logical_init(); #endif #ifdef CONF_TM tm_init(); #endif #ifdef CONF_PROGRAM program_init(); #endif show_on(); // wait till power key released // #ifdef CONF_DKEY dkey_multi=KEY_ANY; while((c=dkey_multi) & KEY_ONOFF); #else while (PRESSED(dbutton(), BUTTON_ONOFF)); delay(100); #endif cls(); #ifndef CONF_PROGRAM lcd_show(man_run); #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif #endif // run app // #ifdef CONF_TM # ifndef CONF_PROGRAM execi(&main,0,0,PRIO_NORMAL,DEFAULT_STACK_SIZE); # endif tm_start(); #else main(0, (void*)0); #endif show_off(); // ON/OFF + PROGRAM -> erase firmware #ifdef CONF_DKEY while((c=dkey_multi) & KEY_ONOFF) if(c&KEY_PRGM) reset_after_shutdown=1; #else while (PRESSED(dbutton(), BUTTON_ONOFF)) if (PRESSED(dbutton(), BUTTON_PROGRAM)) reset_after_shutdown=1; #endif #ifdef CONF_PROGRAM program_shutdown(); #endif #ifdef CONF_LNP lnp_logical_shutdown(); #endif #ifdef CONF_DMOTOR dm_shutdown(); #endif #ifdef CONF_DSENSOR ds_shutdown(); #endif #ifdef CONF_TIME systime_shutdown(); #endif if (reset_after_shutdown) rom_reset(); lcd_clear(); lcd_power_off(); power_off(); } } brickos-0.9.0/kernel/lcd.c0000644000175000017500000002072507777403630013117 0ustar cbcb/*! \file lcd.c \brief Implementation: wrapper for ROM LCD number display functions \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include #include #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////////////// #ifdef CONF_LCD_REFRESH unsigned char lcd_refresh_counter; //!< counter for lcd refresh in ms unsigned char lcd_byte_counter; //!< LCD byte to refresh unsigned char lcd_refresh_period = 2; //!< LCD refresh period in ms #endif //! lcd_shadow buffer: /*! contains the last display_memory bytes written to the LCD controller at position LCD_DATA_OFFSET. lcd_shadow also contains the buffer for the i2c commands written to the LCD controller. At offset LCD_SHORT_CMD a small piece of memory is reserved for direct commands to the LCD controller. This is used for power on/off, and for single byte updates. At offset LCD_LONG_CMD a small piece of memory is reserved for the i2c command header to do a full LCD update. The display data directly follows this header. The entire buffer in memory looks like this: 0 1 2 3 4 5 +------+------+------+------+------+--- ---+ | Addr | Cmd | Data | Addr | 0x00 | display data (9 bytes) | +------+------+------+------+------+--- ---+ \__________________/ \____________________________________/ LCD_SHORT_CMD LCD_LONG_CMD with display data */ static unsigned char lcd_shadow[LCD_DATA_OFFSET + LCD_DATA_SIZE]; /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// //! show number on LCD display /*! \param i the number \param n a number style \param c a comma style */ void lcd_number(int i,lcd_number_style n,lcd_comma_style c ); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 1\n\ .globl _lcd_number\n\ _lcd_number:\n\ push r6 ; save r6\n\ \n\ push r2 ; comma_style -> stack\n\ push r0 ; number -> stack\n\ \n\ mov.w r1,r6 ; number_style -> r6\n\ \n\ jsr @lcd_number ; call ROM\n\ \n\ adds #0x02,sp ; clear stack\n\ adds #0x02,sp\n\ \n\ pop r6 ; restore r6\n\ rts\n\ \n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS //! set single bit convenience macro #define set(b) __asm__ __volatile__("bset %0,@0xbb:8" : : "i"(b)); //! clear single bit convenience macro #define clr(b) __asm__ __volatile__("bclr %0,@0xbb:8" : : "i"(b)); //! generate the necessary delay for the i2c bus. /*! the h8/300 at 16 MHz is slow enough to run without delay, when running this code from RAM. There might be some delay necessary when running from ROM. */ #define slowdown() //! generate an i2c start condition. static __inline__ void i2c_start(void) { set(SDA); set(SCL); slowdown(); clr(SDA); slowdown(); clr(SCL); slowdown(); } //! generate an i2c stop condition. static __inline__ void i2c_stop(void) { clr(SDA); set(SCL); slowdown(); set(SDA); slowdown(); clr(SCL); slowdown(); set(SCL); // relax output driver (saves 0.5 mA) } //! read the acknoledge from the i2c bus. /*! Warning: the value of the acknoledge is ignored. We can't do much on errors anyway. */ static __inline__ void i2c_read_ack(void) { rom_port6_ddr &= ~(1 << SDA); PORT6_DDR = rom_port6_ddr; slowdown(); set(SCL); slowdown(); clr(SCL); rom_port6_ddr |= (1 << SDA); PORT6_DDR = rom_port6_ddr; slowdown(); } //! write one byte to the i2c bus. /*! \param val byte to write to the i2c bus */ static __inline__ void i2c_write(unsigned char val) { unsigned char bit; for (bit = (1 << 7); bit; bit >>= 1) { if (bit & val) { set(SDA); } else { clr(SDA); } slowdown(); set(SCL); slowdown(); clr(SCL); slowdown(); } } //! write an array of bytes to the i2c bus. /*! \param data array of bytes to write to the i2c bus \param len number of bytes to write len bytes are written to the i2c bus, including initial start condition and final stop condition. The first byte must contain a device address and the r/w flag. */ static void lcd_write_data(unsigned char *data, unsigned char len) { unsigned char i; i2c_start(); for (i = 0; i < len; i++) { i2c_write(*data++); i2c_read_ack(); } i2c_stop(); } #ifdef CONF_LCD_REFRESH //! lcd refresh handler, called from system timer interrupt /*! refresh one byte of display_memory. Bytes are refreshed in round robin fashon and the lcd_shadow buffer is updated. If there was no difference between display_memory and the lcd_shadow buffer, the actual write to the LCD controller is skipped. This routine is called every 6ms from the timer interrupt, resulting in a complete LCD update every 54ms, which is a refresh rate of 18 updates per second. */ #ifdef CONF_RCX_COMPILER void lcd_refresh_next_byte(void) #else HANDLER_WRAPPER("lcd_refresh_next_byte", "lcd_refresh_next_byte_core"); //! alternate name for the refresh next byte routine /*! \todo find a better description for this */ void lcd_refresh_next_byte_core(void) #endif { unsigned char byte; byte = lcd_byte_counter++; if (lcd_byte_counter >= LCD_DATA_SIZE) lcd_byte_counter = 0; if (lcd_shadow[byte + LCD_DATA_OFFSET] == display_memory[byte]) return; lcd_shadow[byte + LCD_DATA_OFFSET] = display_memory[byte]; lcd_shadow[LCD_SHORT_CMD + 1] = byte << 1; lcd_shadow[LCD_SHORT_CMD + 2] = display_memory[byte]; lcd_write_data(&lcd_shadow[LCD_SHORT_CMD], 3); } #endif // CONF_LCD_REFRESH //! refresh the entire LCD display /*! the entire 9 bytes of display_memory are written to the LCD controller unconditionally. lcd_shadow is updated to the new values. */ void lcd_refresh(void) { unsigned char i; for (i = 0; i < LCD_DATA_SIZE; i++) lcd_shadow[i + LCD_DATA_OFFSET] = display_memory[i]; lcd_write_data(&lcd_shadow[LCD_LONG_CMD], 11); } //! power on the LCD controller /*! the LCD controller is enabled. */ void lcd_power_on(void) { lcd_shadow[LCD_SHORT_CMD + 1] = LCD_MODE_SET | LCD_ENABLE; lcd_write_data(&lcd_shadow[LCD_SHORT_CMD], 2); } //! power off the LCD controller /*! the LCD controller is put in low power mode and output drivers to the LCD controller are disabled. Note: without disabling the output drivers the CPU will not save power in sleep mode. */ void lcd_power_off(void) { lcd_refresh(); lcd_shadow[LCD_SHORT_CMD + 1] = LCD_MODE_SET | LCD_DISABLE; lcd_write_data(&lcd_shadow[LCD_SHORT_CMD], 2); clr(SCL); clr(SDA); } //! initialize the LCD display driver /*! output drivers are configured as outputs. the lcd_shadow buffer is cleared and initialized. the LCD controller is enabled. */ void lcd_init(void) { rom_port6_ddr |= (1 << SCL); PORT6_DDR = rom_port6_ddr; clr(SCL); rom_port6_ddr |= (1 << SDA); PORT6_DDR = rom_port6_ddr; clr(SDA); memset(lcd_shadow, 0, sizeof(lcd_shadow)); lcd_shadow[LCD_SHORT_CMD] = LCD_DEV_ID | I2C_WRITE; lcd_shadow[LCD_LONG_CMD] = LCD_DEV_ID | I2C_WRITE; lcd_power_on(); #ifdef CONF_LCD_REFRESH lcd_refresh_counter = 0; lcd_byte_counter = 0; #endif } brickos-0.9.0/kernel/lnp-logical.c0000644000175000017500000001627607576365261014570 0ustar cbcb/*! \file lnp-logical.c \brief Implementation: link networking protocol logical layer \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Chris Dearman * Martin Cornelius */ #include #ifdef CONF_LNP #include #include #include #ifdef CONF_AUTOSHUTOFF #include #endif #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////////////// static const unsigned char *tx_ptr; //!< ptr to next byte to transmit static const unsigned char *tx_verify; //!< ptr to next byte to verify static const unsigned char *tx_end; //!< ptr to byte after last volatile signed char tx_state; //!< flag: transmission state //! when to allow next transmission /*! transmit OK -> wait some time to grant others bus access collision -> wait some more, plus "random" amount. receive -> reset timeout to default value. */ static time_t allow_tx; //!< time to allow new transmission #ifdef CONF_TM static sem_t tx_sem; //!< transmitter access semaphore #endif /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// #ifdef CONF_RCX_COMPILER static void rx_handler(void) __attribute__ ((rcx_interrupt)); static void rxerror_handler(void) __attribute__ ((rcx_interrupt)); static void tx_handler(void) __attribute__ ((rcx_interrupt)); void txend_handler(void) __attribute__ ((rcx_interrupt)); #else void rx_handler(void); void rxerror_handler(void); void tx_handler(void); void txend_handler(void); #endif //! enable IR carrier frequency. extern inline void carrier_init(void) { T1_CR =0x9; T1_CSR =0x13; T1_CORA=0x1a; } //! disable IR carrier frequency. extern inline void carrier_shutdown(void) { T1_CR =0; T1_CSR =0; } //! the byte received interrupt handler // #ifdef CONF_RCX_COMPILER static void rx_handler(void) { #else HANDLER_WRAPPER("rx_handler","rx_core"); void rx_core(void) { #endif time_t new_tx; lnp_timeout_reset(); if(tx_state allow_tx) allow_tx = new_tx; lnp_integrity_byte(S_RDR); } else { // echos of own bytes -> collision detection // if(S_RDR!=*tx_verify) { txend_handler(); tx_state=TX_COLL; } else if( tx_end <= ++tx_verify ) { // let transmission end handler handle things // tx_state=TX_IDLE; } } // suppress volatile modifier to generate bit instruction. // *((char*) &S_SR) &=~SSR_RECV_FULL; } //! the receive error interrupt handler // #ifdef CONF_RCX_COMPILER static void rxerror_handler(void) { #else HANDLER_WRAPPER("rxerror_handler","rxerror_core"); void rxerror_core(void) { #endif time_t new_tx; if(tx_state allow_tx) allow_tx = new_tx; } else { txend_handler(); tx_state=TX_COLL; } S_SR&=~SSR_ERRORS; } //! the end-of-transmission interrupt handler // #ifdef CONF_RCX_COMPILER void txend_handler(void) { #else HANDLER_WRAPPER("txend_handler","txend_core"); void txend_core(void) { #endif // shutdown transmit and irqs, clear status flags // S_CR&=~(SCR_TX_IRQ | SCR_TRANSMIT | SCR_TE_IRQ); S_SR&=~(SSR_TRANS_EMPTY | SSR_TRANS_END); } //! the transmit byte interrupt handler /*! write next byte if there's one left, otherwise unhook irq. */ #ifdef CONF_RCX_COMPILER static void tx_handler(void) { #else HANDLER_WRAPPER("tx_handler","tx_core"); void tx_core(void) { #endif if(tx_ptr= *((volatile time_t*)&allow_tx); } static wakeup_t write_complete(wakeup_t data) { return *((volatile signed char*)&tx_state) */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ /* * 2000.05.01 - Paolo Masetti * * - IR lcd now reflect IR mode (near/far) * * 2001.09.10 - Zhengrong Zang * * - Remote control buttons * - Standard firmware async message * * 2002.04.23 - Ted Hess * * - Integrate Ross Crawford/Zhengrong Zang remote control message parser * and RCX op-code dispatcher * */ #include #ifdef CONF_LNP #include #include #include #ifdef CONF_VIS #include #include #endif #ifdef CONF_AUTOSHUTOFF #include #endif #include /////////////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////////////// //! LNP host address (may be changed by dll utility --node=a option) //! Default vaule in config.h may be overidden at compile type unsigned char lnp_hostaddr = (CONF_LNP_HOSTADDR << 4) & CONF_LNP_HOSTMASK; //! the timeout counter in ms volatile unsigned short lnp_timeout_counter; //! the timeout length in ms unsigned short lnp_timeout=LNP_BYTE_TIMEOUT; //! the integrity layer state lnp_integrity_state_t lnp_integrity_state; //! there are no ports for integrity layer packets, so just one handler. /*! FIXME: uninitialized */ volatile lnp_integrity_handler_t lnp_integrity_handler; //! addressing layer packets may be directed to a variety of ports. /*! FIXME: uninitialized FIXME: inefficient if LNP_PORT_MASK doesn't adhere to 0...01...1 scheme. */ volatile lnp_addressing_handler_t lnp_addressing_handler[LNP_PORTMASK+1]; #if !defined(CONF_MM) static char lnp_buffer[260]; #endif // CONF_MM #if defined(CONF_RCX_PROTOCOL) //! remote handler lnp_remote_handler_t lnp_remote_handler; //! RCX protocol header bytes excluding first byte const unsigned char lnp_rcx_header[LNP_RCX_HEADER_LENGTH] = {0xff,0x00}; //! remote header bytes excluding first 3 bytes const unsigned char lnp_rcx_remote_op[LNP_RCX_REMOTE_OP_LENGTH] = {0xd2,0x2d}; //! temp cells for RCX firmware protocol assembly unsigned char lnp_rcx_temp0; unsigned char lnp_rcx_temp1; //! checksum from RCX protocol unsigned char lnp_rcx_checksum; #endif #if defined(CONF_RCX_MESSAGE) //! message header bytes excluding first 3 bytes const unsigned char lnp_rcx_msg_op[LNP_RCX_MSG_OP_LENGTH] = {0xf7,0x08}; //! message from standard firmware unsigned char lnp_rcx_message; #endif /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// #define lnp_checksum_init(sum) (unsigned char)((sum) = 0xff) #define lnp_checksum_step(sum,d) (unsigned char)((sum) += (d)) #ifdef CONF_HOST unsigned char lnp_checksum_copy( unsigned char *dest, const unsigned char *data, unsigned length ) { unsigned char a = 0xff; unsigned char t; do { t = *data++; a += t; *dest++ = t; length--; } while (length > 0); return a; } #else __asm__( ".text\n" "_lnp_checksum_copy:\n" ";; r0: dest, r1: data, r2: length;\n" " add.w r0,r2 ; r2: end \n" " mov.b #0xff,r3l ; r3l: a \n" "0:\n" " mov.b @r1+,r3h ; r3h = *data++ \n" " add.b r3h,r3l ; a += r3h \n" " mov.b r3h,@r0 ; *dest++ = r3h \n" " adds #1,r0 \n" " cmp.w r0,r2 \n" " bne 0b \n" " sub.w r0,r0 \n" " mov.b r3l,r0l \n" " rts \n" ); #endif //! send a LNP integrity layer packet of given length /*! \return 0 on success. */ int lnp_integrity_write(const unsigned char *data,unsigned char length) { int r; #if defined(CONF_MM) char* buffer_ptr = malloc(length+3); #else // CONF_MM char* buffer_ptr = lnp_buffer; #endif // CONF_MM unsigned char c = lnp_checksum_copy( buffer_ptr+2, data, length); lnp_checksum_step( c, buffer_ptr[0]=0xf0 ); lnp_checksum_step( c, buffer_ptr[1]=length ); buffer_ptr[length+2] = c; r = lnp_logical_write(buffer_ptr,length+3); #if defined(CONF_MM) free(buffer_ptr); #endif // CONF_MM return r; } //! send a LNP addressing layer packet of given length /*! \return 0 on success. */ int lnp_addressing_write(const unsigned char *data,unsigned char length, unsigned char dest,unsigned char srcport) { int r; #if defined(CONF_MM) char* buffer_ptr = malloc(length+5); #else // CONF_MM char* buffer_ptr = lnp_buffer; #endif // CONF_MM unsigned char c = lnp_checksum_copy( buffer_ptr+4, data, length ); lnp_checksum_step( c, buffer_ptr[0]=0xf1 ); lnp_checksum_step( c, buffer_ptr[1]=length+2 ); lnp_checksum_step( c, buffer_ptr[2]=dest ); lnp_checksum_step( c, buffer_ptr[3]= (lnp_hostaddr | (srcport & LNP_PORTMASK)) ); buffer_ptr[length+4] = c; r = lnp_logical_write(buffer_ptr,length+5); #if defined(CONF_MM) free(buffer_ptr); #endif // CONF_MM return r; } //! handle LNP packet from the integrity layer void lnp_receive_packet(const unsigned char *data) { unsigned char header=*(data++); unsigned char length=*(data++); lnp_integrity_handler_t intgh; lnp_addressing_handler_t addrh; // only handle non-degenerate packets in boot protocol 0xf0 // switch(header) { case 0xf0: // raw integrity layer packet, no addressing. intgh = lnp_integrity_handler; if(intgh) { #ifdef CONF_AUTOSHUTOFF shutoff_restart(); #endif intgh(data,length); } break; case 0xf1: // addressing layer. if(length>2) { unsigned char dest=*(data++); if(lnp_hostaddr == (dest & LNP_HOSTMASK)) { unsigned char port=dest & LNP_PORTMASK; addrh = lnp_addressing_handler[port]; if(addrh) { unsigned char src=*(data++); #ifdef CONF_AUTOSHUTOFF shutoff_restart(); #endif addrh(data,length-2,src); } } } } // switch(header) } //! receive a byte, decoding LNP packets with a state machine. void lnp_integrity_byte(unsigned char b) { static unsigned char buffer[256+3]; static int bytesRead,endOfData; static unsigned char chk; if(lnp_integrity_state==LNPwaitHeader) bytesRead=0; buffer[bytesRead++]=b; switch(lnp_integrity_state) { case LNPwaitHeader: // valid headers are 0xf0 .. 0xf7 // if(((b & 0xf8) == 0xf0) || (b == 0x55)) { #ifdef CONF_VIS if (lnp_logical_range_is_far()) { dlcd_show(LCD_IR_UPPER); dlcd_show(LCD_IR_LOWER); } else { dlcd_hide(LCD_IR_UPPER); dlcd_show(LCD_IR_LOWER); } #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif #endif // Init checksum lnp_checksum_init( chk ); // switch on protocol header if (b == 0x55) { #if defined(CONF_RCX_PROTOCOL) || defined(CONF_RCX_MESSAGE) // 0x55 is header for standard firmware message lnp_integrity_state = LNPwaitRMH1; #else lnp_integrity_reset(); #endif } else { lnp_integrity_state++; } } break; case LNPwaitLength: endOfData=b+2; lnp_integrity_state++; break; case LNPwaitData: if(bytesRead==endOfData) lnp_integrity_state++; break; case LNPwaitCRC: if(b==chk) lnp_receive_packet(buffer); lnp_integrity_reset(); break; #if defined(CONF_RCX_PROTOCOL) || defined (CONF_RCX_MESSAGE) // state machine to handle remote case LNPwaitRMH1: case LNPwaitRMH2: // waiting for header bytes if ( b == lnp_rcx_header[ lnp_integrity_state-LNPwaitRMH1 ] ) lnp_integrity_state++; else lnp_integrity_reset(); break; case LNPwaitRMH3: case LNPwaitRMH4: if ( b == lnp_rcx_remote_op[ lnp_integrity_state-LNPwaitRMH3 ] ) lnp_integrity_state++; #if defined(CONF_RCX_MESSAGE) else if ( b == lnp_rcx_msg_op[ lnp_integrity_state-LNPwaitRMH3 ] ) lnp_integrity_state = LNPwaitMH4; #endif else lnp_integrity_reset(); break; case LNPwaitRB0: lnp_rcx_temp0 = b; lnp_integrity_state++; break; case LNPwaitRB0I: if ( (unsigned char)~b == lnp_rcx_temp0 ) lnp_integrity_state++; else lnp_integrity_reset(); break; case LNPwaitRB1: lnp_rcx_temp1 = b; lnp_integrity_state++; break; case LNPwaitRB1I: if ( (unsigned char)~b == lnp_rcx_temp1 ) lnp_integrity_state++; else lnp_integrity_reset(); break; case LNPwaitRC: lnp_rcx_checksum = 0xd2 + lnp_rcx_temp0 + lnp_rcx_temp1; if ( b == lnp_rcx_checksum ) lnp_integrity_state++; else lnp_integrity_reset(); break; case LNPwaitRCI: // if checksum valid and remote handler has been installed, call remote handler if ( b == (unsigned char)~lnp_rcx_checksum) { #if defined(CONF_RCX_MESSAGE) // if a message, set message number and exit if (lnp_rcx_temp1 & 0x07) { lnp_rcx_message = (lnp_rcx_temp1 > 2) ? 3 : lnp_rcx_temp1; } else #endif { // Invoke remote handler if any lnp_remote_handler_t rmth = lnp_remote_handler; if (rmth) rmth( (lnp_rcx_temp0<<8)+lnp_rcx_temp1 ); } } // reset state machine when done lnp_integrity_reset(); break; #endif #if defined(CONF_RCX_MESSAGE) // state machine to handle RCX protocol messages case LNPwaitMH3: case LNPwaitMH4: if ( b == lnp_rcx_msg_op[ lnp_integrity_state-LNPwaitMH3 ] ) lnp_integrity_state++; else lnp_integrity_reset(); break; case LNPwaitMN: lnp_rcx_temp0 = b; lnp_integrity_state++; break; case LNPwaitMNC: if ( (unsigned char)~b == lnp_rcx_temp0 ) lnp_integrity_state++; else lnp_integrity_reset(); break; case LNPwaitMC: lnp_rcx_temp1 = 0xf7 + lnp_rcx_temp0; if (b == lnp_rcx_temp1) lnp_integrity_state++; else lnp_integrity_reset(); break; case LNPwaitMCC: // set message variable if it is valid message if ( (unsigned char)~b == lnp_rcx_temp1 ) lnp_rcx_message = lnp_rcx_temp0; // reset state machine lnp_integrity_reset(); break; #endif } // Accumulate checksum lnp_checksum_step( chk, b ); } //! reset the integrity layer on error or timeout. #if defined(CONF_RCX_COMPILER) || defined(CONF_HOST) void lnp_integrity_reset(void) { #else HANDLER_WRAPPER("lnp_integrity_reset","lnp_integrity_reset_core"); void lnp_integrity_reset_core(void) { #endif #ifndef CONF_HOST if(tx_state>TX_IDLE) { txend_handler(); tx_state=TX_COLL; } else #endif if(lnp_integrity_state!=LNPwaitHeader) { lnp_integrity_state=LNPwaitHeader; #ifdef CONF_VIS dlcd_hide(LCD_IR_LOWER); dlcd_hide(LCD_IR_UPPER); #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif #endif } } //! return whether a packet is currently being received /*! \return 1 if yes, else zero */ int lnp_integrity_active(void) { return lnp_integrity_state!=LNPwaitHeader; } //! reset the inter-byte timeout counter. #if defined(CONF_RCX_COMPILER) || defined(CONF_HOST) void lnp_timeout_reset(void) { #else HANDLER_WRAPPER("lnp_timeout_reset","lnp_timeout_reset_core"); void lnp_timeout_reset_core(void) { #endif lnp_timeout_counter=lnp_timeout; } //! set the inter-byte timeout and reset the timeout counter to that value. /*! \param timeout the new timeout value */ void lnp_timeout_set(unsigned short timeout) { lnp_timeout_counter=lnp_timeout=timeout; } //! Initialise protocol handlers /*! Adressing port 0 is reserved for the program handler. */ void lnp_init(void) { int k; for(k=1; k<=LNP_PORTMASK; k++) lnp_addressing_handler[k]=LNP_DUMMY_ADDRESSING; lnp_integrity_handler=LNP_DUMMY_INTEGRITY; #if defined(CONF_RCX_PROTOCOL) lnp_remote_handler=LNP_DUMMY_REMOTE; #endif #if defined(CONF_RCX_MESSAGE) clear_msg(); #endif } #ifdef CONF_RCX_MESSAGE wakeup_t msg_received(wakeup_t m) { return (m == 0 ? lnp_rcx_message != 0 : lnp_rcx_message == m); } //! send a standard firmware message /*! \return 0 on success. */ int send_msg(unsigned char msg) { int r; #if defined(CONF_MM) char* buffer_ptr = malloc(9); #else // CONF_MM char* buffer_ptr = lnp_buffer; #endif // CONF_MM buffer_ptr[0]=0x55; buffer_ptr[1]=0xff; buffer_ptr[2]=0x00; buffer_ptr[3]=0xf7; buffer_ptr[4]=0x08; buffer_ptr[5]=msg; buffer_ptr[6]=(unsigned char) (0xff-msg); buffer_ptr[7]=(unsigned char) (0xf7+msg); buffer_ptr[8]=(unsigned char) (0x08-msg); r = lnp_logical_write(buffer_ptr,9); #if defined(CONF_MM) free(buffer_ptr); #endif // CONF_MM return r; } #endif #endif // CONF_LNP brickos-0.9.0/kernel/mm.c0000644000175000017500000001611107623607320012750 0ustar cbcb/*! \file mm.c \brief Implementation: dynamic memory management \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include #ifdef CONF_MM #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////////////// size_t *mm_first_free; //!< first free block #ifndef CONF_TM typedef size_t tid_t; //! dummy process ID type //! current process ID /*! we need a non-null, non-0xffff current pid even if there is no task management. */ const tid_t ctid=0x0001; #endif /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// // // memory block structure: // 0 1 : pid of owner (0=empty) // 2 3 : size of data block >> 1 // 4 ... 4+2n: data // //! check for free blocks after this one and join them if possible /* \param ptr pointer to size field of current block \return size of block */ size_t mm_try_join(size_t *ptr) { size_t *next=ptr+*ptr+1; size_t increase=0; while(*next==MM_FREE && next>=&mm_start) { increase+=*(next+1) + MM_HEADER_SIZE; next +=*(next+1) + MM_HEADER_SIZE; } return (*ptr)+=increase; } //! defragment free blocks /*! use mm_try_join on each free block of memory */ void mm_defrag() { size_t *ptr = &mm_start; #ifdef CONF_TM ENTER_KERNEL_CRITICAL_SECTION(); #endif while(ptr >= &mm_start) { if(*ptr == MM_FREE) mm_try_join(ptr+1); ptr += *(ptr+1); ptr += MM_HEADER_SIZE; } #ifdef CONF_TM LEAVE_KERNEL_CRITICAL_SECTION(); #endif } //! update first free block pointer /*! \param start pointer to owner field of a memory block to start with. */ void mm_update_first_free(size_t *start) { size_t *ptr=start; while((*ptr!=MM_FREE) && (ptr>=&mm_start)) ptr+=*(ptr+1)+MM_HEADER_SIZE; mm_first_free=ptr; } //! initialize memory management /*! */ void mm_init() { size_t *current,*next; current=&mm_start; // memory layout // MM_BLOCK_FREE (&mm_start); // ram // something at 0xc000 ? MM_BLOCK_RESERVED(0xef30); // lcddata MM_BLOCK_FREE (0xef50); // ram2 MM_BLOCK_RESERVED(0xf000); // motor MM_BLOCK_FREE (0xfe00); // ram4 MM_BLOCK_RESERVED(0xff00); // stack, onchip // expand last block to encompass all available memory *current=(int)(((-(int) current)-2)>>1); mm_update_first_free(&mm_start); } //! allocate a block of memory /*! \param size requested block size \return 0 on error, else pointer to block. */ void *malloc(size_t size) { size_t *ptr,*next; size=(size+1)>>1; // only multiples of 2 #ifdef CONF_TM ENTER_KERNEL_CRITICAL_SECTION(); #endif ptr=mm_first_free; while(ptr>=&mm_start) { if(*(ptr++)==MM_FREE) { // free block? #ifdef CONF_TM mm_try_join(ptr); // unite with later blocks #endif if(*ptr>=size) { // big enough? *(ptr-1)=(size_t)ctid; // set owner // split this block? if((*ptr-size)>=MM_SPLIT_THRESH) { next=ptr+size+1; *(next++)=MM_FREE; *(next)=*ptr-size-MM_HEADER_SIZE; mm_try_join(next); *ptr=size; } // was it the first free one? if(ptr==mm_first_free+1) mm_update_first_free(ptr+*ptr+1); #ifdef CONF_TM LEAVE_KERNEL_CRITICAL_SECTION(); #endif return (void*) (ptr+1); } } ptr+=(*ptr)+1; // find next block. } #ifdef CONF_TM LEAVE_KERNEL_CRITICAL_SECTION(); #endif return NULL; } //! free a previously allocated block of memory. /*! \param the_ptr pointer to block ever heard of free(software_paradigm)? */ void free(void *the_ptr) { size_t *ptr=the_ptr; #ifndef CONF_TM size_t *p2,*next; #endif if(ptr==NULL || (((size_t)ptr)&1) ) return; ptr-=MM_HEADER_SIZE; *((size_t*) ptr)=MM_FREE; // mark as free #ifdef CONF_TM // for task safe operations, free needs to be // atomic and nonblocking, because it may be // called by the scheduler. // // therefore, just update mm_first_free // if(ptr 0) \param size individual block size (must be >0) \return 0 on error, else pointer to block */ void *calloc(size_t nmemb, size_t size) { void *ptr; size_t original_size = size; if (nmemb == 0 || size == 0) return 0; size*=nmemb; // if an overflow occurred, size/nmemb will not equal original_size if (size/nmemb != original_size) return 0; if((ptr=malloc(size))!=NULL) memset(ptr,0,size); return ptr; } //! free all blocks allocated by the current process. /*! called by exit() and kmain(). */ void mm_reaper() { size_t *ptr; // pass 1: mark as free ptr=&mm_start; while(ptr>=&mm_start) { if(*ptr==(size_t)ctid) *ptr=MM_FREE; ptr+=*(ptr+1)+MM_HEADER_SIZE; } // pass 2: defragment free areas // this may alter free blocks mm_defrag(); } //! return the number of bytes of unallocated memory int mm_free_mem(void) { int free = 0; size_t *ptr; #ifdef CONF_TM ENTER_KERNEL_CRITICAL_SECTION(); #endif // Iterate through the free list for (ptr = mm_first_free; ptr >= &mm_start; ptr += *(ptr+1) + MM_HEADER_SIZE) free += *(ptr+1); #ifdef CONF_TM LEAVE_KERNEL_CRITICAL_SECTION(); #endif return free*2; } #endif brickos-0.9.0/kernel/program.c0000644000175000017500000004007707543753616014031 0ustar cbcb/*! \file program.c \brief Implementation: program data structures and functions \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Frank Cremer */ /* * 2000.05.01 - Paolo Masetti * * - Added "CMDirmode" for changing via LNP IR mode * * 2001.05.10 - Matt Ahrens * * - Added free memory and batter life display * Press "view" repeatedly while no programs are running to see * * 2002.4.23 - Ted Hess * * - Added Remote key handler */ #include #ifdef CONF_PROGRAM #include #include #include #include #include #include #include #include #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // // Global Variables // /////////////////////////////////////////////////////////////////////////////// volatile unsigned cprog; //!< the current program /////////////////////////////////////////////////////////////////////////////// // // Internal Variables // /////////////////////////////////////////////////////////////////////////////// const unsigned char min_length[]={ 1, // CMDacknowledge 2, // CMDdelete 13, // CMDcreate 8, // CMDoffsets 4, // CMDdata 2, // CMDrun 2, // CMDirmode 2 // CMDsethost }; static program_t programs[PROG_MAX]; //!< the programs static unsigned char* buffer_ptr; //!< packet receive buffer volatile unsigned char packet_len; //!< packet length volatile unsigned char packet_src; //!< packet sender static sem_t packet_sem; //!< synchronization semaphore #if 0 #define debugs(a) { cputs(a); msleep(500); } #define debugw(a) { cputw(a); msleep(500); } #else #define debugs(a) #define debugw(a) #endif // Forward ref int lrkey_handler(unsigned int etype, unsigned int key); /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// //! check if a given program is valid. /*! \return 0 if invalid */ int program_valid(unsigned nr) { program_t *prog=programs+nr; return (nr < PROG_MAX) && (prog->text_size>0) && (prog->text_size+prog->data_size==prog->downloaded); } //! run the given program static void program_run(unsigned nr) { if(program_valid(nr)) { program_t *prog=programs+nr; // initialize data segments // memcpy(prog->data,prog->data_orig,prog->data_size); memset(prog->bss,0,prog->bss_size); execi((void*) (((char*)prog->text) + prog->start ), 0,0,prog->prio,prog->stack_size); } } //! packet handler, called from interrupt /*! allocates buffer, copies data and wakes parser task. */ static void packet_producer(const unsigned char *data, unsigned char length, unsigned char src) { // old packet still unhandled or empty packet? // if(packet_len>0 || length==0) return; if (buffer_ptr != 0) return; buffer_ptr = malloc(length); memcpy(buffer_ptr,data,length); packet_len=length; packet_src=src; sem_post(&packet_sem); } //! packet command parser task static int packet_consumer(int argc, char *argv[]) { packet_cmd_t cmd; unsigned char nr=0; program_t *prog=programs; // to avoid a silly warning const static unsigned char acknowledge=CMDacknowledge; char msg[8]; while (!shutdown_requested()) { // wait for new packet // packet_len=0; free(buffer_ptr); buffer_ptr = 0; if (sem_wait(&packet_sem) != -1) { if (buffer_ptr == 0) continue; debugw(*(size_t*)buffer_ptr); // handle trivial errors // cmd=buffer_ptr[0]; if (cmd>=CMDlast || packet_len CMDacknowledge) && (cmd <= CMDrun)) { nr = buffer_ptr[1]; if(nr > PROG_MAX) continue; #ifndef CONF_VIS cputc_hex_0(nr+1); #endif } debugw(nr); prog = programs+nr; switch( cmd ) { case CMDdelete: debugs("dele"); if(nb_tasks <= nb_system_tasks) { if(prog->text) free(prog->text); memset(prog,0,sizeof(program_t)); #ifndef CONF_VIS if(nr == cprog) cputc_0('-'); #endif debugs("OK"); lnp_addressing_write(&acknowledge,1,packet_src,0); } break; case CMDcreate: debugs("crea"); if(!prog->text) { memcpy(&(prog->text_size),buffer_ptr+2,11); if((prog->text=malloc(prog->text_size+ 2*prog->data_size+ prog->bss_size ))) { prog->data=prog->text+prog->text_size; prog->bss=prog->data+prog->data_size; prog->data_orig=prog->bss +prog->bss_size; prog->downloaded=0; debugs("OK"); cputw(0); cprog = nr; msg[0]=CMDacknowledge; msg[1]=nr; memcpy(msg+2,prog,6); lnp_addressing_write(msg,8,packet_src,0); } else memset(prog,0,sizeof(program_t)); } break; case CMDdata: debugs("data"); if(prog->text && !program_valid(nr)) { size_t offset=*(size_t*)(buffer_ptr+2); if(offset<=prog->downloaded) { if(offset==prog->downloaded) { memcpy(prog->text+offset,buffer_ptr+4,packet_len-4); prog->downloaded+=packet_len-4; if(program_valid(nr)) { // copy original data segment and we're done. // memcpy(prog->data_orig,prog->data,prog->data_size); cls(); } else cputw(prog->downloaded); debugs("OK"); } else debugs("OLD"); lnp_addressing_write(&acknowledge,1,packet_src,0); } } break; case CMDrun: debugs("run"); if(program_valid(nr)) { cprog = nr; program_stop(0); program_run(nr); debugs("OK"); lnp_addressing_write(&acknowledge,1,packet_src,0); } break; default: debugs("error"); } } } free(buffer_ptr); return 0; } //! stop program void program_stop(int flag) { int count_down = 40; // Kindly request that all user tasks shutdown shutdown_tasks(T_USER); // Wait a bit while (--count_down && (nb_tasks > nb_system_tasks)) { if (flag) cputs("STOP"); msleep(100); } if (nb_tasks > nb_system_tasks) { // Wait no longer. if (flag) { cputs("KILL"); // display immediately lcd_refresh(); } killall(PRIO_HIGHEST-1); } // Reset motors, sensors, sound & LNP as // programs may have motors running, // sensors active or handlers set. // // Programs that exit on their own // are assumed to take the necessary // actions themselves. // #ifdef CONF_DSOUND dsound_stop(); #endif #ifdef CONF_DMOTOR dm_init(); #endif #ifdef CONF_DSENSOR ds_init(); #endif lnp_init(); #ifdef CONF_LR_HANDLER // Reset remote button handler lr_init(); lr_set_handler(lrkey_handler); #endif } //! handle key input (on/off, run, program) int key_handler(int argc, char *argv[]) { int c; #ifndef CONF_VIS cputc_0('-'); #endif while (!shutdown_requested()) { int clear=0; c=getchar(); gotkey: debugs("key "); debugw(c); debugs("task"); debugw(nb_tasks); switch(c) { case KEY_ONOFF: cputs("OFF"); // Kindly request all tasks shutdown shutdown_tasks(T_USER | T_KERNEL); // Except for key_handler ctid->tflags &= (~T_SHUTDOWN); // Wait a bit clear = 50; while (--clear && (nb_tasks > 2)) msleep(100); // Wait no longer. if (nb_tasks > 2) killall(PRIO_HIGHEST); // Now key_handler should shutdown ctid->tflags |= T_SHUTDOWN; break; case KEY_RUN: // toggle: start/stop program if(nb_tasks > nb_system_tasks) { // if program running, stop it clear=1; program_stop(1); } else if(program_valid(cprog)) { program_stop(0); program_run(cprog); } else { cputs("NONE"); clear=1; } break; case KEY_PRGM: // works only if no programs are running. if(nb_tasks <= nb_system_tasks) { int i; for(i=0; i=PROG_MAX) cprog=0; if(program_valid(cprog)) break; } if(i==PROG_MAX) { cputs("NONE"); clear=1; #ifndef CONF_VIS cputc_0('-'); } else cputc_hex_0(cprog+1); #else } #endif } break; case KEY_VIEW: // works only if no programs are running. if (nb_tasks > nb_system_tasks) break; /* * pressing the "view" button cycles through a display of the * amount of the amount of free memory (in decimal and * hexadecimal) and battery power. If a button other than "view" * is pressed while cycling through, we handle that button * ("goto gotkey"). */ cputs("addr"); if ((c = getchar()) != KEY_VIEW) goto gotkey; cputw(lnp_hostaddr); while ((c = getchar()) == KEY_PRGM) { lnp_hostaddr += 0x10; lnp_hostaddr &= CONF_LNP_HOSTMASK; cputw(lnp_hostaddr); } if (c != KEY_VIEW) goto gotkey; if (program_valid(cprog)) { cputs("dele"); if ((c = getchar()) != KEY_VIEW && c != KEY_PRGM) goto gotkey; if (c == KEY_PRGM) { program_t *prog=programs+cprog; if (prog->text) free(prog->text); memset(prog,0,sizeof(program_t)); cputc_0('-'); } } cputs("free"); if ((c = getchar()) != KEY_VIEW) goto gotkey; lcd_int(mm_free_mem()); if ((c = getchar()) != KEY_VIEW) goto gotkey; cputw(mm_free_mem()); if ((c = getchar()) != KEY_VIEW) goto gotkey; #if defined(CONF_DSENSOR) cputs("batt"); if ((c = getchar()) != KEY_VIEW) goto gotkey; lcd_int(get_battery_mv()); if ((c = getchar()) != KEY_VIEW) goto gotkey; #endif // CONF_DSENSOR clear=1; break; } if(clear) { wait_event(dkey_released,KEY_ANY); cls(); } } return 0; } #if defined(CONF_LR_HANDLER) //! handle remote key input (P1-P5, A1-C1, A2-C2, stop, beep) int lrkey_handler(unsigned int etype, unsigned int key) { unsigned char pnr = 0; // If a program is running, stop it // NOTE: this LRKEY is allowed while a program is running! if(key == LRKEY_STOP && etype == LREVT_KEYON && nb_tasks > nb_system_tasks) { program_stop(1); return 1; // we consumed key } // Only interested if no program is running if(nb_tasks <= nb_system_tasks) { // Keydown events dispatched here if (etype == LREVT_KEYON) { switch (key) { #ifdef CONF_DSOUND case LRKEY_BEEP: // Need high pitched beep-beep dsound_system(0); break; #endif // CONF_DSOUND case LRKEY_P5: pnr++; // ... Fallthru case LRKEY_P4: pnr++; // ... Fallthru case LRKEY_P3: pnr++; // ... Fallthru case LRKEY_P2: pnr++; // ... Fallthru case LRKEY_P1: // Start something? if(program_valid(pnr)) { cprog = pnr; // Reset things program_stop(0); #ifdef CONF_VIS cputc_hex_0(pnr+1); #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif #endif // launch Program(n) program_run(pnr); } else { // no such program downloaded cputs("NONE"); } break; #if defined(CONF_DMOTOR) // Motor on commands case LRKEY_A1: // A Motor fwd motor_a_dir(fwd); break; case LRKEY_A2: // A Motor rev motor_a_dir(rev); break; case LRKEY_B1: // B Motor fwd motor_b_dir(fwd); break; case LRKEY_B2: // B Motor rev motor_b_dir(rev); break; case LRKEY_C1: // C Motor fwd motor_c_dir(fwd); break; case LRKEY_C2: // C Motor rev motor_c_dir(rev); break; #endif // CONF_DMOTOR default: // Not consumed return 0; } #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif // Key consumed return 1; } // Keyup events dispatched here if (etype == LREVT_KEYOFF) { switch (key) { #if defined(CONF_DMOTOR) case LRKEY_A1: case LRKEY_A2: // Shut off A motor motor_a_dir(brake); break; case LRKEY_B1: case LRKEY_B2: // Shut off B motor motor_b_dir(brake); break; case LRKEY_C1: case LRKEY_C2: // Shut off C motor motor_c_dir(brake); break; #endif // CONF_DMOTOR case LRKEY_P1: case LRKEY_P2: case LRKEY_P3: case LRKEY_P4: case LRKEY_P5: case LRKEY_STOP: // remove the STOP (or NONE) message cls(); break; default: return 0; } // Used the key return 1; } } #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif // Didn't eat the key return 0; } #endif //! initialize program support /*! run in single tasking mode */ void program_init() { packet_len=0; sem_init(&packet_sem,0,0); execi(&packet_consumer,0,0,PRIO_HIGHEST,DEFAULT_STACK_SIZE); execi(&key_handler,0,0,PRIO_HIGHEST,DEFAULT_STACK_SIZE); #ifdef CONF_LR_HANDLER // Setup kernel remote callback handler and dispatch thread lr_startup(); lr_set_handler(lrkey_handler); #endif lnp_addressing_set_handler(0,&packet_producer); buffer_ptr = 0; } //! shutdown program support /*! run in single tasking mode */ void program_shutdown() { lnp_addressing_set_handler(0,LNP_DUMMY_ADDRESSING); sem_destroy(&packet_sem); #ifdef CONF_LR_HANDLER lr_shutdown(); #endif } #endif // CONF_PROGRAM brickos-0.9.0/kernel/remote.c0000644000175000017500000001022007576365261013641 0ustar cbcb/*! \file remote.c \brief Implementation: LEGO Infrared Remote Control and data structures \author Ross Crawford */ /* * Copyright (c) 2001 Ross Crawford * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. */ /* * 2002.04.23 - Ted Hess * * - Integrated into legOS 0.2.6. Added lr_startup(), lr_shutdown() * Release input buffer while processing keys * */ #include #if defined(CONF_LR_HANDLER) #include #include #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // // Internal Variables // /////////////////////////////////////////////////////////////////////////////// time_t lr_timeoff; // all keys off if no data received before... unsigned int lr_curkeys; // mask of keys currently "ON" unsigned int lr_data; // lnp data byte int lr_dataready = 0; // lr_data valid? lr_handler_t lr_handler; // the user event handler tid_t lr_tid; // Button dispatch thread /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// //! Called from LNP when key data available void lr_getdata(unsigned int x) { // If previous data hasn't been processed yet, this will be lost if (lr_dataready == 0) { lr_data = x; lr_dataready = 1; } // Reset timeout lr_timeoff = get_system_up_time() + LR_TIMEOUT; } //! Key state dispatcher (keyup / keydown) void lr_process(unsigned int lr_keys) { unsigned int keys_on, keys_off, common_keys, k; // If keys pressed has changed if (lr_keys != lr_curkeys) { // Get mask of keys pressed & released since last event common_keys = (lr_keys & lr_curkeys); keys_on = lr_keys & ~common_keys; keys_off = lr_curkeys & ~common_keys; // send event to user handler for each change if (lr_handler) { for (k=1; k; k<<=1) { if (keys_on & k) lr_handler(LREVT_KEYON,k); if (keys_off & k) lr_handler(LREVT_KEYOFF,k); } } // store key mask for next time lr_curkeys = lr_keys; } return; } wakeup_t lr_waitdata(wakeup_t data) { // if time runs out, fake "all keys off" if (get_system_up_time() > lr_timeoff && lr_curkeys != 0) { lr_data = 0; lr_dataready = 1; } // tell lr_thread whether there's any data available return lr_dataready; } //! lr_thread just sits waiting for data, processing it as it arrives int lr_thread(int argc, char *argv[]) { unsigned int lr_keys; while(!shutdown_requested()) { if (wait_event(&lr_waitdata, 0) != 0) { // Snatch input before calling user handler lr_keys = lr_data; // Have local copy of input data, allow buffer to refill lr_dataready = 0; // Call user handler lr_process(lr_keys); } } return 0; } //! Init remote key dispatcher void lr_init() { lnp_remote_set_handler(lr_getdata); return; } //! Startup lr_thread and init protocol handler. void lr_startup() { // start with all keys off, set initial timeout, clear user handler lr_curkeys = 0; lr_timeoff = get_system_up_time() + LR_TIMEOUT; lr_handler = NULL; // Start watcher thread, then tell lnp where we want remote data to go lr_tid = execi(&lr_thread,0,0,PRIO_HIGHEST,DEFAULT_STACK_SIZE); lr_init(); return; } //! Shutdown protocol handler and terminate thread? void lr_shutdown() { // Disconnect protocol handler lnp_remote_set_handler(LNP_DUMMY_REMOTE); lr_set_handler(LR_DUMMY_HANDLER); // terminate thread kill(lr_tid); return; } #endif // CONF_LR_HANDLER brickos-0.9.0/kernel/semaphore.c0000644000175000017500000000736007777403630014340 0ustar cbcb/*! \file semaphore.c \brief Implementation: POSIX 1003.1b semaphores for process synchronization. \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include #ifdef CONF_SEMAPHORES #include /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// //! the semaphore event wakeup function for wait_event(). /*! \param data pointer to the semaphore passed as a wakeup_t */ wakeup_t sem_event_wait(wakeup_t data) { sem_t *sem=(sem_t*) ((unsigned)data); // we're called by the scheduler, therefore in an IRQ handler, // so no worrying about IRQs. // if(*sem) { (*sem)--; return 1; // sem!=0 -> wakeup } return 0; } //! wait on a semaphore /*! \param sem a valid semaphore suspends the calling thread until the semaphore has non-zero count. It then atomically decreases the semaphore count. implemented with wait_event(). */ int sem_wait(sem_t * sem) { // check if semaphore is available, if not, go to sleep if(sem_trywait(sem)) if (wait_event(sem_event_wait,(unsigned long) ((unsigned)sem)) == 0) return -1; return 0; } typedef struct { sem_t *sem; time_t abs_timeout; } timeout_sem_data_t; static wakeup_t sem_event_timeout_wait(wakeup_t data) { timeout_sem_data_t *tsem = (timeout_sem_data_t*) ((unsigned)data); // we're called by the scheduler, therefore in an IRQ handler, // so no worrying about IRQs. // if (*tsem->sem) { (*tsem->sem)--; return 1; // sem!=0 -> wakeup } if (tsem->abs_timeout <= get_system_up_time()) { return 2; // timeout reached -> wakeup } return 0; } int sem_timedwait(sem_t *sem, const time_t abs_timeout) { timeout_sem_data_t data; data.sem = sem; data.abs_timeout = abs_timeout; if (sem_trywait(sem)) { if (wait_event(sem_event_timeout_wait, (wakeup_t) ((unsigned) &data)) != 1) { return -1; // timeout reached. } } return 0; } //! non-blocking check on a semaphore /*! \param sem a valid semaphore a non-blocking variant of sem_wait. If the semaphore has non-zero count, the count is atomically decreased and sem_trywait immediately returns 0. If the semaphore count is zero, sem_trywait immediately returns with error EAGAIN. this is IRQ handler safe. */ int sem_trywait(sem_t * sem); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 1\n\ .globl _sem_trywait\n\ _sem_trywait:\n\ stc ccr,r1h ; save flags \n\ orc #0x80,ccr ; block all but NMI\n\ mov.b @r0,r1l\n\ beq sem_fail ; !=0 -> decrease, return 0\n\ dec r1l\n\ mov.b r1l,@r0\n\ sub.w r0,r0 ; return 0\n\ bra sem_ok\n\ \n\ sem_fail:\n\ mov #0xffff,r0 ; else return 0xffff\n\ \n\ sem_ok:\n\ ldc r1h,ccr ; restore flags\n\ rts\n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS #endif // CONF_SEMAPHORES brickos-0.9.0/kernel/setjmp.c0000644000175000017500000000407507777403630013657 0ustar cbcb/*! \file setjmp.c \brief Implementation: Non-local goto as described in ANSI C. \author Torsten Landschoff */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Contributor(s): Torsten Landschoff */ #include #ifdef CONF_SETJMP int setjmp(jmp_buf env); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 2\n\ .globl _setjmp\n\ _setjmp:\n\ stc ccr,r1h ; remember flags\n\ mov.w #12,r2 ; move r0 'behind' jump buffer\n\ add r2,r0 ; for storing with pre-decrement\n\ \n\ pop r2 ; get return address\n\ mov.w r2,@-r0 ; store return address\n\ mov.w r1,@-r0 ; store flags\n\ mov.w r7,@-r0 ; store registers r4-r7\n\ mov.w r6,@-r0\n\ mov.w r5,@-r0\n\ mov.w r4,@-r0\n\ sub.w r0,r0 ; return value: 0\n\ jmp @r2 ; jump to caller\n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS void longjmp(jmp_buf env, int val); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 2\n\ .globl _longjmp\n\ _longjmp:\n\ mov.w @r0+,r4 ; restore registers r4-r7\n\ mov.w @r0+,r5\n\ mov.w @r0+,r6\n\ mov.w @r0+,r7\n\ mov.w @r0+,r2 ; get flags\n\ mov.w @r0+,r0 ; get return address\n\ push r0 ; set up for rts\n\ mov.w r1,r0 ; return specified value\n\ ldc r2h,ccr ; restore flags\n\ rts ; return to caller\n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS #endif // CONF_SETJMP brickos-0.9.0/kernel/swmux.c0000644000175000017500000000401307543442414013522 0ustar cbcb#include "swmux.h" #ifdef CONF_DSENSOR #ifdef CONF_DSENSOR_SWMUX //sampled multiplexor ranges //0xFE00 - sampled raw value for no sensors touched #define SWMUX_0000_S 0xF000 #define SWMUX_0000_E 0xFFFF //0x9640 - sampled raw value for only A touched #define SWMUX_A000_S 0x9000 #define SWMUX_A000_E 0x9FFF //Ox8180 - sampled raw value for A and B touched #define SWMUX_AB00_S 0x8000 #define SWMUX_AB00_E 0x8BFF //0x8D80 - sampled raw value for A and C touched #define SWMUX_A0C0_S 0x8C00 #define SWMUX_A0C0_E 0x8FFF //Ox7800 - sampled raw value for A, B, and C touched #define SWMUX_ABC0_S 0x7000 #define SWMUX_ABC0_E 0x7FFF //0xC000 - sampled raw value for only B touched #define SWMUX_0B00_S 0xBFF0 #define SWMUX_0B00_E 0xC5FF //0xA6C0 - sampled raw value for B and C touched #define SWMUX_0BC0_S 0xA000 #define SWMUX_0BC0_E 0xAFFF //OxD6C0 - sampled raw value for only C touched #define SWMUX_00C0_S 0xD000 #define SWMUX_00C0_E 0xDFFF //exta sensor D, when pressed A,B,C are masked out //0x0600 #define SWMUX_XXXD_S 0x0000 #define SWMUX_XXXD_E 0x4FFF unsigned char swmux_bits(unsigned int raw) { if(raw>=SWMUX_0000_S && raw <=SWMUX_0000_E) { return 0; } else if (raw>=SWMUX_A000_S && raw <=SWMUX_A000_E) { return SWMUX_A_MASK; } else if (raw>=SWMUX_AB00_S && raw <=SWMUX_AB00_E) { return SWMUX_A_MASK|SWMUX_B_MASK; } else if (raw>=SWMUX_A0C0_S && raw <=SWMUX_A0C0_E) { return SWMUX_A_MASK|SWMUX_C_MASK; } else if (raw>=SWMUX_ABC0_S && raw <=SWMUX_ABC0_E) { return SWMUX_A_MASK|SWMUX_B_MASK|SWMUX_C_MASK; } else if (raw>=SWMUX_0B00_S && raw <=SWMUX_0B00_E) { return SWMUX_B_MASK; } else if (raw>=SWMUX_0BC0_S && raw <=SWMUX_0BC0_E) { return SWMUX_B_MASK|SWMUX_C_MASK; } else if (raw>=SWMUX_00C0_S && raw <=SWMUX_00C0_E) { return SWMUX_C_MASK; } else if (raw>=SWMUX_XXXD_S && raw <=SWMUX_XXXD_E) { return SWMUX_D_MASK; } else { return SWMUX_ERROR_MASK; } }//endof swmux_val #endif //CONF_DSENSOR_SWMUX #endif //CONF_DSENSOR brickos-0.9.0/kernel/systime.c0000644000175000017500000002467707777403630014064 0ustar cbcb/*! \file systime.c \brief Implementation: system time services \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * David Van Wagner */ /* * 2000.05.01 - Paolo Masetti * * - Added battery indicator handler * * 2000.08.12 - Rossz Vmos-Wentworth * * - Added idle shutdown handler * */ #include #ifdef CONF_TIME #include #include #include #include #include #include #include #ifdef CONF_AUTOSHUTOFF #include #endif /////////////////////////////////////////////////////////////////////////////// // // Global Variables // /////////////////////////////////////////////////////////////////////////////// //! current system time in ms /*! \warning This is a 32 bit value which will overflow after 49.7 days of continuous operation. */ volatile time_t sys_time; /////////////////////////////////////////////////////////////////////////////// // // Internal Variables // /////////////////////////////////////////////////////////////////////////////// #ifdef CONF_TM volatile unsigned char tm_timeslice; //!< task time slice volatile unsigned char tm_current_slice; //!< current time remaining void* tm_switcher_vector; //!< pointer to task switcher #endif /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// //! clock handler triggered on the WDT overflow (every msec) on the NMI /*! this is the system clock */ extern void clock_handler(void); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 1\n\ .global _clock_handler\n\ _clock_handler:\n\ mov.w #0x5a07,r6 ; reset wd timer to 6\n\ mov.w r6,@0xffa8\n\ \n\ mov.w @_sys_time+2,r6 ; lower 8 bits\n\ add.b #0x1,r6l ; inc lower 4 bits\n\ addx #0x0,r6h ; add carry to top 4 bits\n\ mov.w r6,@_sys_time+2\n\ bcc sys_nohigh ; if carry, inc upper 8 bits\n\ mov.w @_sys_time,r6 ; \n\ add.b #0x1,r6l ; inc lower 4 bits\n\ addx #0x0,r6h ; add carry to top 4 bits\n\ mov.w r6,@_sys_time\n\ sys_nohigh: \n\ rts\n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS //! subsystem handler for every 2nd msec /*! this is the pulse of the system (subsystems). sound, motor and lcd driver calls are initiated here. task_switch_handler is called from here as well. */ extern void subsystem_handler(void); //! task switch handler called every msec /*! handles swapping between tasks */ extern void task_switch_handler(void); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 1\n\ .global _subsystem_handler\n\ .global _task_switch_handler\n\ .global _systime_tm_return\n\ _subsystem_handler:\n\ ; r6 saved by ROM\n\ \n\ push r0 ; both motors & task\n\ ; switcher need this reg.\n\ " #ifdef CONF_DSOUND "\n\ jsr _dsound_handler ; call sound handler\n\ " #endif // CONF_DSOUND #ifdef CONF_LNP "\n\ mov.w @_lnp_timeout_counter,r6 ; check LNP timeout counter\n\ subs #0x1,r6\n\ mov.w r6,r6 ; subs doesn't change flags!\n\ bne sys_noreset\n\ \n\ jsr _lnp_integrity_reset\n\ mov.w @_lnp_timeout,r6 ; reset timeout\n\ \n\ sys_noreset:\n\ mov.w r6,@_lnp_timeout_counter\n\ " #endif // CONF_LNP #ifdef CONF_DKEY "\n\ jsr _dkey_handler\n\ " #endif // CONF_DKEY #ifndef CONF_TM #ifdef CONF_BATTERY_INDICATOR "\n\ mov.w @_battery_refresh_counter,r6\n\ subs #0x1,r6\n\ bne batt_norefresh\n\ \n\ jsr _battery_refresh\n\ mov.w @_battery_refresh_period,r6\n\ \n\ batt_norefresh:\n\ mov.w r6,@_battery_refresh_counter\n\ " #endif // CONF_BATTERY_INDICATOR #endif // CONF_TM #ifdef CONF_AUTOSHUTOFF "\n\ mov.w @_auto_shutoff_counter,r6\n\ subs #0x1,r6\n\ bne auto_notshutoff\n\ \n\ jsr _autoshutoff_check\n\ mov.w @_auto_shutoff_period,r6\n\ \n\ auto_notshutoff:\n\ mov.w r6,@_auto_shutoff_counter\n\ " #endif // CONF_AUTOSHUTOFF #ifdef CONF_VIS "\n\ mov.b @_vis_refresh_counter,r6l\n\ dec r6l\n\ bne vis_norefresh\n\ \n\ jsr _vis_handler\n\ mov.b @_vis_refresh_period,r6l\n\ \n\ vis_norefresh:\n\ mov.b r6l,@_vis_refresh_counter\n\ " #endif // CONF_VIS #ifdef CONF_LCD_REFRESH "\n\ mov.b @_lcd_refresh_counter,r6l\n\ dec r6l\n\ bne lcd_norefresh\n\ \n\ jsr _lcd_refresh_next_byte\n\ mov.b @_lcd_refresh_period,r6l\n\ \n\ lcd_norefresh:\n\ mov.b r6l,@_lcd_refresh_counter\n\ " #endif // CONF_LCD_REFRESH "\n\ bclr #2,@0x91:8 ; reset compare B IRQ flag\n\ " #ifdef CONF_TM "\n\ pop r0 ; if fallthrough, pop r0\n\ _task_switch_handler:\n\ push r0 ; save r0\n\ \n\ mov.b @_tm_current_slice,r6l\n\ dec r6l\n\ bne sys_noswitch ; timeslice elapsed?\n\ \n\ mov.w @_kernel_critsec_count,r6 ; check critical section\n\ beq sys_switch ; ok to switch\n\ mov.b #1,r6l ; wait another tick\n\ jmp sys_noswitch ; don't switch\n\ \n\ sys_switch:\n\ mov.w @_tm_switcher_vector,r6\n\ jsr @r6 ; call task switcher\n\ \n\ _systime_tm_return:\n\ mov.b @_tm_timeslice,r6l ; new timeslice\n\ \n\ sys_noswitch:\n\ mov.b r6l,@_tm_current_slice\n\ " #endif // CONF_TM #ifdef CONF_DMOTOR "\n\ jsr _dm_handler ; call motor driver\n\ " #endif // CONF_DMOTOR "\n\ pop r0\n\ bclr #3,@0x91:8 ; reset compare A IRQ flag\n\ rts\n\ " ); #endif // DOXYGEN_SHOULD_SKIP_THIS //! initialize system timer /*! task switcher initialized to empty handler motors turned off */ void systime_init(void) { systime_shutdown(); // shutdown hardware sys_time=0l; // init timer #ifdef CONF_TM tm_current_slice=tm_timeslice=TM_DEFAULT_SLICE; tm_switcher_vector=&rom_dummy_handler; // empty handler #endif #ifdef CONF_DMOTOR dm_shutdown(); #endif // configure 16-bit timer // compare B IRQ will fire after one msec // compare A IRQ will fire after another msec // counter is then reset // T_CSR = TCSR_RESET_ON_A; T_CR = TCR_CLOCK_32; T_OCR &= ~TOCR_OCRB; T_OCRA = 1000; T_OCR &= ~TOCR_OCRA; T_OCR |= TOCR_OCRB; T_OCRB = 500; #if defined(CONF_TM) ocia_vector = &task_switch_handler; #else // CONF_TM ocia_vector = &subsystem_handler; #endif // CONF_TM ocib_vector = &subsystem_handler; T_IER |= (TIER_ENABLE_OCB | TIER_ENABLE_OCA); nmi_vector = &clock_handler; WDT_CSR = WDT_CNT_PASSWORD | WDT_CNT_MSEC_64; // trigger every msec WDT_CSR = WDT_CSR_PASSWORD | WDT_CSR_CLOCK_64 | WDT_CSR_WATCHDOG_NMI | WDT_CSR_ENABLE | WDT_CSR_MODE_WATCHDOG; } //! shutdown system timer /*! will also stop task switching and motors. */ void systime_shutdown(void) { T_IER &= ~(TIER_ENABLE_OCA | TIER_ENABLE_OCB); // unhook compare A/B IRQs WDT_CSR &= ~WDT_CSR_ENABLE; // disable wd timer } #ifdef CONF_TM //! set task switcher vector /*! \param switcher the switcher */ void systime_set_switcher(void* switcher) { tm_switcher_vector=switcher; } //! set multitasking timeslice in ms /*! \param slice the timeslice. must be at least 5ms. */ void systime_set_timeslice(unsigned char slice) { if(slice>5) { // some minimum value tm_timeslice=slice; if(tm_current_slice>tm_timeslice) tm_current_slice=tm_timeslice; } } #endif //! retrieve the current system time /*! \return number of msecs the system has been running * Since sys_time is 32bits, it takes more than one * instruction to retrieve; the NMI can fire mid * retrieval; causing the upper and lower 16bits to be * unmatched (lower 16bits could overflow and reset to * 0, while upper 16bits were already read) */ extern time_t get_system_up_time(void); __asm__("\n\ .text\n\ .align 1\n\ .global _get_system_up_time\n\ _get_system_up_time:\n\ push r2\n\ try_again:\n\ mov.w @_sys_time+2, r1\n\ mov.w @_sys_time, r0\n\ mov.w @_sys_time+2, r2\n\ cmp r2, r1\n\ bne try_again\n\ pop r2\n\ rts\n\ "); #endif // CONF_TIME brickos-0.9.0/kernel/template.c0000644000175000017500000000303507535330367014161 0ustar cbcb/*! \file template.c \brief EMPTY FILE. Copy to use. Use this to start a new implementation by copying to new name then editing \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include /////////////////////////////////////////////////////////////////////////////// // // Global Variables // /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // // Internal Variables // /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// brickos-0.9.0/kernel/timeout.c0000644000175000017500000000413307551712562014033 0ustar cbcb/*! \file timeout.c \brief Implementation: Powerdown Timer Routines \author Rossz Vamos-Wentworth */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Rossz Vmos-Wentworth */ #include #include #include #ifdef CONF_AUTOSHUTOFF volatile unsigned int auto_shutoff_counter = 0; // auto_shutoff_secs) idle_powerdown = 1; #ifdef CONF_TM } else shutoff_restart(); #endif // CONF_TM } #endif brickos-0.9.0/kernel/tm.c0000644000175000017500000004246207777403630012777 0ustar cbcb/*! \file tm.c \brief Implementation: Task management \author Markus L. Noga The implementation of the multitasking switcher and scheduler as well as library functions relating to task management. */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Ben Laurie * Lou Sortman */ #include #ifdef CONF_TM #include #include #include #include #include #include #include #ifdef CONF_VIS # include # include # include #endif #define fatal(a) // #define fatal(a) { lcd_clear(); cputs(a); lcd_refresh(); while(1); } /////////////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////////////// pchain_t *priority_head; //!< head of task priority chain tdata_t td_single; //!< single task data tdata_t *ctid; //!< ptr to current task data volatile unsigned int nb_tasks; //!< number of tasks volatile unsigned int nb_system_tasks; //!< number of system (kernel) tasks /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// #if 0 void integrity_check(void) { pchain_t *prio=priority_head; tdata_t *td; if(prio->prev!=NULL) { fatal("ERR10"); } do { if(prio->next) { if(prio->next->prev!=prio) { fatal("ERR11"); } if(prio->next->priority>prio->priority) { fatal("ERR12"); } } td=prio->ctid; do { if(td==NULL) { fatal("ERR13"); } if(td->priority!=prio) { fatal("ERR14"); } if(td->next->prev != td) { fatal("ERR15"); } if(td->prev->next != td) { fatal("ERR16"); } td=td->next; } while(td!=prio->ctid); prio=prio->next; } while(prio); } #endif //! the task switcher /*! the task switcher saves active context and passes sp to scheduler then restores new context from returned sp */ void tm_switcher(void); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 1\n\ .globl _tm_switcher\n\ _tm_switcher:\n\ ; r6 saved by ROM\n\ ; r0 saved by system timer handler\n\ \n\ mov.w r1,@-r7 ; save registers\n\ mov.w r2,@-r7 \n\ mov.w r3,@-r7 \n\ mov.w r4,@-r7 \n\ mov.w r5,@-r7 \n\ \n\ mov.w r7,r0 ; pass sp\n\ \n\ jsr _tm_scheduler ; call scheduler\n\ \n\ _tm_switcher_return: \n\ mov.w r0,r7 ; set new sp\n\ \n\ mov.w @r7+,r5\n\ mov.w @r7+,r4\n\ mov.w @r7+,r3\n\ mov.w @r7+,r2\n\ mov.w @r7+,r1\n\ \n\ ; r0 will be restored by system timer handler\n\ ; r6 will be restored by ROM\n\ \n\ rts ; return to new task\n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS //! the task scheduler /*! \param old_sp current task's current stack pointer \return new task's current stack pointer actual context switches performed by tm_switcher (assembler wrapper) */ size_t *tm_scheduler(size_t *old_sp) { tdata_t *next; // next task to execute pchain_t *priority; wakeup_t tmp; priority=ctid->priority; switch(ctid->tstate) { case T_ZOMBIE: if(ctid->next!=ctid) { // remove from chain for this priority level // priority->ctid =ctid->prev; ctid->next->prev=ctid->prev; ctid->prev->next=ctid->next; } else { // remove priority chain for this priority level // if(priority->next) priority->next->prev = priority->prev; if(priority->prev) priority->prev->next = priority->next; else priority_head = priority->next; free(priority); } // We're on that stack frame being freed right now, // but nobody can interrupt us anyways. // free(ctid->stack_base); // free stack free(ctid); // free task data // // FIXME: exit code? // if ((ctid->tflags & T_KERNEL)==T_KERNEL) --nb_system_tasks; switch(--nb_tasks) { case 1: #ifdef CONF_TM_DEBUG if((priority_head->ctid->tflags & T_IDLE)==0) { // last task is not the idle task fatal("ERR00"); } #endif // CONF_TM_DEBUG // only the idle task remains *((priority_head->ctid->sp_save) + SP_RETURN_OFFSET ) = (size_t) &exit; priority_head->ctid->tstate=T_SLEEPING; break; case 0: // the last task has been removed // -> stop switcher, go single tasking systime_set_switcher(&rom_dummy_handler); ctid=&td_single; return ctid->sp_save; } break; case T_RUNNING: ctid->tstate=T_SLEEPING; // no break case T_WAITING: ctid->sp_save=old_sp; } // find next task willing to run // priority=priority_head; next=priority->ctid->next; while (1) { if (next->tstate==T_SLEEPING) break; if (next->tstate==T_WAITING) { if ((next->tflags & T_SHUTDOWN) != 0) { next->wakeup_data = 0; break; } ctid = next; tmp = next->wakeup(next->wakeup_data); if (tmp != 0) { next->wakeup_data = tmp; break; } } if(next == priority->ctid) { // if we've scanned the whole chain, // go to next priority if(priority->next != NULL) priority = priority->next; #ifdef CONF_TM_DEBUG else { // FIXME: idle task has died // this is a severe error. fatal("ERR01"); } #else else priority = priority_head; #endif next=priority->ctid->next; } else next=next->next; } ctid=next->priority->ctid=next; // execute next task ctid->tstate=T_RUNNING; return ctid->sp_save; } //! yield the rest of the current timeslice /*! (does not speed up the system clock) */ extern void yield(void); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .globl _yield\n\ .align 1\n\ _yield:\n\ stc ccr,r0h ; to fake an IRQ, we have to\n\ push r0 ; store the registers\n\ orc #0x80,ccr ; disable interrupts\n\ \n\ push r6 ; store r6\n\ \n\ mov.w #0x04d4,r0 ; store rom return addr\n\ push r0\n\ \n\ push r0 ; store r0 (destroyed by call.)\n\ \n\ mov.w #_systime_tm_return,r0 ; store systime return addr\n\ push r0\n\ \n\ jmp @_tm_switcher ; call task switcher\n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS //! the idle system task /*! infinite sleep instruction to conserve power */ extern int tm_idle_task(int argc,char **argv) __attribute__ ((noreturn)); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 1\n\ _tm_idle_task:\n\ sleep\n\ bra _tm_idle_task\n\ "); #endif // DOXYGEN_SHOULD_SKIP_THIS #ifdef CONF_VIS //! the man system task /*! infinite loop; when program running, update the man (stand/run) */ int tm_man_task(int argc, char **argv) { int state=0; while (!shutdown_requested()) { if(nb_tasks > nb_system_tasks) state ^= 1; else state=0; lcd_show(state == 0 ? man_stand : man_run); #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif // CONF_LCD_REFRESH msleep(500); } return 0; } #ifdef CONF_BATTERY_INDICATOR //! the battery system task /*! updates the battery low indicator when necessary */ int tm_battery_task(int argc, char **argv) { int bmv; while (!shutdown_requested()) { bmv=get_battery_mv(); if(bmv>BATTERY_NORMAL_THRESHOLD_MV) dlcd_hide(LCD_BATTERY_X); else if(bmvtflags |= T_IDLE; #ifdef CONF_VIS execi(&tm_man_task, 0, NULL, 1, IDLE_STACK_SIZE); #ifdef CONF_BATTERY_INDICATOR execi(&tm_battery_task, 0, NULL, 1, IDLE_STACK_SIZE); #endif // CONF_BATTERY_INDICATOR #endif // CONF_VIS systime_set_timeslice(TM_DEFAULT_SLICE); } //! start task management /*! (called in single tasking mode after task setup) */ void tm_start(void) { disable_irqs(); // no interruptions, please systime_set_switcher(&tm_switcher); yield(); // go! enable_irqs(); // restored state would // disallow interrupts } //! schedule execution of a new task /*! \param code_start start address of code to execute \param argc first argument passed, normally number of strings in argv \param argv second argument passed, normally pointer to argument pointers. \param priority new task's priority \param stack_size stack size for new task \return -1: fail, else tid. will return to caller in any case. */ tid_t execi(int (*code_start)(int,char**),int argc, char **argv, priority_t priority,size_t stack_size) { pchain_t *pchain, *ppchain; // for traversing priority chain int freepchain=0; // get memory // // task & stack area belong to parent task // they aren't freed by mm_reaper() // // avoid deadlock of memory and task semaphores // by preallocation. tdata_t *td=malloc(sizeof(tdata_t)); size_t *sp=malloc(stack_size); // for allocating new priority chain pchain_t *newpchain=malloc(sizeof(pchain_t)); if (td == NULL || sp == NULL || newpchain == NULL) { free(td); free(sp); free(newpchain); return -1; } td->tflags = 0; if ((size_t)code_start < (size_t)&mm_start) { td->tflags |= T_KERNEL; nb_system_tasks++; } else td->tflags |= T_USER; td->stack_base=sp; // these we know already. sp+=(stack_size>>1); // setup initial stack // when main() returns a value, it passes it in r0 // as r0 is also the register to pass single int arguments by // gcc convention, we can just put the address of exit on the stack. *(--sp)=(size_t) &exit; // we have to construct a stack stub so tm_switcher, // systime_handler and the ROM routine can fill the // right values on startup. *(--sp)=(size_t) code_start; // entry point < these two are for *(--sp)=0; // ccr < rte in ROM *(--sp)=0; // r6 < pop r6 in ROM *(--sp)=(size_t) &rom_ocia_return; // ROM return < rts in systime_handler *(--sp)=(size_t) argc; // r0 < pop r0 in systime handler *(--sp)=(size_t) &systime_tm_return; // systime return < rts in tm_switcher *(--sp)=(size_t) argv; // r1..r5 < pop r1..r5 in tm_switcher *(--sp)=0; *(--sp)=0; *(--sp)=0; *(--sp)=0; td->sp_save=sp; // save sp for tm_switcher td->tstate=T_SLEEPING; // task is waiting for execution td->parent=ctid; // set parent ENTER_KERNEL_CRITICAL_SECTION(); ppchain=NULL; for( pchain = priority_head; pchain != NULL && (pchain->priority) > priority; ppchain = pchain, pchain = pchain->next ); if(pchain==NULL || pchain->priority!=priority) { // make new chain // newpchain->priority=priority; newpchain->ctid=td; newpchain->next=pchain; if(pchain) pchain->prev =newpchain; newpchain->prev=ppchain; if(ppchain) ppchain->next=newpchain; else priority_head=newpchain; // initial queue setup // td->prev=td->next=td; td->priority=newpchain; } else { // add at back of queue // td->priority=pchain; td->prev=pchain->ctid->prev; td->next=pchain->ctid; td->next->prev=td->prev->next=td; freepchain=1; // free superfluous pchain. } nb_tasks++; LEAVE_KERNEL_CRITICAL_SECTION(); if(freepchain) free(newpchain); return (tid_t) td; // tid = (tid_t) &tdata_t_struct } //! exit task, returning code /*! \param code The return code \todo save return code; temporarily? \bug ignores return code. */ void exit(int code) { enable_irqs(); // just in case... if (!(ctid->tflags & T_KERNEL)) mm_reaper(); ctid->tstate=T_ZOMBIE; // Yield till dead while(1) yield(); } //! suspend task until wakeup function is non-null /*! \param wakeup the wakeup function. called in task scheduler context. \param data argument passed to wakeup function by scheduler \return return value passed on from wakeup, 0 if exits prematurely */ wakeup_t wait_event(wakeup_t (*wakeup)(wakeup_t),wakeup_t data) { ctid->wakeup =wakeup; ctid->wakeup_data=data; ctid->tstate =T_WAITING; yield(); return ctid->wakeup_data; } //! wakeup function for sleep /*! \param data time to wakeup encoded as a wakeup_t */ static wakeup_t tm_sleep_wakeup(wakeup_t data) { time_t remaining = ((time_t)data) - get_system_up_time(); if (((time_t)data) <= get_system_up_time()) { tm_timeslice = TM_DEFAULT_SLICE; return -1; } if (remaining < tm_timeslice) tm_timeslice = remaining; return 0; } //! delay execution allowing other tasks to run. /*! \param msec sleep duration in milliseconds \return number of milliseconds left if interrupted, else 0. */ unsigned int msleep(unsigned int msec) { #if defined(CONF_TIME) && defined(CONF_TM) if (wait_event(&tm_sleep_wakeup, get_system_up_time() + MSECS_TO_TICKS(msec)) == 0) return (MSECS_TO_TICKS(msec) - get_system_up_time()); #else delay(msec); #endif return 0; } //! delay execution allowing other tasks to run. /*! \param sec sleep duration in seconds \return number of seconds left if interrupted, else 0. */ unsigned int sleep(unsigned int sec) { return msleep(1000*sec)/1000; } //! request that the specified task shutdown as soon as possible. /*! \param tid id of the task to be shutdown */ void shutdown_task(tid_t tid) { tdata_t *td=(tdata_t*) tid; td->tflags |= T_SHUTDOWN; } //! request that tasks with any of the specified flags shutdown. /*! \param flags T_USER to shutdown user tasks, T_USER | T_KERNEL for all tasks */ void shutdown_tasks(tflags_t flags) { pchain_t* pchain; tdata_t* td; ENTER_KERNEL_CRITICAL_SECTION(); pchain = priority_head; while (pchain != NULL) { td = pchain->ctid; do { if ((td->tflags & flags) != 0) { // signal shutdown // td->tflags |= T_SHUTDOWN; } td = td->next; } while (td != pchain->ctid); pchain = pchain->next; } LEAVE_KERNEL_CRITICAL_SECTION(); } //! kill specified task /*! \param tid must be valid process ID, or undefined behaviour will result! */ void kill(tid_t tid) { tdata_t *td=(tdata_t*) tid; if(td==ctid) exit(-1); else { // when the task is switched to the next time, // make it exit immediatlely. ENTER_KERNEL_CRITICAL_SECTION(); *( (td->sp_save) + SP_RETURN_OFFSET )=(size_t) &exit; td->tstate=T_SLEEPING; // in case it's waiting. LEAVE_KERNEL_CRITICAL_SECTION(); } } //! kill all tasks of prio or lower /*! \param prio */ void killall(priority_t prio) { pchain_t *pchain; tdata_t *td; tflags_t flags = T_KERNEL | T_IDLE; if (prio == PRIO_HIGHEST) flags = T_IDLE; ENTER_KERNEL_CRITICAL_SECTION(); // find first chain with smaller or equal priority. // pchain=priority_head; while(pchain!=NULL && priopriority) pchain=pchain->next; while(pchain!=NULL) { td=pchain->ctid; do { if((td!=ctid) && ((td->tflags & flags) == 0)) { // kill it // *( (td->sp_save) + SP_RETURN_OFFSET )=(size_t) &exit; td->tstate=T_SLEEPING; // in case it's waiting. } td=td->next; } while(td!=pchain->ctid); pchain=pchain->next; } LEAVE_KERNEL_CRITICAL_SECTION(); } #endif // CONF_TM brickos-0.9.0/kernel/vis.c0000644000175000017500000000403007551712562013142 0ustar cbcb/*! \file vis.c \brief Implementation: visualization of BrickOS state \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include #ifdef CONF_VIS #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////////////// unsigned char vis_refresh_counter = 0; unsigned char vis_refresh_period = 50; /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// #ifdef CONF_RCX_COMPILER void vis_handler(void) { #else HANDLER_WRAPPER("vis_handler","vis_core"); void vis_core(void) { #endif #ifdef CONF_DSENSOR bit_iload(AD_C_H,0x7); dlcd_store(LCD_S1_ACTIVE); bit_iload(AD_B_H,0x7); dlcd_store(LCD_S2_ACTIVE); bit_iload(AD_A_H,0x7); dlcd_store(LCD_S3_ACTIVE); #endif #ifdef CONF_PROGRAM if(nb_tasks <= nb_system_tasks) { // show only while program not running. if(program_valid(cprog)) cputc_hex_0(cprog+1); else cputc_0('-'); } #endif } #endif // CONF_VIS brickos-0.9.0/lib/0000755000175000017500000000000010173102121011440 5ustar cbcbbrickos-0.9.0/lib/c/0000755000175000017500000000000010173102444011672 5ustar cbcbbrickos-0.9.0/lib/c/Makefile0000644000175000017500000000333407610007120013332 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.8 2003/01/11 12:30:08 emanlove Exp $ ### FILE: lib/c/Makefile - make the c suport library ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # our target LIBTARGET = c # sources # # Cygwin B-20 can't compile printf.c FIXME This is busted in new evironment ifneq (,$(findstring $(OSTYPE),cygwin32)) SOURCES = memcpy.c memset.c strcmp.c strcpy.c strlen.c random.c else SOURCES = memcpy.c memset.c strcmp.c strcpy.c strlen.c random.c printf.c endif ## ## no user servicable parts below ## LIBRARY = lib$(LIBTARGET).a OBJECTS = $(SOURCES:.c=.o) all:: promote-stamp @# nothing to do here but do it silently promote-stamp: $(LIBRARY) cp -f $? ../ @touch $@ include ../../Makefile.common $(LIBRARY): $(OBJECTS) rm -f $@ $(AR) -sq $@ $(OBJECTS) .depend: $(SOURCES) $(MAKEDEPEND) $(SOURCES) > .depend depend:: .depend @# nothing to do here but do it silently clean: rm -f *.o *.map *.coff *.srec *.dis* *~ *.bak *.tgz *.s realclean: clean rm -f $(LIBRARY) ../$(LIBRARY) .depend @rm -f install-stamp promote-stamp tags TAGS install: install-stamp @# nothing to do here but do it silently install-stamp: $(LIBRARY) @if [ ! -d ${pkglibdir} ]; then \ mkdir -p ${pkglibdir}; \ fi cp -f $? ${pkglibdir}/$? @touch $@ uninstall: @rm -f install-stamp .PHONY: all promote-stamp depend clean realclean install install-stamp uninstall ### -------------------------------------------------------------------------- ### End of FILE: lib/c/Makefile ### ========================================================================== brickos-0.9.0/lib/c/memcpy.c0000644000175000017500000000377207777403436013366 0ustar cbcb/*! \file memcpy.c \brief memcpy function \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ typedef unsigned size_t; // data type for memory sizes /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// //! copy memory block from src to dest. /*! \param dest destination \param src source \param size number of bytes to copy \warning behaviour is undefined in case source and destination blocks overlap. */ void memcpy(void* dest,void* src,size_t size) { char *end=((char*)src)+size; int dummy; __asm__ __volatile__( #ifdef CONF_ROM_MEMCPY "\n\ ; memcpy == [r1,r1+r2) -> [r0,r0+r2)\n\ ; rom == [r0,r1) -> [r2,r2+r1-r0)\n\ mov.w r0,r3\n\ mov.w r1,r0\n\ add.w r2,r1\n\ mov.w r3,r2\n\ jmp @rom_memcpy\n\ " #else "\n\ 0:cmp %1,%2\n\ beq 1f\n\ mov.b @%1+,%0l\n\ mov.b %0l,@%3\n\ adds #1,%3\n\ bra 0b\n\ 1:\n\ " #endif : "=&r" (dummy) // output : "r" (src), "r" (end), "r" (dest) // input : "cc","memory" // clobbered ); } brickos-0.9.0/lib/c/memset.c0000644000175000017500000000303107530330675013341 0ustar cbcb/*! \file memset.c \brief memset function \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ typedef unsigned size_t; // data type for memory sizes /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// //! fill memory block with a byte value. /*! \param s start \param c byte fill value \param n number of bytes to fill */ void *memset(void* s,int c,size_t n) { void *res; __asm__ __volatile__( " add.w %1,%0\n" "0:cmp.w %1,%0\n" " beq 1f\n" " mov.b %2l,@-%0\n" " bra 0b\n" "1:" : "=&r" (res) // output : "r" (s), "r" (c), "0" (n) // input : "cc","memory" // clobbered (final) ); return res; } brickos-0.9.0/lib/c/printf.c0000644000175000017500000000712207775246652013372 0ustar cbcb/*! \file printf.c \brief printf function \author Matthew Ahrens */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is from the Brown Computer Science Department, * Weenix support code. * * The Initial Developer of the Original Code is David Powell. * * Contributor(s): Matthew Ahrens */ #include static const char hexdigits[] = "0123456789ABCDEF"; static const char lhexdigits[] = "0123456789abcdef"; static const char empty_string[] = "(null string)"; /* This function takes an unsigned int and puts its ascii * representation at a particular location in a buffer of given * length. The radix used is must also be provided, as well as a * string containing the characters used in the ascii representation. * * This function makes no attempt to handle two-byte characters. */ static int itoa(unsigned int value, char *dst, int pos, int len, int radix, const char *digits) { char sbuf[10]; int spos; spos = 0; while(value) { sbuf[spos] = value % radix; spos++; value /= radix; } if(!spos) *sbuf = 0, spos = 1; for(spos--; pos=0; pos++,spos--) { dst[pos] = digits[(int)sbuf[spos]]; } return pos-1; } /* This function takes a buffer, its length, a format specification, * and a va_list, formats the provided data according the the format * spec, and places the result in the buffer. It returns the length of * the output. The only format options supported by this function * are: * %d - decimal unsigned int * %i - " " " * %x - hexidecimal unsigned int (lowercase letters) * %X - " " " (uppercase letters) * %c - character * %s - string * %% - '%' character */ int vsnprintf(char *dst, int len, const char *fmt, va_list arg) { int pos; int cc; const char *temp; unsigned int scratch; for(pos=0, cc=0; (pos See Numerical Recipes in C 2nd Edition, p. 279-281 for inspiration. */ //#include ///////////////////////////////////////////////////////////////////////////// // // Definitions // ///////////////////////////////////////////////////////////////////////////// #define PRANDOM_SLOTS 16 #define PRANDOM_MASK 0x3fc91ab4 #define PRANDOM_A 16807 #define PRANDOM_M 2147483647 #define PRANDOM_Q 127773 #define PRANDOM_R 2836 //! A pseudo-random number generator typedef struct { long select; long state; long entry[PRANDOM_SLOTS]; } prandom_t; ///////////////////////////////////////////////////////////////////////////// // // Static variables // ///////////////////////////////////////////////////////////////////////////// static prandom_t generator; //!< the generator used. ///////////////////////////////////////////////////////////////////////////// // // Global functions // ///////////////////////////////////////////////////////////////////////////// //! a primitive randomizing step, using a linear congruential generator. void randstep(long *val) { long k; k=(*val)/PRANDOM_Q; *val=PRANDOM_A*(*val-k*PRANDOM_Q)-PRANDOM_R*k; if(*val<0) *val += PRANDOM_M; } //! Initialize pseudo-random number generator from seed. void srandom(unsigned _seed) { unsigned i; unsigned long seed=_seed; // catch zero seeds etc. seed= (seed==PRANDOM_MASK) ? seed : seed^PRANDOM_MASK; // initialize array. randstep(&seed); generator.select=seed & (PRANDOM_SLOTS-1); for(i=0; i */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ //! Compare two strings /*! \param s1 first string \param s2 second string \return <0: s10: s1>s2 */ int strcmp(const char *s1,const char *s2) { while(*s1==*s2 && *s1!=0) { s1++; s2++; } if(*s1==*s2) return 0; if(*s1<*s2) return -1; return 1; } brickos-0.9.0/lib/c/strcpy.c0000644000175000017500000000220107530330675013371 0ustar cbcb/*! \file strcpy.c \brief strcpy function \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ //! Copy null-terminated string from src to dest /*! \param src source \param dest destination \return pointer to dest */ char* strcpy(char *dest,const char *src) { char *d2=dest; while( ( *(d2++) = *(src++) ) != 0 ) ; return dest; } brickos-0.9.0/lib/c/strlen.c0000644000175000017500000000210207530330675013354 0ustar cbcb/*! \file strlen.c \brief strlen function \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ //! Determine string length /*! \param s string \param s2 second string \return string length */ int strlen(const char *s) { int len=0; while(*(s++)) len++; return len; } brickos-0.9.0/lib/c++/0000755000175000017500000000000010173102444012020 5ustar cbcbbrickos-0.9.0/lib/c++/Makefile0000644000175000017500000000304210005036116013453 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.9 2004/01/25 21:59:42 hzeller Exp $ ### FILE: lib/c++/Makefile - make the c++ library ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # our target LIBTARGET = c++ # sources CSOURCES = stub.c CXXSOURCES=mem.cpp ## ## no user servicable parts below ## LIBRARY = lib$(LIBTARGET).a OBJECTS = $(CSOURCES:.c=.o) $(CXXSOURCES:.cpp=.o) all:: promote-stamp @# nothing to do here but do it silently promote-stamp: $(LIBRARY) cp -f $? ../ @touch $@ include ../../Makefile.common $(LIBRARY): $(OBJECTS) rm -f $@ $(AR) -sq $@ $(OBJECTS) .depend: $(CSOURCES) $(CXXSOURCES) $(MAKEDEPEND) $(CSOURCES) $(CXXSOURCES) > .depend depend:: .depend @# nothing to do here but do it silently clean: rm -f *.o *.map *.coff *.srec *.dis* *~ *.bak *.tgz *.s realclean: clean rm -f $(LIBRARY) ../$(LIBRARY) .depend @rm -f install-stamp promote-stamp tags TAGS install: install-stamp @# nothing to do here but do it silently install-stamp: $(LIBRARY) @if [ ! -d ${pkglibdir} ]; then \ mkdir -p ${pkglibdir}; \ fi cp -f $? ${pkglibdir}/$? @touch $@ uninstall: @rm -f install-stamp .PHONY: all promote-stamp depend clean realclean install install-stamp uninstall ### -------------------------------------------------------------------------- ### End of FILE: lib/c++/Makefile ### ========================================================================== brickos-0.9.0/lib/c++/mem.cpp0000644000175000017500000000222010005102232013263 0ustar cbcb/* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Henner Zeller */ #include // for malloc(), free(), size_t def'ns // if we are using 3.x compiler then define new style new/delete #if __GNUC__ >= 3 void* operator new(size_t size) { return malloc(size); } void* operator new[] (size_t size) { return malloc(size); } void operator delete (void *p) { free(p); } void operator delete[] (void *p) { free(p); } #endif brickos-0.9.0/lib/c++/sensor.cpp0000644000175000017500000000301707530330675014052 0ustar cbcb/*! \file c++/sensor.cpp \brief Direct sensor access in C++ \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include "c++/sensor.h" unsigned* const Sensor::s1=&SENSOR_1; //!< RCX sensor 1 address unsigned* const Sensor::s2=&SENSOR_2; //!< RCX sensor 2 address unsigned* const Sensor::s3=&SENSOR_3; //!< RCX sensor 3 address unsigned* const Sensor::battery=&BATTERY; //!< RCX battery sensor address RotationSensor::RotationSensor(unsigned *addr,int initial) : Sensor(addr,1) { ds_rotation_set(ptr,initial); ds_rotation_on(ptr); if(ptr==s1) posPtr=(int * volatile) ds_rotations+2; else if(ptr==s2) posPtr=(int * volatile) ds_rotations+1; else if(ptr==s3) posPtr=(int * volatile) ds_rotations; } brickos-0.9.0/lib/c++/stub.c0000644000175000017500000000475710005102232013143 0ustar cbcb/*! \file c++/stub.c \brief A collection of dirty hacks to get C++ compilation going. \author Markus L. Noga This stub provides the necessary runtime environment for basic C++. The following features currently work:
  • Classes
  • Inheritance
  • new and delete
  • Virtual methods and destructors
Several features are still amiss:
  • Throwing an exception will abort the current thread.
  • RTTI is unimplemented.
*/ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Lars Berntzon */ #include // for malloc(), free(), size_t def'ns // NOTE: use explicit def'n versus due to it's use of config.h (not avail. here) extern void exit(int) __attribute__ ((noreturn)); //! Abort execution /*! Functional version, calls exit(1) */ void __terminate() { exit(-1); } //! Throw an execption in a setjmp environment /*! FIXME: this just terminates the task. */ void __sjthrow() { __terminate(); } //! Return current exception handler context /*! FIXME: null pointer returned */ void* __get_eh_context() { return (void*) 0; } //! FIXME: rtti nop hack. int __rtti_si() { return 0; } //! FIXME: rtti nop hack. int __rtti_user() { return 0; } // if we are using 2.95 compiler then define old style new/delete #if __GNUC__ < 3 //! builtin delete function /*! frees the memory block \param ptr the block to free */ void __builtin_delete(void* ptr) { free(ptr); } //! builtin new function /*! creates a memory block for an object. \param size size of memory to allocate */ void *__builtin_new(unsigned int size) { return malloc(size); } #endif void __pure_virtual() { __terminate(); } brickos-0.9.0/lib/Makefile0000644000175000017500000000155507553436365013142 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.6 2002/10/17 04:30:45 stephmo Exp $ ### FILE: lib/Makefile - make the supporting libraries ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # list of dirctories in this subtree SUBDIRS=c \ mint \ float \ c++ # targets which get passed to these directories all install clean realclean depend uninstall:: @for i in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$i $@ || exit 2; done # target(s) which get acted upon here (or not) tag:: @# nothing to do here but do it silently ### -------------------------------------------------------------------------- ### End of FILE: lib/Makefile ### ========================================================================== brickos-0.9.0/lib/float/0000755000175000017500000000000010173102444012555 5ustar cbcbbrickos-0.9.0/lib/float/Makefile0000644000175000017500000000313307610007175014224 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.9 2003/01/11 12:30:53 emanlove Exp $ ### FILE: lib/float/Makefile - make the floating point math library ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # our target LIBTARGET = float # sources SOURCES = expandsf.s joinsf.s addsf3.s negsf2.s mulsf3.s divsf3.s \ floatsisf.s cmpsf2.s fixsfsi.s startsf.s normalsf.s ## ## no user servicable parts below ## LIBRARY = lib$(LIBTARGET).a OBJECTS = $(SOURCES:.s=.o) all:: promote-stamp @# nothing to do here but do it silently promote-stamp: $(LIBRARY) cp -f $? ../ @touch $@ include ../../Makefile.common $(LIBRARY): $(OBJECTS) rm -f $@ $(AR) -sq $@ $(OBJECTS) .depend: $(SOURCES) $(MAKEDEPEND) $(SOURCES) > .depend depend:: .depend @# nothing to do here but do it silently clean: rm -f *.o *.map *.coff *.srec *.dis* *~ *.bak *.tgz realclean: clean rm -f $(LIBRARY) ../$(LIBRARY) .depend @rm -f install-stamp promote-stamp tags TAGS install: install-stamp @# nothing to do here but do it silently install-stamp: $(LIBRARY) @if [ ! -d ${pkglibdir} ]; then \ mkdir -p ${pkglibdir}; \ fi cp -f $? ${pkglibdir}/$? @touch $@ uninstall: @rm -f install-stamp .PHONY: all promote-stamp depend clean realclean install install-stamp uninstall ### -------------------------------------------------------------------------- ### End of FILE: lib/float/Makefile ### ========================================================================== brickos-0.9.0/lib/float/README0000644000175000017500000000622210014027536013441 0ustar cbcbLibfloat.a (Dec 16 2000 release) Written by Kekoa Proudfoot Released May 27, 1999 INTRODUCTION Libfloat.a provides single precision floating point support for H8 processors. Libfloat.a is a part of Librcx, which is distributed under the Mozilla Public License. Please see the file ../LICENSE for details. Routines include: addsf3: single precision floating point add subsf3: single precision floating point subtract mulsf3: single precision floating point multiply divsf3: single precision floating point divide negsf2: single precision floating point negate cmpsf2, eqsf2, nesf2, ltsf2, lesf2, gtsf2, gesf2: single precision floating point compare, all returning -1, 0, or 1 comparisons differ in what they return if input is NaN (not a number) fixsfsi: conversion from single precision floating point to signed long integer fixunssfsi: conversion from single precision floating point to unsigned long integer floatsisf: conversion from signed long integer to single precision floating point ufloatsisf: conversion from unsigned long integer to single precision floating point USAGE NOTES GCC will use all of these functions except ufloatsisf and perhaps also cmpsf2. The ufloatsisf routine is specifically intended to be used to override GCC's built-in support for converting unsigned long integers to floating point. GCC performs each such conversion as an invocation of floatsisf wrapped in additional support code, and because the support code is lengthy, each conversion requires a large amount of code space. Alternatively, an invocation of the ufloatsisf routine is both smaller and faster. You can override GCC's support for conversion from unsigned long integer to single precision floating point as follows: - declare the replacement conversion routine: extern float __ufloatsisf (unsigned long value); - call the routine in place of a cast from unsigned long to float: unsigned long ulvalue; float fvalue; ... fvalue = __ufloatsisf(ulvalue); You do not need to use ufloatsisf for converting unsigned short, unsigned int, or unsigned char types, since GCC's support for these conversions is already reasonably efficient. The floating point support implemented in this directory conforms to a subset of IEEE 754. In particular, this implementation does not support traps, signalling NaNs, status flags, or rounding modes other than round to even, and the only functions implemented are those directly accessible in C using standard operators. The total size of all routines in the library is currently 1124 bytes. A few possible optimizations were left out of this release and may be incorporated into a later version of this library. ACKNOWLEDGEMENTS - Kieran Elby sent in a "0 - x" bug report for subsf3 VERSION HISTORY May 27 1999 - initial release - total size: 1142 bytes Dec 16 2000 - fixed Kieran's "0 - x" bug - simplified negsf2 - total size: 1124 bytes BUG REPORTS Any bugs or problems with this library should be reported to: kekoa@graphics.stanford.edu --- Kekoa Proudfoot December 16, 2000 brickos-0.9.0/lib/float/addsf3.s0000644000175000017500000002144710014027241014110 0ustar cbcb/* * addsf3.s * * Floating point add, single precision: r0r1 += r2r3 * Also implements floating point subtract, single precision: r0r1 -= r2r3 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ ; bug fixes: ; - 12/16/2000 fixed sp+16 sign bug (bug symptom found by Kieran Elby) ; possible optimizations: ; - combine multiple returns of second/larger operand ; - possibly simplify shift left 6 by factoring out common left shift op ; - possibly simplify stickyshift by factoring out common stickyshift op ; - possibly remove shift left 6 by computing a 1.32 result (use carry bit) .section .text ;; ;; function: subsf3 ;; input: float in r0r1 and float at sp+2 ;; output: float in r0r1 ;; .global ___subsf3 ___subsf3: ; Negate the second input mov.b @(2,r7),r2l xor.b #0x80,r2l mov.b r2l,@(2,r7) ; Fall through to add routine ;; ;; function: __addsf3 ;; input: float in r0r1 and float at sp+2 ;; output: float in r0r1 ;; .global ___addsf3 ___addsf3: ; Invoke the preamble to expand input operands jsr ___startsf subentry: ; At this point, registers/stack contain the following: ; r0r1 - first operand ; r2h - second operand flags ; r2l - second operand sign ; r3h - first operand flags ; r3l - first operand sign ; r4 - first operand exponent ; r5r6 - first operand mantissa ; sp+0 - second operand exponent ; sp+2 - second operand flags (same as r2h) ; sp+3 - second operand sign (same as r2l) ; sp+4 - second operand mantissa ; sp+16 - second operand ; Note on flag bits: 0=zero, 1=inf, 2=nan ; Is the first operand a NaN? ; If yes, return the first operand (the value already in r0r1) btst #2,r3h ; if nan flag of first operand set ; Hack! bne return_jmp ; non-zero indicates true ; Is the second operand a NaN? btst #2,r2h ; if nan flag of second operand set beq endif_0 ; zero indicates false ; Return the second operand (which we need to load off stack) mov.w @(16,r7),r0 ; set return value to second operand (sp+16) mov.w @(18,r7),r1 ; Hack! bra return_jmp endif_0: ; Are the operands both infinite with different signs? bld #7,r3l ; get sign of first operand bxor #7,r2l ; xor with sign bit of second operand band #1,r3h ; and with inf bit of first operand band #1,r2h ; and with inf bit of second operand bcc endif_1 ; carry clear indicates false ; Both operands are infinite with different signs, so return NaN mov.w #0x7fff,r0 ; set return value to NaN (7fffffff) mov.w #0xffff,r1 ; Hack! bra return_jmp endif_1: ; At this point, registers contain the following: ; r0r1 - first operand ; r2h - second operand flags ; r2l - second operand sign ; r3h - first operand flags ; r3l - first operand sign ; r4 - first operand exponent ; r5r6 - first operand mantissa ; We no longer need r0 r1 r2h r3h mov.b r2l,r3h ; transfer second operand sign to r3h ; We now have r0 r1 r2 free ; Our goal now is to make the registers/stack contain the following: ; r0r1 - smaller operand mantissa ; r2 - exponent difference (larger exponent minus smaller) ; r3h - subtract flag (xor of signs) ; r3l - larger operand sign ; r4 - [empty] ; r5r6 - larger operand mantissa ; sp+2 - larger operand exponent ; sp+16 - larger operand ; Set subtract flag xor.b r3l,r3h ; Does the second operand have a larger exponent? mov.w @r7,r2 ; load second operand exponent (sp+0) to r2 sub.w r4,r2 ; subtract first exponent (r4) from second (r2) ble else_2 ; branch if second exponent <= first exponent ; Second operand is larger, rearrange accordingly mov.w r5,r0 ; move first (smaller) mantissa to r0r1 mov.w r6,r1 mov.b @(3,r7),r3l ; load second (larger) sign to r3l mov.w @(4,r7),r5 ; load second (larger) mantissa to r5r6 mov.w @(6,r7),r6 bra endif_2 else_2: ; First operand is larger, rearrange accordingly ; Also, negate exponent difference mov.w r0,@(16,r7) ; store first (larger) operand to sp+16 mov.w r1,@(18,r7) mov.w r4,@r7 ; store first (larger) exponent to sp+0 mov.w @(4,r7),r0 ; load second (smaller) mantissa to r0r1 mov.w @(6,r7),r1 not.b r2l ; negate exponent difference not.b r2h adds.w #1,r2 endif_2: ; We have now successfully rearranged things ; Our registers and stack contain what we set out to have them contain ; See above ; If exponent difference exceeds 25, then return the larger operand mov.w #25,r4 ; load 25 to free register cmp.w r4,r2 ; if exponent difference (r2) > 25 ble endif_3 ; Return larger operand mov.w @(16,r7),r0 ; load larger operand to r0r1 mov.w @(18,r7),r1 ; Hack! return_jmp: bra return endif_3: ; Shift left both mantissas by 6 places mov.b #6,r4l ; use r4l as counter, set to 6 dowhile_4: add.w r1,r1 ; use add to shift smaller mantissa left addx.b r0l,r0l addx.b r0h,r0h add.w r6,r6 ; use add to shift larger mantissa left addx.b r5l,r5l addx.b r5h,r5h dec.b r4l ; decrement counter bne dowhile_4 ; repeat if counter not yet zero ; Shift the smaller operand right by the exponent difference ; Since exponent difference is less than 25, use only r2l as counter ; Maintain a sticky bit in lsb while_5: dec.b r2l ; if there are more places to shift blt endwhile_5 ; negative counter indicates false shlr.b r0h ; shift mantissa right 1 place rotxr.b r0l rotxr.b r1h rotxr.b r1l ; places old sticky bit in carry bor #0,r1l ; or lsb with old sticky bit to get new bit bst #0,r1l ; store new sticky bit bra while_5 endwhile_5: ; Load saved exponent from stack mov.w @r7,r4 ; load larger exponent from sp+0 ; Add or subtract? mov.b r3h,r3h ; if subtract flag not set bne else_6 ; Add add.w r1,r6 ; compute r5r6 + r0r1 addx.b r0l,r5l addx.b r0h,r5h ; If result is zero, we do not change sign, since signs were same bra endif_6 else_6: ; Subtract sub.w r1,r6 ; compute r5r6 - r0r1 subx.b r0l,r5l subx.b r0h,r5h ; Is result zero? bne else_7 ; non-zero indicates false ; Make sign zero so we return +0, not -0 sub.b r3l,r3l ; clear sign byte bra endif_7 else_7: ; Result is non-zero. Is it negative? bge endif_8 ; greater than or equal indicates false ; Flip sign xor.b #0x80,r3l ; invert sign ; Negate mantissa mov.w r5,r0 ; transfer mantissa to r0r1 mov.w r6,r1 sub.w r5,r5 ; zero destination sub.w r6,r6 sub.w r1,r6 ; subtract original mantissa subx.b r0l,r5l subx.b r0h,r5h endif_8: ; Normalize jsr ___normalizesf endif_7: endif_6: jsr ___joinsf return: ; Invoke the epilogue to cleanup and return jmp ___finishsf brickos-0.9.0/lib/float/cmpsf2.s0000644000175000017500000001301310014027204014123 0ustar cbcb/* * cmpsf2.s * * Floating point compare: r0r1 = (r0r1 > r2r3) - (r0r1 < r2r3) * GCC apparently does not call this because it is not normal IEEE * * For GCC, we also implement: == != < > <= >= * All of these return -1 0 1 as with the ordinary floating point compare * However, all return false given NaN input, except != which returns true * * The non-GCC non-IEEE floating point compare returns zero given NaN input * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ .section .text ;; ;; functions: cmpsf2, eqsf2, nesf2, ltsf2, gtsf2, lesf2, gesf2 ;; input: float in r0r1 and float at sp+2 ;; output: int in r0 ;; ; In all cases, assume r2 and r3 saved by caller .global ___eqsf2 .global ___nesf2 .global ___ltsf2 .global ___lesf2 ___eqsf2: ___nesf2: ___ltsf2: ___lesf2: ; Load 1 as NaN return value mov.b #1,r2l bra compareentry .global ___gtsf2 .global ___gesf2 ___gtsf2: ___gesf2: ; Load -1 as NaN return value mov.b #-1,r2l bra compareentry .global ___cmpsf2 ___cmpsf2: ; Load 0 as NaN return value sub.b r2l,r2l compareentry: ; Save registers push r4 push r5 ; Clear flag byte sub.b r2h,r2h ; Set flags for first operand mov.w r0,r3 ; copy first operand to r3r4 mov.w r1,r4 bsr setflags ; updates r2h, does not change r3r4 ; Set flags for second operand mov.w @(6,r7),r3 ; load second operand to r3r4 mov.w @(8,r7),r4 bsr setflags ; updates r2h, does not change r3r4 ; Set a negative flag if both operands negative bld #7,r0h ; load sign bit of first operand to carry band #7,r3h ; and with sign bit of second operand bst #2,r2h ; store carry as flag bit ; Note on flag bits: 0=either non-zero, 1=either NaN, 2=both negative ; Is the NaN flag set? btst #1,r2h ; is NaN flag (bit 1) set? beq endif_0 ; zero indicates false ; One of the operands is a NaN ; Move NaN return value to r0l and return mov.b r2l,r0l bra return endif_0: ; Is the non-zero flag clear? btst #0,r2h ; is non-zero flag (bit 0) clear? bne endif_1 ; non-zero indicates false (flag set) ; Neither operand is non-zero, so both operands are zero ; Operands are equal, so move zero return value to r0l and return sub.b r0l,r0l bra return endif_1: ; Subtract second operand (r3r4) from first operand (r0r1) sub.w r4,r1 subx.b r3l,r0l subx.b r3h,r0h ; Is the result equal to zero? ; If yes, return value of zero already in r0l, return beq return ; zero indicates true ; Is the result greater than zero? blt else_2 ; Set the return value to 2 (for now, 2 indicates greater than) mov.b #2,r0l bra endif_2 else_2: ; Set return value to 0 (for now, 0 indicates less than) sub.b r0l,r0l endif_2: ; Is the negative flag set? btst #2,r2h ; is negative flag (bit 2) set? beq endif_3 ; zero indicates false ; Both operands are negative, so fix incorrect sense of compare xor.b #2,r0l ; change 2 to 0 and 0 to 2 endif_3: ; Decrement return value dec.b r0l ; change 2 to 1 and 0 to -1 return: ; Sign extend return value bld #7,r0l subx.b r0h,r0h ; Restore registers pop r5 pop r4 ; Return rts ;; ;; function: setflags ;; input: float in r3r4, previous flags in r2h ;; output: updated flags in r2h ;; registers: assumes r5 free, preserves r3r4 ;; setflags: ; Note on relevant flag bits: 0=either non-zero, 1=either NaN ; Move upper input word to r5 and mask off msb mov.w r3,r5 and.b #0x7f,r5h ; Is the input non-zero? mov.w r4,r4 ; is the lower word non-zero? bne if_4 ; non-zero indicates true mov.w r5,r5 ; is the upper word non-zero? beq endif_4 ; zero indicates false if_4: ; Input is non-zero, set the non-zero flag bset #0,r2h ; set the non-zero flag to 1 endif_4: ; Is input a NAN ((input & 7fffffff) > 7f800000) ? add.b #0,r4l ; subtract 7f800000 from r5r4 addx.b #0,r4h ; do subtract by adding -7f800000=80800000 addx.b #0x80,r5l addx.b #0x80,r5h ble endif_5 ; less than or equal indicates false ; Input is NaN, set the NaN flag bset #1,r2h endif_5: rts brickos-0.9.0/lib/float/divsf3.s0000644000175000017500000001663510014035141014143 0ustar cbcb/* * divsf3.s * * Floating point divide, single precision: r0r1 /= r2r3 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot * * Includes bug fixes by Evgeni Krimer * and Roman Barsky * Project site - http://www.cs.technion.ac.il/~barsky/brickos.html * Last updated 26 Oct 2003 * */ .section .text ;; ;; function: divsf3 ;; input: float in r0r1 and float at sp+2 ;; output: float in r0r1 ;; .global ___divsf3 ___divsf3: ; Invoke the preamble to expand input operands jsr ___startsf ; At this point, registers/stack contain the following: ; r0r1 - first operand ; r2h - second operand flags ; r2l - second operand sign ; r3h - first operand flags ; r3l - first operand sign ; r4 - first operand exponent ; r5r6 - first operand mantissa ; sp+0 - second operand exponent ; sp+2 - second operand flags (same as r2h) ; sp+3 - second operand sign (same as r2l) ; sp+4 - second operand mantissa ; sp+16 - second operand ; Note on flag bits: 0=zero, 1=inf, 2=nan ; Is the first operand a NaN? ; If yes, return the first operand (the value already in r0r1) bld #2,r3h ; if nan flag of first operand set ; Hack! bcs return_jmp ; carry set indicates true ; Is the second operand a NaN? bld #2,r2h ; if nan flag of second operand set bcc endif_0 ; carry clear indicates false ; Return the second operand (which we need to load off stack) mov.w @(16,r7),r0 ; set return value to second operand (sp+16) mov.w @(18,r7),r1 ; Hack! bra return_jmp endif_0: ; Are both operands zero or both operands infinity? bld #0,r3h ; load zero flag of first operand to carry band #0,r2h ; and carry with zero flag of second operand bcs if_1 ; carry set indicates true bld #1,r3h ; load inf flag of first operand to carry band #1,r2h ; and carry with inf flag of second operand bcc endif_1 ; carry clear indicates false if_1: ; Zero divided by zero or infinity divided by infinity, so return NaN mov.w #0x7fff,r0 ; set return value to NaN (7fffffff) mov.w #0xffff,r1 ; Hack! return_jmp: bra return endif_1: ; Compute new sign byte xor.b r2l,r3l ; xor second sign (r2l) into first sign (r3l) ; At this point, we no longer need the following: ; r0r1 - first operand ; r2h - second operand flags ; r2l - second operand sign ; r3h - first operand flags ; Is second operand zero or first operand infinity? bld #0,r2h ; load zero flag of second operand to carry bor #1,r3h ; or carry with inf flag of first operand bcc endif_2 ; Return +/- infinity according to sign mov.w #0x7f80,r0 ; load infinity (7f800000) to return value sub.w r1,r1 or.b r3l,r0h ; or sign bit into upper byte bra return endif_2: ; Compute new exponent mov.w @r7,r0 ; load second operand exponend (sp+0) to temp sub.w r0,r4 ; add temp to exponent of first operand (r4) add.b #126,r4l ; add bias minus one (compensate for 2.29) addx.b #0,r4h ; finish addition ; At this point r0 r1 r2 r3h are free and we want to perform a divide ; We need 6 words plus 1 byte of registers to do this ; Keep r3l where it is, but make r4 free ; Save result exponent to stack mov.w r4,@r7 ; sp+0 is result exponent ; Numerator (first operand mantissa) already in r5r6 ; Load denominator (second operand mantissa) to r0r1 mov.w @(4,r7),r0 ; sp+4 is second operand mantissa mov.w @(6,r7),r1 ; Initialize quotient (r2r4) sub.w r2,r2 ; load zero to r2r4 sub.w r4,r4 ; Initialize counter (r3h) mov.b #26,r3h ; set counter to 26 ; Divide dowhile_3: ; If numerator >= denominator cmp.w r0,r5 ; compare upper words (r5 ? r0) ;bgt if_4 ; greater than indicates true ; NOTE that previous line compares ; signed which causes a bug ; fixed by Krimer and Barsky bhi if_4 ; greater than indicates true ;blt endif_4 ; less than indicates false ; NOTE that previous line compares ; signed which causes a bug ; fixed by Krimer and Barsky blo endif_4 ; less than indicates false cmp.w r1,r6 ; compare lower words (r6 ? r1) ;blt endif_4 ; less than indicates false ; NOTE that previous line compares ; signed which causes a bug ; fixed by Krimer and Barsky blo endif_4 ; less than indicates false if_4: ; Subtract denominator from numerator sub.w r1,r6 ; subtract r0r1 from r5r6 subx.b r0l,r5l subx.b r0h,r5h ; Set quotient bit bset #4,r4l ; set 1 << 4 bit of quotient endif_4: ; Shift numerator and quotient left one place add.w r6,r6 ; shift numerator left one place using add addx.b r5l,r5l addx.b r5h,r5h add.w r4,r4 ; shift quotient left one place using add addx.b r2l,r2l addx.b r2h,r2h ; Decrement counter dec.b r3h ; decrement counter bne dowhile_3 ; repeat if counter not yet zero ; Set sticky bit of quotient if remainder (numerator) is non-zero or.b r5h,r5l ; or remainder bytes together or.b r5l,r6h or.b r6h,r6l add.b #0xff,r6l ; set carry if remainder non-zero bst #0,r4l ; store sticky bit (carry) in lsb of quotient ; Move result to r5r6 mov.w r2,r5 ; copy quotient to r5r6 mov.w r4,r6 ; Restore result exponent from stack mov.w @r7,r4 ; sp+0 is result exponent ; Join jsr ___joinsf return: ; Invoke the epilogue to cleanup and return jmp ___finishsf brickos-0.9.0/lib/float/expandsf.s0000644000175000017500000001046210014027272014553 0ustar cbcb/* * expandsf.s * * Expands a single float into a flag byte, a sign byte, an exponent, * and a mantissa. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ .section .text ;; ;; function: expandsf ;; input: float in r5r6 ;; output: flags in r3h, sign in r3l, exp in r4, mant in r5r6 ;; flag bits: 0=zero, 1=inf, 2=nan ;; .global ___expandsf ___expandsf: ; Clear flag byte sub.b r3h,r3h ; clear flags (r3h) ; Extract sign (to r3l) mov.b r5h,r3l ; extract byte and.b #0x80,r3l ; mask to get sign bit ; Extract exponent (to r4) sub.w r4,r4 ; clear exponent (r4) mov.b r5h,r4l ; copy upper 7 bits of exponent from r5h bld #7,r5l ; load lsb to carry (lsb is msb of r5l) rotxl.b r4l ; rotate to align ; Clear upper mantissa bit (mantissa is in r5l r6h r6l) bclr #7,r5l ; clear upper bit of second mantissa byte ; Upper byte of mantissa (r5h) as a temporary, for now ; Set it to non-zero if mantissa (r5l r6h r6l) is non-zero mov.b r5l,r5h ; set temp (r5h) non-zero if mantissa non-zero or.b r6h,r5h or.b r6l,r5h ; Is the exponent non-zero? Note r4h is known to be zero. mov.b r4l,r4l ; if exponent (r4l) non-zero beq else_0 ; Does the exponent indicate infinity or NaN? Note r4h is zero. cmp.b #0xff,r4l ; if exponent (r4l) is ff bne endif_1 ; Set the infinity flag if the mantissa is zero ; Set the NaN flag if the mantissa is non-zero ; Use temp in r5h to see if mantissa is zero or not add.b #0xff,r5h ; set carry if temp non-zero (destroying temp) bist #1,r3h ; set inf flag to ~carry (mantissa zero) bst #2,r3h ; set nan flag to carry (mantissa non-zero) ; Make exponent huge so it dominates finites ; Simplifies e.g. adding finite to inf or dividing inf by finite mov.b #0x01,r4h ; set lsb of upper exponent byte endif_1: ; Set the hidden one bit in the mantissa bset #7,r5l ; set hidden one bit bra endif_0 else_0: ; Exponent is zero. ; Is the mantissa non-zero, indicating a denorm? ; Use temp in r5h to see if mantissa is zero or not mov.b r5h,r5h ; if mantissa is non-zero beq else_2 ; Set the exponent to 1, its true value mov.b #0x01,r4l ; set exponent (r4l) to one ; Normalize the mantissa ; Do/while appropriate because must shift left at least one place dowhile_3: ; Shift mantissa one place to left add.w r6,r6 ; shift mantissa left 1 place by adding addx.b r5l,r5l ; note only 3 significant bytes ; Decrement exponent subs.w #1,r4 ; Is one bit set? (one bit is in 1 << 23 or 00800000 position) btst #7,r5l ; check 00800000 bit of mantissa beq dowhile_3 ; zero indicates bit not set yet bra endif_2 else_2: ; Mantissa is zero, indicating a zero value ; Set the zero flag bset #0,r3h ; set zero flag endif_2: endif_0: ; Clear the upper mantissa byte, which we used as a temporary sub.b r5h,r5h ; clear upper mantissa byte rts brickos-0.9.0/lib/float/fixsfsi.s0000644000175000017500000001550410014027371014420 0ustar cbcb/* * fixsfsi.s * * Floating point to signed long conversion, single precision: * r0r1 = (long) float r0r1 * Floating point to unsigned long conversion, single precision: * r0r1 = (unsigned long) float r0r1 * * As far as I can tell, conversions for out-of-range values not well-defined * I chose to implement the following: * * For conversion to signed long, values for out-of-range conversions are: * * converted value < -MAXINT -> -MAXINT * converted value > +MAXINT -> +MAXINT * input value == NaN -> +MAXINT * * For conversion to unsigned long, values for out-of-range conversions are: * * converted value < 0 -> +MAXUINT * converted value > +MAXUINT -> +MAXUINT * input value == NaN -> +MAXUINT * * -MAXINT is -2^31, +MAXINT is 2^31-1, +MAXUINT is 2^32-1 * * Another possibility would have been to return numbers modulo 2^31 or 2^32 * Or, could have returned either +MAXINT or +MAXUINT given out-of-range input * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ .section .text ;; ;; function: fixsfsi ;; input: float in r0r1 ;; output: signed long in r0r1 ;; .global ___fixsfsi ___fixsfsi: ; Assume r2 and r3 saved by caller mov.b #0,r2h ; load sign mask mov.b #157,r2l ; load maximum exponent (bias + 30) mov.b #0x80,r3h ; load upper byte of lower return value mov.b #0x7f,r3l ; load upper byte of higher return value ; Jump to fix routine bra fix ;; ;; function: fixunssfsi ;; input: float in r0r1 ;; output: unsigned long in r0r1 ;; .global ___fixunssfsi ___fixunssfsi: ; Assume r2 and r3 saved by caller mov.b #0x80,r2h ; load sign mask mov.b #158,r2l ; load maximum exponent (bias + 31) mov.b #0xff,r3h ; load upper byte of lower return value mov.b #0xff,r3l ; load upper byte of higher return value ; Fall through to fix routine ;; ;; function: fix ;; input: float in r0r1, sign mask in r2h, max exp in r2l, return values in r3 ;; output: signed or unsigned long in r0r1 ;; fix: ; Save registers push r4 push r5 push r6 ; Rearrange registers mov.w r0,r5 ; copy input operand to r5r6 mov.w r1,r6 mov.w r3,r0 ; copy return values to r0 ; Expand the input operand jsr ___expandsf ; expand to r3h r3l r4 r5r6 ; At this point, registers contain the following: ; r0h - upper byte of lower return value ; r0l - upper byte of higher return value (also used if input is NaN) ; r1 - [empty] ; r2h - sign mask ; r2l - maximum exponent ; r3h - input operand flags ; r3l - input operand sign ; r4 - input operand exponent ; r5r6 - input operand mantissa ; Note on flag bits: 0=zero, 1=inf, 2=nan ; Is the exponent small enough to make the number effectively zero? mov.w #127,r1 ; load bias to r1 cmp.w r1,r4 ; is exponent < bias? bge endif_0 ; greater than or equal indicates false ; Return zero result sub.w r0,r0 ; load zero to result (r0r1) sub.w r1,r1 bra return endif_0: ; Are we doing an unsigned conversion and is the number negative? ; Or does number's exponent exceed the maximum allowed value? ; Use sign mask to implement first test ; Also, note that if first test false, r2h cleared to zero for second test and.b r3l,r2h ; and sign into sign mask bne if_1 ; not equal indicates true cmp.w r2,r4 ; is exponent > maximum value for conversion? ble endif_1 ; less than or equal indicates false if_1: ; Input is out of range. ; Is the number positive or NaN? bild #7,r3l ; load ~sign bit to carry bor #2,r3h ; or with nan flag bit bcc endif_2 ; carry clear indicates false ; Move upper byte of higher return value to r0h mov.b r0l,r0h endif_2: ; Correct upper byte of return value now in r0h ; Push lsb down into lower bytes bld #0,r0h ; load lsb to carry subx.b r0l,r0l ; bit extend right subx.b r1h,r1h subx.b r1l,r1l bra return endif_1: ; At this point, we no longer need r0 r1 r2 ; Left shift mantissa by 8 places ; This makes later shift take more time, but it also makes code smaller mov.b r5l,r5h ; shift by rearranging bytes mov.b r6h,r5l mov.b r6l,r6h sub.b r6l,r6l ; Subtract bias + 31 from exponent add.b #-158,r4l ; subtract bias + 31 from exponent addx.b #-1,r4h ; Is exponent < 0 ? ; Note: do nothing if exponent >= 0 ; Also note exponent should not be greater than zero if maximum ; exponent checks done correctly bge endif_3 ; greater than or equal indicates false ; Shift mantissa right, increasing exponent until it reaches zero ; Note exponent only has 1 significant byte dowhile_4: shlr.b r5h ; shift mantissa right one place rotxr.b r5l rotxr.b r6h rotxr.b r6l inc r4l ; increment exponent blt dowhile_4 ; continue while less than zero endif_3: ; Copy result to output mov.w r5,r0 ; copy result (r5r6) to output (r0r1) mov.w r6,r1 ; Is sign < 0 ? mov.b r3l,r3l ; is sign < 0 ? bge endif_5 ; greater than or equal indicates false ; Negate result sub.w r0,r0 ; zero destination sub.w r1,r1 sub.w r6,r1 ; subtract result (result in r5r6) subx.b r5l,r0l subx.b r5h,r0h endif_5: return: ; Restore registers pop r6 pop r5 pop r4 rts brickos-0.9.0/lib/float/floatsisf.s0000644000175000017500000001107210014027371014733 0ustar cbcb/* * floatsisf.s * * Signed long to floating point conversion, single precision: * r0r1 = (float) long r0r1 * Unsigned long to floating point conversion, single precision: * r0r1 = (float) unsigned long r0r1 * * GCC does not directly invoke the unsigned long conversion function * Instead, it wraps the signed long function with a good amount of extra code * You can save space by calling the latter conversion function yourself * If you want to use it, you should invoke it yourself, as a function * The declaration is: extern float __ufloatsisf (unsigned long value); * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ ; possible optimizations ; - integrate msb test and sticky shift with fixoverflow in joinsf ; - add a bor #7,r5h to see if four bit is set ; - factor out stickyshift function, rewrite fixoverflow in joinsf to call it ; - affects this, since we can then call stickyshift right ; - if ufloatsisf removed, msb test should set mantissa to 7fffffff ; - also, msb test should be moved earlier to inside negative input test .section .text ;; ;; function: ufloatsisf ;; input: unsigned long in r0r1 ;; output: float in r0r1 ;; .global ___ufloatsisf ___ufloatsisf: ; Save registers (assume r2 and r3 saved by caller) push r4 push r5 mov.w r6,r2 ; we need r6 specifically, but do not need r2 ; Jump into floatsisf bra ufloatentry ;; ;; function: floatsisf ;; input: signed long in r0r1 ;; output: float in r0r1 ;; .global ___floatsisf ___floatsisf: ; Save registers (assume r2 and r3 saved by caller) push r4 push r5 mov.w r6,r2 ; we need r6 specifically, but do not need r2 ; Is input negative? btst #7,r0h ; is r0r1 < 0? beq else_0 ; equal indicates false ; Set sign to negative mov.b #0x80,r3l ; set sign (r3l) to 0x80 to indicate negative ; Store -input to mantissa sub.w r5,r5 ; zero destination sub.w r6,r6 sub.w r1,r6 ; subtract input subx.b r0l,r5l subx.b r0h,r5h bra endif_0 else_0: ufloatentry: ; Set sign to positive sub.b r3l,r3l ; set sign (r3l) to zero to indicate positive ; Store input to mantissa mov.w r0,r5 ; set mantissa mov.w r1,r6 endif_0: ; Set exponent mov.w #156,r4 ; set exponent to 29 + bias, bias is 127 ; Is msb set? btst #7,r5h ; is msb set? beq else_1 ; zero indicates false ; Mantissa overflow, so shift right one place, maintaining sticky bit shlr.b r5h ; shift mantissa right 1 place rotxr.b r5l rotxr.b r6h rotxr.b r6l ; last shift places old sticky bit in carry bor #0,r6l ; or lsb with old sticky bit bst #0,r6l ; store new sticky bit ; Increase exponent adds.w #1,r4 ; add one to exponent bra endif_1 else_1: ; Is mantissa non-zero? mov.w r5,r5 ; check upper word bne if_2 ; not equal to zero indicates true mov.w r6,r6 ; check lower word beq endif_2 ; equal to zero indicates false if_2: ; Is the two bit (40000000) clear? btst #6,r5h ; check 40000000 bit bne endif_3 ; non-zero indicates false (bit set) ; Normalize jsr ___normalizesf endif_3: endif_2: endif_1: ; Join jsr ___joinsf return: ; Restore registers mov.w r2,r6 pop r5 pop r4 rts brickos-0.9.0/lib/float/joinsf.s0000644000175000017500000001323210014027371014231 0ustar cbcb/* * joinsf.s * * Joins a sign byte, an exponent, and a mantissa into a single float. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ ; possible optimizations: ; - factor sticky shift (4 shift ops, 2 bit ops) into a bsr .section .text ;; ;; function: joinsf ;; input: sign in r3l, exp in r4, mant in r5r6 ;; output: float in r0r1 ;; .global ___joinsf ___joinsf: ; Check for and fix overflow, converting 2.29 to 1.29 bsr fixoverflow ; Is exponent < 1 and is mantissa one bit set? mov.w r4,r4 ; if exponent < 1 bgt endif_0 ; greater than implies false btst #5,r5h ; if mantissa one bit set beq endif_0 ; non-zero implies false ; Handle a denorm. ; Is exponent < -23? mov.w #-23,r0 ; load -23 to r0, which is currently free cmp.w r0,r4 ; if exponent < -23 bge else_1 ; greater than or equal implies false ; Set mantissa and exponent to zero sub.w r5,r5 ; clear mantissa sub.w r6,r6 sub.w r4,r4 ; clear exponent bra endif_1 else_1: ; Shift mantissa right 1 - exponent places, maintaining sticky bit ; Note that since -23 <= exponent < 1, can use byte for counter ; Also note that 1 - exponent is at least 1, so use do/while ; Use r0l for counter mov.b #1,r0l ; load 1 to counter (r0l) sub.b r4l,r0l ; subtract exponent dowhile_2: ; Shift exponent right one place, maintaining sticky bit shlr.b r5h ; shift mantissa right 1 place rotxr.b r5l rotxr.b r6h rotxr.b r6l ; last shift places old sticky bit in carry bor #0,r6l ; or lsb with old sticky bit bst #0,r6l ; store new sticky bit dec.b r0l; ; decrement counter and repeat if non-zero bne dowhile_2 ; Set exponent to 1 mov.w #1,r4 ; load 1 to exponent (r4) endif_1: endif_0: ; Round to nearest even by adding 0x1f if lsb is zero, 0x20 if lsb is one ; The lsb in this case is that of the rounded mantissa (the 1 << 6 bit) ; We do math by computing mantissa + 0x1f + carry, where lsb is in carry bld #6,r6l ; load lsb to carry addx.b #0x1f,r6l ; add 0x1f with carry addx.b #0,r6h ; finish addition addx.b #0,r5l addx.b #0,r5h ; Since that might have overflowed, check for and fix overflow bsr fixoverflow ; Check for infinite result (exponent > 254) mov.w #254,r0 ; load 254 to r0 cmp.w r0,r4 ; if exponent > 254 ble endif_2 ; less than or equal indicates false ; Return +inf if positive (sign==0x00), -inf if negative (sign==0x80) mov.w #0x7f80,r0 ; load 0x7f800000 to r0r1 sub.w r1,r1 or.b r3l,r0h ; or upper byte with sign byte to set sign bra return endif_2: ; Is one bit zero (indicating denorm or zero)? btst #5,r5h ; is one bit set? bne endif_3 ; non-zero indicates false ; Set exponent to zero sub.w r4,r4 ; clear exponent to zero endif_3: ; Shift result right 6 places to remove guard bits mov.b #6,r0l ; use r0l as counter, set to 6 dowhile_4: shlr.b r5h ; shift mantissa right 1 place rotxr.b r5l rotxr.b r6h rotxr.b r6l dec.b r0l ; decrement counter bne dowhile_4 ; repeat if counter not yet zero ; Pack exponent (note 0 <= exp <= 254) mov.b r4l,r5h ; store in upper mantissa byte shlr.b r5h ; shift right one place bst #7,r5l ; store exponent lsb in msb of next byte ; Set sign bit or.b r3l,r5h ; or in the sign byte ; Move result to r0r1 mov.w r5,r0 mov.w r6,r1 return: rts ;; ;; function: fixoverflow ;; input: exponent in r4, 2.29 or 1.29 mantissa in r5r6 ;; output: exponent in r4, 1.29 mantissa in r5r6 ;; fixoverflow: btst #6,r5h ; is two bit set? beq endif_5 ; zero indicates false ; Shift mantissa right one place, maintaining sticky bit shlr.b r5h ; shift mantissa right 1 place rotxr.b r5l rotxr.b r6h rotxr.b r6l ; last shift places old sticky bit in carry bor #0,r6l ; or lsb with old sticky bit bst #0,r6l ; store new sticky bit ; Increase exponent adds.w #1,r4 ; add one to exponent endif_5: rts brickos-0.9.0/lib/float/mulsf3.s0000644000175000017500000001754010014027536014163 0ustar cbcb/* * mulsf3.s * * Floating point multiply, single precision: r0r1 *= r2r3 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ ; possible optimizations: ; - use push/pop to save exponent and sign on stack ; - might it have been faster/simpler to inline a 24 iteration multiply? ; - this only requires 3b + 3b + 4b + 1b in regs to implement? .section .text ;; ;; function: mulsf3 ;; input: float in r0r1 and float at sp+2 ;; output: float in r0r1 ;; .global ___mulsf3 ___mulsf3: ; Invoke the prologue to expand input operands jsr ___startsf ; At this point, registers/stack contain the following: ; r0r1 - first operand ; r2h - second operand flags ; r2l - second operand sign ; r3h - first operand flags ; r3l - first operand sign ; r4 - first operand exponent ; r5r6 - first operand mantissa ; sp+0 - second operand exponent ; sp+2 - second operand flags (same as r2h) ; sp+3 - second operand sign (same as r2l) ; sp+4 - second operand mantissa ; sp+16 - second operand ; Note on flag bits: 0=zero, 1=inf, 2=nan ; Is the first operand a NaN? ; If yes, return the first operand (the value already in r0r1) bld #2,r3h ; if nan flag of first operand set ; Hack! bcs return_jmp ; carry set indicates true ; Is the second operand a NaN? bld #2,r2h ; if nan flag of second operand set bcc endif_0 ; carry clear indicates false ; Return the second operand (which we need to load off stack) mov.w @(16,r7),r0 ; set return value to second operand (sp+16) mov.w @(18,r7),r1 ; Hack! return_jmp: bra return endif_0: ; Is the first operand infinity and the second operand zero? ; Or is the second operand infinity and the first operand zero? bld #1,r3h ; load inf flag of first operand to carry band #0,r2h ; and carry with zero flag of second operand bcs if_1 ; carry set indicates true bld #1,r2h ; load inf flag of second operand to carry band #0,r3h ; and carry with zero flag of first operand bcc endif_1 ; carry clear indicates false if_1: ; Zero multiplied by infinity, so return NaN mov.w #0x7fff,r0 ; set return value to NaN (7fffffff) mov.w #0xffff,r1 bra return endif_1: ; At this point, we no longer need the following: ; r0r1 - first operand ; r2h - second operand flags ; r3h - first operand flags ; Compute new exponent mov.w @r7,r0 ; load second operand exponent (sp+0) to temp add.w r0,r4 ; add temp to exponent of first operand (r4) add.b #-127,r4l ; subtract bias addx.b #-1,r4h ; finish subtraction ; Compute new sign xor.b r2l,r3l ; xor second sign (r2l) into first sign (r3l) ; At this point r2l is also free (and therefore all of r2 is free) ; We now want to multiply the two mantissas ; We need r3 and r4 free to do this ; Save result exponent and sign to stack mov.w r4,@r7 ; sp+0 is result exponent mov.b r3l,@(3,r7) ; sp+3 is result sign ; Given two 1.23 mantissas, compute a 2.30 product with a sticky lsb ; Use three 24 by 8 multiplies to multiply two 24-bit mantissas ; Save first mantissa to r2r3 mov.w r5,r2 ; copy r5r6 to r2r3 mov.w r6,r3 ; note multiply done using r5r6 ; Perform first multiply (first mantissa * lower byte of second mantissa) mov.b @(7,r7),r4l ; load lower byte of second mantissa to r4l bsr mul_24_8 ; multiply r5l r6h r6l by r4l ; Save lower four result bytes in r0r1 mov.w r5,r0 ; copy r5r6 to r0r1 mov.w r6,r1 ; Perform second multiply (first mantissa * middle byte of second mantissa) mov.w r2,r5 ; copy first mantissa back to r5r6 from r2r3 mov.w r3,r6 mov.b @(6,r7),r4l ; load middle byte of second mantissa to r4l bsr mul_24_8 ; multiply r5l r6h r6l by r4l ; Combine new result into old and propagate carry into fifth result byte add.b r6l,r1h ; add corresponding bytes addx.b r6h,r0l addx.b r5l,r0h addx.b #0,r5h ; propagate carry ; Combine lower two result bytes into a single sticky byte or.b r1l,r1h ; compute new sticky byte ; Save fifth result byte mov.b r5h,r1l ; store fifth result byte ; Perform final multiply (first mantissa * upper byte of second mantissa) mov.w r2,r5 ; copy first mantissa back to r5r6 from r2r3 mov.w r3,r6 mov.b @(5,r7),r4l ; load upper byte of second mantissa to r4l bsr mul_24_8 ; multiply r5l r6h r6l by r4l ; Combine old result into new and propagate carry into upper result byte add.w r0,r6 ; add corresponding bytes addx.b r1l,r5l addx.b #0,r5h ; propagate carry ; 2.30 result now in r5r6 ; Set sticky bit if sticky byte or result lsb non-zero add.b #0xff,r1h ; set carry if sticky byte non-zero bor #0,r6l ; or carry with lsb to get sticky bit bst #0,r6l ; store sticky bit in lsb ; Sticky shift the result right one place to get a 2.29 value shlr.b r5h ; shift mantissa right 1 place rotxr.b r5l rotxr.b r6h rotxr.b r6l ; places old sticky bit in carry bor #0,r6l ; or lsb with old sticky bit to get new bit bst #0,r6l ; store new sticky bit ; Restore result exponent and sign from stack mov.w @r7,r4 ; sp+0 is result exponent mov.b @(3,r7),r3l ; sp+3 is result sign ; Pack the result jsr ___joinsf return: ; Invoke the epilogue to cleanup and return jmp ___finishsf ;; ;; function: mul_24_8: ;; input: three-byte operand in r5l r6h r6l, single-byte operand in r4l ;; output: four-byte product in r5 r6 ;; registers: assumes r4h r5h free ;; mul_24_8: ; Rearrange bytes mov.b r6h,r4h ; move middle byte of three-byte operand to r4h ; Perform bytewise multiply mulxu.b r4l,r5 ; multiply r5l r4h r6l by single-byte operand mulxu.b r4l,r6 ; result split into words in r5 r4 r6 mulxu.b r4h,r4 ; r5 r4 r6 are resp. upper middle lower words ; Combine results ; Add lower byte of middle word into upper byte of lower word ; Add upper byte of middle word into lower byte of upper word, using carry ; Propagate second carry to upper byte of upper word add.b r4l,r6h ; add corresponding bytes addx.b r4h,r5l ; add corresponding bytes, with carry addx.b #0,r5h ; propagate second carry rts brickos-0.9.0/lib/float/negsf2.s0000644000175000017500000000222210014027536014125 0ustar cbcb/* * negsf2.s * * Floating point negate, single precision: -r0r1 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ ; possible optimizations ; - remove NaN check ;; ;; function: negsf2 ;; input: float in r0r1 ;; output: float in r0r1 ;; .section .text .global ___negsf2 ___negsf2: ; Negate operand xor.b #0x80,r0h ; flip sign bit of operand return: rts brickos-0.9.0/lib/float/normalsf.s0000644000175000017500000000321510014027536014565 0ustar cbcb/* * normalsf.s * * Normalizes a denormalized 1.29 mantissa by left shifting it * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ .section .text ;; ;; function: normalizesf ;; input: exp in r4, mant in r5r6, mant must be non-zero and in 1.29 format ;; output: exp in r4, mant in r5r6 ;; .global ___normalizesf ___normalizesf: ; Left shift while one bit not set (final format is 1.29) while_0: ; Is one bit set? (one bit is in 1 << 29 or 20000000 position) btst #5,r5h ; load 20000000 bit of mantissa bne endwhile_0 ; non-zero indicates bit set ; Shift mantissa one place to left add.w r6,r6 ; use add to shift mantissa left 1 place addx.b r5l,r5l addx.b r5h,r5h ; Decrement exponent subs.w #1,r4 ; Repeat bra while_0 endwhile_0: rts brickos-0.9.0/lib/float/startsf.s0000644000175000017500000000612210014027536014432 0ustar cbcb/* * startsf.s * * Common preamble for floating point routines that take two operands * Common epilogue for floating point routines that take two operands * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx floating point code, released May 27, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ .section .text ;; ;; function: startsf ;; input: float in r0r1 and float at caller's sp+2 before call ;; output: first float in r0r1 and second float at caller's sp+16 after call ;; expanded first float, r3 flags/sign, r4 exponent, r5r6 mantissa ;; expanded second float, sp+0 exponent, sp+2 flags/sign, sp+4 mantissa ;; expanded second float flags/sign also in r2 ;; saved r4, r5, r6 at caller's sp+12, sp+10, sp+8 ;; .global ___startsf ___startsf: ; Assume r2 and r3 saved by original caller pop r2 ; load return address to r2 ; Save registers on stack push r4 push r5 push r6 ; Expand the second operand mov.w @(8,r7),r5 ; copy second operand (sp+8) to r5r6 mov.w @(10,r7),r6 jsr ___expandsf ; expand to r3h r3l r4 r5r6 ; Save expanded second operand to stack by pushing in reverse order push r6 ; mantissa lower word push r5 ; mantissa upper word push r3 ; flags, sign push r4 ; exponent ; At this point, stack looks like caller will see it: ; sp+0 - second operand exponent ; sp+2 - second operand flags ; sp+3 - second operand sign ; sp+4 - second operand mantissa ; sp+8 - saved r6 ; sp+10 - saved r5 ; sp+12 - saved r4 ; sp+14 - caller's return address ; sp+16 - second operand ; Put our return address back on stack push r2 ; Copy second operand flags/sign to r2 mov.w r3,r2 ; Expand the first operand mov.w r0,r5 ; copy first operand to r5r6 mov.w r1,r6 jsr ___expandsf ; expand to r3h r3l r4 r5r6 ; Return rts ;; ;; entry point: finishsf ;; input: return value in r0r1 ;; output: cleans up stack, restoring r4 r5 r6 and leaving r0r1 intact ;; .global ___finishsf ___finishsf: ; Deallocate stack space add.b #8,r7l addx.b #0,r7h ; Restore registers pop r6 pop r5 pop r4 ; Return for caller rts brickos-0.9.0/lib/mint/0000755000175000017500000000000010173102444012417 5ustar cbcbbrickos-0.9.0/lib/mint/Makefile0000644000175000017500000000314107610007223014057 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.8 2003/01/11 12:31:15 emanlove Exp $ ### FILE: lib/mint/Makefile - make the integer math library ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # our target LIBTARGET = mint # sources SOURCES= cmpsi2.c divhi3.c modhi3.c mulhi3.c udivhi3.c umodhi3.c \ divsi3.c modsi3.c mulsi3.c ucmpsi2.c udivsi3.c umodsi3.c ## ## no user servicable parts below ## LIBRARY = lib$(LIBTARGET).a OBJECTS=$(SOURCES:.c=.o) all:: promote-stamp @# nothing to do here but do it silently promote-stamp: $(LIBRARY) cp -f $? ../ @touch $@ include ../../Makefile.common $(LIBRARY): $(OBJECTS) rm -f $@ $(AR) -sq $@ $(OBJECTS) .depend: $(SOURCES) $(MAKEDEPEND) $(SOURCES) > .depend depend:: .depend @# nothing to do here but do it silently clean: rm -f *.o *.map *.coff *.srec *.dis* *~ *.bak *.tgz *.s realclean: clean rm -f $(LIBRARY) ../$(LIBRARY) .depend @rm -f install-stamp promote-stamp tags TAGS install: install-stamp @# nothing to do here but do it silently install-stamp: $(LIBRARY) @if [ ! -d ${pkglibdir} ]; then \ mkdir -p ${pkglibdir}; \ fi cp -f $? ${pkglibdir}/$? @touch $@ uninstall: @rm -f install-stamp .PHONY: all promote-stamp depend clean realclean install install-stamp uninstall ### -------------------------------------------------------------------------- ### End of FILE: lib/mint/Makefile ### ========================================================================== brickos-0.9.0/lib/mint/cmpsi2.c0000644000175000017500000000267707777403436014021 0ustar cbcb/* * cmpsi2.c * * Implementation of cmpsi2, a 32-bit signed compare: r0r1 <=> r2r3 * Returns -1, 0, or 1, which might not be correct. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ("\n\ .section .text\n\ \n\ .global ___cmpsi2\n\ \n\ ___cmpsi2:\n\ \n\ sub.w r3,r1\n\ subx.b r2l,r0l\n\ subx.b r2h,r0h\n\ \n\ blt else_0\n\ \n\ beq else_1\n\ \n\ ; First operand greater than second operand\n\ \n\ mov.w #1,r0\n\ rts\n\ \n\ else_1:\n\ \n\ ; First operand equal to second operand\n\ \n\ sub.w r0,r0\n\ rts\n\ \n\ endif_1:\n\ \n\ else_0:\n\ \n\ ; First operand less than second operand\n\ \n\ mov.w #-1,r0\n\ rts\n\ \n\ endif_0:\n\ \n\ ; Not reached\n\ "); brickos-0.9.0/lib/mint/divhi3.c0000644000175000017500000000217507530330675013772 0ustar cbcb/* * divhi3.c * * Wrapper for ROM divhi3 routine, a 16-bit signed divide: r0 /= r1 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ( ".section .text\n\t" ".global ___divhi3\n" "___divhi3:\n\t" "push r5\n\t" "push r6\n\t" "mov.w r0,r6\n\t" "mov.w r1,r5\n\t" "jsr @@82\n\t" "mov.w r6,r0\n\t" "pop r6\n\t" "pop r5\n\t" "rts" ); brickos-0.9.0/lib/mint/divsi3.c0000644000175000017500000000234607530330675014005 0ustar cbcb/* * divsi3.c * * Wrapper for ROM divsi3 routine, a 32-bit signed divide: r0r1 /= r2r3 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ( ".section .text\n\t" ".global ___divsi3\n" "___divsi3:\n\t" "push r4\n\t" "push r5\n\t" "push r6\n\t" "mov.w r1,r6\n\t" "mov.w r0,r5\n\t" "mov.w r3,r4\n\t" "mov.w r2,r3\n\t" "jsr @@88\n\t" "mov.w r6,r1\n\t" "mov.w r5,r0\n\t" "pop r6\n\t" "pop r5\n\t" "pop r4\n\t" "rts" ); brickos-0.9.0/lib/mint/modhi3.c0000644000175000017500000000217507530330675013767 0ustar cbcb/* * modhi3.c * * Wrapper for ROM modhi3 routine, a 16-bit signed modulo: r0 %= r1 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ( ".section .text\n\t" ".global ___modhi3\n" "___modhi3:\n\t" "push r5\n\t" "push r6\n\t" "mov.w r0,r6\n\t" "mov.w r1,r5\n\t" "jsr @@80\n\t" "mov.w r6,r0\n\t" "pop r6\n\t" "pop r5\n\t" "rts" ); brickos-0.9.0/lib/mint/modsi3.c0000644000175000017500000000320607530330675013776 0ustar cbcb/* * modsi3.c * * 32-bit signed modulo: r0r1 %= r2r3 * * Calls the ROM version of divsi3, which leaves the absolute value of the * remainder in r3r4. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Rcxlib code, released January 20, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ( ".section .text\n\t" ".global ___modsi3\n" "___modsi3:\n\t" "push r4\n\t" "push r5\n\t" "push r6\n\t" "push r0\n\t" "mov.w r1,r6\n\t" "mov.w r0,r5\n\t" "mov.w r3,r4\n\t" "mov.w r2,r3\n\t" "jsr @@88\n\t" "mov.w r4,r1\n\t" "mov.w r3,r0\n\t" "# negate remainder if numerator was less than zero\n\t" "btst #0x7,@r7\n\t" "beq skipnegate\n\t" "not.b r0l\n\t" "not.b r0h\n\t" "not.b r1l\n\t" "not.b r1h\n\t" "add.b #0x1,r1l\n\t" "addx #0x0,r1h\n\t" "addx #0x0,r0l\n\t" "addx #0x0,r0h\n" "skipnegate:\n\t" "adds #0x2,r7\n\t" "pop r6\n\t" "pop r5\n\t" "pop r4\n\t" "rts" ); brickos-0.9.0/lib/mint/mulhi3.c0000644000175000017500000000255307777403436014016 0ustar cbcb/*! \file mulhi3.c \brief 16 bit multiplication routine \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ //! 16 bit signed multiplication */ /*! \param a multiplicand \param b multiplicand \return product */ int __mulhi3(int a,int b); __asm__ ("\n\ .section .text\n\ .global ___mulhi3\n\ ___mulhi3:\n\ ; param r0,r1\n\ ; return r0\n\ ; clobber r2\n\ \n\ mov.w r0,r2\n\ mulxu.b r1h,r2\n\ mov.b r0h,r2h\n\ mulxu.b r1l,r0\n\ add.b r2l,r0h\n\ mulxu.b r2h,r1\n\ add.b r1l,r0h\n\ rts\n\ "); brickos-0.9.0/lib/mint/mulsi3.c0000644000175000017500000000234107530330675014013 0ustar cbcb/* * mulsi3.c * * Wrapper for ROM mulsi3 routine, a 32-bit multiply: r0r1 *= r2r3 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ( ".section .text\n\t" ".global ___mulsi3\n" "___mulsi3:\n\t" "push r4\n\t" "push r5\n\t" "push r6\n\t" "mov.w r1,r6\n\t" "mov.w r0,r5\n\t" "mov.w r3,r4\n\t" "mov.w r2,r3\n\t" "jsr @@84\n\t" "mov.w r6,r1\n\t" "mov.w r5,r0\n\t" "pop r6\n\t" "pop r5\n\t" "pop r4\n\t" "rts" ); brickos-0.9.0/lib/mint/ucmpsi2.c0000644000175000017500000000270407777403436014175 0ustar cbcb/* * ucmpsi2.c * * Implementation of ucmpsi2, a 32-bit unsigned compare: r0r1 <=> r2r3 * Returns -1, 0, or 1, which might not be correct. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ("\n\ .section .text\n\ \n\ .global ___ucmpsi2\n\ \n\ ___ucmpsi2:\n\ \n\ sub.w r3,r1\n\ subx.b r2l,r0l\n\ subx.b r2h,r0h\n\ \n\ blo else_0\n\ \n\ beq else_1\n\ \n\ ; First operand greater than second operand\n\ \n\ mov.w #1,r0\n\ rts\n\ \n\ else_1:\n\ \n\ ; First operand equal to second operand\n\ \n\ sub.w r0,r0\n\ rts\n\ \n\ endif_1:\n\ \n\ else_0:\n\ \n\ ; First operand less than second operand\n\ \n\ mov.w #-1,r0\n\ rts\n\ \n\ endif_0:\n\ \n\ ; Not reached\n\ "); brickos-0.9.0/lib/mint/udivhi3.c0000644000175000017500000000220307530330675014147 0ustar cbcb/* * udivhi3.c * * Wrapper for ROM udivhi3 routine, a 16-bit unsigned divide: r0 /= r1 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ( ".section .text\n\t" ".global ___udivhi3\n" "___udivhi3:\n\t" "push r5\n\t" "push r6\n\t" "mov.w r0,r6\n\t" "mov.w r1,r5\n\t" "jsr @@78\n\t" "mov.w r6,r0\n\t" "pop r6\n\t" "pop r5\n\t" "rts" ); brickos-0.9.0/lib/mint/udivsi3.c0000644000175000017500000000235407530330675014171 0ustar cbcb/* * udivsi3.c * * Wrapper for ROM udivsi3 routine, a 32-bit unsigned divide: r0r1 /= r2r3 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ( ".section .text\n\t" ".global ___udivsi3\n" "___udivsi3:\n\t" "push r4\n\t" "push r5\n\t" "push r6\n\t" "mov.w r1,r6\n\t" "mov.w r0,r5\n\t" "mov.w r3,r4\n\t" "mov.w r2,r3\n\t" "jsr @@86\n\t" "mov.w r6,r1\n\t" "mov.w r5,r0\n\t" "pop r6\n\t" "pop r5\n\t" "pop r4\n\t" "rts" ); brickos-0.9.0/lib/mint/umodhi3.c0000644000175000017500000000220307530330675014144 0ustar cbcb/* * umodhi3.c * * Wrapper for ROM umodhi3 routine, a 16-bit unsigned modulo: r0 %= r1 * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ( ".section .text\n\t" ".global ___umodhi3\n" "___umodhi3:\n\t" "push r5\n\t" "push r6\n\t" "mov.w r0,r6\n\t" "mov.w r1,r5\n\t" "jsr @@76\n\t" "mov.w r6,r0\n\t" "pop r6\n\t" "pop r5\n\t" "rts" ); brickos-0.9.0/lib/mint/umodsi3.c0000644000175000017500000000242607530330675014166 0ustar cbcb/* * umodsi3.c * * 32-bit unsigned modulo: r0r1 %= r2r3 * * Calls the ROM version of udivsi3, which leaves the remainder in r3r4. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ __asm__ ( ".section .text\n\t" ".global ___umodsi3\n" "___umodsi3:\n\t" "push r4\n\t" "push r5\n\t" "push r6\n\t" "mov.w r1,r6\n\t" "mov.w r0,r5\n\t" "mov.w r3,r4\n\t" "mov.w r2,r3\n\t" "jsr @@86\n\t" "mov.w r4,r1\n\t" "mov.w r3,r0\n\t" "pop r6\n\t" "pop r5\n\t" "pop r4\n\t" "rts" ); brickos-0.9.0/util/0000755000175000017500000000000010173102444011657 5ustar cbcbbrickos-0.9.0/util/dll-src/0000755000175000017500000000000010173102444013217 5ustar cbcbbrickos-0.9.0/util/dll-src/Makefile0000644000175000017500000000466507630443311014677 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.9 2003/03/02 18:00:41 paolom Exp $ ### FILE: util/dll-src/Makefile - make program download & link support utilities ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # specify environment before including the common stuff BUILDING_HOST_UTILS = true include ../../Makefile.common INSTALL_DIR = .. EXE1 = dll$(EXT) MAN1 = dll.1 TARGET1 = $(INSTALL_DIR)/$(EXE1) SRCS1 = loader.c rcxtty.c keepalive.c $(BRICKOS_ROOT)/kernel/lnp.c lx.c OBJS1 = $(notdir $(SRCS1:.c=.o)) EXE2 = makelx$(EXT) TARGET2 = $(INSTALL_DIR)/$(EXE2) SRCS2 = convert.c srec.c srecload.c lx.c OBJS2 = $(SRCS2:.c=.o) EXE3 = genlds$(EXT) TARGET3 = $(INSTALL_DIR)/$(EXE3) EXE4 = fixdeps$(EXT) TARGET4 = $(INSTALL_DIR)/$(EXE4) SINGLE_SRC_TARGETS = $(TARGET3) $(TARGET4) ALL_TARGETS = $(TARGET1) $(TARGET2) $(SINGLE_SRC_TARGETS) LIBS= # # Martin Cornelius solution to include problems (avoid -I/usr/include) # CFLAGS+=-I. -I$(BRICKOS_ROOT)/include/lnp all:: $(ALL_TARGETS) @# nothing to do here but do it silently clean: rm -f *.o *~ *.bak realclean: clean rm -f $(ALL_TARGETS) @rm -f .depend install-stamp .depend: $(CC) -M $(CFLAGS) -c $(SRCS1) $(SRCS2) >.depend depend:: .depend @# nothing to do here but do it silently install: install-stamp @# nothing to do here but do it silently install-stamp: $(ALL_TARGETS) cp -f $(TARGET1) $(bindir)/$(EXE1) @if [ ! -d ${pkglibdir} ]; then \ mkdir -p ${pkglibdir}; \ fi cp -f $(TARGET2) $(pkglibdir)/$(EXE2) cp -f $(TARGET3) $(pkglibdir)/$(EXE3) cp -f $(TARGET4) $(pkglibdir)/$(EXE4) @if [ ! -d ${mandir}/man1 ]; then \ mkdir -p ${mandir}/man1; \ fi cp -f $(MAN1) $(mandir)/man1/$(MAN1) @touch $@ uninstall: rm -f install-stamp $(mandir)/man1/$(MAN1) $(bindir)/$(EXE1) $(TARGET1): $(OBJS1) $(CC) -o $@ $(OBJS1) $(LIBS) $(CFLAGS) $(TARGET2): $(OBJS2) $(CC) -o $@ $(OBJS2) $(LIBS) $(CFLAGS) %.o: %.c $(CC) -o $@ -c $< $(CFLAGS) %.o: $(BRICKOS_ROOT)/kernel/%.c $(CC) -o $@ -c $< $(CFLAGS) ../%$(EXT): %.c $(CC) -o $@ $< $(CFLAGS) # remove debug symbols strip: strip $(ALL_TARGETS) .PHONY: depend all clean realclean install ### -------------------------------------------------------------------------- ### End of FILE: util/dll-src/Makefile ### ========================================================================== brickos-0.9.0/util/dll-src/config.h0000644000175000017500000000613407543442414014654 0ustar cbcb/*! \file include/config.h \brief kernel configuration file \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __config_h__ #define __config_h__ // compilation environment // //#define CONF_RCX_COMPILER //!< a special RCX compiler is used. #define CONF_HOST // core system services // #define CONF_TIME //!< system time #define CONF_MM //!< memory management #define CONF_TM //!< task management #define CONF_TM_VIS //!< display task statuus #define CONF_TM_DEBUG //!< view key shows current instruction pointer #define CONF_SEMAPHORES //!< POSIX semaphores #define CONF_PROGRAM //!< dynamic program loading support // networking services // #define CONF_LNP //!< link networking protocol //#define CONF_LNP_VIS //!< display LNP activity //#define CONF_LNP_FAST //!< enable 4800 bps LNP #define CONF_LNP_HOSTADDR 0x8 //!< LNP host address #define CONF_LNP_HOSTMASK 0xf0 //!< LNP host mask // drivers // //#define CONF_DKEY //!< debounced key driver //#define CONF_LCD_REFRESH //!< automatic display updates //#define CONF_CONIO //!< console //#define CONF_ASCII //!< ascii console //#define CONF_DSOUND //!< direct sound //#define CONF_DMOTOR //!< direct motor //#define CONF_DSENSOR //!< direct sensor //#define CONF_DSENSOR_ROTATION //!< rotation sensor //#define CONF_DSENSOR_SWMUX //!< techno-stuff swmux sensor // dependencies // #if defined(CONF_ASCII) && !defined(CONF_CONIO) #error "Ascii needs console IO" #endif #if defined(CONF_DKEY) && !defined(CONF_TIME) #error "Key debouncing needs system time." #endif #if defined(CONF_TM) && !defined(CONF_TIME) #error "Task management needs system time." #endif #if defined(CONF_TM) && !defined(CONF_MM) #error "Task management needs memory management." #endif #if defined(CONF_MM) && defined(CONF_TM) && !defined(CONF_SEMAPHORES) #error "Tasksafe memory management needs semaphores." #endif #if defined(CONF_LNP) && defined(CONF_TM) && !defined(CONF_SEMAPHORES) #error "Tasksafe networking needs semaphores." #endif #if defined(CONF_PROGRAM) && (!defined(CONF_TM) || !defined(CONF_LNP)) #error "Programm support needs task management and networking" #endif #if defined(CONF_DSENSOR_ROTATION) && !defined(CONF_DSENSOR) #error "Rotation sensor needs general sensor code." #endif #endif // __config_h__ brickos-0.9.0/util/dll-src/convert.c0000644000175000017500000001373207623077400015062 0ustar cbcb/*! \file covert.c \brief convert two suitable dsrec files into a BrickOS executable \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 2, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): */ #include #include #include #include #include #include #include #include #include #include #include #if (defined(__unix__) || defined(unix)) && !defined(USG) #include #endif #define DEFAULT_STACK_SIZE 1024 //!< default program stack size #define RELOC_MAX 16384 //!< maximum number of relocations #if (defined(__sun__) && defined(__svr4__)) || defined(BSD) // Solaris||BSD #undef HAVE_GETOPT_LONG #else #define HAVE_GETOPT_LONG 1 #endif #ifdef HAVE_GETOPT_LONG #include //! long command-line options static const struct option long_options[]={ {"stack" ,required_argument,0,'s'}, {"verbose",no_argument ,0,'v'}, {"display",no_argument ,0,'d'}, {0 ,0 ,0,0 } }; #else // HAVE_GETOPT_LONG #define getopt_long(ac, av, opt, lopt, lidx) (getopt((ac), (av), (opt))) #endif // HAVE_GETOPT_LONG int verbose_flag=0; //!< display some diagnostics if non-zero //! build BrickOS executable from images /*! the segment sizes and start offset need to be set already. */ void lx_from_images(lx_t *lx,image_t *img,unsigned short stack_size) { const unsigned char diff_hi=(img[1].base - img[0].base) >> 8; const unsigned char diff_lo=(img[1].base - img[0].base) & 0xff; const unsigned short size=img[0].text_size + img[0].data_size; int i; if(verbose_flag) printf("diff_hi=0x%02x diff_lo=0x%02x\n",diff_hi,diff_lo); // trivial checks // if(img[0].text_size != img[1].text_size || img[0].data_size != img[1].data_size || img[0].bss_size != img[1].bss_size ) { fprintf(stderr,"image size mismatch\n"); exit(-1); } if(img[0].offset != img[1].offset) { fprintf(stderr,"starting offset mismatch\n"); exit(-1); } if(!diff_hi || !diff_lo) { fprintf(stderr,"need images whose base offsets differ in high and low byte\n"); exit(-1); } // create BrickOS executable header // lx->version =0; lx->base =img[0].base; lx->text_size =img[0].text_size; lx->data_size =img[0].data_size; lx->bss_size =img[0].bss_size; lx->stack_size=stack_size; lx->offset =img[0].offset; lx->num_relocs=0; if(verbose_flag) printf("base =0x%04x offset =0x%04x\n" "text_size=0x%04x data_size=0x%04x bss_size=0x%04x stack_size=0x%04x\n", lx->base,lx->offset,lx->text_size,lx->data_size,lx->bss_size,lx->stack_size); if((lx->reloc=malloc(RELOC_MAX*sizeof(unsigned short)))==NULL) { fprintf(stderr,"out of memory\n"); exit(-1); } if((lx->text=malloc(size))==NULL) { fprintf(stderr,"out of memory\n"); exit(-1); } memcpy(lx->text,img[0].text,size); // compare images & build relocation table. // for(i=0; inum_relocs,i); lx->reloc[lx->num_relocs++]=(unsigned short)i++; } } } } //! do everything. int main(int argc, char **argv) { image_t img[2]; lx_t lx; int opt; int display_flag = 0; unsigned short stack_size=DEFAULT_STACK_SIZE; #ifdef HAVE_GETOPT_LONG int option_index; #endif // read command-line options // while((opt=getopt_long(argc, argv, "s:vd", (struct option *)long_options, &option_index) )!=-1) { unsigned tmp; switch(opt) { case 's': sscanf(optarg,"%x",&tmp); stack_size=(unsigned short)tmp; break; case 'v': verbose_flag=1; break; case 'd': display_flag=1; break; } } if(argc-optind<3) { fprintf(stderr,"usage: %s file.ds1 file.ds2 file.lx\n" " [-s] [-v] [-d]\n" " size in hex, please.\n", argv[0]); exit(1); } image_load(img , argv[optind++]); image_load(img+1, argv[optind++]); lx_from_images(&lx,img,stack_size); if(lx_write(&lx, argv[optind])) { fprintf(stderr,"error writing %s\n",argv[optind]); return -1; } if (display_flag) { printf("version=%d\n", lx.version); printf("base=0x%x\n", lx.base); printf("text_size=%d\n", lx.text_size); printf("data_size=%d\n", lx.data_size); printf("bss_size=%d\n", lx.bss_size); printf("stack_size=%d\n", lx.stack_size); printf("start_offset=%d\n", lx.offset); printf("num_relocs=%d\n", lx.num_relocs); printf("contiguous free memory required to download=%d\n", lx.text_size + lx.data_size*2 + lx.bss_size); } return 0; } brickos-0.9.0/util/dll-src/dll.10000644000175000017500000001030407531064451014063 0ustar cbcb.\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH dll 1 "May 12, 2002" "brickOS" "brickOS Utility" .\" Please adjust this date whenever revising the manpage. .\" .\" --------------------------------------- .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .\" --------------------------------------- .SH NAME dll \- A user-program downloader for the RCX. .\" .SH SYNOPSIS .B dll .RI [ options ] " command | {file}.lx" .\" .SH DESCRIPTION This manual page documents the .B dll user-program download command. .P \fBdll\fP is a program which is used to download user programs written for brickOS to the RCX. .P .\" .SH OPTIONS This program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). The options supported by \fBdll\fP are: .TP .B (run with no parms) Show built-in help (summary of options) .TP .B \-e, \-\-execute Execute program after download. .TP .B \-i{0|1}, \-\-irmode={0|1} Set IR mode (on RCX) to near(0) or far(1) .TP .B \-p{1-8}, \-\-program={1-8} Download program to program-slot-number {1-8} .br .sp NOTE: LegOS supports 8 program slots where the Mindstorms original firmware only supports 5. .TP .B \-r{hostaddress}, \-\-rcxaddr={hostaddress} Send to RCX LNP at host address {0-15}. Default is 0. See also \--node={hostaddress} .TP .B \-s{srcport}, \-\-srcport={srcport} Send to RCX LNP source port {0-15} .TP .B \-t{ttydevice} \-\-tty={ttydevice} Specify serial tty device where IR tower is connected. .br .sp NOTE: The environment variable RCXTTY may be used in place of \-tty .TP .B \-v, \-\-verbose Enable verbose output .\" .SH COMMANDS .TP .B \-d{1-8}, \-\-delete={1-8} Delete program from program-slot-number {1-8} .TP .B \-n{hostaddress}, \-\-node={hostaddress} Set RCX LNP host address to {0-15} .\" .SH ENVIRONMENT VARIABLES .B dll will respond to the environment variable RCXTTY. This should be set to the serial device to which the IR tower is connected. Use of RCXTTY is equivalent the using the -tty command-line option. .\" .SH EXAMPLES .B dll is a simple command to use. The following examples show most of the uses. .P \fBEx1:\fP download demo/robots.lx to the RCX as program 0. .sp .nf $ dll -tty=/dev/ttyS0 demo/robots.lx $ .fi .br .sp NOTE: there is no response from dll(1) on a successful download. You can, however watch the RCX display during the download and see activity. .P \fBEx2:\fP download the demo/linetrack.lx into program-slot 7. (note we are first setting RCXTTY so we don't have to keep specifying the tty device each download). .sp .nf $ export RCXTTY=/dev/ttyS1 $ dll -p7 demo/linetrack.lx $ .fi .P \fBEx3:\fP download demo/rover.lx but we are leaving the RCX powered off (assume RCXTTY is already set). .sp .nf $ dll -p2 demo/rover.lx error deleting program $ .fi .sp NOTE: \fBdll\fP first deletes the existing program from the specified program slot and then downloads the new one. This error indicates that the first thing \fBdll\fP tried to do did not succeed. .P We'll leave the experiment of running \fBdll\fP with --verbose set as an exercise for you our reader... (This is actually a combination of progress infromation and debug ouput.) .\" .SH ERROR MESSAGES Unfortunately, there is basically only one dll error message, and it applies to most possible errors, including a disconnected IR tower, an RCX that is turned off, an RCX that doesn't have brickOS, and an RCX that has brickOS and is already running a program. So, check all those things when dll fails. .\" .SH SEE ALSO .BR firmdl3(1) .\" .\" .SH AUTHOR \fBdll was written by:\fP Markus L. Noga. .P Addiitonal Contributor(s): everyone discussing LNP at LUGNET .P This manual page was written by Stephen M Moraco , for the Debian GNU/Linux system (but may be used by others). brickos-0.9.0/util/dll-src/fixdeps.c0000644000175000017500000000143307530330675015042 0ustar cbcb#include #include #define MAX_LINE 1024 int main(int argc, char **argv) { char buffer[MAX_LINE]; const char *kernel_prefix; int prefix_len; // get kernel prefix // if(argc<2) { fprintf(stderr,"usage: makedepend | %s kernelprefix > .depend\n",argv[0]); return -1; } kernel_prefix=argv[1]; prefix_len=strlen(kernel_prefix); // process dependencies line by line. // while(fgets(buffer,MAX_LINE-1,stdin)) { const char *file,*deps; buffer[1023]=0; file=strtok(buffer,":"); deps=strtok(NULL ,":"); // leave out kernel prefix // if(file && *file && deps && *deps) { if(!strncmp(file,kernel_prefix,prefix_len)) file+=prefix_len; fprintf(stdout,"%s:%s",file,deps); } } return 0; } brickos-0.9.0/util/dll-src/genlds.c0000644000175000017500000001621607775617272014675 0ustar cbcb/*! \file genlds.c \brief BrickOS linker script generation \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 2, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 2000 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include #include #include #define MAX_SYMBOLS 65536 //!< max symbols, enough for the RCX #define MAX_SYMLEN 256 //!< max symbol length. //! symbol type. typedef struct { unsigned addr; char text[MAX_SYMLEN]; } symbol_t; //! the list of symbols symbol_t symbols[MAX_SYMBOLS]; //! read the kernel symbols from a file static unsigned read_symbols(FILE *f,symbol_t *symbols,unsigned max,unsigned *ram) { char buffer[MAX_SYMLEN]; unsigned i=0; for(; i \n\ * \n\ */\n\ \n\ OUTPUT_FORMAT(\"symbolsrec\")\n\ OUTPUT_ARCH(h8300)\n\ ENTRY(\"_main\")\n\ \n\ MEMORY {\n\ rom : o = 0x0000, l = 0x8000\n\ kern : o = 0x8000, l = 0x%04x\n\ ram : o = 0x%04x, l = 0x%04x\n\ stack : o = 0xfefc, l = 0x0004\n\ eight : o = 0xff00, l = 0x0100\n\ }\n\ \n\ SECTIONS {\n\ \n\ .rom : {\n\ /* used rom functions */\n\ \n\ _rom_reset_vector = 0x0000;\n\ \n\ _reset = 0x03ae ;\n\ lcd_show = 0x1b62 ;\n\ lcd_hide = 0x1e4a ;\n\ lcd_number = 0x1ff2 ;\n\ lcd_clear = 0x27ac ;\n\ power_init = 0x2964 ;\n\ sound_system = 0x299a ;\n\ power_off = 0x2a62 ;\n\ sound_playing = 0x3ccc ;\n\ \n\ _rom_dummy_handler = 0x046a ;\n\ _rom_ocia_handler = 0x04cc ;\n\ _rom_ocia_return = 0x04d4 ;\n\ \n\ } > rom\n\ \n\ .kernel : {\n\ /* kernel symbols (relative to 0x8000) */\n\ ", now,kernel_name,ram, kernlen,ram,ramlen); } //! print the linker script footer. static void print_footer(FILE *f) { fprintf(f, " /* end of kernel symbols */\n\ } > kern\n\ \n\ .text BLOCK(2) : {\n\ ___text = . ;\n\ *(.text) /* must start with text for clean entry */ \n\ *(.rodata)\n\ *(.strings)\n\ *(.vectors) /* vectors region (dummy) */\n\ *(.persist)\n\ \n\ ___text_end = . ;\n\ } > ram\n\ \n\ .tors BLOCK(2) : {\n\ ___ctors = . ;\n\ *(.ctors)\n\ ___ctors_end = . ;\n\ ___dtors = . ;\n\ *(.dtors)\n\ ___dtors_end = . ;\n\ } > ram\n\ \n\ .data BLOCK(2) : {\n\ ___data = . ;\n\ *(.data)\n\ *(.tiny)\n\ ___data_end = . ;\n\ } > ram\n\ \n\ .bss BLOCK(2) : {\n\ ___bss = . ;\n\ *(.bss)\n\ *(COMMON)\n\ ___bss_end = ALIGN(2) ;\n\ } >ram\n\ \n\ .stack : {\n\ _stack = . ; \n\ *(.stack)\n\ } > topram\n\ \n\ .eight 0xff00: {\n\ *(.eight)\n\ \n\ /* on-chip module registers (relative to 0xff00) */\n\ \n\ _T_IER = 0x90 ;\n\ _T_CSR = 0x91 ;\n\ _T_CNT = 0x92 ;\n\ _T_OCRA = 0x94 ;\n\ _T_OCRB = 0x94 ;\n\ _T_CR = 0x96 ;\n\ _T_OCR = 0x97 ;\n\ _T_ICRA = 0x98 ;\n\ _T_ICRB = 0x9a ;\n\ _T_ICRC = 0x9c ;\n\ _T_ICRD = 0x9e ;\n\ _WDT_CSR = 0xa8 ;\n\ _WDT_CNT = 0xa9 ;\n\ _PORT1_PCR = 0xac ;\n\ _PORT2_PCR = 0xad ;\n\ _PORT3_PCR = 0xae ;\n\ _PORT1_DDR = 0xb0 ;\n\ _PORT2_DDR = 0xb1 ;\n\ _PORT1 = 0xb2 ;\n\ _PORT2 = 0xb3 ;\n\ _PORT3_DDR = 0xb4 ;\n\ _PORT4_DDR = 0xb5 ;\n\ _PORT3 = 0xb6 ;\n\ _PORT4 = 0xb7 ;\n\ _PORT5_DDR = 0xb8 ;\n\ _PORT6_DDR = 0xb9 ;\n\ _PORT5 = 0xba ;\n\ _PORT6 = 0xbb ;\n\ _PORT7 = 0xbe ;\n\ _STCR = 0xc3 ;\n\ _SYSCR = 0xc4 ;\n\ _T0_CR = 0xc8 ;\n\ _T0_CSR = 0xc9 ;\n\ _T0_CORA = 0xca ;\n\ _T0_CORB = 0xcb ;\n\ _T0_CNT = 0xcc ;\n\ _T1_CR = 0xd0 ;\n\ _T1_CSR = 0xd1 ;\n\ _T1_CORA = 0xd2 ;\n\ _T1_CORB = 0xd3 ;\n\ _T1_CNT = 0xd4 ;\n\ _S_MR = 0xd8 ;\n\ _S_BRR = 0xd9 ;\n\ _S_CR = 0xda ;\n\ _S_TDR = 0xdb ;\n\ _S_SR = 0xdc ;\n\ _S_RDR = 0xdd ;\n\ _AD_A = 0xe0 ;\n\ _AD_A_H = 0xe0 ;\n\ _AD_A_L = 0xe1 ;\n\ _AD_B = 0xe2 ;\n\ _AD_B_H = 0xe2 ;\n\ _AD_B_L = 0xe3 ;\n\ _AD_C = 0xe4 ;\n\ _AD_C_H = 0xe4 ;\n\ _AD_C_L = 0xe5 ;\n\ _AD_D = 0xe6 ;\n\ _AD_D_H = 0xe6 ;\n\ _AD_D_L = 0xe7 ;\n\ _AD_CSR = 0xe8 ;\n\ _AD_CR = 0xe9 ;\n\ \n\ /* end of on-chip module registers */\n\ \n\ } > eight\n\ \n\ .stab 0 (NOLOAD) : {\n\ [ .stab ]\n\ }\n\ \n\ .stabstr 0 (NOLOAD) : {\n\ [ .stabstr ]\n\ }\n\ \n\ } /* SECTIONS */\n\ " ); } int main(int argc, char *argv[]) { const char *kernel_name; unsigned num_symbols; unsigned ram,kernlen,ramlen; time_t now_time; char *now; // determine kernel name // if(argc<2) { fprintf(stderr,"usage: %s kernelname < kernel.map\n",argv[0]); return -1; } kernel_name=argv[1]; // parse kernel symbols // num_symbols=read_symbols(stdin,symbols,MAX_SYMBOLS,&ram); // calculate kernel and ram size // kernlen=ram - 0x8000; ramlen =0xfefc - ram; // create timestamp // now_time=time(NULL); now =ctime(&now_time); // print linker script // print_header (stdout,now,kernel_name,ram,kernlen,ramlen); print_symbols(stdout,symbols,num_symbols); print_footer (stdout); return 0; } brickos-0.9.0/util/dll-src/keepalive.c0000644000175000017500000000466307530330675015355 0ustar cbcb/*! \file keepalive.h \brief Keepalive functionality for the IR tower \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 2, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): */ #include #include #include #include #include #include #include #include #if defined(_WIN32) #include #endif #include "rcxtty.h" #include "keepalive.h" // keepalive settings // #define KEEPALIVE_TIMEOUT_S 3 #define KEEPALIVE_TIMEOUT_US 700000 #define KEEPALIVE_BYTE 0xff extern int verbose_flag; //! the keepalive byte (same as tower power on) const static char keepaliveByte = KEEPALIVE_BYTE; //! renew keepalive timer because you sent something void keepaliveRenew() { static struct itimerval it = { {KEEPALIVE_TIMEOUT_S, KEEPALIVE_TIMEOUT_US}, {KEEPALIVE_TIMEOUT_S, KEEPALIVE_TIMEOUT_US}}; setitimer(ITIMER_REAL, &it, NULL); } //! send keepalive byte & renew keepalive static void keepaliveSend(FILEDESCR fd) { if (verbose_flag) fputs("\nKeepAliveSend: keeping the IR tower alive...",stderr); if (mywrite(fd, &keepaliveByte, 1) != 1) { myperror("sending keepalive"); exit(-1); } keepaliveRenew(); } //! keepalive signal handler static void keepaliveHandler(int arg) { if (verbose_flag) fputs("\nHandler: keeping the IR tower alive...\n",stderr); keepaliveSend(rcxFD()); } //! initialize keepalive void keepaliveInit(void) { if (verbose_flag) fputs("KeepAlive Init...", stderr); signal(SIGALRM, keepaliveHandler); keepaliveSend(rcxFD()); } //! shutdown keepalive void keepaliveShutdown() { static const struct itimerval it = { {0, 0}, {0, 0}}; setitimer(ITIMER_REAL, &it, 0); signal(SIGALRM, SIG_DFL); } brickos-0.9.0/util/dll-src/keepalive.h0000644000175000017500000000210107530330675015343 0ustar cbcb/*! \file keepalive.h \brief Keepalive functionality for the IR tower \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 2, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): */ #ifndef __keepalive_h__ #define __keepalive_h__ //! initialize keepalive void keepaliveInit(); //! shutdown keepalive void keepaliveShutdown(); //! renew keepalive timer void keepaliveRenew(); #endif brickos-0.9.0/util/dll-src/loader.c0000644000175000017500000003665310147022343014646 0ustar cbcb/*! \file loader.c \brief BrickOS task downloading \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 2, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): everyone discussing LNP at LUGNET */ /* 2000.05.01 * * Modifications to the original loader.c file for LegOS 0.2.2 include: * * Paolo Masetti's patches to eliminate "Invalid Argument" error and * to get rid of several compiler warnings: * * http://www.lugnet.com/robotics/rcx/legos/?n=619 * * Markus L. Noga's solution to Cygwin's failure to define the O_ASYNC symbol: * * http://www.lugnet.com/robotics/rcx/legos/?n=439 * * Paolo Masetti's adaptation for definitive porting to Win32. No more errors in * serial communication and conditional compile for Winnt (cygnwin). * Several addition to dll option to better support user. Execute dll without * arguments to get help. * */ /* 2002.04.01 * * Modifications to the original loader.c file in LegOS 0.2.4 include: * * Hary D. Mahesan's update to support USB IR firmware downloading * using RCX 2.0's USB tower under WIN32 on Cygwin. * * * * CVS inclusion, revision and modification by Paolo Masetti. * * */ #include #include #include #include #include #include #include #include #include #if defined(_WIN32) #include #endif #if (defined(__unix__) || defined(unix)) && !defined(USG) #include #endif #include #include #include "rcxtty.h" #include "keepalive.h" #include #define MAX_DATA_CHUNK 0xf8 //!< maximum data bytes/packet for boot protocol #define XMIT_RETRIES 5 //!< number of packet transmit retries #define REPLY_TIMEOUT 750000 //!< timeout for reply #define BYTE_TIME (1000*LNP_BYTE_TIME) //!< time to transmit a byte. #define PROG_MIN 1 #define PROG_MAX 8 #define ADDR_MIN 0 #define ADDR_MAX 15 #define DEFAULT_DEST 0 #define DEFAULT_PROGRAM PROG_MIN #define DEFAULT_SRCPORT 0 #define DEFAULT_PRIORITY 10 typedef enum { CMDacknowledge, //!< 1: CMDdelete, //!< 1+ 1: b[nr] CMDcreate, //!< 1+12: b[nr] s[textsize] s[datasize] s[bsssize] s[stacksize] s[start] b[prio] CMDoffsets, //!< 1+ 7: b[nr] s[text] s[data] s[bss] CMDdata, //!< 1+>3: b[nr] s[offset] array[data] CMDrun, //!< 1+ 1: b[nr] CMDirmode, //!< 1+ 1: b[0=near/1=far] CMDsethost, //!< 1+ 1: b[hostaddr] CMDlast //!< ? } packet_cmd_t; #if (defined(__sun__) && defined(__svr4__)) || defined(BSD) // Solaris||BSD #undef HAVE_GETOPT_LONG #else #define HAVE_GETOPT_LONG 1 #endif #ifdef HAVE_GETOPT_LONG #include static const struct option long_options[]={ {"rcxaddr",required_argument,0,'r'}, {"program",required_argument,0,'p'}, {"delete", required_argument,0,'d'}, {"srcport",required_argument,0,'s'}, {"tty", required_argument,0,'t'}, {"irmode", required_argument,0,'i'}, {"node" , required_argument,0,'n'}, {"execute",no_argument ,0,'e'}, {"verbose",no_argument ,0,'v'}, {0 ,0 ,0,0 } }; #else // HAVE_GETOPT_LONG #define getopt_long(ac, av, opt, lopt, lidx) (getopt((ac), (av), (opt))) #endif // HAVE_GETOPT_LONG volatile int receivedAck=0; volatile unsigned short relocate_to=0; unsigned int rcxaddr = DEFAULT_DEST, prog = DEFAULT_PROGRAM, srcport = DEFAULT_SRCPORT, hostaddr = DEFAULT_DEST, irmode = -1; int run_flag=0; int verbose_flag=0; int tty_usb=0; int pdelete_flag=0; int hostaddr_flag=0; void io_handler(void); /*! blocking I/R write. *! return number of bytes written, or negative for error. */ int lnp_logical_write(const void *data, size_t length) { // With Win32 we are using Blocking Write by default #if !defined(_WIN32) fd_set fds; // wait for transmission // do { FD_ZERO(&fds); FD_SET(rcxFD(),&fds); } while(select(rcxFD()+1,NULL,&fds,NULL,NULL)<1); #endif // transmit // #if defined(LINUX) || defined(linux) if (tty_usb == 0) #endif keepaliveRenew(); return mywrite(rcxFD(), data, length)!=length; } //! send a LNP layer 0 packet of given length /*! \return 0 on success. */ int lnp_assured_write(const unsigned char *data, unsigned char length, unsigned char dest, unsigned char srcport) { int i; struct timeval timeout,now; unsigned long total,elapsed; for(i=0; i 10000*LNP_BYTE_TIMEOUT) { if(verbose_flag) fprintf(stderr,"\n#time %lu ",diff); lnp_integrity_reset(); } #if defined(_WIN32) // Remember, USB support only in WIN32 environments. if (tty_usb == 0) { ReadFile(rcxFD(), buffer, sizeof(buffer), &len, NULL); } else { struct timeval timeout, timenow; unsigned long total, elapsed; gettimeofday(&timeout,0); total = REPLY_TIMEOUT+(long)sizeof(buffer)*BYTE_TIME; while(len == 0) { ReadFile(rcxFD(), buffer, sizeof(buffer), &len, NULL); gettimeofday(&timenow, 0); // calculate elapsed time as usual elapsed=1000000*(timenow.tv_sec - timeout.tv_sec ) + (timenow.tv_usec - timeout.tv_usec); if(elapsed > total) break; } } #else len=read(rcxFD(),buffer,sizeof(buffer)); #endif for(i=0; itext_size+lx->data_size; if(verbose_flag) fputs("\ndata ",stderr); buffer[0]=CMDdata; buffer[1]=prog-1; for(i=0; iMAX_DATA_CHUNK) chunkSize=MAX_DATA_CHUNK; buffer[2]= i >> 8; buffer[3]= i & 0xff; memcpy(buffer+4,lx->text + i,chunkSize); if(lnp_assured_write(buffer,chunkSize+4,rcxaddr,srcport)) { fputs("error downloading program\n",stderr); exit(-1); } } } int main(int argc, char **argv) { lx_t lx; // the brickOS executable char *filename; int opt; #ifdef HAVE_GETOPT_LONG int option_index; #endif unsigned char buffer[256+3]=""; char *tty=NULL; while((opt=getopt_long(argc, argv, "r:p:d:s:t:i:n:ev", (struct option *)long_options, &option_index) )!=-1) { switch(opt) { case 'e': run_flag=1; break; case 'r': sscanf(optarg,"%d",&rcxaddr); if (rcxaddr > ADDR_MAX || rcxaddr < ADDR_MIN) { fprintf(stderr, "LNP host address not in range 0..15\n"); return -1; } rcxaddr = (rcxaddr << 4) & CONF_LNP_HOSTMASK; break; case 'p': sscanf(optarg,"%d",&prog); break; case 's': sscanf(optarg,"%d",&srcport); if (srcport > ADDR_MAX || srcport < ADDR_MIN) { fprintf(stderr, "LNP port number not in range 0..15\n"); return -1; } break; case 't': sscanf(optarg,"%s",buffer); break; case 'i': sscanf(optarg,"%x",&irmode); break; case 'd': sscanf(optarg,"%d",&prog); pdelete_flag=1; break; case 'n': sscanf(optarg,"%d",&hostaddr); if (hostaddr > ADDR_MAX || hostaddr < ADDR_MIN) { fprintf(stderr, "LNP host address not in range 0..15\n"); return -1; } hostaddr_flag=1; break; case 'v': verbose_flag=1; break; } } if (prog > PROG_MAX || prog < PROG_MIN) { fprintf(stderr, "Program not in range 1..8\n"); return -1; } // load executable // if(((argc-optind < 1) && !(pdelete_flag || hostaddr_flag)) || ((argc-optind > 0 ) && (pdelete_flag || hostaddr_flag))) { char *usage_string = "Options:\n" " -p , --program= set destination program to \n" " -r , --rcxaddr= send to RCX host address \n" " -s , --srcport= send to RCX source port \n" " -t , --tty= set IR Tower com port \n" #if defined(_WIN32) " -t , --tty= set IR Tower USB mode \n" #else " (if \"usb\" is in the port, use USB mode)\n" #endif " -i<0/1> , --irmode=<0/1> set IR mode near(0)/far(1) on RCX\n" " -e , --execute execute program after download\n" " -v , --verbose verbose mode\n" "\nCommands:\n" " -d , --delete= delete program from memory\n" " -n , --node= set LNP host address in brick\n" "\n" "Default COM port or USB support can be set using environment variable RCXTTY.\n" "Eg:\tset RCXTTY=COM2\n" "\tset RCXTTY=USB\n" "\n" ; fprintf(stderr, "usage: %s [options] [command | file.lx]\n", argv[0]); fprintf(stderr, usage_string); return -1; } // Ignore filename if -dn or -na given if (!(pdelete_flag || hostaddr_flag)) { filename=argv[optind++]; if(lx_read(&lx,filename)) { fprintf(stderr,"unable to load brickOS executable from %s.\n",filename); return -1; } } // Moved tty device setting for a new option on command line if (buffer[0]) tty=buffer; if (!tty) tty = getenv(TTY_VARIABLE); if (!tty) tty = DEFAULTTTY; // Check if USB IR tower is selected. #if defined(_WIN32) if (stricmp(tty, "usb")==0) { tty_usb = 1; if(verbose_flag) fputs("\n\n Hary Mahesan - LEGO USB IR Tower Mode\n\n",stderr); tty="\\\\.\\legotower1"; // Set the correct usb tower if you have more than one (unlikely). } #elif defined(LINUX) || defined(linux) /* If the tty string contains "usb", e.g. /dev/usb/lego0, we */ /* assume it is the USB tower. /dev/usb/lego0 is the default name of */ /* the device in the LegoUSB (http://legousb.sourceforge.net) project. */ /* If yours doesn't contain the "usb" string, just link it. */ if (strstr(tty,"usb") !=0) { tty_usb=1; if (verbose_flag) fputs("\nC.P. Chan & Tyler Akins - USB IR Tower Mode for Linux.\n",stderr); } #endif LNPinit(tty); if (verbose_flag) fputs("\nLNP Initialized...\n",stderr); lnp_addressing_set_handler(0,ahandler); if(verbose_flag) fprintf(stderr,"loader hostaddr=0x%02x hostmask=0x%02x portmask=0x%02x\n", rcxaddr & 0x00ff, LNP_HOSTMASK & 0x00ff, srcport & 0x00ff); // Set IR mode if (irmode != -1) { buffer[0]=CMDirmode; buffer[1]=irmode; if(lnp_assured_write(buffer,2,rcxaddr,srcport)) { fputs("error setting IR mode to far\n",stderr); return -1; } } // Set LNP host address if (hostaddr_flag) { if(verbose_flag) fputs("\nset LNP host address", stderr); buffer[0] = CMDsethost; buffer[1] = hostaddr; if(lnp_assured_write(buffer,2,rcxaddr,srcport)) { fputs("error setting host address\n",stderr); return -1; } fprintf(stderr, "LNP host address set to %d\n", hostaddr); return 0; } if(verbose_flag) fputs("\ndelete",stderr); buffer[0]=CMDdelete; buffer[1]=prog-1; // prog 0 if(lnp_assured_write(buffer,2,rcxaddr,srcport)) { fputs("error deleting program\n",stderr); return -1; } // All done if -dn given if (pdelete_flag) { fprintf(stderr, "P%d deleted\n", prog); return 0; } if(verbose_flag) fputs("\ncreate ",stderr); buffer[ 0]=CMDcreate; buffer[ 1]=prog-1; // prog 0 buffer[ 2]=lx.text_size>>8; buffer[ 3]=lx.text_size & 0xff; buffer[ 4]=lx.data_size>>8; buffer[ 5]=lx.data_size & 0xff; buffer[ 6]=lx.bss_size>>8; buffer[ 7]=lx.bss_size & 0xff; buffer[ 8]=lx.stack_size>>8; buffer[ 9]=lx.stack_size & 0xff; buffer[10]=lx.offset >> 8; // start offset from text segment buffer[11]=lx.offset & 0xff; buffer[12]=DEFAULT_PRIORITY; if(lnp_assured_write(buffer,13,rcxaddr,srcport)) { fputs("error creating program\n",stderr); return -1; } // relocation target address in relocate_to // lx_relocate(&lx,relocate_to); lnp_download(&lx); fprintf(stderr, "\n"); if (run_flag) { if(verbose_flag) fputs("\nrun ",stderr); buffer[0]=CMDrun; buffer[1]=prog-1; // prog 0 if(lnp_assured_write(buffer,2,rcxaddr,srcport)) { fputs("error running program\n",stderr); return -1; } } return 0; } brickos-0.9.0/util/dll-src/lx.c0000644000175000017500000000661507533315222014024 0ustar cbcb/*! \file lx.c \brief BrickOS executable file support \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 2, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): everyone discussing LNP at LUGNET */ #include #include #include #include #include #include #include #include #include #define ASSURED_WRITE(fd,buf,len) \ if((rc=write(fd,buf,len))!=(len)) { \ close(fd); \ return rc; \ } #define ASSURED_READ(fd,buf,len) \ if((rc=read(fd,buf,len))!=(len)) { \ close(fd); \ return rc; \ } int lx_write(const lx_t *lx,const unsigned char *filename) { #if defined(_WIN32) int i,rc,fd=open(filename,O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,S_IRUSR | S_IWUSR | S_IRGRP); #else int i,rc,fd=creat(filename,S_IRUSR | S_IWUSR | S_IRGRP); #endif unsigned short tmp; if(fd<0) return fd; // write ID // ASSURED_WRITE(fd,"brickOS",8); // write header data in MSB // for(i=0; itext,lx->text_size + lx->data_size); // write relocation data in MSB // for(i=0; inum_relocs; i++) { tmp=htons( lx->reloc[i] ); ASSURED_WRITE(fd,&tmp,2); } close(fd); return 0; } int lx_read(lx_t *lx,const unsigned char *filename) { #if defined(_WIN32) int i,rc,fd=open(filename,O_RDONLY | O_BINARY); #else int i,rc,fd=open(filename,O_RDONLY); #endif unsigned char buffer[8]; unsigned short tmp; if(fd<0) return fd; // check ID // ASSURED_READ(fd,buffer,8); if(strcmp(buffer,"brickOS")) { close(fd); return -1; } // read header data in MSB // for(i=0; itext=malloc(lx->text_size + lx->data_size))==0) { close(fd); return -1; } ASSURED_READ(fd,lx->text,lx->text_size + lx->data_size); // read relocation data in MSB // if(lx->num_relocs) { if((lx->reloc=malloc(sizeof(unsigned short)*lx->num_relocs))==0) { close(fd); return -1; } for(i=0; inum_relocs; i++) { ASSURED_READ(fd,&tmp,2); lx->reloc[i]=ntohs(tmp); } } return 0; } void lx_relocate(lx_t *lx,unsigned short base) { unsigned short diff=base-lx->base; int i; for(i=0; inum_relocs; i++) { unsigned char *ptr=lx->text+lx->reloc[i]; unsigned short off =(ptr[0]<<8) | ptr[1]; off+=diff; ptr[0]=off >> 8; ptr[1]=off & 0xff; } lx->base=base; } brickos-0.9.0/util/dll-src/lx.h0000644000175000017500000000402407533315222014021 0ustar cbcb/*! \file lx.h \brief BrickOS executable file support \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 2, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): everyone discussing LNP at LUGNET */ #ifndef __lx_h__ #define __lx_h__ #define HEADER_FIELDS 8 //!< number of header fields stored on disk typedef struct { unsigned short version; //!< version number unsigned short base; //!< current text segment base address unsigned short text_size; //!< size of read-only segment unsigned short data_size; //!< size of initialized data segment unsigned short bss_size; //!< size of uninitialized data segment unsigned short stack_size; //!< stack size unsigned short offset; //!< start offset from text unsigned short num_relocs; //!< number of relocations. unsigned char *text; //!< program text (not stored on disk) unsigned short *reloc; //!< relocations (not stored on disk) } lx_t; //!< the BrickOS executable type //! write a BrickOS exectutable to a file int lx_write(const lx_t *lx,const unsigned char *filename); //! read a BrickOS executable from a file int lx_read(lx_t *lx,const unsigned char *filename); //! relocate a BrickOS executable to a new base address (may be called repeatedly). void lx_relocate(lx_t *lx,unsigned short base); #endif // __lx_h__ brickos-0.9.0/util/dll-src/rcxtty.c0000644000175000017500000001377010147022343014730 0ustar cbcb/*! \file rcxtty.c \brief Basic RCX communication \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 2, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ /* 2002.04.01 * * Modifications to the original loader.c file in LegOS 0.2.4 include: * * Hary D. Mahesan's update to support USB IR firmware downloading * using RCX 2.0's USB tower under WIN32 on Cygwin. * * * * CVS inclusion, revision and modification by Paolo Masetti. * * */ #include #include #include #include #if defined(_WIN32) #include #else #include #include #include #endif #include "rcxtty.h" extern int tty_usb; //! the one and only RCX file descriptor static FILEDESCR rcxFd = BADFILE; //! get RCX file descriptor FILEDESCR rcxFD(void) { return rcxFd; } void myperror(char *str) { #if defined(_WIN32) fprintf(stderr, "Error %lu: %s\n", (unsigned long) GetLastError(), str); #else perror(str); #endif } int mywrite(FILEDESCR fd, const void *buf, size_t len) { #if defined(_WIN32) DWORD nBytesWritten=0; if (WriteFile(fd, buf, len, &nBytesWritten, NULL)) return nBytesWritten; else return -1; #else /* For usb tower, the driver, legousbtower, uses interrupt */ /* urb which can only carry up to 8 bytes at a time. To */ /* transmit more we have to check and send the rest. It is */ /* a good thing to check, so I'll make it general. */ int actual = 0; int rc; char * cptr; int retry = 1000; if (len < 1) return len; cptr = (char *) buf; while (actual < len) { rc = (long) write(fd, cptr+actual, len-actual); if (rc == -1) { if ((errno == EINTR) || (errno == EAGAIN)) { rc = 0; usleep(10); retry --; } else return -1; } actual += rc; if (retry < 1) return actual; } return len; #endif } //! initialize RCX communications port int rcxInit(const char *tty, int highspeed) { /* * Copyright (C) 1998, 1999, Kekoa Proudfoot. All Rights Reserved. * * License to copy, use, and modify this software is granted provided that * this notice is retained in any copies of any part of this software. * * The author makes no guarantee that this software will compile or * function correctly. Also, if you use this software, you do so at your * own risk. * * Kekoa Proudfoot * kekoa@graphics.stanford.edu * 10/3/98 */ // char *tty; FILEDESCR fd; #if defined(_WIN32) DCB dcb; COMMTIMEOUTS CommTimeouts; #else struct termios ios; #endif if (*tty == '-' && !*(tty + 1)) // read from standard input if tty="-" fd = 0; #if defined(_WIN32) else if ((fd = CreateFile(tty, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) { fprintf(stderr, "Error %lu: Opening %s\n", (unsigned long) GetLastError(), tty); #else else if ((fd = open(tty, O_RDWR | O_EXCL)) < 0) { fprintf(stderr,"Error opening tty=%s, ",tty); perror("open"); #endif return -1; } #if !defined(_WIN32) if (tty_usb == 0 && !isatty(fd)) { close(fd); fprintf(stderr, "%s: not a tty\n", tty); return -1; } #endif #if defined(_WIN32) // These settings below definitely do not apply to the USB IR Tower, so if() them out. if(tty_usb==0) { // Serial settings FillMemory(&dcb, sizeof(dcb), 0); if (!GetCommState(fd, &dcb)) { // get current DCB // Error in GetCommState myperror("GetCommState"); return -1; } else { dcb.ByteSize = 8; dcb.Parity = (highspeed ? 0 : 1); // 0-4=no,odd,even,mark,space dcb.StopBits = 0; // 0,1,2 = 1, 1.5, 2 dcb.fBinary = TRUE ; dcb.fParity = FALSE ; dcb.fAbortOnError = FALSE ; dcb.BaudRate = (highspeed ? CBR_4800 : CBR_2400); // Update DCB rate. // Set new state. if (!SetCommState(fd, &dcb)) { // Error in SetCommState. Possibly a problem with the communications // port handle or a problem with the DCB structure itself. myperror("SetCommState"); return -1; } if (!GetCommTimeouts (fd, &CommTimeouts)) myperror("GetCommTimeouts"); // Change the COMMTIMEOUTS structure settings. CommTimeouts.ReadIntervalTimeout = MAXDWORD; CommTimeouts.ReadTotalTimeoutMultiplier = 0; CommTimeouts.ReadTotalTimeoutConstant = 0; CommTimeouts.WriteTotalTimeoutMultiplier = 10; CommTimeouts.WriteTotalTimeoutConstant = 1000; // Set the time-out parameters for all read and write operations // on the port. if (!SetCommTimeouts(fd, &CommTimeouts)) myperror("SetCommTimeouts"); } } rcxFd=fd; #else if (tty_usb == 0) { memset(&ios, 0, sizeof(ios)); ios.c_cflag = CREAD | CLOCAL | CS8 | (highspeed ? 0 : PARENB | PARODD); cfsetispeed(&ios, highspeed ? B4800 : B2400); cfsetospeed(&ios, highspeed ? B4800 : B2400); if (tcsetattr(fd, TCSANOW, &ios) == -1) { perror("tcsetattr"); exit(1); } } rcxFd=fd; #endif return 0; } //! shutdown RCX communications port void rcxShutdown() { #if defined(_WIN32) CloseHandle(rcxFd); #else close(rcxFd); #endif rcxFd=BADFILE; } brickos-0.9.0/util/dll-src/rcxtty.h0000644000175000017500000000344507530330675014747 0ustar cbcb/*! \file rcxtty.h \brief Basic RCX communication \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 2, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Paolo Masetti * */ #ifndef __rcxtty_h__ #define __rcxtty_h__ #if defined(_WIN32) #define FILEDESCR HANDLE #define BADFILE NULL #else #define FILEDESCR int #define BADFILE -1 #endif // port settings // #define TTY_VARIABLE "RCXTTY" //!< environment variable to override defaults #if defined(linux) || defined(LINUX) #define DEFAULTTTY "/dev/ttyS0" //!< Linux - COM1 #elif defined(_WIN32) #define DEFAULTTTY "com1" //!< Cygwin - COM1 #elif defined(sparc) #define DEFAULTTTY "/dev/ttyb" //!< Sun - serial port B #else #define DEFAULTTTY "/dev/ttyd2" //!< IRIX - second serial port #endif //! initialize RCX communications port int rcxInit(const char *tty, int highspeed); //! shutdown RCX communications port void rcxShutdown(); //! get RCX file descriptor FILEDESCR rcxFD(void); //! perror() wrapper void myperror(char *str); //! write() wrapper int mywrite(FILEDESCR fd, const void *buf, size_t len); #endif brickos-0.9.0/util/dll-src/srec.c0000644000175000017500000000702407530330675014336 0ustar cbcb/* * Copyright (C) 1998, 1999, Kekoa Proudfoot. All Rights Reserved. * * License to copy, use, and modify this software is granted provided that * this notice is retained in any copies of any part of this software. * * The author makes no guarantee that this software will compile or * function correctly. Also, if you use this software, you do so at your * own risk. * * Kekoa Proudfoot * kekoa@graphics.stanford.edu * 10/3/98 */ /* S-record routines */ /* srec.c */ #include #include "srec.h" static signed char ctab[256] = { -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, 0,10,11,12,13,14,15,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, 0,10,11,12,13,14,15,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, }; static int ltab[10] = {4,4,6,8,0,4,0,8,6,4}; #define C1(l,p) (ctab[l[p]]) #define C2(l,p) ((C1(l,p)<<4)|C1(l,p+1)) int srec_decode(srec_t *srec, char *_line) { int len, pos = 0, count, alen, sum = 0; unsigned char *line = (unsigned char *)_line; if (!srec || !line) return S_NULL; for (len = 0; line[len]; len++) if (line[len] == '\n' || line[len] == '\r') break; if (len < 4) return S_INVALID_HDR; if (line[0] != 'S') return S_INVALID_HDR; for (pos = 1; pos < len; pos++) { if (C1(line, pos) < 0) return S_INVALID_CHAR; } srec->type = C1(line, 1); count = C2(line, 2); if (srec->type > 9) return S_INVALID_TYPE; alen = ltab[srec->type]; if (alen == 0) return S_INVALID_TYPE; if (len < alen + 6 || len < count * 2 + 4) return S_TOO_SHORT; if (count > 37 || len > count * 2 + 4) return S_TOO_LONG; sum += count; len -= 4; line += 4; srec->addr = 0; for (pos = 0; pos < alen; pos += 2) { unsigned char value = C2(line, pos); srec->addr = (srec->addr << 8) | value; sum += value; } len -= alen; line += alen; for (pos = 0; pos < len - 2; pos += 2) { unsigned char value = C2(line, pos); srec->data[pos / 2] = value; sum += value; } srec->count = count - (alen / 2) - 1; sum += C2(line, pos); if ((sum & 0xff) != 0xff) return S_INVALID_CKSUM; return S_OK; } int srec_encode(srec_t *srec, char *line) { int alen, count, sum = 0, pos; if (srec->type > 9) return S_INVALID_TYPE; alen = ltab[srec->type]; if (alen == 0) return S_INVALID_TYPE; line += sprintf(line, "S%d", srec->type); if (srec->count > 32) return S_TOO_LONG; count = srec->count + (alen / 2) + 1; line += sprintf(line, "%02X", count); sum += count; while (alen) { int value; alen -= 2; value = (srec->addr >> (alen * 4)) & 0xff; line += sprintf(line, "%02X", value); sum += value; } for (pos = 0; pos < srec->count; pos++) { line += sprintf(line, "%02X", srec->data[pos]); sum += srec->data[pos]; } sprintf(line, "%02X\n", (~sum) & 0xff); return S_OK; } brickos-0.9.0/util/dll-src/srec.h0000644000175000017500000000167607530330675014352 0ustar cbcb/* * Copyright (C) 1998, 1999, Kekoa Proudfoot. All Rights Reserved. * * License to copy, use, and modify this software is granted provided that * this notice is retained in any copies of any part of this software. * * The author makes no guarantee that this software will compile or * function correctly. Also, if you use this software, you do so at your * own risk. * * Kekoa Proudfoot * kekoa@graphics.stanford.edu * 10/3/98 */ /* S-record routines */ /* srec.h */ typedef struct { unsigned char type; unsigned long addr; unsigned char count; unsigned char data[32]; } srec_t; #define S_OK 0 #define S_NULL -1 #define S_INVALID_HDR -2 #define S_INVALID_CHAR -3 #define S_INVALID_TYPE -4 #define S_TOO_SHORT -5 #define S_TOO_LONG -6 #define S_INVALID_CKSUM -7 extern int srec_decode(srec_t *srec, char *line); extern int srec_encode(srec_t *srec, char *line); brickos-0.9.0/util/dll-src/srecload.c0000644000175000017500000001374107530330675015201 0ustar cbcb/*! \file srecload.c \brief load symbol-srec files \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 2, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ /* * Copyright (C) 1998, 1999, Kekoa Proudfoot. All Rights Reserved. * * License to copy, use, and modify this software is granted provided that * this notice is retained in any copies of any part of this software. * * The author makes no guarantee that this software will compile or * function correctly. Also, if you use this software, you do so at your * own risk. * * Kekoa Proudfoot * kekoa@graphics.stanford.edu * 10/3/98 */ #include #include #include #include #include "srec.h" #include "srecload.h" #define IMG_LOWEST 0x0000 #define IMG_HIGHEST 0xffff #define IMG_MAXSIZE 0x10000 //! load symbols from symbolsrec file /*! \return current line in file the symbol section is enclosed in $$ symbol line format is SYMBOL $ADDR */ static int symbols_load(image_t *img,FILE *file) { char buf[256]; int doubledollar=0; unsigned short text=0, text_end=0, data=0, data_end=0, bss=0, bss_end=0, ctors=0, ctors_end=0, dtors=0, dtors_end=0, _main=0; int line=0; // read in symbols // while(doubledollar<2 && fgets(buf, 80, file)) { int i; line++; // skip empty lines // for(i=0; buf[i] && isspace(buf[i]); i++) ; if (!buf[i]) continue; if(buf[i]=='$' && buf[i+1]=='$') { // delimiter? // doubledollar++; } else { // symbol / address pair // char *symbol; unsigned short address; if(doubledollar<1) { fprintf(stderr,"malformed symbolsrec file at line %d\n",line); exit(-1); } // read symbol // symbol=buf+i; while(buf[i] && buf[i]!=' ') i++; if(buf[i]!=' ' || buf[i+1]!='$') { fprintf(stderr,"malformed symbolsrec file at line %d\n",line); exit(-1); } buf[i]=0; address=(unsigned short) strtoul(buf+i+2,NULL,16); // retain relevant offsets // if(!strcmp(symbol,"___text")) text=address; else if(!strcmp(symbol,"___text_end")) text_end=address; else if(!strcmp(symbol,"___data")) data=address; else if(!strcmp(symbol,"___data_end")) data_end=address; else if(!strcmp(symbol,"___bss")) bss=address; else if(!strcmp(symbol,"___bss_end")) bss_end=address; else if(!strcmp(symbol,"___ctors")) ctors=address; else if(!strcmp(symbol,"___ctors_end")) ctors_end=address; else if(!strcmp(symbol,"___dtors")) dtors=address; else if(!strcmp(symbol,"___dtors_end")) dtors_end=address; else if(!strcmp(symbol,"_main")) _main=address; } } // save general file information // img->base =text; // added ctor/dtor sections for C++. They reside between text and data // so they've been added to text for simplicity. -stephen 14Jan01 img->text_size=(text_end - text) + (ctors_end - ctors) + (dtors_end - dtors); img->data_size=data_end - data; img->bss_size = bss_end - bss; img->offset =_main-text; return line; } void image_load(image_t *img,const char *filename) { FILE *file; char buf[256]; srec_t srec; int line; unsigned short size,start=0; if ((file = fopen(filename, "r")) == NULL) { fprintf(stderr, "%s: failed to open\n", filename); exit(1); } // read symbols from file // line=symbols_load(img,file); size=img->text_size+img->data_size; if((img->text=calloc(size,1))== NULL) { fprintf(stderr, "out of memory\n"); exit(1); } // Build an image of the srecord data // while (fgets(buf, 80, file)) { int i,error; line++; // skip empty lines // for(i=0; buf[i] && isspace(buf[i]); i++) ; if (!buf[i]) continue; // decode line // if ((error = srec_decode(&srec, buf)) < 0) { char *errstr = NULL; switch (error) { case S_NULL: errstr = "null string error"; break; case S_INVALID_HDR: errstr = "invalid header"; break; case S_INVALID_CHAR: errstr = "invalid character"; break; case S_INVALID_TYPE: errstr = "invalid type"; break; case S_TOO_SHORT: errstr = "line to short"; break; case S_TOO_LONG: errstr = "line too line"; break; case S_INVALID_CKSUM: /* ignored */ break; default: errstr = "unknown error"; break; } if (errstr) { fprintf(stderr, "%s: %s on line %d\n", filename, errstr, line); exit(1); } } // handle lines // if (srec.type == 1) { if (srec.addr < img->base || srec.addr + srec.count > img->base + size) { fprintf(stderr, "%s: address [0x%4.4lX, 0x%4.4lX] out of bounds [0x%4.4X-0x%4.4X] on line %d\n",filename, srec.addr, (srec.addr + srec.count), img->base, (img->base + size), line); exit(1); } memcpy(img->text + srec.addr - img->base, srec.data, srec.count); } else if (srec.type == 9) { start = srec.addr; } } // trivial verification // if(start != img->base + img->offset) { fprintf(stderr, "%s: main isn't entry point\n",filename); exit(1); } } brickos-0.9.0/util/dll-src/srecload.h0000644000175000017500000000112107530330675015173 0ustar cbcb#ifndef __srecload_h__ #define __srecload_h__ //! wrapper for an s-record image typedef struct { unsigned short base; //!< base address unsigned short text_size; //!< length from base address unsigned short data_size; unsigned short bss_size; unsigned short offset; //!< start offset from base address unsigned char *text; //!< text at base address } image_t; //! load an RCX s-record file and return its image /*! \param filename file to load \param img image to store to */ void image_load(image_t *img,const char *filename); #endif brickos-0.9.0/util/Makefile0000644000175000017500000000303007630443311013320 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.8 2003/03/02 18:00:41 paolom Exp $ ### FILE: util/Makefile - make the hosted utilities ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # specify environment before including the common stuff BUILDING_HOST_UTILS = true include ../Makefile.common # Define here the executable files to be build EXECUTABLES = fontdesign UTILITY_SCRIPT = merge-map # Needed for DOS/WIN32 platforms ifdef EXT TARGETS = $(addsuffix $(EXT),$(EXECUTABLES)) else TARGETS = $(EXECUTABLES) endif SUBDIRS = dll-src firmdl all:: $(TARGETS) @# nothing to do here but do it silently all clean depend install realclean strip uninstall:: @for i in $(SUBDIRS) ; do $(MAKE) $(MFLAGS) NODEPS=yes -C $$i $@ || exit 2 ; done # remove debug symbols strip:: strip $(TARGETS) # build our one local program fontdesign$(EXT): fontdesign.c $(CC) -o $@ $< $(CFLAGS) install:: install-stamp install-stamp: $(TARGETS) $(UTILITY_SCRIPT) @if [ ! -d ${pkglibdir} ]; then \ mkdir -p ${pkglibdir}; \ fi cp -f $(TARGETS) ${pkglibdir} cp -f $(UTILITY_SCRIPT) ${pkglibdir} @touch $@ tag:: @# nothing to do here but do it silently realclean:: clean rm -f $(TARGETS) @rm -f install-stamp ### -------------------------------------------------------------------------- ### End of FILE: util/Makefile ### ========================================================================== brickos-0.9.0/util/fontdesign.c0000644000175000017500000000341407530330675014201 0ustar cbcb/*! \file fontdesign.c \brief Rather spartan font design tool for a rather spartan display \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #include void show_it(unsigned value) { printf("\n0x%-2x: %c\n",value,(value&4?'_':'.')); printf(" %c%c%c\n",(value&8?'|':'.'), (value&1?'_':'.'), (value&2?'|':'.')); printf(" %c%c%c\n",(value&16?'|':'.'), (value&32?'_':'.'), (value&64?'|':'.')); } int main() { int value=0; int norefresh=0; while(1) { norefresh=0; switch(getchar()) { case '2': case '3': value^=4; break; case 'q': value^=8; break; case 'e': value^=2; break; case 'w': case 's': value^=1; break; case 'a': value^=16; break; case 'y': case 'x': case 'c': value^=32; break; case 'd': value^=64; break; case ' ': if(value) value=0; else value=0x7f; break; case 27: return 0; default: norefresh=1; } if(!norefresh) show_it(value); } } brickos-0.9.0/util/merge-map0000755000175000017500000000374607530330675013505 0ustar cbcb#!/usr/bin/perl ## ## legOS - the independent LEGO Mindstorms OS ## util/merge-map - merge a map file with disassembly ## (c) 1998 by Markus L. Noga ## # read symbols $mapname=shift; open MAP,"<$mapname" || die "Cannot open map file.\n"; while($line=) { chop $line; $line=~/0000([0-9a-fA-F]+) (.) (.+)/; $addr=$1; $type=$2; $symb=$3; # only overwrite with symbols, not .text etc. if( (!$symbols{$addr}) || !($symb=~/^\./) ) { $symbols{$addr}=$symb; # deal with 8 bit references, too. if($addr=~/[fF][fF]([0-9a-fA-F]+)/) { $symbols{$1}=$symb; } } } close MAP; # read and comment disassembly $disname=shift; open DIS,"<$disname" || die "Cannot open disassembly.\n"; $maxoffset=15; while($line=) { # annotate symbol references if($line=~/0x([0-9a-fA-F]{2,})((:0|:8|:16)?)/) { $addr=$1; if($2 eq ":8") { #handle 8-bit symbols (offsets possible) $symb=$symbols{$addr}; if($symb) { $line=~s/0x$addr:8/$symb/g; } } else { #handle 16-bit symbols (offsets possible) $offset=hex $addr; for($i=0; $i<$maxoffset; $i++) { $check=sprintf "%04x",$offset-$i; $symb=$symbols{$check}; if($symb) { if(!$i) { $line=~s/0x$addr((:0|:16)?)/$symb/g; } else { $line=~s/0x$addr((:0|:16)?)/$symb+$i/g; } $i=$maxoffset; } } } } elsif($line=~/\(([0-9a-fA-F]{2,})\)/) { if($symbols{$1}) { $line=~s/\(([0-9a-fA-F]{2,})\)/($symbols{$1})/g; } } # transform all register names to rN, r7 to sp if($line=~/[^a-zA-Z0-9_ ]([er]|er)[0-9][^a-zA-Z0-9_ ]/) { $line=~s/([^a-zA-Z0-9_ ])([er]|er)([0-9])([^a-zA-Z0-9_ ])/$1r$3$4/g; } if($line=~/[^a-zA-Z0-9_]r7[^a-zA-Z0-9_]/) { $line=~s/([^a-zA-Z0-9_])r7([^a-zA-Z0-9_])/$1sp$2/g; } # reintroduce push/pop if($line=~/(.*)mov\.w\s*(.*),\@\-sp(.*)/) { $line="$1push\t$2$3\n"; } elsif($line=~/(.*)mov\.w\s*\@sp\+,(.*)/) { $line="$1pop\t$2\n"; } print $line; } close DIS; brickos-0.9.0/util/firmdl/0000755000175000017500000000000010173102444013134 5ustar cbcbbrickos-0.9.0/util/firmdl/LICENSE0000644000175000017500000004642107530330675014164 0ustar cbcb MOZILLA PUBLIC LICENSE Version 1.0 ---------------- 1. Definitions. 1.1. ``Contributor'' means each entity that creates or contributes to the creation of Modifications. 1.2. ``Contributor Version'' means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. 1.3. ``Covered Code'' means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. 1.4. ``Electronic Distribution Mechanism'' means a mechanism generally accepted in the software development community for the electronic transfer of data. 1.5. ``Executable'' means Covered Code in any form other than Source Code. 1.6. ``Initial Developer'' means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. 1.7. ``Larger Work'' means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. 1.8. ``License'' means this document. 1.9. ``Modifications'' means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is: A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. B. Any new file that contains any part of the Original Code or previous Modifications. 1.10. ``Original Code'' means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. 1.11. ``Source Code'' means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or a list of source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. 1.12. ``You'' means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, ``You'' includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, ``control'' means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of fifty percent (50%) or more of the outstanding shares or beneficial ownership of such entity. 2. Source Code License. 2.1. The Initial Developer Grant. The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: (a) to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, or as part of a Larger Work; and (b) under patents now or hereafter owned or controlled by Initial Developer, to make, have made, use and sell (``Utilize'') the Original Code (or portions thereof), but solely to the extent that any such patent is reasonably necessary to enable You to Utilize the Original Code (or portions thereof) and not to any greater extent that may be necessary to Utilize further Modifications or combinations. 2.2. Contributor Grant. Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: (a) to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code or as part of a Larger Work; and (b) under patents now or hereafter owned or controlled by Contributor, to Utilize the Contributor Version (or portions thereof), but solely to the extent that any such patent is reasonably necessary to enable You to Utilize the Contributor Version (or portions thereof), and not to any greater extent that may be necessary to Utilize further Modifications or combinations. 3. Distribution Obligations. 3.1. Application of License. The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. 3.2. Availability of Source Code. Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. 3.3. Description of Modifications. You must cause all Covered Code to which you contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. 3.4. Intellectual Property Matters (a) Third Party Claims. If You have knowledge that a party claims an intellectual property right in particular functionality or code (or its utilization under this License), you must include a text file with the source code distribution titled ``LEGAL'' which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If you obtain such knowledge after You make Your Modification available as described in Section 3.2, You shall promptly modify the LEGAL file in all copies You make available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. (b) Contributor APIs. If Your Modification is an application programming interface and You own or control patents which are reasonably necessary to implement that API, you must also include this information in the LEGAL file. 3.5. Required Notices. You must duplicate the notice in Exhibit A in each file of the Source Code, and this License in any documentation for the Source Code, where You describe recipients' rights relating to Covered Code. If You created one or more Modification(s), You may add your name as a Contributor to the notice described in Exhibit A. If it is not possible to put such notice in a particular Source Code file due to its structure, then you must include such notice in a location (such as a relevant directory file) where a user would be likely to look for such a notice. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. 3.6. Distribution of Executable Versions. You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. 3.7. Larger Works. You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. 4. Inability to Comply Due to Statute or Regulation. If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Application of this License. This License applies to code to which the Initial Developer has attached the notice in Exhibit A, and to related Covered Code. 6. Versions of the License. 6.1. New Versions. Netscape Communications Corporation (``Netscape'') may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. 6.2. Effect of New Versions. Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Netscape. No one other than Netscape has the right to modify the terms applicable to Covered Code created under this License. 6.3. Derivative Works. If you create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), you must (a) rename Your license so that the phrases ``Mozilla'', ``MOZILLAPL'', ``MOZPL'', ``Netscape'', ``NPL'' or any confusingly similar phrase do not appear anywhere in your license and (b) otherwise make it clear that your version of the license contains terms which differ from the Mozilla Public License and Netscape Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) 7. DISCLAIMER OF WARRANTY. COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN ``AS IS'' BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 8. TERMINATION. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. 9. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. 10. U.S. GOVERNMENT END USERS. The Covered Code is a ``commercial item,'' as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of ``commercial computer software'' and ``commercial computer software documentation,'' as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. 11. MISCELLANEOUS. This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in, the United States of America: (a) unless otherwise agreed in writing, all disputes relating to this License (excepting any dispute relating to intellectual property rights) shall be subject to final and binding arbitration, with the losing party paying all costs of arbitration; (b) any arbitration relating to this Agreement shall be held in Santa Clara County, California, under the auspices of JAMS/EndDispute; and (c) any litigation relating to this Agreement shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. 12. RESPONSIBILITY FOR CLAIMS. Except in cases where another Contributor has failed to comply with Section 3.4, You are responsible for damages arising, directly or indirectly, out of Your utilization of rights under this License, based on the number of copies of Covered Code you made available, the revenues you received from utilizing such rights, and other relevant factors. You agree to work with affected parties to distribute responsibility on an equitable basis. EXHIBIT A. ``The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is Librcx code, released February 9, 1999. The Initial Developer of the Original Code is Kekoa Proudfoot. Portions created by Kekoa Proudfoot are Copyright (C) 1999 Kekoa Proudfoot. All Rights Reserved. Contributor(s): ______________________________________.'' brickos-0.9.0/util/firmdl/Makefile0000644000175000017500000000307607630443312014610 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.9 2003/03/02 18:00:42 paolom Exp $ ### FILE: util/firmdl/Makefile - make firmware download utility ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- # specify environment before including the common stuff BUILDING_HOST_UTILS = true include ../../Makefile.common FIRMDL3 = firmdl3$(EXT) MKIMG = mkimg$(EXT) MAN1 = firmdl3.1 ALL_TARGETS = ../$(FIRMDL3) $(MKIMG) all:: fastdl.h $(ALL_TARGETS) @# nothing to do here but do it silently $(MKIMG): mkimg.o srec.o $(CC) $^ -o $@ $(CFLAGS) ../$(FIRMDL3): firmdl.o srec.o rcx_comm.o $(CC) $^ -o $@ $(CFLAGS) fastdl.h: $(MKIMG) fastdl.srec ./$(MKIMG) fastdl.srec > $@ depend:: @# nothing to do here but do it silently install: install-stamp @# nothing to do here but do it silently install-stamp: $(ALL_TARGETS) $(MAN1) cp -f ../$(FIRMDL3) $(bindir) @if [ ! -d ${mandir}/man1 ]; then \ mkdir -p ${mandir}/man1; \ fi cp -f $(MAN1) $(mandir)/man1/$(MAN1) @touch $@ uninstall: rm -f $(mandir)/man1/$(MAN1) $(bindir)/$(FIRMDL3) install-stamp clean: rm -f *.o *~ *.bak realclean: clean rm -f fastdl.h $(ALL_TARGETS) @rm -f install-stamp # remove debug symbols strip: strip $(ALL_TARGETS) .PHONY: realclean clean install depend all ### -------------------------------------------------------------------------- ### End of FILE: util/firmdl/Makefile ### ========================================================================== brickos-0.9.0/util/firmdl/README0000644000175000017500000000405707530330675014036 0ustar cbcbfirmdl About: A firmware downloader for the RCX. Version 3.0. Supports single and quad speed downloading. Quad-rate downloading is a feature that significantly reduces firmware download times. It is implemented on top of a fast serial protocol that has a 2x baud rate with no complements or parity bits. The fast protocol is enabled by a short firmware stub that reconfigures some control registers and tweaks some ROM program state. Once the firmware stub is downloaded and executed, the ROM responds to the fast serial protocol, which the downloader then uses to transfer the actual firmware file. Because the initial firmware stub is small, all but the most trivial programs see a download time improvement when using quad-speed downloading. The caveat to using quad-speed downloading is its sensitivity to lighting conditions. Getting quad-speed downloading to work right might require some trial and error. In addition to avoiding harsh lighting conditions, it is important to place the RCX around 4-12 inches from the IR tower. Compiling: Typing "make" should do the trick. Running: usage: firmdl [options] srecfile (e.g. firmdl Firm0309.lgo) If necessary, set DEFAULTTTY, below, to the serial device you want to use. Set the RCXTTY environment variable to override DEFAULTTTY. Use the command-line option --tty=TTY to override RCXTTY and DEFAULTTTY. Use the command-line option --slow to revert to slow downloads. Use the command-line option --help for more information. Acknowledgements: Laurent Demailly, Allen Martin, Markus Noga, Gavin Smyth, and Luis Villa all contributed something to some version of this program. Version history: 1.x: single speed downloading plus many small revisions 2.0: double speed downloading, improved comm code, never released 3.0: quad speed downloads, misc other features, version numbering 3.1: changed mkimg to ./mkimg in Makefile 3.2: made srec code more lenient, use SREC_STRICT for old behavior License: See the file LICENSE for more information. Author: Kekoa Proudfoot kekoa@graphics.stanford.edu 10/13/99 brickos-0.9.0/util/firmdl/dump.c0000644000175000017500000000144607530330675014266 0ustar cbcb#include #include #include "srec.h" void fatal (char *fmt, ...) { va_list arglist; va_start(arglist, fmt); vfprintf(stderr, fmt, arglist); va_end(arglist); exit(1); } int main (int argc, char **argv) { FILE *file; char buf[256]; int line = 0; srec_t srec; if (argc != 2) fatal("usage: %s filename\n", argv[0]); if (!(file = fopen(argv[1], "r"))) fatal("%s: couldn't open\n", argv[1]); while (fgets(buf, sizeof(buf), file)) { int error; line++; if ((error = srec_decode(&srec, buf)) < 0) { if (error != S_INVALID_CKSUM) { fatal("%s: %s on line %d\n", argv[1], srec_strerror(error), line); } } if (srec.type == 0) { srec.data[srec.count] = '\0'; printf("S0: %s\n", srec.data); } } } brickos-0.9.0/util/firmdl/fastdl.s0000644000175000017500000000422307530330675014612 0ustar cbcb/* * fastdl.s * * A hack so to get the ROM running in a state with a doubled serial * baud rate, at least until it is turned off and back on again. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Librcx code, released February 9, 1999. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ .lsym rom_init_handlers, 0x0688 .lsym init_timer, 0x3b9a .lsym rom_main_loop_state, 0xee5e .lsym rom_dispatch_struct, 0xee64 .lsym rom_counter_struct, 0xee74 .lsym rom_power_off_minutes, 0xee80 .lsym rom_update_function_state, 0xef06 .lsym rom_use_complements_flag, 0xef51 .global __start __start: ; Set up as if ROM were waking RCX up mov.w #15,r6 mov.w r6,@rom_power_off_minutes mov.w #rom_dispatch_struct,r6 push r6 mov.w #rom_counter_struct,r6 jsr @init_timer adds.w #2,r7 mov.w #rom_main_loop_state,r6 jsr @rom_init_handlers ; Double the baud rate mov.b #103,r6l mov.b r6l,@0xd9:8 ; Turn off parity bclr #5,@0xd8:8 ; Turn off complements sub.b r6l,r6l mov.b r6l,@rom_use_complements_flag ; Hack the update function state so we don't hear two beeps mov.b #2,r6l mov.b r6l,@rom_update_function_state ; Hack the main loop state so we reenter ROM main loop correctly mov.b #13,r6l mov.b r6l,@rom_main_loop_state ; Return control back to ROM rts ; String needed for new firmware .string "Do you byte, when I knock?" brickos-0.9.0/util/firmdl/fastdl.srec0000644000175000017500000000042307530330675015302 0ustar cbcbS00E000066617374646C2E7372656398 S11880007906000F6B86EE807906EE646DF67906EE745E003BCC S11880159A0B877906EE5E5E0006887FD87250FE673ED918EED4 S118802A6A8EEF51FE026A8EEF06FE0D6A8EEE5E5470446F2032 S118803F796F7520627974652C207768656E2049206B6E6F63C5 S10780546B3F00007A S90380007C brickos-0.9.0/util/firmdl/firmdl.c0000644000175000017500000003170710172605305014570 0ustar cbcb/* * firmdl3.c * * A firmware downloader for the RCX. Version 3.0. Supports single and * quad speed downloading. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Firmdl code, released October 3, 1998. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1998, 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot * Laurent Demailly * Allen Martin * Markus Noga * Gavin Smyth * Luis Villa */ /* * usage: firmdl [options] srecfile (e.g. firmdl Firm0309.lgo) * * If necessary, set DEFAULTTTY, below, to the serial device you want to use. * Set the RCXTTY environment variable to override DEFAULTTTY. * Use the command-line option --tty=TTY to override RCXTTY and DEFAULTTTY. * * Acknowledgements: * * Laurent Demailly, Allen Martin, Markus Noga, Gavin Smyth, and Luis * Villa all contributed something to some version of this program. * * Version history: * * 1.x: single speed downloading plus many small revisions * 2.0: double speed downloading, improved comm code, never released * 3.0: quad speed downloads, misc other features, version numbering * 3.1: fixed checksum algorithm, increased max file size * Kekoa Proudfoot * kekoa@graphics.stanford.edu * 10/3/98, 10/3/99 */ /* 2002.04.01 * * Modifications to the original loader.c file in LegOS 0.2.4 include: * * Hary D. Mahesan's update to support USB IR firmware downloading * using RCX 2.0's USB tower under WIN32 on Cygwin. * * * * CVS inclusion, revision and modification by Paolo Masetti. * * */ #include #include #include #include #include #include #include #include #include #include #include #include #if defined(_WIN32) #include #endif #include "rcx_comm.h" #include "srec.h" /* Machine-dependent defines */ #if defined(LINUX) || defined(linux) #define DEFAULTTTY "/dev/ttyS0" /* Linux - COM1 */ #elif defined (_WIN32) #define DEFAULTTTY "com1" /* Cygwin - COM1 */ #elif defined (sun) #define DEFAULTTTY "/dev/ttya" /* Solaris - first serial port - untested */ #else #define DEFAULTTTY "/dev/ttyd2" /* IRIX - second serial port */ #endif /* Global variables */ char *progname; int tty_usb = 0; extern int __comm_debug; #include "fastdl.h" /* Defines */ #define BUFFERSIZE 4096 #define RETRIES 10 #define WAKEUP_TIMEOUT 4000 #define UPLOAD_TIMEOUT 50 #define IMAGE_START 0x8000 #define IMAGE_MAXLEN 0x7000 #define TRANSFER_SIZE 200 /* Stripping zeros is not entirely legal if firmware expects trailing zeros */ /* Define FORCE_ZERO_STRIPPING to force zero stripping for all files */ /* Normally you do not want to do this */ /* Possibly useful only if you explicitly zero pad for OCX compatiblity */ /* Since zero stripping is okay for Firm0309.lgo, that is done automatically */ #if 0 #define FORCE_ZERO_STRIPPING #endif /* Functions */ int srec_load (char *name, unsigned char *image, int maxlen, unsigned short *start) { FILE *file; char buf[256]; srec_t srec; int line = 0; int length = 0; int strip = 0; /* Initialize starting address */ *start = IMAGE_START; /* Open file */ if ((file = fopen(name, "r")) == NULL) { fprintf(stderr, "%s: ERROR- failed to open %s\n", progname, name); exit(1); } /* Clear image to zero */ memset(image, 0, maxlen); /* Read image file */ while (fgets(buf, sizeof(buf), file)) { int error, i; line++; /* Skip blank lines */ for (i = 0; buf[i]; i++) if (!isspace(buf[i])) break; if (!buf[i]) continue; /* Decode line */ if ((error = srec_decode(&srec, buf)) < 0) { if (error != SREC_INVALID_CKSUM) { fprintf(stderr, "%s: %s on line %d\n", name, srec_strerror(error), line); exit(1); } } /* Detect Firm0309.lgo header, set strip=1 if found */ if (srec.type == 0) { if (srec.count == 16) if (!strncmp(srec.data, "?LIB_VERSION_L00", 16)) strip = 1; } /* Process s-record data */ else if (srec.type == 1) { if (srec.addr < IMAGE_START || srec.addr + srec.count > IMAGE_START + maxlen) { fprintf(stderr, "%s: address out of bounds on line %d\n", name, line); exit(1); } if (srec.addr + srec.count - IMAGE_START > length) length = srec.addr + srec.count - IMAGE_START; memcpy(&image[srec.addr - IMAGE_START], &srec.data, srec.count); } /* Process image starting address */ else if (srec.type == 9) { if (srec.addr < IMAGE_START || srec.addr > IMAGE_START + maxlen) { fprintf(stderr, "%s: address out of bounds on line %d\n", name, line); exit(1); } *start = srec.addr; } } /* Strip zeros */ #ifdef FORCE_ZERO_STRIPPING strip = 1; #endif if (strip) { int pos; for (pos = IMAGE_MAXLEN - 1; pos >= 0 && image[pos] == 0; pos--); length = pos + 1; } /* Check length */ if (length == 0) { fprintf(stderr, "%s: image contains no data\n", name); exit(1); } return length; } void image_dl(FILEDESCR fd, unsigned char *image, int len, unsigned short start, int use_comp, char *filename) { unsigned short cksum = 0; unsigned char send[BUFFERSIZE]; unsigned char recv[BUFFERSIZE]; int addr, index, size, i; /* Compute image checksum */ int cksumlen = (start + len < 0xcc00) ? len : 0xcc00 - start; assert(len > 0); for (i = 0; i < cksumlen; i++) cksum += image[i]; /* Delete firmware */ send[0] = 0x65; send[1] = 1; send[2] = 3; send[3] = 5; send[4] = 7; send[5] = 11; if (rcx_sendrecv(fd, send, 6, recv, 1, 50, RETRIES, use_comp) != 1) { fprintf(stderr, "%s: delete firmware failed\n", progname); exit(1); } /* Start firmware download */ send[0] = 0x75; send[1] = (start >> 0) & 0xff; send[2] = (start >> 8) & 0xff; send[3] = (cksum >> 0) & 0xff; send[4] = (cksum >> 8) & 0xff; send[5] = 0; if (rcx_sendrecv(fd, send, 6, recv, 2, 50, RETRIES, use_comp) != 2) { fprintf(stderr, "%s: start firmware download failed\n", progname); exit(1); } /* Transfer data */ fprintf(stderr, "\rTransferring \"%s\" to RCX...\n", filename); addr = 0; index = 1; for (addr = 0, index = 1; addr < len; addr += size, index++) { fprintf(stderr,"\r%3d%% \r",(100*addr)/len); size = len - addr; send[0] = 0x45; if (index & 1) send[0] |= 0x08; if (size > TRANSFER_SIZE) size = TRANSFER_SIZE; else if (0) /* Set index to zero to make sound after last transfer */ index = 0; send[1] = (index >> 0) & 0xff; send[2] = (index >> 8) & 0xff; send[3] = (size >> 0) & 0xff; send[4] = (size >> 8) & 0xff; memcpy(&send[5], &image[addr], size); for (i = 0, cksum = 0; i < size; i++) cksum += send[5 + i]; send[size + 5] = cksum & 0xff; if (rcx_sendrecv(fd, send, size + 6, recv, 2, UPLOAD_TIMEOUT, RETRIES, use_comp) != 2 || recv[1] != 0) { fprintf(stderr, "%s: transfer data failed\n", progname); exit(1); } } fputs("100% \n",stderr); /* Unlock firmware */ send[0] = 0xa5; send[1] = 76; // 'L' send[2] = 69; // 'E' send[3] = 71; // 'G' send[4] = 79; // 'O' send[5] = 174; // '' /* Use longer timeout so ROM has time to checksum firmware */ if (rcx_sendrecv(fd, send, 6, recv, 26, 150, RETRIES, use_comp) != 26) { fprintf(stderr, "%s: unlock firmware failed\n", progname); exit(1); } } int main (int argc, char **argv) { unsigned char image[IMAGE_MAXLEN]; unsigned short image_start; unsigned int image_len; char *tty = NULL; int use_fast = 1; int usage = 0; FILEDESCR fd; int status; progname = argv[0]; /* Parse command line */ argv++; argc--; while (argc && argv[0][0] == '-') { if (argv[0][1] == '-') { if (!strcmp(argv[0], "--")) { argv++; argc--; break; } else if (!strcmp(argv[0], "--debug")) { __comm_debug = 1; } else if (!strcmp(argv[0], "--fast")) { use_fast = 1; } else if (!strcmp(argv[0], "--slow")) { use_fast = 0; } else if (!strncmp(argv[0], "--tty", 5)) { if (argv[0][5] == '=') { tty = &argv[0][6]; } else if (argc > 1) { argv++; argc--; tty = argv[0]; } else tty = ""; if (!tty[0]) { fprintf(stderr, "%s: invalid tty: %s\n", progname, tty); exit(1); } } else if (!strcmp(argv[0], "--help")) { usage = 1; } else { fprintf(stderr, "%s: unrecognized option %s\n", progname, argv[0]); exit(1); } } else { char *p = &argv[0][1]; if (!*p) break; while (*p) { switch (*p) { case 'f': use_fast = 1; break; case 's': use_fast = 0; break; case 'h': usage = 1; break; default: fprintf(stderr, "%s: unrecognized option -- %c\n", progname, *p); exit(1); } p++; } } argv++; argc--; } if (usage || argc != 1) { char *usage_string = " --debug show debug output, mostly raw bytes\n" " -f, --fast use fast 4x downloading (default)\n" " -s, --slow use slow 1x downloading\n" " --tty=TTY assume tower connected to TTY\n" #if defined(_WIN32) " --tty=usb assume tower connected to USB\n" #else " (if device name contains \"usb\", use USB mode)\n" #endif " -h, --help display this help and exit\n" ; fprintf(stderr, "usage: %s [options] filename\n", progname); fprintf(stderr, usage_string); exit(1); } /* Load the s-record file */ image_len = srec_load(argv[0], image, IMAGE_MAXLEN, &image_start); /* Get the tty name */ if (!tty) tty = getenv("RCXTTY"); if (!tty) tty = DEFAULTTTY; #if defined(_WIN32) //Check the command line to see if IR tower is USB. if(stricmp(tty,"usb")==0) { tty_usb = 1; if(__comm_debug) fprintf(stderr, "Hary Mahesan - USB IR Tower Mode.\n"); tty = "\\\\.\\legotower1"; // Set the correct usb tower if you have more than one (unlikely). } #elif defined(LINUX) || defined(linux) /* If the tty string contains "usb", e.g. /dev/usb/lego0, we */ /* assume it is the USB tower. If you use something else that doesn't */ /* have "usb" in the device name, link it. /dev/usb/lego0 is the */ /* name of the dirver installed by LegoUSB */ /* (http://legousb.sourceforge.net) */ if (strstr(tty,"usb") !=0) { tty_usb=1; if (__comm_debug) fprintf(stderr, "P.C. Chan & Tyler Akins - USB IR Tower Mode for Linux.\n"); } #endif if (use_fast && (tty_usb==0)) { //For now, run USB only at 2400bps (slow mode). /* Try to wake up the tower in fast mode */ fd = rcx_init(tty, 0); // Slow startup seems better with low batteries... if ((status = rcx_wakeup_tower(fd, WAKEUP_TIMEOUT)) < 0) { fprintf(stderr, "%s: %s\n", progname, rcx_strerror(status)); exit(1); } // Let's put IR in Fast mode. rcx_close(fd); fd = rcx_init(tty, 1); /* Check if already alive in fast mode */ if (!rcx_is_alive(fd, 0)) { /* Not alive in fast mode, download fastdl in slow mode */ rcx_close(fd); fd = rcx_init(tty, 0); if (!rcx_is_alive(fd, 1)) { fprintf(stderr, "%s: no response from rcx\n", progname); exit(1); } image_dl(fd, fastdl_image, fastdl_len, fastdl_start, 1, "Fast Download Image"); /* Go back to fast mode */ rcx_close(fd); fd = rcx_init(tty, 1); } /* Download image in fast mode */ image_dl(fd, image, image_len, image_start, 0, argv[0]); rcx_close(fd); } else { /* Try to wake up the tower in slow mode */ fd = rcx_init(tty, 0); // USB tower does not need to be waken up... if(tty_usb==0) { if ((status = rcx_wakeup_tower(fd, WAKEUP_TIMEOUT)) < 0) { fprintf(stderr, "%s: %s\n", progname, rcx_strerror(status)); exit(1); } if (!rcx_is_alive(fd, 1)) { /* See if alive in fast mode */ rcx_close(fd); fd = rcx_init(tty, 1); if (rcx_is_alive(fd, 0)) { fprintf(stderr, "%s: rcx is in fast mode\n", progname); fprintf(stderr, "%s: turn rcx off then back on to " "use slow mode\n", progname); exit(1); } fprintf(stderr, "%s: no response from rcx\n", progname); exit(1); } } /* Download image */ image_dl(fd, image, image_len, image_start, 1, argv[0]); rcx_close(fd); } return 0; } brickos-0.9.0/util/firmdl/firmdl3.10000644000175000017500000001433307531064451014573 0ustar cbcb.\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH firmdl3 1 "January 6, 2001" "brickOS" "brickOS Utility" .\" Please adjust this date whenever revising the manpage. .\" .\" --------------------------------------- .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .\" --------------------------------------- .SH NAME firmdl3 \- A firmware downloader for the RCX. Version 3.0. .\" .SH SYNOPSIS .B firmdl3 .RI [ options ] " srecfile" .\" .SH DESCRIPTION This manual page documents the .B firmdl3 kernel download command. .P \fBfirmdl3\fP is a program which is used to download the brickOS kernel (firmware). .B firmdl3 Supports single and quad rate downloading (quad-rate is default). .P Quad-rate downloading is a feature that significantly reduces firmware download times. It is implemented on top of a fast serial protocol that has a 2x baud rate with no complements or parity bits. The fast protocol is enabled by a short firmware stub that reconfigures some control registers and tweaks some ROM program state. Once the firmware stub is downloaded and executed, the ROM responds to the fast serial protocol, which the downloader then uses to transfer the actual firmware file. Because the initial firmware stub is small, all but the most trivial programs see a download time improvement when using quad-speed downloading. .P The caveat to using quad-speed downloading is its sensitivity to lighting conditions. Getting quad-speed downloading to work right might require some trial and error. In addition to avoiding harsh lighting conditions, it is important to place the RCX around 4-12 inches from the IR tower. .\" .SH OPTIONS This program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). The options supported by \fBfirmdl3\fP are: .TP .B \-h, \-\-help Show built-in help (summery of options) .TP .B \-f, \-\-fast Use 'fast' (4x) download algorithm (default) .TP .B \-s, \-\-slow Use 'slow' (1x) download algorithm (Use if experiencing download problems) .TP .B \-\-tty={ttydevice} Specify serial serial tty where IR tower is connected. .br .sp NOTE: The environment variable RCXTTY may be used in place of \-tty .TP .B \-\-debug Enable debugging. (Mostly displays raw bytes). .\" .SH ENVIRONMENT VARIABLES .B firmdl3 will respond to the environment variable RCXTTY. This should be set to the serial device to which the IR tower is connected. Use of RCXTTY is equivalent the using the -tty command-line option. .\" .SH EXAMPLES .B firmdl3 is a simple command to use. The following examples show most of the uses. .P \fBEx1:\fP download the brickOS kernal to ttyS0. .sp .nf $ firmdl3 -tty=/dev/ttyS0 /usr/lib/brickos/brickOS.srec Transferring "Fast Download Image" to RCX... 100% Transferring "/usr/lib/brickos/brickOS.srec" to RCX... 100% $ .fi .P \fBEx2:\fP download the brickOS kernal to ttyS1 (set env var 1st). .sp .nf $ export RCXTTY=/dev/ttyS1 $ firmdl3 /usr/lib/brickos/brickOS.srec Transferring "Fast Download Image" to RCX... 100% Transferring "/usr/lib/brickos/brickOS.srec" to RCX... 100% $ .fi .P \fBEx3:\fP download the brickOS kernal using slow protocol (assumes RCXTTY is already set). .sp .nf $ firmdl3 --slow /usr/lib/brickos/brickOS.srec Transferring "/usr/lib/brickos/brickOS.srec" to RCX... 100% $ .fi .sp NOTE: the missing indication of the "Fast Download Image" being sent. .P We'll leave the experiment of running \fBfirmdl3\fP with --debug set as an exercise for you our reader... (You really interested in seeing all the bytes fly by? ;-) .\" .SH ERROR MESSAGES .P (excerpt from brickOS HOWTO) .TP .B delete firmware failed Because of a limitation in the Lego firmware, \fBfirmdl3\fP cannot delete LegOS. Instead, before downloading the new firmware, you must first stop the old LegOS program, and then hold down the Prgm button while hitting the On/Off switch. This will delete the old LegOS firmware, allowing a new download. Alternately, if you see no green light on the IR box and get this error message, it may indicate you have a dead battery in the IR tower. .TP .B /dev/ttyS0: Permission denied, com1: Permission denied, or a similar message. The first part of the error message is the output port that \fBfirmdl3\fP is trying to use. This can mean two things. Either you have specified the wrong device or you have specified the correct device but do not have permission to access it. If it is an access problem, speak to your sysadmin. If not, you can use the --tty argument to specify another device. For example, to specify the standard device under linux, try \'firmdl3 --tty /dev/ttyS0\'. Under cygwin, you probably probably want to use \'firmdl3 --tty com1\'. If you discover that this is the case, you may wish to recompile \fBfirmdl3\fP to make your setting the default. .TP .B /dev/ttyS0: Input/output error or a similar message. You forgot to plug the tower in, most likely. .TP .B unlock firmware failed This indicates that there was a slight corruption in the download. Clear brickOS and download it again. .TP .B no response from RCX This error should be called "you forgot to turn on your RCX, moron." If I hadn't done it about 10 million times, I'd submit the patch to change the error myself. .P If \fBfirmdl3\fP gives you repeated problems, you may want to try using the --slow argument, which will make your download much slower but can correct for certain errors caused by ambient light. .\" .SH SEE ALSO .BR dll(1) .\" .SH AUTHOR .P Laurent Demailly, Allen Martin, Markus Noga, Gavin Smyth, and Luis Villa all contributed something to some version of \fBfirmdl3\fP. .P \fBfirmdl3 was written by:\fP Kekoa Proudfoot .br - 10/13/99 .P This manual page was written by Stephen M Moraco , for the Debian GNU/Linux system (but may be used by others). brickos-0.9.0/util/firmdl/mkimg.c0000644000175000017500000001167107623604610014422 0ustar cbcb/* * mkimg.c * * A program to make an image .c file given an s-record file. * * Compile with: cc mkimg.c srec.c -o mkimg * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Firmdl code, released October 3, 1998. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1998, 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ #include #include #include #include #include "srec.h" #define IMAGE_START 0x8000 #define IMAGE_MAXLEN 0x4000 /* Stripping zeros is not entirely legal if firmware expects trailing zeros */ /* Define FORCE_ZERO_STRIPPING to force zero stripping for all files */ /* Normally you do not want to do this */ /* Possibly useful only if you explicitly zero pad for OCX compatiblity */ /* Since zero stripping is okay for Firm0309.lgo, that is done automatically */ #if 0 #define FORCE_ZERO_STRIPPING #endif /* Functions */ int srec_load (char *name, unsigned char *image, int maxlen, unsigned short *start) { FILE *file; char buf[256]; srec_t srec; int line = 0; int length = 0; int strip = 0; /* Initialize starting address */ *start = IMAGE_START; /* Open file */ if ((file = fopen(name, "r")) == NULL) { fprintf(stderr, "%s: failed to open\n", name); exit(1); } /* Clear image to zero */ memset(image, 0, maxlen); /* Read image file */ while (fgets(buf, sizeof(buf), file)) { int error, i; line++; /* Skip blank lines */ for (i = 0; buf[i]; i++) if (!isspace(buf[i])) break; if (!buf[i]) continue; /* Decode line */ if ((error = srec_decode(&srec, buf)) < 0) { if (error != SREC_INVALID_CKSUM) { fprintf(stderr, "%s: %s on line %d\n", name, srec_strerror(error), line); exit(1); } } /* Detect Firm0309.lgo header, set strip=1 if found */ if (srec.type == 0) { if (srec.count == 16) if (!strncmp(srec.data, "?LIB_VERSION_L00", 16)) strip = 1; } /* Process s-record data */ else if (srec.type == 1) { if (srec.addr < IMAGE_START || srec.addr + srec.count > IMAGE_START + maxlen) { fprintf(stderr, "%s: address out of bounds on line %d\n", name, line); exit(1); } if (srec.addr + srec.count - IMAGE_START > length) length = srec.addr + srec.count - IMAGE_START; memcpy(&image[srec.addr - IMAGE_START], &srec.data, srec.count); } /* Process image starting address */ else if (srec.type == 9) { if (srec.addr < IMAGE_START || srec.addr > IMAGE_START + maxlen) { fprintf(stderr, "%s: address out of bounds on line %d\n", name, line); exit(1); } *start = srec.addr; } } /* Strip zeros */ #ifdef FORCE_ZERO_STRIPPING strip = 1; #endif if (strip) { int pos; for (pos = IMAGE_MAXLEN - 1; pos >= 0 && image[pos] == 0; pos--); length = pos + 1; } /* Check length */ if (length == 0) { fprintf(stderr, "%s: image contains no data\n", name); exit(1); } return length; } char *basename (char *path) { char *last = strrchr(path, '/'); return (last) ? last + 1 : path; } char *build_image_name (char *dst, char *src) { char *base = basename(src); while (*base) { if ((*base >= 'a' && *base <= 'z') || (*base >= 'A' && *base <= 'A') || (*base >= '0' && *base <= '9') || *base == '_') *dst++ = *base; else if (*base == '.') break; else *dst++ = '_'; base++; } *dst++ = '\0'; return dst; } int main (int argc, char **argv) { unsigned char image_name[64]; unsigned char image[IMAGE_MAXLEN]; unsigned short image_start; unsigned int image_len; int i; argv[0] = basename(argv[0]); if (argc != 2) { fprintf(stderr, "usage: %s filename\n", argv[0]); exit(1); } build_image_name(image_name, argv[1]); /* Load the s-record file */ image_len = srec_load(argv[1], image, IMAGE_MAXLEN, &image_start); /* Dump a .c file */ printf("/* Image file generated from %s by %s. */\n", argv[1], argv[0]); printf("/* See source for %s for license info. */\n", argv[1]); printf("\n"); printf("int %s_len = %d;\n", image_name, image_len); printf("unsigned char %s_image[] = {", image_name); for (i = 0; i < image_len; i++) { if (i % 16 == 0) printf("\n "); printf("%3d,", image[i]); } printf("\n"); printf("};\n"); printf("unsigned short %s_start = 0x%04x;\n", image_name, image_start); return 0; } brickos-0.9.0/util/firmdl/rcx_comm.c0000644000175000017500000003511010173100517015106 0ustar cbcb/* * rcx_comm.c * * RCX communication routines. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Firmdl code, released October 3, 1998. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1998, 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ /* 2002.04.01 * * Modifications to the original loader.c file in LegOS 0.2.4 include: * * Hary D. Mahesan's update to support USB IR firmware downloading * using RCX 2.0's USB tower under WIN32 on Cygwin. * * * * CVS inclusion, revision and modification by Paolo Masetti. * * */ #include #include #include #include #include #include #include #include #include #include #if defined(_WIN32) #include #else #include #include #endif #include "rcx_comm.h" /* Defines */ #define BUFFERSIZE 4096 /* Globals */ int __comm_debug = 0; extern int tty_usb; /* Timer routines */ typedef struct timeval timeval_t; #define tvupdate(tv) gettimeofday(tv,NULL) #define tvsec(tv) ((tv)->tv_sec) #define tvmsec(tv) ((tv)->tv_usec * 1e-3) static float timer_reset(timeval_t *timer) { tvupdate(timer); return 0; } static float timer_read(timeval_t *timer) { timeval_t now; tvupdate(&now); return tvsec(&now) - tvsec(timer) + (tvmsec(&now) - tvmsec(timer)) * 1e-3; } void myperror(char *str) { #if defined(_WIN32) fprintf(stderr, "Error %lu: %s\n", (unsigned long) GetLastError(), str); #else perror(str); #endif } /* Timeout read routine */ static int nbread (FILEDESCR fd, void *buf, int maxlen, int timeout) { char *bufp = (char *)buf; int len = 0; #if defined(LINUX) | defined(linux) int count; fd_set fds; struct timeval tv; #endif while (len < maxlen) { #if defined(_WIN32) if(tty_usb) { // USB Stuff here // We can't use Serial timeouts. DWORD count = 0; struct timeval timebegin ,timenow; unsigned long elapsed; // for timeout values gettimeofday(&timebegin,0); while(count==0) { ReadFile( fd, &bufp[len], maxlen - len, &count, NULL); gettimeofday(&timenow,0); elapsed = (timenow.tv_sec - timebegin.tv_sec ) + (timenow.tv_usec - timebegin.tv_usec); if(elapsed > timeout) break; } if(count==0) { if(__comm_debug) printf("Hary Mahesan - USB mode: nbread(len=%d, maxlen=%d) break...timed out\n", len, maxlen); break; } len += count; //update len } else { // Serial port stuff now. DWORD count = 0; COMMTIMEOUTS CommTimeouts; GetCommTimeouts (fd, &CommTimeouts); // Change the COMMTIMEOUTS structure settings. CommTimeouts.ReadIntervalTimeout = MAXDWORD; CommTimeouts.ReadTotalTimeoutMultiplier = 0; CommTimeouts.ReadTotalTimeoutConstant = timeout; CommTimeouts.WriteTotalTimeoutMultiplier = 10; CommTimeouts.WriteTotalTimeoutConstant = 1000; // Set the time-out parameters for all read and write operations // on the port. SetCommTimeouts(fd, &CommTimeouts); if (ReadFile(fd, &bufp[len], maxlen - len, &count, NULL) == FALSE) { myperror("ReadFile"); fprintf(stderr, "nb_read - error reading tty: %lu\n", (unsigned long) GetLastError()); exit(1); } len += count; if (count == 0) { if(__comm_debug) printf("Serial mode: nbread(len=%d, maxlen=%d) break...timed out\n", len, maxlen); break; } } #else if (tty_usb == 1) { // LegoUSB doesn't work with select(), so just set a read // timeout and then later check to see if the read timed out // without reading data. ioctl(fd, _IOW('u', 0xc8, int), timeout); } else { FD_ZERO(&fds); FD_SET(fd, &fds); tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; if (select(fd+1, &fds, NULL, NULL, &tv) < 0) { perror("select"); exit(1); } if (!FD_ISSET(fd, &fds)) break; } count = read(fd, &bufp[len], maxlen - len); // If no data was read from a USB tower and the read() timed out, // go ahead and assume we are done reading data. if (tty_usb == 1 && count == -1 && errno == ETIMEDOUT) { break; } if (count < 0) { perror("read"); exit(1); } len += count; #endif } return len; } /* discard all characters in the input queue of tty */ static void rx_flush(FILEDESCR fd) { #if defined(_WIN32) if (tty_usb == 0) { PurgeComm(fd, PURGE_RXABORT | PURGE_RXCLEAR); } else { char echo[BUFFERSIZE]; nbread(fd, echo, BUFFERSIZE, 200); } #else char echo[BUFFERSIZE]; nbread(fd, echo, BUFFERSIZE, 200); #endif } int mywrite(FILEDESCR fd, const void *buf, size_t len) { #if defined(_WIN32) DWORD nBytesWritten=0; WriteFile(fd, buf, len, &nBytesWritten, NULL); return nBytesWritten; #else /* For usb tower, the driver, legousbtower, uses interrupt */ /* urb which can only carry up to 8 bytes at a time. To */ /* transmit more we have to check and send the rest. It is */ /* a good thing to check, so I'll make it general. */ int actual = 0; int rc; char * cptr; int retry = 1000; if (len < 1) return len; cptr = (char *) buf; while (actual < len) { rc = (long) write(fd, cptr+actual, len-actual); if (rc == -1) { if ((errno == EINTR) || (errno == EAGAIN)) { rc = 0; usleep(10); retry --; } else return -1; } actual += rc; if (retry < 1) return actual; } return len; #endif } /* RCX routines */ FILEDESCR rcx_init(char *tty, int is_fast) { FILEDESCR fd; #if defined(_WIN32) DCB dcb; #else struct termios ios; #endif if (__comm_debug) printf("mode = %s\n", is_fast ? "fast" : "slow"); #if defined(_WIN32) // have windows platform I/O if ((fd = CreateFile(tty, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) { fprintf(stderr, "Error %lu: Opening %s\n", (unsigned long) GetLastError(), tty); exit(1); } //These settings don't apply to the USB tower, so if{} them out. if(tty_usb==0) { // Serial settings FillMemory(&dcb, sizeof(dcb), 0); if (!GetCommState(fd, &dcb)) { // get current DCB // Error in GetCommState myperror("GetCommState"); exit(1); } else { dcb.ByteSize = 8; dcb.Parity = (is_fast ? 0 : 1); // 0-4=no,odd,even,mark,space dcb.StopBits = 0; // 0,1,2 = 1, 1.5, 2 dcb.fBinary = TRUE ; dcb.fParity = (is_fast ? FALSE : TRUE) ; dcb.fAbortOnError = FALSE ; dcb.BaudRate = (is_fast ? CBR_4800 : CBR_2400); // Update DCB rate. // Set new state. if (!SetCommState(fd, &dcb)) { // Error in SetCommState. Possibly a problem with the communications // port handle or a problem with the DCB structure itself. myperror("SetCommState"); exit(1); } } // GetCommState } // usb #else // have linux platform I/O if ((fd = open(tty, O_RDWR)) < 0) { fprintf(stderr,"ERROR: tty=%s, ",tty); perror("open"); exit(1); } if (tty_usb == 0){ if (!isatty(fd)) { close(fd); fprintf(stderr, "%s: not a tty\n", tty); exit(1); } memset(&ios, 0, sizeof(ios)); ios.c_cflag = CREAD | CLOCAL | CS8 | (is_fast ? 0 : PARENB | PARODD); cfsetispeed(&ios, is_fast ? B4800 : B2400); cfsetospeed(&ios, is_fast ? B4800 : B2400); if (tcsetattr(fd, TCSANOW, &ios) == -1) { perror("tcsetattr"); exit(1); } } #endif return fd; } void rcx_close(FILEDESCR fd) { #if defined(_WIN32) CloseHandle(fd); #else close(fd); #endif } int rcx_wakeup_tower (FILEDESCR fd, int timeout) { char msg[] = { 0x10, 0xfe, 0x10, 0xfe }; char keepalive = 0xff; char buf[BUFFERSIZE]; timeval_t timer; int count = 0; int len; // First, I send a KeepAlive Byte to settle IR Tower... mywrite(fd, &keepalive, 1); usleep(20000); rx_flush(fd); timer_reset(&timer); do { if (__comm_debug) { printf("writelen = %d\n", sizeof(msg)); hexdump("W", msg, sizeof(msg)); } if (mywrite(fd, msg, sizeof(msg)) != sizeof(msg)) { myperror("write"); exit(1); } count += len = nbread(fd, buf, BUFFERSIZE, 50); if (len == sizeof(msg) && !memcmp(buf, msg, sizeof(msg))) return RCX_OK; /* success */ if (__comm_debug) { printf("recvlen = %d\n", len); hexdump("R", buf, len); } rx_flush(fd); } while (timer_read(&timer) < (float)timeout / 1000.0f); if (!count) return RCX_NO_TOWER; /* tower not responding */ else return RCX_BAD_LINK; /* bad link */ } /* Hexdump routine */ #define LINE_SIZE 16 #define GROUP_SIZE 4 #define UNPRINTABLE '.' void hexdump(char *prefix, void *buf, int len) { unsigned char *b = (unsigned char *)buf; int i, j, w; for (i = 0; i < len; i += w) { w = len - i; if (w > LINE_SIZE) w = LINE_SIZE; if (prefix) printf("%s ", prefix); printf("%04x: ", i); for (j = 0; j < w; j++, b++) { printf("%02x ", *b); if ((j + 1) % GROUP_SIZE == 0) putchar(' '); } putchar('\n'); } } int rcx_send (FILEDESCR fd, void *buf, int len, int use_comp) { char *bufp = (char *)buf; char buflen = len; char msg[BUFFERSIZE]; char echo[BUFFERSIZE]; int msglen, echolen; int sum; int tty_usb_echo = 0; // USB do not echos /* Encode message */ msglen = 0; sum = 0; if (use_comp) { msg[msglen++] = 0x55; msg[msglen++] = 0xff; msg[msglen++] = 0x00; while (buflen--) { msg[msglen++] = *bufp; msg[msglen++] = (~*bufp) & 0xff; sum += *bufp++; } msg[msglen++] = sum; msg[msglen++] = ~sum; } else { msg[msglen++] = 0xff; while (buflen--) { msg[msglen++] = *bufp; sum += *bufp++; } msg[msglen++] = sum; } /* Send message */ if (mywrite(fd, msg, msglen) != msglen) { myperror("write"); exit(1); } /* Receive echo */ // USB Tower doesn't echo if(tty_usb == tty_usb_echo) { echolen = nbread(fd, echo, msglen, 100); if (__comm_debug) { printf("msglen = %d, echolen = %d\n", msglen, echolen); hexdump("C", echo, echolen); } /* Check echo */ /* Ignore data, since rcx might send ack even if echo data is wrong */ if (echolen != msglen /* || memcmp(echo, msg, msglen) */ ) { /* Flush connection if echo is bad */ rx_flush(fd); return RCX_BAD_ECHO; } } // USB return len; } int rcx_recv (FILEDESCR fd, void *buf, int maxlen, int timeout, int use_comp) { char *bufp = (char *)buf; unsigned char msg[BUFFERSIZE]; int msglen; int sum; int pos; int len; /* Receive message */ msglen = nbread(fd, msg, BUFFERSIZE, timeout); if (__comm_debug) { printf("recvlen = %d\n", msglen); hexdump("R", msg, msglen); } /* Check for message */ if (!msglen) return RCX_NO_RESPONSE; /* Verify message */ if (use_comp) { if (msglen < 5 || (msglen - 3) % 2 != 0) return RCX_BAD_RESPONSE; if (msg[0] != 0x55 || msg[1] != 0xff || msg[2] != 0x00) return RCX_BAD_RESPONSE; for (sum = 0, len = 0, pos = 3; pos < msglen - 2; pos += 2) { if (msg[pos] != ((~msg[pos+1]) & 0xff)) return RCX_BAD_RESPONSE; sum += msg[pos]; if (len < maxlen) bufp[len++] = msg[pos]; } if (msg[pos] != ((~msg[pos+1]) & 0xff)) return RCX_BAD_RESPONSE; if (msg[pos] != (sum & 0xff)) return RCX_BAD_RESPONSE; /* Success */ return len; } else { if (msglen < 4) return RCX_BAD_RESPONSE; if (msg[0] != 0x55 || msg[1] != 0xff || msg[2] != 0x00) return RCX_BAD_RESPONSE; for (sum = 0, len = 0, pos = 3; pos < msglen - 1; pos++) { sum += msg[pos]; if (len < maxlen) bufp[len++] = msg[pos]; } /* Return success if checksum matches */ if (msg[pos] == (sum & 0xff)) return len; /* Failed. Possibly a 0xff byte queued message? (unlock firmware) */ for (sum = 0, len = 0, pos = 3; pos < msglen - 2; pos++) { sum += msg[pos]; if (len < maxlen) bufp[len++] = msg[pos]; } /* Return success if checksum matches */ if (msg[pos] == (sum & 0xff)) return len; /* Failed. Possibly a long message? */ /* Long message if opcode is complemented and checksum okay */ /* If long message, checksum does not include opcode complement */ for (sum = 0, len = 0, pos = 3; pos < msglen - 1; pos++) { if (pos == 4) { if (msg[3] != ((~msg[4]) & 0xff)) return RCX_BAD_RESPONSE; } else { sum += msg[pos]; if (len < maxlen) bufp[len++] = msg[pos]; } } if (msg[pos] != (sum & 0xff)) return RCX_BAD_RESPONSE; /* Success */ return len; } } int rcx_sendrecv (FILEDESCR fd, void *send, int slen, void *recv, int rlen, int timeout, int retries, int use_comp) { int status = 0; if (__comm_debug) printf("sendrecv %d:\n", slen); while (retries--) { if ((status = rcx_send(fd, send, slen, use_comp)) < 0) { if (__comm_debug) printf("status = %s\n", rcx_strerror(status)); continue; } if ((status = rcx_recv(fd, recv, rlen, timeout, use_comp)) < 0) { if (__comm_debug) printf("status = %s\n", rcx_strerror(status)); continue; } break; } if (__comm_debug) { if (status > 0) printf("status = %s\n", rcx_strerror(0)); else printf("status = %s\n", rcx_strerror(status)); } return status; } int rcx_is_alive (FILEDESCR fd, int use_comp) { unsigned char send[1] = { 0x10 }; unsigned char recv[1]; return (rcx_sendrecv(fd, send, 1, recv, 1, 50, 5, use_comp) == 1); } char *rcx_strerror (int error) { switch (error) { case RCX_OK: return "no error"; case RCX_NO_TOWER: return "tower not responding"; case RCX_BAD_LINK: return "bad ir link"; case RCX_BAD_ECHO: return "bad ir echo"; case RCX_NO_RESPONSE: return "no response from rcx"; case RCX_BAD_RESPONSE: return "bad response from rcx"; default: return "unknown error"; } } brickos-0.9.0/util/firmdl/rcx_comm.h0000644000175000017500000000523507530330675015135 0ustar cbcb/* * rcx_comm.h * * RCX communication routines. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Firmdl code, released October 3, 1998. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1998, 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ #ifndef RCX_COMM_H_INCLUDED #define RCX_COMM_H_INCLUDED #define RCX_OK 0 #define RCX_NO_TOWER -1 #define RCX_BAD_LINK -2 #define RCX_BAD_ECHO -3 #define RCX_NO_RESPONSE -4 #define RCX_BAD_RESPONSE -5 #if defined(_WIN32) #define FILEDESCR HANDLE #define BADFILE NULL #else #define FILEDESCR int #define BADFILE -1 #endif /* Get a file descriptor for the named tty, exits with message on error */ extern FILEDESCR rcx_init (char *tty, int is_fast); /* Close a file descriptor allocated by rcx_init */ extern void rcx_close (FILEDESCR fd); /* Try to wakeup the tower for timeout ms, returns error code */ extern int rcx_wakeup_tower (FILEDESCR fd, int timeout); /* Try to send a message, returns error code */ /* Set use_comp=1 to send complements, use_comp=0 to suppress them */ extern int rcx_send (FILEDESCR fd, void *buf, int len, int use_comp); /* Try to receive a message, returns error code */ /* Set use_comp=1 to expect complements */ /* Waits for timeout ms before detecting end of response */ extern int rcx_recv (FILEDESCR fd, void *buf, int maxlen, int timeout, int use_comp); /* Try to send a message and receive its response, returns error code */ /* Set use_comp=1 to send and receive complements, use_comp=0 otherwise */ /* Waits for timeout ms before detecting end of response */ extern int rcx_sendrecv (FILEDESCR fd, void *send, int slen, void *recv, int rlen, int timeout, int retries, int use_comp); /* Test whether or not the rcx is alive, returns 1=yes, 0=no */ /* Set use_comp=1 to send complements, use_comp=0 to suppress them */ extern int rcx_is_alive (FILEDESCR fd, int use_comp); /* Convert an error code to a string */ extern char *rcx_strerror(int error); /* Hexdump routine */ extern void hexdump(char *prefix, void *buf, int len); #endif /* RCX_COMM_H_INCLUDED */ brickos-0.9.0/util/firmdl/srec.c0000644000175000017500000001100407530330675014244 0ustar cbcb/* * srec.c * * S-record routines. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Firmdl code, released October 3, 1998. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1998, 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ #include #include #include "srec.h" /* Tables */ static signed char ctab[256] = { -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, -1,10,11,12,13,14,15,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,10,11,12,13,14,15,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, }; static int ltab[10] = {4,4,6,8,0,4,0,8,6,4}; /* Macros */ #define C1(l,p) (ctab[l[p]]) #define C2(l,p) ((C1(l,p)<<4)|C1(l,p+1)) /* Static functions */ int srec_decode(srec_t *srec, char *_line) { int len, pos = 0, count, alen, sum = 0; unsigned char *line = (unsigned char *)_line; if (!srec || !line) return SREC_NULL; for (len = 0; line[len]; len++) if (line[len] == '\n' || line[len] == '\r') break; if (len < 4) return SREC_INVALID_HDR; if (line[0] != 'S') return SREC_INVALID_HDR; for (pos = 1; pos < len; pos++) { if (C1(line, pos) < 0) return SREC_INVALID_CHAR; } srec->type = C1(line, 1); count = C2(line, 2); if (srec->type > 9) return SREC_INVALID_TYPE; alen = ltab[srec->type]; if (alen == 0) return SREC_INVALID_TYPE; if (len < alen + 6) return SREC_TOO_SHORT; if (count > alen + SREC_DATA_SIZE + 2) return SREC_TOO_LONG; if (len != count * 2 + 4) return SREC_INVALID_LEN; sum += count; len -= 4; line += 4; srec->addr = 0; for (pos = 0; pos < alen; pos += 2) { unsigned char value = C2(line, pos); srec->addr = (srec->addr << 8) | value; sum += value; } len -= alen; line += alen; for (pos = 0; pos < len - 2; pos += 2) { unsigned char value = C2(line, pos); srec->data[pos / 2] = value; sum += value; } srec->count = count - (alen / 2) - 1; sum += C2(line, pos); if ((sum & 0xff) != 0xff) return SREC_INVALID_CKSUM; return SREC_OK; } int srec_encode(srec_t *srec, char *line) { int alen, count, sum = 0, pos; if (srec->type > 9) return SREC_INVALID_TYPE; alen = ltab[srec->type]; if (alen == 0) return SREC_INVALID_TYPE; line += sprintf(line, "S%d", srec->type); if (srec->count > 32) return SREC_TOO_LONG; count = srec->count + (alen / 2) + 1; line += sprintf(line, "%02X", count); sum += count; while (alen) { int value; alen -= 2; value = (srec->addr >> (alen * 4)) & 0xff; line += sprintf(line, "%02X", value); sum += value; } for (pos = 0; pos < srec->count; pos++) { line += sprintf(line, "%02X", srec->data[pos]); sum += srec->data[pos]; } sprintf(line, "%02X\n", (~sum) & 0xff); return SREC_OK; } char * srec_strerror (int error) { switch (error) { case SREC_OK: return "no error"; case SREC_NULL: return "null string error"; case SREC_INVALID_HDR: return "invalid header"; case SREC_INVALID_CHAR: return "invalid character"; case SREC_TOO_SHORT: return "line too short"; case SREC_TOO_LONG: return "line too long"; case SREC_INVALID_LEN: return "length error"; case SREC_INVALID_CKSUM: return "checksum error"; default: return "unknown error"; } } brickos-0.9.0/util/firmdl/srec.h0000644000175000017500000000346107530330675014261 0ustar cbcb/* * srec.h * * Header file for s-record routines. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is Firmdl code, released October 3, 1998. * * The Initial Developer of the Original Code is Kekoa Proudfoot. * Portions created by Kekoa Proudfoot are Copyright (C) 1998, 1999 * Kekoa Proudfoot. All Rights Reserved. * * Contributor(s): Kekoa Proudfoot */ #ifndef SREC_H_INCLUDED #define SREC_H_INCLUDED #ifdef SREC_STRICT #define SREC_DATA_SIZE 32 #else #define SREC_DATA_SIZE 256 #endif typedef struct { unsigned char type; unsigned long addr; unsigned char count; unsigned char data[SREC_DATA_SIZE]; } srec_t; /* This function decodes a line into an srec; returns negative on error */ extern int srec_decode (srec_t *srec, char *line); /* This function encodes an srec into a line; returns negative on error */ extern int srec_encode (srec_t *srec, char *line); /* Error values */ #define SREC_OK 0 #define SREC_NULL -1 #define SREC_INVALID_HDR -2 #define SREC_INVALID_CHAR -3 #define SREC_INVALID_TYPE -4 #define SREC_TOO_SHORT -5 #define SREC_TOO_LONG -6 #define SREC_INVALID_LEN -7 #define SREC_INVALID_CKSUM -8 /* Use srec_strerror to convert error codes into strings */ extern char *srec_strerror (int errno); #endif /* SREC_H_INCLUDED */ brickos-0.9.0/include/0000755000175000017500000000000010173102120012314 5ustar cbcbbrickos-0.9.0/include/c++/0000755000175000017500000000000010173102120012664 5ustar cbcbbrickos-0.9.0/include/c++/Battery.H0000644000175000017500000000300307623536051014427 0ustar cbcb/*! \file include/c++/Battery.H \brief C++ Battery Class Interface \author Pat Welch (legOS@mousebrains.com) Defines interface to RCX-internal battery sensor */ // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #ifndef _Battery_H_ #define _Battery_H_ #include #include #if defined(CONF_DSENSOR) /** * \class Battery Battery.H c++/Battery.H * Battery-sensor interface (RCX Internal). * This class deals with the battery sensor. * * It provides only the single get() method. * * \see The other sensor classes: Sensor, LightSensor, RotationSensor, TouchSensor */ class Battery { public: /** * get the current battery strength value * \return int current battery reading in milliVolts (mV) * \note this is the c++ implementation of get_battery_mv() */ static int get() {return get_battery_mv();} }; #else // CONF_DSENSOR #warning Enable CONF_DSENSOR to use Battery.H #endif // CONF_DSENSOR #endif // _Battery_H_ brickos-0.9.0/include/c++/CriticalSectionBlock.H0000644000175000017500000001060310002533131017030 0ustar cbcb// The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // Contributor Henner Zeller #ifndef __CRITICALSECTIONBLOCK_H #define __CRITICALSECTIONBLOCK_H #include /** * A CriticalSectionBlock locks a critical section for the lifetime of the * CriticalSectionBlock. * * The CriticalSectionBlock gets a critical section and initially * enters it, i.e. the constructor blocks until the section is free. The * critical section is unlocked in the destructor. * * The actual trick is, that if the CriticalSectionBlock is created * as automatic variable on the stack (complicated expression for * local variable), C++ implicitly calls the destructor, * whenever we leave the block it is created in. * * Leaving the block may be due to a regular return, or an Exception or * just falling off the edge, thus this automatically takes care of * cleaning up the section which is especially handy if we expect Exceptions. * Never forgotten-to-unlock critical sections again .. (isn't this cool ?) * * Usage like: *
 * --------------------------------------------------------------------
 * critsec_t someCriticalSection;
 * void foo () {
 *     CriticalSectionBlock criticalSection(&someCriticalSection);
 *     //.. critical section protected ...
 *     myCriticalDataStructure = 42;
 *    // criticalSection is automatically released
 * }
 * --------------------------------------------------------------------- 
 * 
* * There is as well a macro available which utilizes this class to make * it really easy to use and to read. People who have programmed * Java reckognize this; use this in favour of the plain CriticalSectionBlock * because it improves readability a lot: * *
 * --------------------------------------------------------------------- 
 * critsec_t someCriticalSection;
 * void foo () {
 *     // ...
 *     synchronized (&someCriticalSection) {
 *         //.. critical section protected...
 *         myCriticalDataStructure = 42;
 *     }
 *     // ...
 * }
 * --------------------------------------------------------------------- 
 * 
* * @author Henner Zeller */ class CriticalSectionBlock { private: critsec_t *_critsec; /** * little hack, to make it possible to implement the synchronized() * macro with the for(;;) loop below. */ char _checkonceHackCounter; public: /** * Constructor locks the critical section. */ CriticalSectionBlock (critsec_t *critsec) : _critsec(critsec), _checkonceHackCounter(1) { enter_critical_section(_critsec); } /** * don't use. Used internally for the synchronized() { } macro. */ inline bool checkonce() { return _checkonceHackCounter-- > 0; } /** * destructor automatically unlocks the critical section. */ ~CriticalSectionBlock () { leave_critical_section(_critsec); } }; /** * cool macro which makes it possible to use the CriticalSectionBlock the * way you are used to in Java (..if you are used to java). Basically you * use it this way: * *
 * --------------------------------------------------------------------- 
 * critsec_t someCriticalSection;
 * void foo () {
 *     // ...
 *     synchronized (&someCriticalSection) {
 *         //.. critical section protected with critical section.
 *         myCriticalDataStructure = 42;
 *     }
 *     // ...
 * }
 * --------------------------------------------------------------------- 
 * 
* * The implementation of this macro creates a automatic variable within the * initialization part of a for-loop which is valid for the lifetime of the * block within the curly braces. * * BUGS: wastes some CPU cyles for a counter which is neccessary to abuse * the for(;;) loop to have this behaviour. Any ideas ? * * @author Henner Zeller */ #define synchronized(cs) for(CriticalSectionBlock __currentlocked(cs);__currentlocked.checkonce();/* */) /* * Local variables: * c-basic-offset: 8 * End: */ #endif /* __CRITICALSECTIONBLOCK_H */ brickos-0.9.0/include/c++/Lamp.H0000644000175000017500000000530410005030703013671 0ustar cbcb/*! \file include/c++/Lamp.H \brief C++ Lamp Class Interface \author Stephen M Moraco (stephmo@users.sourceforge.net) Defines interface to Lamp control via the output ports of the RCX */ // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Stephen M Moraco (stephmo@users.sourceforge.net) #ifndef _Lamp_H_ #define _Lamp_H_ #include #if defined(CONF_DMOTOR) #include /** * \class Lamp Lamp.H c++/Lamp.H * Lamp control interface. * Define a lamp connection to the RCX so we can turn the lamp on(), off() * or set its brightness(). * \note Lamps are controlled via motor ports so this is based on the Motor.H code * \see The other control classes: Motor, MotorPair, Sound */ class Lamp { public: /** * The RCX output pad to which the Lamp is connected */ enum Port { A, //!< RCX output pad A B, //!< RCX output pad B C //!< RCX output pad C }; /** * construct a lamp connected to {port} * \param port designator of pad to which this lamp is connected */ Lamp(enum Port port) : ms(port == A ? motor_a_speed : (port == B) ? motor_b_speed : motor_c_speed), md(port == A ? motor_a_dir : (port == B) ? motor_b_dir : motor_c_dir) { } /** * destroy our lamp instance * \note the lamp is turned off when the instance is destroyed */ ~Lamp() { off(); } /** * Turn the Lamp on * \return Nothing */ const void on() const { direction(::fwd); } /** * Turn the Lamp off * \return Nothing */ const void off() const { direction(::off); } /** * Set the power to the lamp * \param level the desired power setting specifying the intensity of the light. [must be between min (0) and max (255)] * \return Nothing */ const void brightness(const unsigned char level) const { speed(level); } private: const void speed(const unsigned char speed) const { (*ms)(speed); } const void direction(const MotorDirection dir) const { (*md)(dir); } void (*ms)(unsigned char speed); void (*md)(const MotorDirection dir); }; #else // CONF_DMOTOR #warning Enable CONF_DMOTOR to use Lamp.H #endif // CONF_DMOTOR #endif // _Lamp_H_ brickos-0.9.0/include/c++/LightSensor.H0000644000175000017500000000527607544273363015302 0ustar cbcb/*! \file include/c++/LightSensor.H \brief C++ LightSensor Class Interface \author Pat Welch (legOS@mousebrains.com) Defines interface to LightSensors plugged into the RCX */ // // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #ifndef _LightSensor_H_ #define _LightSensor_H_ #include #include #if defined(CONF_DSENSOR) /** * \class LightSensor LightSensor.H c++/LightSensor.H * Light-sensor interface (active/passive mode). * The LightSensor Class - using a %LightSensor in active or passive mode * * At construction time you specify the RCX connector pad to which * the %LightSensor is attached. * * This class provides two methods to read the value of the * sensor [\ref #get, \ref #sample] * * \note access methods from the base class \ref Sensor * if you desire access to the raw sensor values or to the power control * methods. * * \see The other sensor classes: Sensor, RotationSensor, and TouchSensor */ class LightSensor : public Sensor { public: /** * Instance an active light sensor at {port} * \param port The connector pad (1, 2 or 3) to which the light sensor is * attached */ LightSensor(const Sensor::Port port) : Sensor(port, true) {} /** * Get the current lightSensor value. * * NOTE: ultimately, this will be scaled to fall between 0 and 100. * \return unsigned int - the current light sensor reading * \see LightSensor#sample */ unsigned int get() const {return LIGHT(sensor);} /** * Get the average of {size} samples, waiting {wait} mSec between each sample * \param size - Number of samples to average (default = 10 samples) * \param wait - time (in mS) to wait between samples (default = 2mS) * \return unsigned int - The average of the sampled values * \see LightSensor#get */ unsigned int sample(unsigned int size = 10, int wait = 2) const { if (size == 0) size = 1; unsigned int sum(get()); for (unsigned int i = 1; i < size; ++i) { sum += get(); delay(wait); } return sum / size; } }; #else // CONF_DSENSOR #warning Enable CONF_DSENSOR to use LightSensor.H #endif // CONF_DSENSOR #endif // _LightSensor_H_ brickos-0.9.0/include/c++/Motor.H0000644000175000017500000000764710005030703014114 0ustar cbcb/*! \file include/c++/Motor.H \brief C++ Motor Class Interface \author Pat Welch (legOS@mousebrains.com) Defines interface to Motors plugged into the RCX */ // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. #ifndef _Motor_H_ #define _Motor_H_ #include #if defined(CONF_DMOTOR) #include // for the delay() function #include /** * \class Motor Motor.H c++/Motor.H * Motor control interface. * This class is designed to manipulate motors attached to an RCX * \see The other control classes: MotorPair, Sound, Lamp * \par Design Note * I avoided using derived classes since they were typically * three times larger. Also, if one is using Motor(Motor::A), all the decision * logic is optimized away in the compiler, so no extra space is used for that. */ class Motor { public: /** * valid port designators */ enum Port { A, //!< RCX output pad A B, //!< RCX output pad B C //!< RCX output pad C }; /** * motor speed range */ enum Limits { min = 0, //!< Minimum velocity (0) max = 255 //!< Maximum velocity (255) }; /** * construct a motor connected to {port} * \param port designator of pad to which this motor is connected */ Motor(const Port port) : ms(port == A ? motor_a_speed : (port == B) ? motor_b_speed : motor_c_speed), md(port == A ? motor_a_dir : (port == B) ? motor_b_dir : motor_c_dir) { } /** * destroy our motor instance * \sideeffect When the class is destroyed, the motor is turned off. */ ~Motor() {off();} /** * set the motor speed * \param speed the desired setting. Must be between * min (0) and max (255) * \return Nothing */ const void speed(const unsigned char speed) const { (*ms)(speed); } /** * set the motor direction * \param dir must be one of the MotorDirection values * \return Nothing */ const void direction(const MotorDirection dir) const { (*md)(dir); } /** * set motor direction to forward * \return Nothing */ const void forward() const { direction(fwd); } /** * set motor direction to forward at speed {s} * \param s the desired speed. Must be between * min (0) and max (255) * \return Nothing */ const void forward(const unsigned char s) const { forward(); speed(s); } /** * set the motor direction to reverse * \return Nothing */ const void reverse() const { direction(rev); } /** * set the motor direction to reverse at speed {s} * \param s the desired speed. Must be between * min (0) and max (255) * \return Nothing */ const void reverse(const unsigned char s) const { reverse(); speed(s); } /** * set the motor to brake * \return nothing * \todo describe what brake means */ const void brake() const { direction(::brake); } /** * set the motor to brake and delay return * \param duration time in mSec to delay before returning * \return nothing * \todo describe what brake means */ const void brake(int duration) const { brake(); delay(duration); } /** * turn the motor off * this disables power and the motor coasts to a stop * \return nothing */ const void off() const { direction(::off); } private: void (*ms)(unsigned char speed); //!< current velocity setting for this motor instance void (*md)(const MotorDirection dir); //!< current direction setting for this motor instance }; #else // CONF_DMOTOR #warning Enable CONF_DMOTOR to use Motor.H #endif // CONF_DMOTOR #endif // _Motor_H_ brickos-0.9.0/include/c++/MotorPair.H0000644000175000017500000001304110005030704014712 0ustar cbcb/*! \file include/c++/MotorPair.H \brief C++ MotorPair Class Interface \author Pat Welch (legOS@mousebrains.com) Defines interface to a pair of Motors to be treated as one unit */ // // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #ifndef _MotorPair_H_ #define _MotorPair_H_ #include #if defined(CONF_DMOTOR) #include // for the delay() function #include /// \class MotorPair MotorPair.H c++/MotorPair.H /// Pair-of-motors control interface. /// /// Often our robots use two motors, one on either side, which should be controlled /// together as one. This class makes this simple by allowing the coder to treat /// the pair as a single motor. /// /// The two motors can be connected to any of the output ports. When creating an /// instance of this class, simply specify which two output ports are involved. /// /// The normal Motor methods speed(), direction(), forward(), reverse(), brake(), /// and off() still apply. /// /// This class adds two new types of control: /// \li turning about the center (between the /// two wheels) [left(), right()] /// /// \li turning while using one of the wheels as the /// center of rotation [pivotLeft() and pivotRight()]. /// /// \note both motors will be turned off when this class is /// destroyed. /// /// \see The other control classes: Motor, Sound, Lamp /// class MotorPair { public: /// define a pair of motors specifying the connection of each to the /// RCX MotorPair(const Motor::Port lport, const Motor::Port rport) : mLeft(lport), mRight(rport) {} /// destroy this MotorPair instance /// \note both motors will be turned off when this class is destroyed ~MotorPair() {} /// set the speed of our two motors void speed(const int s) const { mLeft.speed(s); mRight.speed(s); } /// set the direction of our two motors /// \param dir one of the MotorDirection values void direction(const MotorDirection dir) const { if (dir == ::fwd) { mLeft.direction(::fwd); mRight.direction(::rev); } else if (dir == ::rev) { mLeft.direction(::rev); mRight.direction(::fwd); } else { mLeft.direction(dir); mRight.direction(dir); } } /// move forward void forward() const { direction(::fwd); } /// move reverse void reverse() const { direction(::rev); } /// stop without coasting void brake() const { mLeft.direction(::brake); mRight.direction(::brake); } /// stop but allow coasting void off() const { mLeft.direction(::off); mRight.direction(::off); } /// turn left about the center of the robot /// \note both motors in the pair are turning void left() const { mLeft.direction(::fwd); mRight.direction(::fwd); } /// turn left about the left wheel of the robot /// \note the left motor is brake'd while the right motor is turning void pivotLeft() const { mLeft.brake(); mRight.direction(::rev); } /// turn right about the center of the robot /// \note both motors in the pair are turning void right() const { mLeft.direction(::rev); mRight.direction(::rev); } /// turn right about the right wheel of the robot /// \note the right motor is brake'd while the left motor is turning void pivotRight() const { mLeft.direction(::fwd); mRight.brake(); } /// move forward at speed {s} /// \param s the desired speed (power level) void forward(const int s) const { forward(); speed(s); } /// move reverse (go backwards) at speed {s} /// \param s the desired speed (power level) void reverse(const int s) const { reverse(); speed(s); } /// turn left at speed {s} /// \param s the desired speed (power level) /// \note spins about the center of the motor pair void left(const int s) const { left(); speed(s); } /// turn left at speed {s} but pivot around left wheel /// \param s the desired speed (power level) /// \note spins about the left wheel void pivotLeft(const int s) const { pivotLeft(); speed(s); } /// turn right at speed {s} /// \param s the desired speed (power level) /// \note spins about the center of the motor pair void right(const int s) const { right(); speed(s); } /// turn right at speed {s} but pivot around right wheel /// \param s the desired speed (power level) /// \note spins about the right wheel void pivotRight(const int s) const { pivotRight(); speed(s); } /// apply the brakes to both motors then delay for {ms} mSec /// \param ms the time in mSec to wait before returning to caller void brake(const int ms) const { brake(); delay(ms); } /// the minimum and maximum speeds a motor can go, its limits. enum Limits { min = Motor::min, //!< minimum motor speed setting max = Motor::max //!< maximum motor speed setting }; private: const Motor mLeft; //!< the left Motor instance const Motor mRight; //!< the right Motor instance }; #else // CONF_DMOTOR #warning Enable CONF_DMOTOR to use MotorPair.H #endif // CONF_DMOTOR #endif // _MotorPair_H_ brickos-0.9.0/include/c++/RotationSensor.H0000644000175000017500000000656007544273363016027 0ustar cbcb/*! \file include/c++/RotationSensor.H \brief C++ RotationSensor Class Interface \author Pat Welch (legOS@mousebrains.com) Defines interface to RotationSensors plugged into the RCX */ // // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #ifndef _RotationSensor_H_ #define _RotationSensor_H_ #include #include #include #if defined(CONF_DSENSOR) && defined(CONF_DSENSOR_ROTATION) /** * \class RotationSensor RotationSensor.H c++/RotationSensor.H * Rotation-sensor interface (active mode). * Provide an interface to rotation sensor hardware attached to the RCX * * At construction time you specify the RCX connector pad to * which the rotation sensor is attached and its initial position * (default = 0). * * Additionally, RotationSensor provides methods to: * \li enable and disable rotation sensing [\ref #on, \ref #off] * \li set or read the current position * * \see Sensor, LightSensor, TouchSensor */ class RotationSensor : public Sensor { public: /** * Create an instance of an active rotation sensor which is attached at {port} * \param port the pad to which the rotation sensor is attached * \param position initial starting position (default = 0) */ RotationSensor(const Port port, int position = 0) : Sensor((Sensor::Port) port, true), rsensor((port == S1) ? ROTATION_1 : (port == S2) ? ROTATION_2 : ROTATION_3) #ifdef CONF_DSENSOR_VELOCITY , rvelocity((port == S1) ? VELOCITY_1 : (port == S2) ? VELOCITY_2 : VELOCITY_3) #endif // CONF_DSENSOR_VELOCITY { on(); //! Turn on tracking of the sensor pos(position); //! Set the current position } /** * Destroy this instance */ ~RotationSensor() { off(); //! Turn off tracking of this sensor } /** * turn on rotation tracking */ void on() const {ds_rotation_on(&sensor);} /** * turn off rotation tracking */ void off() const {ds_rotation_off(&sensor);} /** * set the current absolute postion * \param position the absolute value to use (typically zero) */ void pos(int position) const {ds_rotation_set(&sensor, position);} /** * get the current absolute postion * \return int the current relative position */ int pos() const {return rsensor;} #ifdef CONF_DSENSOR_VELOCITY /** * get the current rotational velocity * \return int the current velocity */ int velocity() const {return rvelocity;} #endif // CONF_DSENSOR_VELOCITY private: /** * the raw sensor value */ volatile int& rsensor; #ifdef CONF_DSENSOR_VELOCITY /** * the raw velocity value */ volatile int& rvelocity; #endif // CONF_DSENSOR_VELOCITY }; #else #warning Enable CONF_DSENSOR && CONF_DSENSOR_ROTATION to use RotationSensor.H #endif // CONF_DSENSOR, CONF_DSENSOR_ROTATION #endif // _RotationSensor_H_ brickos-0.9.0/include/c++/Sensor.H0000644000175000017500000001307207544273363014303 0ustar cbcb/*! \file include/c++/Sensor.H \brief C++ Sensor Class Interface \author Pat Welch (legOS@mousebrains.com) Defines interface to Sensors plugged into the RCX */ // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #ifndef _Sensor_H_ #define _Sensor_H_ #include #if defined(CONF_DSENSOR) #include #include /** * \class Sensor Sensor.H c++/Sensor.H * Basic sensor interface. * This is the base class for all sensors. * * At construction time you specify the RCX connector pad [\ref #Port] to * which the sensor is attached and whether it should be powered (active/on) * or not (passive/off). * * The %Sensor class provides methods to: * \li read the value of the sensor [\ref #get, \ref #sample] * * \li power the sensor as needed [\ref #on, \ref #off, \ref #active, * \ref #passive, \ref #mode] * * \note Generally touch sensors [identical to Sensor but may be spelled * TouchSensor] are not powered. * Light sensors [\ref LightSensor] may be powered or not (the values are * smaller when they are powered and the sensor is more tolerant of ambient * light) and Rotation sensors [\ref RotationSensor] must be powered when * sensing rotation. * \todo how does TemperatureSensor figure in here...? */ class Sensor { public: /** * List of sensor identifiers (IDs). * * S1, S2, S3 are connector pads 1, 2 and 3 on the RCX. * * Battery is the internal sensor allowing a program to read * the current battery voltage in milliVolts * * \short Possible Sensor Port Values * \see Battery */ enum Port { S1 = 0, //!< RCX sensor port 1 S2, //!< RCX sensor port 2 S3, //!< RCX sensor port 3 Battery //!< RCX battery sensor }; /** * Construct a new sensor instance. * * At time of construction identify where the sensor is connected and * whether it should be active or passive (default is passive). * * \param port The port to be associated with this instance of a sensor * \param makeActive T/F - Where true means make active (default is false, passive) * \see Sensor#Port */ Sensor(const Port port, bool makeActive = false) : sensor((port == S1) ? SENSOR_1 : (port == S2) ? SENSOR_2 : (port == S3) ? SENSOR_3 : BATTERY) { if (makeActive) active(); // Don't use mode here, since this saves memory else passive(); } /** * Destroy this sensor instance * * \note Just before the sensor instance is destroyed the power to the * input pad is turned off (in case is was active) thereby * conserving battery power. */ ~Sensor() {off();} /** * Get the current sensor reading * * \return unsigned int - The current raw sensor value * \see Sensor#sample */ unsigned int get() const {return sensor;} /** * Set the sensor (mode) to active or passive * * \param makeActive - T/F - Where true means to go active * (voltage is supplied to the connector pad) * \see Sensor#off, Sensor#on, Sensor#active, Sensor#passive */ void mode(bool makeActive) const { if (makeActive) active(); else passive(); } /** * Set the sensor to passive (turn off voltage to connector) * \see Sensor#active, Sensor#on, Sensor#off, Sensor#mode */ void passive() const {ds_passive(&sensor);} /** * Set the sensor to active (provide voltage to connector) * \see Sensor#passive, Sensor#on, Sensor#off, Sensor#mode */ void active() const {ds_active(&sensor);} /** * Turn the sensor on (provide voltage to connector) * \see Sensor#off, Sensor#active, Sensor#passive, Sensor#mode */ void on () const {active();} /** * Turn the sensor off (turn off voltage to connector) * \see Sensor#on, Sensor#active, Sensor#passive, Sensor#mode */ void off() const {passive();} /** * Quickly turn sensor off then back on. * \see Sensor#on, Sensor#off, Sensor#active, Sensor#passive, Sensor#mode */ void strobe() const {off(); on();} /** * Turn sensor off, wait for {ms} milliSeconds, then then turn it back on. * \param ms - Number of milliSeconds to wait between off and back on * \see Sensor#on, Sensor#off, Sensor#active, Sensor#passive, Sensor#mode */ void strobe(const int ms) const {off(); delay(ms); on();} /** * Get the average of {size} samples, waiting {wait} mSec between each sample * \param size - Number of samples to average (default = 10 samples) * \param wait - time (in mS) to wait between samples (default = 2mS) * \return unsigned int - The average of the sampled values * \see Sensor#get */ unsigned int sample(unsigned int size = 10, int wait = 2) const { if (size == 0) size = 1; unsigned int sum(get()); for (unsigned int i = 1; i < size; ++i) { sum += get(); delay(wait); } return sum / size; } protected: /** * The address of our sensor value */ volatile unsigned int& sensor; }; #else // CONF_DSENSOR #warning Enable CONF_DSENSOR to use Sensor.H #endif // CONF_DSENSOR #endif // _Sensor_H_ brickos-0.9.0/include/c++/Sound.H0000644000175000017500000000456507544273363014131 0ustar cbcb/*! \file include/c++/Sound.H \brief C++ Sound Class Interface \author Pat Welch (legOS@mousebrains.com) Defines interface to RCX-internal speaker and sound generation routines */ // // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #ifndef _Sound_H_ #define _Sound_H_ #include #include #if defined(CONF_DSOUND) /** * \class Sound Sound.H c++/Sound.H * Sound generation interface. * Sound Generation Class interface * * \see The other control classes: Motor, MotorPair, Lamp */ class Sound { public: /** * Play a list of notes (song). * \li to poll for playing complete try Sound::playing() * \li to wait for playing complete try dsound_finished() * \param notes pointer to an array of note_t elements * \return Nothing */ static void play(const note_t *notes) {return dsound_play(notes);} /** * Determine if a sound is currently playing * \return T/F where T means a sound is playing * \see dsound_finished() */ static int playing() {return dsound_playing();} /** * Play the system_beep sound * \return Nothing */ static void beep() {dsound_system(DSOUND_BEEP);} /** * Stop a currently playing sound * \return Nothing */ static void stop() {dsound_stop();} /** * Set the default duration * \param len the duration in mSec? * \return Nothing * \todo get the real scoop here, then provde better description */ static void duration(const unsigned int len) {dsound_set_duration(len);} /** * Set the amount of time between notes * \param len the duration in mSec? * \return Nothing * \todo get the real scoop here, then provde better description */ static void internote(const unsigned int len) {dsound_set_internote(len);} }; #else #warning Enable CONF_DSOUND to use Sound.H #endif // CONF_DSOUND #endif // _Sound_H_ brickos-0.9.0/include/c++/TemperatureSensor.H0000644000175000017500000000613407544273363016522 0ustar cbcb/*! \file include/c++/TemperatureSensor.H \brief C++ TemperatureSensor Class Interface \author Pat Welch (legOS@mousebrains.com) Defines interface to temperature sensors */ // // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #ifndef _TemperatureSensor_H_ #define _TemperatureSensor_H_ #include #include #if defined(CONF_DSENSOR) /** * \class TemperatureSensor TemperatureSensor.H c++/TemperatureSensor.H * Temperature-sensor interface. * This is class deals with temperature sensors * * The methods include: * TemperatureSensor(sensor port) * C() returns a float which is the temperature in C. The sensor appears * to have a resolution of ~1/8 degree. * F() returns a float which is the temperature in F. * tenths() returns an int which is the temperature in C * 10 * degrees() returns an int which is the temperature in C * * It also includes all methods in Sensor * * N.B. the transform from sensor reading to temperature is done using * a simple linear regression compared to my outdoor thermometer over the * range of -20 to +30 C. I can not vouch for the accuracy or precision of * these numbers! So if you have a well calibrated temperature monitor, and * you can check my conversions, please let me know the results, and I can * clean up the regression parameters. */ class TemperatureSensor : public Sensor { public: /** * Construct a temperature sensor. * * At time of construction identify where it is connected. * \param port The port to be associated with this instance * \see Sensor#Port */ TemperatureSensor(const Sensor::Port port) : Sensor(port, false) {} /** * Destroy this instance of TemperatureSensor */ ~TemperatureSensor() {} /** * Get the current temperature in Celsius * * \return float - the current temperature in C */ float C() const { return 93.8136 - 0.122241 * static_cast(get() >> 6); } /** * Get the current temperature in F * * \return float - the current temperature in F */ float F() const {return C() * 1.8 + 32;} /** * Get the current temperature in C * 10, as an int * * \return int - the current temperature in C * 10 */ int tenths() const {return static_cast(C() * 10.);} /** * Get the current temperature in C, as an int * * \return int - the current temperature in C */ int degrees() const {return static_cast(C());} }; #else // CONF_DSENSOR #warning Enable CONF_DSENSOR to use TemperatureSensor.H #endif // CONF_DSENSOR #endif // _TemperatureSensor_H_ brickos-0.9.0/include/c++/TouchSensor.H0000644000175000017500000000371207544273363015306 0ustar cbcb/*! \file include/c++/TouchSensor.H \brief C++ TouchSensor Class Interface \author Pat Welch (legOS@mousebrains.com) Defines the interface to a TouchSensor plugged into RCX */ // // The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License // at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See // the License for the specific language governing rights and // limitations under the License. // // This software was developed as part of the legOS project. // // Contributor: Pat Welch (legOS@mousebrains.com) #ifndef _TouchSensor_H_ #define _TouchSensor_H_ #include #include #if defined(CONF_DSENSOR) /** * \class TouchSensor TouchSensor.H c++/TouchSensor.H * Touch-sensor interface (passive mode). * The Touch %Sensor Class - using a touch sensor in passive mode * * At construction time you specify the RCX connector pad to which the * touchSensor is attached. * * \note TouchSensor is implemented as a simple redefine of the Sensor * class (saved ~48 bytes per instance). See "list of all members", above, or * refer to the Sensor class for all methods * * \see The other sensor classes: Sensor, LightSensor, RotationSensor */ class TouchSensor : public Sensor { public: /** * construct a TouchSensor connected to pad {port} * \param port and input port of the RCX * \return Nothing */ TouchSensor(const Sensor::Port port) : Sensor(port, false) {} /** * determine if touch sensor is pressed * \return T/F where T means touch sensor was pressed */ bool pressed() const {return TOUCH(sensor);} }; #else // CONF_DSENSOR #warning Enable CONF_DSENSOR to use TouchSensor.H #endif // CONF_DSENSOR #endif // _TouchSensor_H_ brickos-0.9.0/include/lnp/0000755000175000017500000000000010173102120013105 5ustar cbcbbrickos-0.9.0/include/lnp/sys/0000755000175000017500000000000010173102120013723 5ustar cbcbbrickos-0.9.0/include/lnp/sys/irq.h0000644000175000017500000000762607535330363014726 0ustar cbcb/*! \file include/lnp/sys/irq.h \brief Internal LNP Interface: RCX redirected IRQ vectors \author Markus L. Noga Lego Mindstorms RCX IRQ redirection vector table All redirected handlers can assume r6 to be saved All redirected handlers must return with rts, *not* rte. \warning Incomplete. */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_irq_h__ #define __sys_irq_h__ #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #ifdef CONF_RCX_COMPILER #define HANDLER_WRAPPER(wrapstring,handstring) #else #define HANDLER_WRAPPER(wrapstring,handstring) \ __asm__ (".text\n.align 1\n.global _" wrapstring "\n_" wrapstring \ ": push r0\npush r1\npush r2\npush r3\njsr @_" handstring \ "\npop r3\npop r2\npop r1\npop r0\nrts\n") #endif /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// extern void *reset_vector; //!< reset vector extern void *nmi_vector; //!< NMI interrupt vector extern void *irq0_vector; //!< IRQ0 interrupt vector extern void *irq1_vector; //!< IRQ1 interrupt vector extern void *irq2_vector; //!< IRQ2 interrupt vector extern void *icia_vector; //!< ICIA interrupt vector extern void *icib_vector; //!< ICIB interrupt vector extern void *icic_vector; //!< ICIC interrupt vector extern void *icid_vector; //!< ICID interrupt vector extern void *ocia_vector; //!< OCIA interrupt vector extern void *ocib_vector; //!< OCIB interrupt vector extern void *fovi_vector; //!< FOVI interrupt vector extern void *cmi0a_vector; //!< CMI0A interrupt vector extern void *cmi0b_vector; //!< CMI0B interrupt vector extern void *ovi0_vector; //!< OVI0 interrupt vector extern void *cmi1a_vector; //!< CMI1A interrupt vector extern void *cmi1b_vector; //!< CMI1B interrupt vector extern void *ovi1_vector; //!< OVI1 interrupt vector extern void *eri_vector; //!< ERI interrupt vector extern void *rxi_vector; //!< RXI interrupt vector extern void *txi_vector; //!< TXI interrupt vector extern void *tei_vector; //!< TEI interrupt vector extern void *ad_vector; //!< A/D interrupt vector extern void *wovf_vector; //!< WOVF interrupt vector extern void *rom_reset_vector; //!< ROM reset vector extern void rom_ocia_handler(); //!< ROM OCIA interrupt handler extern void rom_ocia_return(); //!< return address in ROM OCIA handler extern void rom_dummy_handler(); //!< address of an RTS instruction /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! disable interrupt processing extern inline void disable_irqs() { __asm__ __volatile__("\torc #0x80,ccr\n":::"cc"); } //! enable interrupt processing extern inline void enable_irqs() { __asm__ __volatile__("\tandc #0x7f,ccr\n":::"cc"); } #ifdef __cplusplus } #endif #endif // __sys_irq_h__ brickos-0.9.0/include/lnp/sys/lnp.h0000644000175000017500000001072507535330363014716 0ustar cbcb/*! \file sys/lnp.h \brief Internal LNP Interface: link networking protocol \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_lnp_h__ #define __sys_lnp_h__ #ifdef __cplusplus extern "C" { #endif #include "../lnp.h" #ifdef CONF_LNP /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #define LNP_HOSTMASK CONF_LNP_HOSTMASK //!< the LNP host mask (config.h) //! LNP port mask is derived from host mask #define LNP_PORTMASK (0x00ff & ~CONF_LNP_HOSTMASK) #if defined(CONF_RCX_PROTOCOL) || defined(CONF_RCX_MESSAGE) //! length of header from remote/rcx, -1 because first byte is used to id sequence #define LNP_RCX_HEADER_LENGTH (3-1) //! length of remote button op, -3 because first 3 bytes is used to id sequence #define LNP_RCX_REMOTE_OP_LENGTH (5-3) //! length of rcx message op, -3 because first 3 bytes is used to id sequence #define LNP_RCX_MSG_OP_LENGTH (5-3) #endif //! states for the integrity layer state machine typedef enum { LNPwaitHeader, LNPwaitLength, LNPwaitData, LNPwaitCRC, #if defined(CONF_RCX_PROTOCOL) || defined(CONF_RCX_MESSAGE) //! states when waiting for rcx protocol message LNPwaitRMH1, // note that first byte is consumed by LNPwaitHeader LNPwaitRMH2, // inverted header LNPwaitRMH3, // actually, RCX opcode dispatch LNPwaitRMH4, // remote opcode inverted #endif #ifdef CONF_RCX_PROTOCOL //! states when waiting for remote buttons args LNPwaitRB0, // high-byte LNPwaitRB0I, LNPwaitRB1, // low-byte LNPwaitRB1I, LNPwaitRC, // RCX checksum LNPwaitRCI, #endif #ifdef CONF_RCX_MESSAGE //! states when waiting for rcx message opcode LNPwaitMH3, // RCX message OP LNPwaitMH4, LNPwaitMN, // message number LNPwaitMNC, LNPwaitMC, // RCX checksum LNPwaitMCC, #endif } lnp_integrity_state_t; /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// //! the timeout counter in ms extern volatile unsigned short lnp_timeout_counter; //! the timeout length in ms extern unsigned short lnp_timeout; //! the integrity layer state extern lnp_integrity_state_t lnp_integrity_state; /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! the LNP `copy and compute checksum' function. extern unsigned char lnp_checksum_copy( unsigned char *dest, const unsigned char *data, unsigned length ); //! receive a byte from the physical layer, decoding integrity layer //! packets. /*! \param b the byte to receive */ extern void lnp_integrity_byte(unsigned char b); //! reset the integrity layer on error or timeout. extern void lnp_integrity_reset(void) #ifdef CONF_RCX_COMPILER __attribute__ ((rcx_interrupt)) #endif ; //! return whether a packet is currently being received /*! \return 1 if yes, else zero */ extern inline int lnp_integrity_active(void) { return lnp_integrity_state!=LNPwaitHeader; } //! reset the inter-byte timeout counter. extern void lnp_timeout_reset(void) #ifdef CONF_RCX_COMPILER __attribute__ ((rcx_interrupt)) #endif ; //! set the inter-byte timeout and reset the timeout counter to that //! value. /*! \param timeout the new timeout value */ extern inline void lnp_timeout_set(unsigned short timeout) { lnp_timeout_counter=lnp_timeout=timeout; } //! Initialise protocol handlers /*! Adressing port 0 is reserved for the program handler. * DLL transfers programs to this port. */ extern void lnp_init(void); #endif // CONF_LNP #ifdef __cplusplus } #endif #endif // __sys_lnp_h__ brickos-0.9.0/include/lnp/sys/lnp-logical.h0000644000175000017500000000601607551712562016327 0ustar cbcb/*! \file include/lnp/sys/lnp-logical.h \brief Internal LNP Interface: link networking protocol logical layer \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_lnp_logical_h__ #define __sys_lnp_logical_h__ #ifdef __cplusplus extern "C" { #endif #include "../lnp-logical.h" #ifdef CONF_LNP #ifndef CONF_HOST #include #else #define MSECS_TO_TICKS(a) (a) #endif /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #ifdef CONF_LNP_FAST #define LNP_LOGICAL_BAUD_RATE B4800 //!< baud rate #define LNP_LOGICAL_PARITY SMR_P_NONE //!< parity #define LNP_BYTE_TIME MSECS_TO_TICKS(3) //!< time to transmit a byte #else #define LNP_LOGICAL_BAUD_RATE B2400 //!< baud rate #define LNP_LOGICAL_PARITY SMR_P_ODD //!< parity #define LNP_BYTE_TIME MSECS_TO_TICKS(5) //!< time to transmit a byte #endif #define LNP_BYTE_TIMEOUT (3*LNP_BYTE_TIME/2) //!< timeout waiting for a byte #define LNP_BYTE_SAFE (4*LNP_BYTE_TIME) //!< delay before transmitting a byte #define LNP_WAIT_TXOK (2*LNP_BYTE_TIMEOUT) //!< delay after good transmit #define LNP_WAIT_COLL (4*LNP_BYTE_TIMEOUT) //!< delay after collision #define TX_COLL (-1) //!< not transmitting, last xmit was collision #define TX_IDLE ( 0) //!< not transmitting, last xmit OK #define TX_ACTIVE ( 1) //!< currently transmitting /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// extern volatile signed char tx_state; //!< transmit status /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! Initialize the logical layer (IR port) // extern void lnp_logical_init(void); //! Shutdown the logical layer (IR port) // extern void lnp_logical_shutdown(void); //! Callback: end of transmission // void txend_handler(void) #ifdef RCX_COMPILER __attribute__ ((rcx_interrupt)) #endif ; #endif // CONF_LNP #ifdef __cplusplus } #endif #endif // __sys_lnp_logical_h__ brickos-0.9.0/include/lnp/lnp-logical.h0000644000175000017500000000510407541267663015514 0ustar cbcb/*! \file include/lnp/lnp-logical.h \brief LNP Interface: link networking protocol logical layer \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __lnp_logical_h__ #define __lnp_logical_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_LNP #ifdef CONF_HOST #include #else #include #include #endif /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// #ifndef CONF_HOST //! Set the IR transmitter range /*! Configure the INFRARED transmitter power * \param far: 0: sets short range, 1: sets long range * \return Nothing * * NOTE1: this setting remains in effect until changed or * the RCX power is turned off. * * NOTE2: toggles port 4 bit 0 * \todo determine what clears this and then correct NOTE1 */ extern inline void lnp_logical_range(int far) { if(far) *((char*)&PORT4) &=~1; else *((char*)&PORT4) |=1; } //! Test the IR transmitter range setting /*! Determine if the INFRARED transmitter power is set to long range * \return T/F where TRUE means transmitter is set to long range */ extern inline int lnp_logical_range_is_far(void) { return !(*((char*)&PORT4)&1); } #endif //! Write buffer to IR port /*! Write {len} chars (starting at {buf}) to IR port. * \param buf pointer to array of chars to be written * \param len number of chars in array (to be written) * \return 0 if OK, else collision * * NOTE: doesn't return until all are written * (blocking write) */ extern int lnp_logical_write(const void *buf,size_t len); //! Empty the IR receive buffer. /*! \return Nothing */ extern void lnp_logical_fflush(void); #endif // CONF_LNP #ifdef __cplusplus } #endif #endif // __lnp_logical_h__ brickos-0.9.0/include/lnp/lnp.h0000644000175000017500000001074107540516171014075 0ustar cbcb/*! \file include/lnp/lnp.h \brief LNP Interface: link networking protocol \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __lnp_h__ #define __lnp_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_LNP #ifdef CONF_RCX_MESSAGE #include #endif /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// //! the integrity layer packet handler type /*! arguments are (data,length). */ typedef void (*lnp_integrity_handler_t) (const unsigned char *, unsigned char); //! the addressing layer packet handler type /*! arguments are (data,length,src_address). */ typedef void (*lnp_addressing_handler_t) (const unsigned char *, unsigned char, unsigned char); //! dummy integrity layer packet handler #define LNP_DUMMY_INTEGRITY ((lnp_integrity_handler_t)0) //! dummy addressing layer packet handler #define LNP_DUMMY_ADDRESSING ((lnp_addressing_handler_t)0) #ifdef CONF_RCX_PROTOCOL //! handler for remote /*! arguments are (buttonstate) */ typedef void (*lnp_remote_handler_t) (unsigned int); //! dummy remote packet handler #define LNP_DUMMY_REMOTE ((lnp_remote_handler_t)0) #endif /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// //! there are no ports for integrity layer packets, so there's just // one handler. extern volatile lnp_integrity_handler_t lnp_integrity_handler; //! addressing layer packets may be directed to a variety of ports. extern volatile lnp_addressing_handler_t lnp_addressing_handler[]; //! LNP host address extern unsigned char lnp_hostaddr; #ifdef CONF_RCX_PROTOCOL //! packets from remote have no ports extern lnp_remote_handler_t lnp_remote_handler; #endif /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! set the integrity layer packet handler extern inline void lnp_integrity_set_handler(lnp_integrity_handler_t handler) { lnp_integrity_handler = handler; } //! set an addressing layer packet handler for a port. extern inline void lnp_addressing_set_handler(unsigned char port, lnp_addressing_handler_t handler) { if (!(port & CONF_LNP_HOSTMASK)) // sanity check. lnp_addressing_handler[port] = handler; } //! set new LNP host address extern inline void lnp_set_hostaddr(unsigned char host) { lnp_hostaddr = ((host << 4) & CONF_LNP_HOSTMASK); } #ifdef CONF_RCX_PROTOCOL //! set the remote packet handler extern inline void lnp_remote_set_handler(lnp_remote_handler_t handler) { lnp_remote_handler = handler; } #endif #ifdef CONF_RCX_MESSAGE //! message variable extern unsigned char lnp_rcx_message; //! send a standard firmware message extern int send_msg(unsigned char msg); //! clear last message from standard firmware extern inline void clear_msg(void) { lnp_rcx_message = 0; } //! wait until receive a message wakeup_t msg_received(wakeup_t m); //! read received message from standard firmware extern inline unsigned char get_msg(void) { clear_msg(); if (wait_event(msg_received, 0) == 0) return 0; return lnp_rcx_message; } #endif //! send a LNP integrity layer packet of given length /*! \return 0 on success. */ extern int lnp_integrity_write(const unsigned char *data,unsigned char length); //! send a LNP addressing layer packet of given length /*! \return 0 on success. */ extern int lnp_addressing_write(const unsigned char *data,unsigned char length, unsigned char dest,unsigned char srcport); #endif // CONF_LNP #ifdef __cplusplus } #endif #endif // _lnp_h__ brickos-0.9.0/include/atomic.h0000644000175000017500000000363107775646041014001 0ustar cbcb/*! \file include/atomic.h \brief Interface: critical section management \author Henner Zeller Defines types and functions to implement atomic counters. */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Joseph A. Woolley */ #ifndef __atomic_h__ #define __atomic_h__ #include #ifdef CONF_ATOMIC #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** * The data type that allows for atomic count operations. * @see atomic_inc */ typedef volatile unsigned char atomic_t; /** * decrement atomic counter without interruption. * locks interrupts except NMI, decrements count * then restores interrupts. * @param counter the counter resource to be decremented * @see atomic_inc */ extern void atomic_dec(atomic_t* counter); /** * increment atomic counter without interruption. * locks interrupts except NMI, increments count * then restores interrupts. * @param counter the counter resource to be incremented * @see atomic_dec */ extern void atomic_inc(atomic_t* counter); #if defined(__cplusplus) } #endif /* __cplusplus */ #endif /* CONF_ATOMIC */ #endif /* __critsec_h__ */ brickos-0.9.0/include/conio.h0000644000175000017500000001467407775246710013644 0ustar cbcb/*! \file include/conio.h \brief Interface: console input / output \author Markus L. Noga \warning If CONF_LCD_REFRESH is set in config.h, the kernel will refresh the display automatically every 100ms. Otherwise, display updates are realized exclusively by lcd_refresh(). \par Display positions Digit display positions are denumerated from right to left, starting with 0 for the digit to the right of the running man. \par LCD Postions: 5 4 3 2 1 {man} 0 \par NOTE: Position 5 is only partially present on the LCD display. \par Native segment masks In these bitmasks, bit 0 toggles the middle segment. Bit 1 toggles the top right segment, and the remaining segments are denumerated counterclockwise. The dot isn't encoded because it is desirable */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __conio_h_ #define __conio_h_ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_CONIO #include #include #include /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #ifndef DOXYGEN_SHOULD_SKIP_INTERNALS //! Table: list of native patterns, one for each HEX character /*! \index HEX char value (0-9, a-f) */ extern const char hex_display_codes[]; #ifdef CONF_ASCII //! Table: list of native patterns, one for each ASCII character /*! \index ASCII char value (least significant 7 bits ONLY) */ extern const char ascii_display_codes[]; #endif // CONF_ASCII #endif // DOXYGEN_SHOULD_SKIP_INTERNALS /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// #endif // CONF_CONIO //! delay approximately ms mSec /*! \todo why is delay() in this file? */ extern void delay(unsigned ms); #ifdef CONF_CONIO // // display native mode segment mask at fixed display position // // encoding: middle=1, topr=2, top=4, ... (counterclockwise) // dot not included because not reliably present. // //! write bit-pattern for segments at position 0 of LCD extern void cputc_native_0(char mask); //! write bit-pattern for segments at position 1 of LCD extern void cputc_native_1(char mask); //! write bit-pattern for segments at position 2 of LCD extern void cputc_native_2(char mask); //! write bit-pattern for segments at position 3 of LCD extern void cputc_native_3(char mask); //! write bit-pattern for segments at position 4 of LCD extern void cputc_native_4(char mask); //! write bit-pattern for segments at position 5 of LCD extern void cputc_native_5(char mask); //! Set/Clear individual segments at specified position of LCD /*! (this is essentially a dispatcher for cputc_native_[0-5] functions) * \param mask the segment pattern to be displayed * \param pos the location at which to display the segment pattern * \return Nothing */ extern void cputc_native(char mask, int pos); //! write HEX digit to position 0 of LCD extern inline void cputc_hex_0(unsigned nibble) { cputc_native_0(hex_display_codes[(nibble) & 0x0f]); } //! write HEX digit to position 1 of LCD extern inline void cputc_hex_1(unsigned nibble) { cputc_native_1(hex_display_codes[(nibble) & 0x0f]); } //! write HEX digit to position 2 of LCD extern inline void cputc_hex_2(unsigned nibble) { cputc_native_2(hex_display_codes[(nibble) & 0x0f]); } //! write HEX digit to position 3 of LCD extern inline void cputc_hex_3(unsigned nibble) { cputc_native_3(hex_display_codes[(nibble) & 0x0f]); } //! write HEX digit to position 4 of LCD extern inline void cputc_hex_4(unsigned nibble) { cputc_native_4(hex_display_codes[(nibble) & 0x0f]); } //! write HEX digit to position 5 of LCD extern inline void cputc_hex_5(unsigned nibble) { cputc_native_5(hex_display_codes[(nibble) & 0x0f]); } //! Write HEX digit to specified position of LCD /*! (this is essentially a dispatcher for cputc_hex_[0-5] functions) * \param c the HEX digit to be displayed * \param pos the location at which to display the HEX digit * \return Nothing */ extern inline void cputc_hex(char c, int pos) { cputc_native(hex_display_codes[(c) & 0x7f], pos); } //! Write a HEX word to LCD extern void cputw(unsigned word); #ifdef CONF_ASCII //! write ASCII char to position 0 of LCD extern inline void cputc_0(unsigned c) { cputc_native_0(ascii_display_codes[(c) & 0x7f]); } //! write ASCII char to position 1 of LCD extern inline void cputc_1(unsigned c) { cputc_native_1(ascii_display_codes[(c) & 0x7f]); } //! write ASCII char to position 2 of LCD extern inline void cputc_2(unsigned c) { cputc_native_2(ascii_display_codes[(c) & 0x7f]); } //! write ASCII char to position 3 of LCD extern inline void cputc_3(unsigned c) { cputc_native_3(ascii_display_codes[(c) & 0x7f]); } //! write ASCII char to position 4 of LCD extern inline void cputc_4(unsigned c) { cputc_native_4(ascii_display_codes[(c) & 0x7f]); } //! write ASCII char to position 5 of LCD extern inline void cputc_5(unsigned c) { cputc_native_5(ascii_display_codes[(c) & 0x7f]); } //! Write ASCII character to specified position of LCD /*! (this is essentially a dispatcher for cputc_[0-5] functions) * \param c the ASCII char to be displayed * \param pos the location at which to display the ASCII char * \return Nothing */ extern inline void cputc(char c, int pos) { cputc_native(ascii_display_codes[(c) & 0x7f], pos); } // //! Write string s to LCD (Only first 5 chars) // extern void cputs(char *s); // //! clear user portion of LCD // extern void cls(); #else #define cls() lcd_clear() #endif // CONF_ASCII #else #define cls() lcd_clear() #endif // CONF_CONIO #ifdef __cplusplus } #endif #endif // __conio_h__ brickos-0.9.0/include/critsec.h0000644000175000017500000000717110005036567014146 0ustar cbcb/*! \file include/critsec.h \brief Interface: critical section management \author Joseph A. Woolley Defines types and functions to implement critical sections. */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Joseph A. Woolley */ #if !defined(__critsec_h__) #define __critsec_h__ #if defined(__cplusplus) extern "C" { #endif // __cplusplus #include #if defined(CONF_TM) && defined(CONF_CRITICAL_SECTIONS) #include #include #ifndef DOXYGEN_SHOULD_SKIP_INTERNALS //! critical section data structure /*! tracks current count (level of nesting) and the task that is in the critical section(s) count will be zero when no tasks are within a critical section. */ struct critsec { atomic_t count; tdata_t* task; }; #endif // DOXYGEN_SHOULD_SKIP_INTERNALS //! critical section type definition typedef struct critsec critsec_t; //! don't use locked_decrement anymore but atomic_dec() /*! @deprecated use atomic_dec() instead */ #define locked_decrement(counter) atomic_dec(counter) //! wakeup when critical section is available /*! wakeup function used to sleep a task until a critical section is available. called while processing an interrupt, so interrupts are already disabled. \return 0 to continue waiting, non-zero to wakeup task. \sa enter_critical_section */ extern wakeup_t wait_critical_section(wakeup_t data); //! initialize critical section /*! sets count field of critical section to zero \param cs pointer to critical section (critsec_t) \return always 0 \sa enter_critical_section \sa leave_critical_section \sa destroy_critical_section */ #define initialize_critical_section(cs) (cs)->count=0 //! enter critical section /*! block other tasks if they attempt to enter a region of code protected by the same critical section. \param cs pointer to critical section (critsec_t) \return 1 if successful, 0 if failure \sa initialize_critical_section \sa leave_critical_section \sa destroy_critical_section */ extern int enter_critical_section(critsec_t* cs); //! leave critical section /*! allow other tasks to enter critical regions of code protected by this critical section. \param cs pointer to critical section (critsec_t) \return results of locked_decrement (always 0) \sa initialize_critical_section \sa enter_critical_section \sa destroy_critical_section */ #define leave_critical_section(cs) atomic_dec(&(cs)->count) //! destroy critical section (does nothing) /*! currently there are no resources that are dynamically allocated. \param cs pointer to critical section (critsec_t) \sa initialize_critical_section \sa enter_critical_section \sa leave_critical_section */ #define destroy_critical_section(cs) #endif // CONF_TM && CONF_CRITICAL_SECTIONS #if defined(__cplusplus) } #endif // __cplusplus #endif // __critsec_h__ brickos-0.9.0/include/dbutton.h0000644000175000017500000000431707777403700014201 0ustar cbcb/*! \file include/dbutton.h \brief Interface: query raw button states \author Markus L. Noga \warning this is raw, unprocessed input. buttons will bounce. please use dkey functions instead. */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __dbutton_h__ #define __dbutton_h__ #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////////////// #define BUTTON_ONOFF 0x0002 //!< the on/off button #define BUTTON_RUN 0x0004 //!< the run button #define BUTTON_VIEW 0x4000 //!< the view button #define BUTTON_PROGRAM 0x8000 //!< the program button // buttons are active low // //! true if any of the specified buttons is released // #define RELEASED(state,button) ((state) & (button)) //! true if all of the specified buttons are pressed // #define PRESSED(state,button) (!RELEASED(state,button)) /////////////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////////////// //! get button states /*! masks as defined above */ extern inline int dbutton(void) { int rv; __asm__ __volatile__("\n\ mov.b @_PORT4,%0l\n\ mov.b @_PORT7,%0h\n\ " :"=r"(rv) // output : // input :"cc" // clobbered ); return rv; } #ifdef __cplusplus } #endif #endif // __dbutton_h__ brickos-0.9.0/include/dirpd.h0000644000175000017500000000317407543506517013625 0ustar cbcb/*! \file include/dirpd.h \brief Interface: direct control of Dual IR Proximity Detector \author Mark Falco (falcom@onebox.com) This code applies to the Dual IR Proximity Detector that can be ordered from http://www.techno-stuff.com. You may need to modify the ranges */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * Contributor(s): Mark Falco (falcom@onebox.com) */ #ifndef DIRPD_H #define DIRPD_H //0xdec0 - sampled value for object to left #define DIRPD_LEFT_S 0xd000 #define DIRPD_LEFT_E 0xe000 //0xb700 - sampled value for object to right #define DIRPD_RIGHT_S 0xb000 #define DIRPD_RIGHT_E 0xbfff //0xffc0 - sampled value for object to center #define DIRPD_CENTER_S 0xf000 #define DIRPD_CENTER_E 0xffff //0x8d40 - sampled value for no object #define DIRPD_NONE_S 0x8000 #define DIRPD_NONE_E 0x8fff //pass in a value obtained from an active sensor #define DIRPD_LEFT(araw) (araw >= DIRPD_LEFT_S && araw <= DIRPD_LEFT_E) #define DIRPD_RIGHT(araw) (araw >= DIRPD_RIGHT_S && araw <= DIRPD_RIGHT_E) #define DIRPD_CENTER(araw) (araw >= DIRPD_CENTER_S && araw <= DIRPD_CENTER_E) #define DIRPD_NONE(araw) (araw >= DIRPD_NONE_S && araw <= DIRPD_NONE_E) #endif //DIRPD_H brickos-0.9.0/include/dkey.h0000644000175000017500000000461007535330360013443 0ustar cbcb/*! \file include/dkey.h \brief Interface: debounced key driver \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __dkey_h__ #define __dkey_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_DKEY #include /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #define KEY_ONOFF 0x01 //!< the on/off key is pressed #define KEY_RUN 0x02 //!< the run key is pressed #define KEY_VIEW 0x04 //!< the view key is pressed #define KEY_PRGM 0x08 //!< the program key is pressed #define KEY_ANY 0x0f //!< any of the keys /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// //! the currently active keys /*! this is a bitmask - multi-key combinations are admissible. */ extern volatile unsigned char dkey_multi; //! the current key /*! this is not a bitmask - at most one key at a time. */ extern volatile unsigned char dkey; /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! wakeup if any of the given keys is pressed. // extern wakeup_t dkey_pressed(wakeup_t data); //! wakeup if all of the given keys are released. // extern wakeup_t dkey_released(wakeup_t data); //! wait for keypress and return key code. /*! key combinations not admissible. */ extern int getchar(); #endif // CONF_DKEY #ifdef __cplusplus } #endif #endif // __dkey_h__ brickos-0.9.0/include/dlcd.h0000644000175000017500000001154407535330361013422 0ustar cbcb/*! \file include/dlcd.h \brief Interface: direct control of LCD display \author Markus L. Noga \warning If CONF_LCD_REFRESH is set in config.h, the kernel will refresh the display automatically every 100ms. Otherwise, display updates are realized exclusively by lcd_refresh(). */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __dlcd_h__ #define __dlcd_h__ #ifdef __cplusplus extern "C" { #endif #include /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// // LCD segment control byte and bit locations // 0xNNNN,0xM => Mth bit (value 1< */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __dmotor_h__ #define __dmotor_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_DMOTOR /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// //! the motor directions typedef enum { off = 0, //!< freewheel fwd = 1, //!< forward rev = 2, //!< reverse brake = 3 //!< hold current position } MotorDirection; #ifndef DOXYGEN_SHOULD_SKIP_INTERNALS //! the motor status type. typedef struct { union { unsigned assembler; //!< assures word alignment for assembler struct { unsigned char delta; //!< the speed setting volatile unsigned char sum; //!< running sum } c; } access; //!< provides access from C and assembler unsigned char dir; //!< output pattern when sum overflows } MotorState; #endif // DOXYGEN_SHOULD_SKIP_INTERNALS #define MIN_SPEED 0 //!< minimum motor speed #define MAX_SPEED 255 //!< maximum motor speed /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// //! motor drive patterns /*! to be indexed with MotorDirections \sa MotorDirections */ extern const unsigned char dm_a_pattern[4], dm_b_pattern[4], dm_c_pattern[4]; extern MotorState dm_a, //!< motor A state dm_b, //!< motor B state dm_c; //!< motor C state /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// #ifdef CONF_VIS /* ** motor_*_dir() functions will display direction arrows, so ** define them in kernel/dmotor.c */ extern void motor_a_dir(MotorDirection dir); //!< set motor A direction to dir extern void motor_b_dir(MotorDirection dir); //!< set motor B direction to dir extern void motor_c_dir(MotorDirection dir); //!< set motor C direction to dir #else /* ** No display, so make these functions inline */ //! set motor A direction /*! \param dir the direction */ extern inline void motor_a_dir(MotorDirection dir) { dm_a.dir = dm_a_pattern[dir]; } //! set motor B direction /*! \param dir the direction */ extern inline void motor_b_dir(MotorDirection dir) { dm_b.dir = dm_b_pattern[dir]; } //! set motor C direction /*! \param dir the direction */ extern inline void motor_c_dir(MotorDirection dir) { dm_c.dir = dm_c_pattern[dir]; } #endif // ifdef CONF_VIS //! set motor A speed /*! \param speed the speed */ extern inline void motor_a_speed(unsigned char speed) { dm_a.access.c.delta = speed; } //! set motor B speed /*! \param speed the speed */ extern inline void motor_b_speed(unsigned char speed) { dm_b.access.c.delta = speed; } //! set motor C speed /*! \param speed the speed */ extern inline void motor_c_speed(unsigned char speed) { dm_c.access.c.delta = speed; } #endif // CONF_DMOTOR #ifdef __cplusplus } #endif #endif // __dmotor_h__ brickos-0.9.0/include/dsensor.h0000644000175000017500000001672107543442414014175 0ustar cbcb/*! \file include/dsensor.h \brief Interface: direct reading of sensors \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ /* * 2000.04.30 - Paolo Masetti * * - Some typecast & ()s in macros to avoid strange effects * using them... * * 2000.09.06 - Jochen Hoenicke * * - Added velocity calculation for rotation sensor. */ #ifndef __dsensor_h__ #define __dsensor_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_DSENSOR #include #include /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// // //!< the raw sensors // #define SENSOR_1 AD_C //!< Sensor on input pad 1 #define SENSOR_2 AD_B //!< Sensor on input pad 2 #define SENSOR_3 AD_A //!< Sensor on input pad 3 #define BATTERY AD_D //!< Battery sensor // //!< active light sensor: estimated raw values // #define LIGHT_RAW_BLACK 0xffc0 //!< active light sensor raw black value #define LIGHT_RAW_WHITE 0x5080 //!< active light sensor raw white value // // convert raw values to 0 (dark) .. LIGHT_MAX (bright) // roughly 0-100. // #define LIGHT(a) (147 - ds_scale(a)/7) //!< map light sensor to 0..LIGHT_MAX #define LIGHT_MAX LIGHT(LIGHT_RAW_WHITE) //!< maximum decoded value // // processed active light sensor // #define LIGHT_1 LIGHT(SENSOR_1) //!< light sensor on input 1 #define LIGHT_2 LIGHT(SENSOR_2) //!< light sensor on input 2 #define LIGHT_3 LIGHT(SENSOR_3) //!< light sensor on input 3 #ifdef CONF_DSENSOR_ROTATION // // processed rotation sensor // #define ROTATION_1 (ds_rotations[2]) //!< rotation sensor on input 1 #define ROTATION_2 (ds_rotations[1]) //!< rotation sensor on input 2 #define ROTATION_3 (ds_rotations[0]) //!< rotation sensor on input 3 #endif #ifdef CONF_DSENSOR_VELOCITY // // processed velocity sensor // #define VELOCITY_1 (ds_velocities[2]) #define VELOCITY_2 (ds_velocities[1]) #define VELOCITY_3 (ds_velocities[0]) #endif #ifdef CONF_DSENSOR_MUX #define SENSOR_1A (ds_muxs[2][0]) #define SENSOR_1B (ds_muxs[2][1]) #define SENSOR_1C (ds_muxs[2][2]) #define SENSOR_2A (ds_muxs[1][0]) #define SENSOR_2B (ds_muxs[1][1]) #define SENSOR_2C (ds_muxs[1][2]) #define SENSOR_3A (ds_muxs[0][0]) #define SENSOR_3B (ds_muxs[0][1]) #define SENSOR_3C (ds_muxs[0][2]) #endif //CONF_DSENSOR_MUX //! Convert raw data to touch sensor (0: off, else pressed) #define TOUCH(a) ((unsigned int)(a) < 0x8000) // Processed touch sensors // #define TOUCH_1 TOUCH(SENSOR_1) //!< touch sensor on input 1 #define TOUCH_2 TOUCH(SENSOR_2) //!< touch sensor on input 2 #define TOUCH_3 TOUCH(SENSOR_3) //!< touch sensor on input 3 #define ds_scale(x) ((unsigned int)(x)>>6) //!< mask off bottom 6 bits #define ds_unscale(x) ((unsigned int)(x)<<6) //!< leave room for bottom 6 bits /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// // // don't manipulate directly unless you know what you're doing! // extern unsigned char ds_activation; //!< activation bitmask #ifdef CONF_DSENSOR_ROTATION extern unsigned char ds_rotation; //!< rotation bitmask extern volatile int ds_rotations[3]; //!< rotational position #endif #ifdef CONF_DSENSOR_VELOCITY extern volatile int ds_velocities[3]; //!< rotational velocity #endif #ifdef CONF_DSENSOR_MUX extern unsigned char ds_mux; //!< mux bitmask extern volatile int ds_muxs[3][3]; //!< mux ch values #endif //CONF_DSENSOR_MUX /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! set sensor mode to active (light sensor emits light, rotation works) /*! \param sensor: &SENSOR_1,&SENSOR_2,&SENSOR_3 */ extern inline void ds_active(volatile unsigned *sensor) { if (sensor == &SENSOR_3) bit_set(&ds_activation, 0); else if (sensor == &SENSOR_2) bit_set(&ds_activation, 1); else if (sensor == &SENSOR_1) bit_set(&ds_activation, 2); } //! set sensor mode to passive (light sensor detects ambient light) /*! \param sensor: &SENSOR_1,&SENSOR_2,&SENSOR_3 */ extern inline void ds_passive(volatile unsigned *sensor) { if (sensor == &SENSOR_3) { bit_clear(&ds_activation, 0); bit_clear(&PORT6, 0); } else if (sensor == &SENSOR_2) { bit_clear(&ds_activation, 1); bit_clear(&PORT6, 1); } else if (sensor == &SENSOR_1) { bit_clear(&ds_activation, 2); bit_clear(&PORT6, 2); } } #ifdef CONF_DSENSOR_ROTATION //! set rotation to an absolute value /*! \param sensor one of &SENSOR_1, &SENSOR_2, or &SENSOR_3 \param pos the current rotational postion (typically use 0 here) \return Nothing The axis should be inert during the function call. */ extern void ds_rotation_set(volatile unsigned *sensor, int pos); //! start tracking rotation sensor /*! \param sensor: &SENSOR_1,&SENSOR_2,&SENSOR_3 */ extern inline void ds_rotation_on(volatile unsigned *sensor) { if (sensor == &SENSOR_3) bit_set(&ds_rotation, 0); else if (sensor == &SENSOR_2) bit_set(&ds_rotation, 1); else if (sensor == &SENSOR_1) bit_set(&ds_rotation, 2); } //! stop tracking rotation sensor /*! \param sensor: &SENSOR_1,&SENSOR_2,&SENSOR_3 */ extern inline void ds_rotation_off(volatile unsigned *sensor) { if (sensor == &SENSOR_3) bit_clear(&ds_rotation, 0); else if (sensor == &SENSOR_2) bit_clear(&ds_rotation, 1); else if (sensor == &SENSOR_1) bit_clear(&ds_rotation, 2); } #endif // CONF_DSENSOR_ROTATION #ifdef CONF_DSENSOR_MUX #define DS_MUX_POST_SWITCH 150 //! start multiplexing /*! \param sensor: &SENSOR_1,&SENSOR_2,&SENSOR_3 \param ch1: indicates if ch1 is to be scanned \param ch2: indicates if ch2 is to be scanned \param ch3: indicates if ch3 is to be scanned ch1-ch3 also indicates how long to wait after switching to a channel before reading from it. DS_MUX_POST_SWITCH defines a good default, but some sensors require more time, others may work with less. specifying 0 will keep the port from being switched to or read */ extern void ds_mux_on(volatile unsigned *sensor, unsigned int ch1, unsigned int ch2, unsigned int ch3); //! stop multiplexing /*! \param sensor: &SENSOR_1,&SENSOR_2,&SENSOR_3 */ extern inline void ds_mux_off(volatile unsigned *sensor) { if (sensor == &SENSOR_3) bit_clear(&ds_mux, 0); else if (sensor == &SENSOR_2) bit_clear(&ds_mux, 1); else if (sensor == &SENSOR_1) bit_clear(&ds_mux, 2); }//endof ds_mux_off #endif // CONF_DSENSOR_MUX #endif // CONF_DSENSOR #ifdef __cplusplus } #endif #endif // __dsensor_h__ brickos-0.9.0/include/dsound.h0000644000175000017500000001525007775657433014030 0ustar cbcb/*! \file include/dsound.h \brief Interface: direct control of sound \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Froods */ #ifndef __dsound_h__ #define __dsound_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_DSOUND #include #include /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// /// the note structure describing a single note. /// \note a song to play is made up of an array of these structures /// which is then handed to dsound_play() [in C] or Sound::play() [in C++]. /// /// The last entry in the list should have the {pitch} value set to \ref PITCH_END /// /// Rests should be specified by placing \ref PITCH_PAUSE in the {pitch} value. /// The duration of the rest is placed in {length}. typedef struct { unsigned char pitch; //!< note pitch, 0 ^= A_0 (~55 Hz) unsigned char length; //!< note length in 1/16ths } note_t; //! \defgroup noteDurations standard note/rest durations //@{ /// Whole note in terms of sixteenths #define WHOLE 16 /// Half note in terms of sixteenths #define HALF 8 /// Quater note in terms of sixteenths #define QUARTER 4 /// Eighth note in terms of sixteenths #define EIGHTH 2 //@} // PITCH_H is European equivalent to American B note. //! \defgoup notePitches standard note pitch values //@{ /// Note Pitch Value #define PITCH_A0 0 #define PITCH_Am0 1 #define PITCH_H0 2 #define PITCH_C1 3 #define PITCH_Cm1 4 #define PITCH_D1 5 #define PITCH_Dm1 6 #define PITCH_E1 7 #define PITCH_F1 8 #define PITCH_Fm1 9 #define PITCH_G1 10 #define PITCH_Gm1 11 #define PITCH_A1 12 #define PITCH_Am1 13 #define PITCH_H1 14 #define PITCH_C2 15 #define PITCH_Cm2 16 #define PITCH_D2 17 #define PITCH_Dm2 18 #define PITCH_E2 19 #define PITCH_F2 20 #define PITCH_Fm2 21 #define PITCH_G2 22 #define PITCH_Gm2 23 #define PITCH_A2 24 #define PITCH_Am2 25 #define PITCH_H2 26 #define PITCH_C3 27 #define PITCH_Cm3 28 #define PITCH_D3 29 #define PITCH_Dm3 30 #define PITCH_E3 31 #define PITCH_F3 32 #define PITCH_Fm3 33 #define PITCH_G3 34 #define PITCH_Gm3 35 #define PITCH_A3 36 #define PITCH_Am3 37 #define PITCH_H3 38 #define PITCH_C4 39 #define PITCH_Cm4 40 #define PITCH_D4 41 #define PITCH_Dm4 42 #define PITCH_E4 43 #define PITCH_F4 44 #define PITCH_Fm4 45 #define PITCH_G4 46 #define PITCH_Gm4 47 #define PITCH_A4 48 #define PITCH_Am4 49 #define PITCH_H4 50 #define PITCH_C5 51 #define PITCH_Cm5 52 #define PITCH_D5 53 #define PITCH_Dm5 54 #define PITCH_E5 55 #define PITCH_F5 56 #define PITCH_Fm5 57 #define PITCH_G5 58 #define PITCH_Gm5 59 #define PITCH_A5 60 #define PITCH_Am5 61 #define PITCH_H5 62 #define PITCH_C6 63 #define PITCH_Cm6 64 #define PITCH_D6 65 #define PITCH_Dm6 66 #define PITCH_E6 67 #define PITCH_F6 68 #define PITCH_Fm6 69 #define PITCH_G6 70 #define PITCH_Gm6 71 #define PITCH_A6 72 #define PITCH_Am6 73 #define PITCH_H6 74 #define PITCH_C7 75 #define PITCH_Cm7 76 #define PITCH_D7 77 #define PITCH_Dm7 78 #define PITCH_E7 79 #define PITCH_F7 80 #define PITCH_Fm7 81 #define PITCH_G7 82 #define PITCH_Gm7 83 #define PITCH_A7 84 #define PITCH_Am7 85 #define PITCH_H7 86 #define PITCH_C8 87 #define PITCH_Cm8 88 #define PITCH_D8 89 #define PITCH_Dm8 90 #define PITCH_E8 91 #define PITCH_F8 92 #define PITCH_Fm8 93 #define PITCH_G8 94 #define PITCH_Gm8 95 #define PITCH_A8 96 //@} //! specify a pause (rest) #define PITCH_PAUSE 97 //! maximum pitch value #define PITCH_MAX 98 //! mark the end of a list of note_t entries #define PITCH_END 255 //! system sounds #define DSOUND_BEEP 0 //! max system sound #define DSOUND_SYS_MAX 1 //! default duration of 1/16th note in ms #define DSOUND_DEFAULT_16th_ms 200 //! default duration internote spacing in ms #define DSOUND_DEFAULT_internote_ms 15 /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// #ifndef DOXYGEN_SHOULD_SKIP_INTERNALS extern unsigned dsound_16th_ms; //!< length of 1/16 note in ms extern unsigned dsound_internote_ms; //!< length of internote spacing in ms extern volatile note_t *dsound_next_note; //!< pointer to current note extern volatile time_t dsound_next_time; //!< when to play next note extern const note_t *dsound_system_sounds[]; //!< system sound data #endif // DOXYGEN_SHOULD_SKIP_INTERNALS /////////////////////////////////////////////////////////////////////// // // User functions // /////////////////////////////////////////////////////////////////////// //! play a sequence of notes static inline void dsound_play(const note_t *notes) { dsound_next_note=(volatile note_t*) notes; dsound_next_time=0; } //! play a system sound static inline void dsound_system(unsigned nr) { if(nr */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __mem_h__ #define __mem_h__ /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #define NULL ((void*)0) //!< null pointer value typedef unsigned size_t; //!< data type for memory sizes #endif brickos-0.9.0/include/persistent.h0000644000175000017500000000335107535330362014712 0ustar cbcb/*! \file include/persistent.h \brief Interface: Definitions for persistent data \author Eddie C. Dost */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __persistent_h_ #define __persistent_h_ #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// //! Define storage persistent across different runs of a program /*! This macro is used to mark initialized data (doesn't apply to uninitialized data) as `persistent' data. This data will be saved across different runs of the program. Usage: You should insert __persistent between the variable name and equal sign followed by value, e.g: static int counter __persistent = 0; static char data[] __persistent = { 0x32, 0x36, ... }; */ #define __persistent __attribute__ ((__section__ (".persist"))) #ifdef __cplusplus } #endif #endif // __persistent_h__ brickos-0.9.0/include/remote.h0000644000175000017500000000514707543452540014014 0ustar cbcb/*! \file include/remote.h \brief Interface: LEGO Infrared Remote Control \author Ross Crawford */ /* * Copyright (c) 2001 Ross Crawford * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * */ #ifndef _REMOTE_H #define _REMOTE_H #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_LR_HANDLER //! timeout value in mSec #define LR_TIMEOUT 100 //! The message #1 key #define LRKEY_M1 0x1 //! The message #2 key #define LRKEY_M2 0x2 //! The message #3 key #define LRKEY_M3 0x4 //! Motor-A forward (up) #define LRKEY_A1 0x8 //! Motor-B forward (up) #define LRKEY_B1 0x10 //! Motor-C forward (up) #define LRKEY_C1 0x20 //! Motor-A reverse (down) #define LRKEY_A2 0x40 //! Motor-B reverse (down) #define LRKEY_B2 0x80 //! Motor-C reverse (down) #define LRKEY_C2 0x100 //! Run Program 1 #define LRKEY_P1 0x200 //! Run Program 2 #define LRKEY_P2 0x400 //! Run Program 3 #define LRKEY_P3 0x800 //! Run Program 4 #define LRKEY_P4 0x1000 //! Run Program 5 #define LRKEY_P5 0x2000 //! Stop key #define LRKEY_STOP 0x4000 //! Beep Key #define LRKEY_BEEP 0x8000 //! enumerate our event types enum _evt { LREVT_KEYON = 1, //!< a key on the remote was pressed LREVT_KEYOFF = 2 //!< a key on the remote was released } EventType; //!< the LEGO IR Remote event types //! the remote key handler type /*! \param event_type was key pressed or released? * \param key the key, on the remote, that was pressed/released * \return 0 if not processed, otherwise non-zero. */ typedef int (*lr_handler_t) (unsigned int, unsigned int); //! remote handler extern lr_handler_t lr_handler; //! start the LEGO IR Remote subsystem void lr_startup(void); //! initialize the LEGO IR Remote subsystem void lr_init(void); //! stop the LEGO IR Remote subsystem void lr_shutdown(void); //! set a new handler for LEGO IR Remote messages /*! \param handler pointer to a function which is to be the * processing function for received messages * \return Nothing */ extern inline void lr_set_handler(lr_handler_t handler) { lr_handler = handler; } //! dummy remote event handler #define LR_DUMMY_HANDLER ((lr_handler_t)0) #endif // CONF_TM #ifdef __cplusplus } #endif #endif brickos-0.9.0/include/semaphore.h0000644000175000017500000001162710005036571014471 0ustar cbcb/*! \file include/semaphore.h \brief Interface: POSIX 1003.1b semaphores for task synchronization \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Henner Zeller (sem_timedwait()) */ #ifndef __semaphore_h__ #define __semaphore_h__ #ifdef __cplusplus extern "C" { #endif #include #include /* time_t */ #include #ifdef CONF_SEMAPHORES /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// typedef atomic_t sem_t; //!< the semaphore data-type #define EAGAIN 0xffff //!< the error code /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! Initialize a semaphore /*! sem_init() initializes the semaphore object pointed to by * {sem} by setting its internal count to {value} * \param sem a pointer to the semaphore to be initialized * \param value the initial value for count * \param pshared (this argument is ignored) * \return (always 0) */ extern inline int sem_init(sem_t * sem, int pshared, unsigned int value) { *sem = (sem_t) value; return 0; } //! Wait for semaphore (blocking) /*! sem_wait() suspends the calling task until the semaphore * pointed to by {sem} has non-zero count. It then atomically * decreases the semaphore count. * \param sem a pointer to the semaphore on which to wait * \return 0 if wait returned immediately, EAGAIN if task did have to * wait for the semaphore. */ extern int sem_wait(sem_t * sem); /** * Wait for semaphore (blocking with timeout). * * sem_timedwait() suspends the calleing task until either the semaphore * pointed to by {sem} has non-zero count or the given absolute timeout * passed. Note the timeout is an ABSOLUTE time not relative (yes the standard * is that stupid); so if you want a relative waiting time, call the * function with get_system_up_time() + relativeTime. * * If the semaphore reached a non-zero count its value is then atomically * decreased. * * @param sem a pointer to the semaphore on which to wait * @param abs_timeout the absolute timeout of this operation. If the * semaphore cannot be locked up to this time, this function returns. * @return 0 if the semaphore could successfully be locked; -1 if the * timeout has been reached. * @note in IEEE 1003.1, the timeout is passed as a struct timeval not * a time_t. */ extern int sem_timedwait(sem_t * sem, const time_t abs_timeout); //! Try a wait for semaphore (non-blocking) /*! sem_trywait() is a non-blocking variant of sem_wait(). If the * semaphore pointed to by {sem} has non-zero count, the count * is atomically decreased and sem_trywait immediately * returns 0. If the semaphore count is zero, sem_trywait * immediately returns with error EAGAIN. * \param sem a pointer to the semaphore on which to attempt a wait * \return 0 if decremented the semaphore or EAGAIN if can't * * NOTE: this is IRQ handler safe. */ extern int sem_trywait(sem_t * sem); //! Post a semaphore /*! sem_post() atomically increases the count of the semaphore * pointed to by {sem}. This function never blocks and can * safely be used in asynchronous signal handlers. * \param sem a pointer to the semaphore to be signaled * \return (always returns 0) */ extern inline int sem_post(sem_t * sem) { atomic_inc(sem); return 0; } // //! Get the semaphore value // extern inline int sem_getvalue(sem_t * sem, int *sval) { *sval = *sem; return 0; } //! We're done with the semaphore, destroy it /*! sem_destroy() destroys a semaphore object, freeing the * resources it might hold. * \param sem a pointer to the semaphore to be destroyed * \return (always returns 0) * * NOTE: No tasks should be waiting on * the semaphore at the time sem_destroy is called. */ extern inline int sem_destroy(sem_t * sem) { return 0; } #endif // CONF_SEMAPHORES #ifdef __cplusplus } #endif #endif // __semaphore_h__ brickos-0.9.0/include/setjmp.h0000644000175000017500000000464507623100544014016 0ustar cbcb/*! \file include/setjmp.h \brief Non-local goto as specified in ANSI C \author Torsten Landschoff */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * */ #ifndef __setjmp_h__ #define __setjmp_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_SETJMP /*----[ Data type definitions ]-----------------------------------------*/ //! Information stored for non-local jumps /*! * Stores the machine status for non-local jumps. * The H8/300 CPU has the following state information: * - 8 registers of 16 bit each (r0, r1, ..., r7) * - the program counter * - a condition code register of a single byte * To allow execution of a longjmp we have to return to the state saved * in a jmp_buf just like from a subroutine invocation. The machine * description of gcc for the H8 says that r0,r1,r2,r3 are destroyed * by a subroutine call. Therefore we need to save the condition code, * the program counter of the caller (where we want to return), and the * registers r4, r5, r6, r7. We are using 6 words for that and ignore * a byte at restore time. */ typedef int jmp_buf[6]; /*----[ Function prototypes ]-------------------------------------------*/ //! Save execution context for non-local goto /*! * Records the current machine status for a non-local goto. The saved * status will be invalidated when returning from the stack frame * where it was set. * @param env buffer for saved machine status * @return 0 when returning directly (after saving the state), or * whatever was given to longjmp when returning via a non-local goto */ extern int setjmp(jmp_buf env); //! Non-local jump to saved machine context /*! * Restores a machine context as saved via setjmp. * @param env the buffer of the saved machine status * @param val the value to return from the setjmp function */ extern void longjmp(jmp_buf env, int val); #endif // CONF_SETJMP #ifdef __cplusplus } #endif #endif // __setjmp_h__ brickos-0.9.0/include/stdlib.h0000644000175000017500000000667307541715440014006 0ustar cbcb/*! \file include/stdlib.h \brief Interface: reduced standard C library This file describes the public programming interface for memory management services and random number services \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __stdlib_h__ #define __stdlib_h__ #ifdef __cplusplus extern "C" { #endif #include /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// // // Standard memory management. // See the Linux man pages for details. // //! allocate and return pointer to initialized memory /*! calloc() allocates memory for an array of {nmemb} elements of {size} bytes * each and returns a pointer to the allocated memory. The memory is filled * with zero values. * \param nmemb the number of members to allocate * \param size the size (in bytes) of each member to be allocated * \return a pointer to the allocated memory (or NULL if failed) * * NOTE: content of the returned memory is initialized by this routine * \bug multiplication overflow (elements * size) is not detected * */ extern void *calloc(size_t nmemb, size_t size); //! allocate and return pointer to uninitialized memory /*! malloc() allocates {size} bytes of memory and returns a pointer to it. * \param size the number of bytes of memory to be allocated * \return a pointer to the allocated memory (or NULL if failed) * * NOTE: content of the returned memory is not initialized by this routine */ extern void *malloc(size_t size); //! return the allocated memory to memory management. /*! free() frees the memory space pointed to by {ptr}, which must have been * returned by a previous call to malloc(), or calloc(). Other- * wise, or if free(ptr) has already been called before, undefined * behaviour occurs. If ptr is NULL, no operation is performed. * \param ptr a pointer to previously allocated memory * \return Nothing */ extern void free(void *ptr); //! generate a random number /*! The random() function returns successive pseudo-random numbers * \return a random number in the range from 0 to RAND_MAX */ extern long int random(void); //! seed the random number generator /*! The srandom() function sets its argument as the seed for a new sequence * of pseudo-random integers to be returned by random(). These sequences * are repeatable by calling srandom() with the same seed value. If no * seed value is provided, the random() function is automatically seeded * with a value of 1. * \param seed * \return Nothing */ extern void srandom(unsigned int seed); #ifdef __cplusplus } #endif #endif // __stdlib_h__ brickos-0.9.0/include/string.h0000644000175000017500000000420107535330362014013 0ustar cbcb/*! \file include/string.h \brief Interface: string functions \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __string_h__ #define __string_h__ #ifdef __cplusplus extern "C" { #endif #include /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! copy memory block from src to dest. /*! \param dest destination \param src source \param size number of bytes to copy \warning behaviour is undefined in case source and destination blocks overlap. */ extern void *memcpy(void *dest, const void *src, size_t size); //! fill memory block with a byte value. /*! \param s start \param c byte fill value \param n number of bytes to fill */ extern void *memset(void *s, int c, size_t n); //! Copy null-terminated string from src to dest /*! \param src source \param dest destination \return pointer to dest */ extern char *strcpy(char *dest, const char *src); //! Determine string length /*! \param s string \return string length */ extern int strlen(const char *s); //! Compare two strings /*! \param s1 first string \param s2 second string \return <0: s10: s1>s2 */ extern int strcmp(const char *s1, const char *s2); #ifdef __cplusplus } #endif #endif // __string_h__ brickos-0.9.0/include/swmux.h0000644000175000017500000000463307543506517013707 0ustar cbcb/*! \file include/swmux.h \brief Interface: direct control of a touch sensor multiplexor \author Mark Falco (falcom@onebox.com) The TouchSensor Multiplexor is a device which allows three TouchSensors to be connected to a single input port. This code applies to the touch sensor multiplexor (swmux) that can be ordered from http://www.techno-stuff.com, tweaking the ranges in swmux.c should make it work with other similar multiplexors */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Mark Falco (falcom@onebox.com) */ #ifndef SWMUX_H #define SWMUX_H #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_DSENSOR #ifdef CONF_DSENSOR_SWMUX /*bit masks for for checking the parsed value*/ #define SWMUX_A_MASK 1 #define SWMUX_B_MASK 2 #define SWMUX_C_MASK 4 #define SWMUX_D_MASK 8 #define SWMUX_ERROR_MASK 16 //value not recognized /*Takes in raw sensor values and converts into a bitfield indicating the state of the attached touch sensors. If there is an error interepting the raw sensor value the error bit will be set, in which case the other bits should be ignored. The bitfield is EDCBA, and can be examined by "anding" the field with the above masks. The E in EDCBA is error in case you're wondering. */ unsigned char swmux_bits(unsigned int raw); //these macros will make do the anding for you #define SWMUX_A(bitfield) (bitfield & SWMUX_A_MASK) #define SWMUX_B(bitfield) (bitfield & SWMUX_B_MASK) #define SWMUX_C(bitfield) (bitfield & SWMUX_C_MASK) #define SWMUX_D(bitfield) (bitfield & SWMUX_D_MASK) #define SWMUX_ERROR(bitfield) (bitfield & SWMUX_ERROR_MASK) #ifdef __cplusplus }//extern C #endif #endif //CONF_DSENSOR_SWMUX #endif //CONF_DSENSOR #endif //SWMUX_H brickos-0.9.0/include/template.h0000644000175000017500000000312407535330363014324 0ustar cbcb/*! \file include/template.h \brief EMPTY FILE. Copy to use. Use this to start a new interface by copying to new name then editing \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __template_h__ #define __template_h__ #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// #ifdef __cplusplus } #endif #endif // __template_h__ brickos-0.9.0/include/time.h0000644000175000017500000000410007576365261013454 0ustar cbcb/*! \file include/time.h \brief Interface: Time-related data and types \author Markus L. Noga \bug time_t is a 32 bit value which will overflow after 49.7 days of continuous operation. */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __time_h__ #define __time_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_TIME /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// //! time type /*! \bug This is a 32 bit value which will overflow after 49.7 days of continuous operation. */ typedef unsigned long time_t; // // time & related stuff // //! timer tick in ms #define TICK_IN_MS 1 //! number of mS tics in 1Sec #define TICKS_PER_SEC 1000 #define SECS_TO_TICKS(a) ((a)*TICKS_PER_SEC) //!< conv. Sec's to TICKs #define MSECS_TO_TICKS(a) ((a)/TICK_IN_MS) //!< conv. mSec's to TICKs /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// //extern volatile time_t sys_time; //!< current system time // use get_system_up_time() instead of accessing sys_time directly. time_t get_system_up_time(void); #endif // CONF_TIME #ifdef __cplusplus } #endif #endif brickos-0.9.0/include/tm.h0000644000175000017500000001076510004702002013114 0ustar cbcb/*! \file include/tm.h \brief Interface: task management \author Markus L. Noga Defines types and flags used in task management. */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Lou Sortman */ #ifndef __tm_h__ #define __tm_h__ #ifdef __cplusplus extern "C" { #endif // __cplusplus #include #include /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// typedef volatile unsigned char tstate_t; //!< task state type typedef volatile unsigned char tflags_t; //!< task flags type typedef unsigned char priority_t; //!< task priority type //! The lowest possible task priority #define PRIO_LOWEST 1 //! The priority of most tasks #define PRIO_NORMAL 10 //! The highest possible task priority #define PRIO_HIGHEST 20 typedef unsigned long wakeup_t; //!< wakeup data area type // //! task states /*! \todo the following comments on the defined may cause problems in * when used in macros/expressions, etc. FixEm? */ #define T_DEAD 0 //!< dead and gone, stack freed #define T_ZOMBIE 1 //!< terminated, cleanup pending #define T_WAITING 2 //!< waiting for an event #define T_SLEEPING 3 //!< sleeping. wants to run. #define T_RUNNING 4 //!< running // //! task flags // #define T_KERNEL (1 << 0) //!< kernel task #define T_USER (1 << 1) //!< user task #define T_IDLE (1 << 2) //!< idle task #define T_SHUTDOWN (1 << 7) //!< shutdown requested #define DEFAULT_STACK_SIZE 512 //!< that's enough. #ifndef DOXYGEN_SHOULD_SKIP_INTERNALS /** * priority chain data structure * @internal */ struct _pchain_t { priority_t priority; //!< numeric priority level struct _pchain_t *next; //!< lower priority chain struct _pchain_t *prev; //!< higher priority chain struct _tdata_t *ctid; //!< current task in chain }; /** priority chain data type * a shorthand */ typedef struct _pchain_t pchain_t; /** task data structure * @internal */ struct _tdata_t { size_t *sp_save; //!< saved stack pointer tstate_t tstate; //!< task state tflags_t tflags; //!< task flags pchain_t *priority; //!< priority chain struct _tdata_t *next; //!< next task in queue struct _tdata_t *prev; //!< previous task in queue struct _tdata_t *parent; //!< parent task size_t *stack_base; //!< lower stack boundary wakeup_t(*wakeup) (wakeup_t); //!< event wakeup function wakeup_t wakeup_data; //!< user data for wakeup fn }; //! task data type /*! a shorthand */ typedef struct _tdata_t tdata_t; #endif // DOXYGEN_SHOULD_SKIP_INTERNALS #if defined(CONF_TM) //! test to see if task has been asked to shutdown /*! Check task shutdown flag. If set, the task should shutdown * as soon as possible. If clear, continue running. */ #define shutdown_requested() ((ctid->tflags & T_SHUTDOWN) != 0) extern tdata_t *ctid; #else // CONF_TM #define shutdown_requested() (0) #endif // CONF_TM //! task id type /*! In effect, the kernel simply typecasts *tdata_t to tid_t. */ typedef signed int tid_t; #ifdef __cplusplus } #endif // __cplusplus #endif brickos-0.9.0/include/unistd.h0000644000175000017500000000751407775644655014050 0ustar cbcb/*! \file include/unistd.h \brief Interface: reduced UNIX standard library \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __unistd_h__ #define __unistd_h__ #ifdef __cplusplus extern "C" { #endif #include #include /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// #ifdef CONF_TM /*! start task executing (with passed paramters) * called from user code * \param code_start the entry-point of the new task * \param argc the count of arguments passed (0 if none) * \param argv an array of pointers each pointing to an argument (NULL if none) * \param priority the priority at which to run this task * \param stack_size the amount of memory in bytes to allocate to this task for its call stack * \return -1 if failed to start, else tid (task-id) */ extern tid_t execi(int (*code_start) (int, char **), int argc, char **argv, priority_t priority, size_t stack_size); /*! signal shutdown for a task * \param tid TaskId of task to be notified */ extern void shutdown_task(tid_t tid); /*! signal shutdown for many tasks * \param flags indicating... * \todo research {flags}, then fix this documentation */ extern void shutdown_tasks(tflags_t flags); /*! kill specified (tid) task * \param tid TaskId of task to be killed * \todo FIXME: this belongs in a different header */ extern void kill(tid_t tid); /*! kill all tasks with priority less than or equal equal to p, excluding self. * \param p priority of tasks at which or below we kill tasks * \sideeffect All tasks meeting this criteria are killed */ extern void killall(priority_t p); /*! exit task, returning code * \param code the exit code to return to the caller */ extern void exit(int code) __attribute__((noreturn)); // //! current task yields the rest of timeslice // extern void yield(void); /*! suspend task until wakeup function returns non-null * \param wakeup the function to be called when woken up * \param data the wakeup_t structure to be passed to the called function * \return wakeup() return value * \note wakeup function is called in task scheduler context */ extern wakeup_t wait_event(wakeup_t(*wakeup) (wakeup_t), wakeup_t data); //! delay execution allowing other tasks to run /*! \param sec sleep duration in seconds * \return number of seconds left if interrupted, else 0 * \bug interruptions not implemented */ extern unsigned int sleep(unsigned int sec); /*! delay execution allowing other tasks to run * \param msec sleep duration in milliSeconds * \return number of milliSeconds left if interrupted, else 0 * \bug interruptions not implemented */ extern unsigned int msleep(unsigned int msec); #else extern inline wakeup_t wait_event(wakeup_t(*wakeup) (wakeup_t), wakeup_t data) { wakeup_t res; while (!(res = wakeup(data))) /* wait */; return res; } // Replacement for sleep/msleep if no TM #define sleep(s) delay(1000*(s)) #define msleep(s) delay(s) #endif #ifdef __cplusplus } #endif #endif // __unistd_h__ brickos-0.9.0/include/rom/0000755000175000017500000000000010173102120013111 5ustar cbcbbrickos-0.9.0/include/rom/registers.h0000644000175000017500000000360707535330364015324 0ustar cbcb/*! \file include/rom/registers.h \brief ROM Interface: RCX registers cached by ROM functions \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __rom_registers_h__ #define __rom_registers_h__ #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// extern unsigned char rom_port1_ddr; //!< ROM shadow of port 1 DDR extern unsigned char rom_port2_ddr; //!< ROM shadow of port 2 DDR extern unsigned char rom_port3_ddr; //!< ROM shadow of port 3 DDR extern unsigned char rom_port4_ddr; //!< ROM shadow of port 4 DDR extern unsigned char rom_port5_ddr; //!< ROM shadow of port 5 DDR /*! Port 6 is connected to both LCD and active sensor output. As lcd_refresh() is a ROM call, we need to update this location if active sensors are to remain active after a LCD refresh. */ extern unsigned char rom_port6_ddr; //!< ROM shadow of port 6 DDR extern unsigned char rom_port7_pin; //!< ROM shadow of port 7 pin #ifdef __cplusplus } #endif #endif // __rom_registers_h__ brickos-0.9.0/include/rom/lcd.h0000644000175000017500000001220007541267663014054 0ustar cbcb/*! \file include/rom/lcd.h \brief ROM Interface: RCX LCD control \author Markus L. Noga \warning If CONF_LCD_REFRESH is set in config.h, the kernel will refresh the display automatically every 100ms. Otherwise, display updates are realized exclusively by lcd_refresh(). */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __rom_lcd_h__ #define __rom_lcd_h__ #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// //! LCD segment codes /*! these are not to be confused with the codes defined in direct-lcd.h circle and dot codes cycle. cycle state is preserved on powerdown. each dot code should be invoked six times before using the other. mixing them will result in strange behaviour. */ typedef enum { man_stand = 0x3006, man_run = 0x3007, s1_select = 0x3008, s1_active = 0x3009, s2_select = 0x300A, s2_active = 0x300B, s3_select = 0x300C, s3_active = 0x300D, a_select = 0x300E, a_left = 0x300F, a_right = 0x3010, b_select = 0x3011, b_left = 0x3012, b_right = 0x3013, c_select = 0x3014, c_left = 0x3015, c_right = 0x3016, unknown_1 = 0x3017, //!< seemingly without effect. cycle reset? circle = 0x3018, //!< 0..3 quarters: add one. 4 quarters: reset dot = 0x3019, //!< 0..4 dots: add a dot. 5 dots: reset // dots are added on the right. dot_inv = 0x301A, //!< 0 dots: show 5. 1..4 dots: subtract one // dots are removed on the left battery_x = 0x301B, ir_half = 0x301C, //! the IR display values are mutually exclusive. ir_full = 0x301D, //! the IR display values are mutually exclusive. everything= 0x3020 } lcd_segment; //! LCD number display styles /*! note: signed and unsigned are taken by the C programming language */ typedef enum { digit = 0x3017, //!< single digit on the right // works only with comma_style digit sign = 0x3001, //!< signed, no leading zeros unsign = 0x301F //!< unsigned, 0 displayed as 0000 } lcd_number_style; //! LCD comma display styles /* */ typedef enum { digit_comma = 0x0000, //!< single digit on the right // works only with number_style digit e0 = 0x3002, //!< whole e_1 = 0x3003, //!< 10ths e_2 = 0x3004, //!< 100ths e_3 = 0x3005, //!< 1000ths, problematic with negatives } lcd_comma_style; // lcd display comma style //! display an integer in decimal #define lcd_int(i) lcd_number(i,sign,e0) //! display an unsigned value in decimal #define lcd_unsigned(u) lcd_number(u,unsign,e0) //! display a clock. /*! passing an argument of 1015 will display 10.15 */ #define lcd_clock(t) lcd_number(t,unsign,e_2) //! display a single digit right of the man symbol #define lcd_digit(d) lcd_number(d,digit,digit_comma) /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// /*! g++ warns about __asm__ __volatile__. we define the problem away. * the CXX symbol is predefined in the Makefile * \todo (when move to g++ 3.x) determine if this is still the case * and fix this if not... */ #ifdef CXX #define ASMVOLATILE #else #define ASMVOLATILE __volatile__ #endif //! show LCD segment /*! \param segment segment to show */ extern inline void lcd_show(lcd_segment segment) { __asm__ ASMVOLATILE( "push r6\n" "mov.w %0,r6\n" "jsr @lcd_show\n" "pop r6\n" : // outputs :"r"(segment) // inputs ); } //! hide LCD segment /*! \param segment segment to hide */ extern inline void lcd_hide(lcd_segment segment) { __asm__ ASMVOLATILE( "push r6\n" "mov.w %0,r6\n" "jsr @lcd_hide\n" "pop r6\n" : // outputs :"r"(segment) // inputs ); } //! show number on LCD display /*! \param i the number \param n a number style \param c a comma style */ extern void lcd_number(int i, lcd_number_style n, lcd_comma_style c); //! clear LCD display extern inline void lcd_clear(void) { __asm__ ASMVOLATILE( "push r6\n" "jsr @lcd_clear\n" "pop r6\n" ); } #ifdef __cplusplus } #endif #endif // __rom_lcd_h__ brickos-0.9.0/include/rom/system.h0000644000175000017500000000375007777403700014643 0ustar cbcb/*! \file include/rom/system.h \brief ROM Interface: RCX system control functions \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __rom_system_h__ #define __rom_system_h__ #ifdef __cplusplus extern "C" { #endif #include /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! enters software standby mode. extern inline void power_off(void) { __asm__ __volatile__("\n\ push r6\n\ bset #7,@0xc4:8 ; software standby mode\n\ jsr @ power_off ; ROM call\n\ pop r6\n\ "); } //! disables software standby mode so tm_idle_task() can use the sleep // instruction. extern inline void power_init(void) { __asm__ __volatile__("\n\ push r6\n\ jsr @ power_init ; ROM call\n\ bclr #7,@0xc4:8 ; disable software standby\n\ pop r6\n\ "); } //! erases BrickOS, returning control to ROM. extern void reset(void) __attribute__((noreturn)); //! turns off interrupts, then issues reset. extern inline void rom_reset(void) __attribute__((noreturn)); extern inline void rom_reset(void) { disable_irqs(); reset(); } #ifdef __cplusplus } #endif #endif // __rom_system_h__ brickos-0.9.0/include/rom/sound.h0000644000175000017500000000442407541715440014442 0ustar cbcb/*! \file include/rom/sound.h \brief ROM Interface: RCX sound functions \author Markus L. Noga \warning These functions will only work if ROM is allowed to handle the OCIA interrupt. system time, motor control and task management depend upon handling it themselves. */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __rom_sound_h__ #define __rom_sound_h__ #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! play one of the system sounds. /*! \param nr - the number of the system sound to be played * \return Nothing * NOTE: the system beep sound (#0) is the only system sound * implemented at this time. * \bug FIXME: register clobbers */ extern inline void sound_system(unsigned nr) { __asm__ __volatile__( "push %0\n" "mov.w #0x4003,r6\n" "jsr @sound_system\n" "adds #0x2,sp\n" : // output :"r"(nr) // input :"r6", "cc", "memory" // clobbered ); } //! is a sound playing? /*! \return T/F where T means a sound is playing */ extern inline int sound_playing(void) { unsigned rc; __asm__ __volatile__( "mov.w r7,r6\n" "push r6\n" "mov.w #0x700c,r6\n" "jsr @sound_playing\n" "adds #0x2,sp\n" "mov.w @r7,%0\n" :"=r"(rc) // output : // input :"r6", "cc", "memory" // clobbered ); return rc; } #ifdef __cplusplus } #endif #endif // __rom_sound_h__ brickos-0.9.0/include/sys/0000755000175000017500000000000010173102120013132 5ustar cbcbbrickos-0.9.0/include/sys/battery.h0000644000175000017500000000352107535330364015003 0ustar cbcb/*! \file include/sys/battery.h \brief Internal Interface: battery handling \author Paolo Masetti */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Paolo Masetti */ #ifndef __sys_battery_h__ #define __sys_battery_h__ #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// // Battery is normal if over 6700mV, low if under 6300mV #define BATTERY_NORMAL_THRESHOLD_MV 6700 #define BATTERY_LOW_THRESHOLD_MV 6300 /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// /** * get current battery voltage * @return int voltage in millivolts */ extern int get_battery_mv(); /** * cause the battery voltage sensor value to be refreshed */ extern void battery_refresh(void) #ifdef CONF_RCX_COMPILER __attribute__ ((rcx_interrupt)) #endif ; #ifdef __cplusplus } #endif #endif // __sys_battery_h__ brickos-0.9.0/include/sys/bitops.h0000644000175000017500000000476410004646671014637 0ustar cbcb/*! \file include/sys/bitops.h \brief Internal Interface: H8/300 bit operations \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_bitops_h__ #define __sys_bitops_h__ #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// // g++ warns about __asm__ const. we define the problem away. // the CXX symbol is predefined in the Makefile // #if defined(CXX) || __GNUC__ >= 3 # define ASMCONST #else # define ASMCONST const #endif // // the H8/300 processor offers many useful bit operations. // sometimes, we have to help gcc to realize their full // potential. // // the bit operations don't alter cc except for bld // //! set a single bit in memory /*! *((char*)byte)|=(1< Defines types and functions used for kernel level critical sections. */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Joseph A. Woolley */ #if !defined(__sys_critsec_h__) #define __sys_critsec_h__ #if defined(__cplusplus) extern "C" { #endif // __cplusplus #include #include #if defined(CONF_TM) extern atomic_t kernel_critsec_count; #define INITIALIZE_KERNEL_CRITICAL_SECTION() kernel_critsec_count=0 #define ENTER_KERNEL_CRITICAL_SECTION() atomic_inc(&kernel_critsec_count) #define LEAVE_KERNEL_CRITICAL_SECTION() atomic_dec(&kernel_critsec_count) #define DESTROY_KERNEL_CRITICAL_SECTION() #else // CONF_TM #define INITIALIZE_KERNEL_CRITICAL_SECTION() #define ENTER_KERNEL_CRITICAL_SECTION() #define LEAVE_KERNEL_CRITICAL_SECTION() #define DESTROY_KERNEL_CRITICAL_SECTION() #endif // CONF_TM #if defined(__cplusplus) } #endif // __cplusplus #endif // __sys_critsec_h__ brickos-0.9.0/include/sys/dmotor.h0000644000175000017500000000322307535330364014634 0ustar cbcb/*! \file include/sys/dmotor.h \brief Internal Interface: direct motor control \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_dmotor_h__ #define __sys_dmotor_h__ #ifdef __cplusplus extern "C" { #endif #include "../dmotor.h" #ifdef CONF_DMOTOR /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// // the RCX-specific motor driver I/O address extern unsigned char motor_controller; //!< RCX Motor Controller port /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! initialize motors // void dm_init(void); //! shutdown motors // void dm_shutdown(void); #endif // CONF_DMOTOR #ifdef __cplusplus } #endif #endif // __sys_dmotor_h__ brickos-0.9.0/include/sys/dsensor.h0000644000175000017500000000303707535330364015010 0ustar cbcb/*! \file include/sys/dsensor.h \brief Internal Interface: direct sensor access \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_dsensor_h__ #define __sys_dsensor_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_DSENSOR #include #include "../dsensor.h" /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! initialize sensor a/d conversion /*! all sensors set to passive mode */ extern void ds_init(void); //! shutdown sensor a/d conversion /*! all sensors set to passive mode */ extern void ds_shutdown(void); #endif // CONF_DSENSOR #ifdef __cplusplus } #endif #endif // __sys_dsensor_h__ brickos-0.9.0/include/sys/dsound.h0000644000175000017500000000314407535330364014626 0ustar cbcb/*! \file include/sys/dsound.h \brief Internal Interface: direct sound control \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Froods */ #ifndef __sys_dsound_h__ #define __sys_dsound_h__ #ifdef __cplusplus extern "C" { #endif #include "../dsound.h" #ifdef CONF_DSOUND /////////////////////////////////////////////////////////////////////// // // System functions // /////////////////////////////////////////////////////////////////////// //! sound handler, called from system timer interrupt extern void dsound_handler() #ifdef CONF_RCX_COMPILER __attribute__ ((rcx_interrupt)) #endif ; //! initialize sound driver extern void dsound_init(); //! shutdown sound driver extern void dsound_shutdown(); #endif // CONF_DSOUND #ifdef __cplusplus } #endif #endif /* __sys_dsound_h__ */ brickos-0.9.0/include/sys/h8.h0000644000175000017500000002641607551712562013662 0ustar cbcb/*! \file include/sys/h8.h \brief Internal Interface: H8/3297 processor registers \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_h8_h__ #define __sys_h8_h__ #ifdef __cplusplus extern "C" { #endif // 16 bit timer registers // //! 16-bit timer interrupt enable register extern unsigned char T_IER; //! 16-bit timer control / status register extern volatile unsigned char T_CSR; //! 16-bit timer count register extern volatile unsigned T_CNT; //! 16-bit timer output compare register A extern unsigned T_OCRA; //! 16-bit timer output compare register B /* address shared with T_OCRA */ extern unsigned T_OCRB; //! 16-bit timer control register extern unsigned char T_CR; //! 16-bit timer output control register extern unsigned char T_OCR; //! 16-bit timer input capture A register extern volatile unsigned T_ICRA; //! 16-bit timer input capture B register extern volatile unsigned T_ICRB; //! 16-bit timer input capture C register extern volatile unsigned T_ICRC; //! 16-bit timer input capture D register extern volatile unsigned T_ICRD; // // TIER bitmasks // #define TIER_ENABLE_ICA 0x80 // input capture IRQ enables #define TIER_ENABLE_ICB 0x40 #define TIER_ENABLE_ICC 0x20 #define TIER_ENABLE_ICD 0x10 #define TIER_ENABLE_OCA 0x08 // output compare IRQ enables #define TIER_ENABLE_OCB 0x04 #define TIER_ENABLE_OF 0x02 // overflow IRQ enable #define TIER_RESERVED 0x01 // always set. // // TCSR bitmasks // #define TCSR_ICA 0x80 // input capture events #define TCSR_ICB 0x40 #define TCSR_ICC 0x20 #define TCSR_ICD 0x10 #define TCSR_OCA 0x08 // output compare events #define TCSR_OCB 0x04 #define TCSR_OF 0x02 // overflow event #define TCSR_RESET_ON_A 0x01 // reset counter on match A // // TCR bitmasks // #define TCR_A_RISING 0x80 // input capture on rising #define TCR_B_RISING 0x40 // edge. if not set -> lower #define TCR_C_RISING 0x20 #define TCR_D_RISING 0x10 #define TCR_BUFFER_A 0x08 // buffer A in C #define TCR_BUFFER_B 0x04 // buffer B in D #define TCR_CLOCK_2 0x00 // clock = pclock / 2 #define TCR_CLOCK_8 0x01 // clock = pclock / 8 #define TCR_CLOCK_32 0x02 // clock = pclock / 32 #define TCR_CLOCK_EXT 0x03 // external clock, rising edge // // TOCR bitmasks // #define TOCR_OCRA 0x00 // select register to write #define TOCR_OCRB 0x10 #define TOCR_ENABLE_A 0x08 // enable output signals #define TOCR_ENABLE_B 0x04 #define TOCR_HIGH_LEVEL_A 0x02 // set output to high for match #define TOCR_HIGH_LEVEL_B 0x01 // // 8 bit timer registers // //! serial / timer control register extern unsigned char STCR; //! timer 0 control register extern unsigned char T0_CR; //! timer 0 control / status register extern volatile unsigned char T0_CSR; //! timer 0 constant A register extern unsigned char T0_CORA; //! timer 0 constant B register extern unsigned char T0_CORB; //! timer 0 counter register extern volatile unsigned char T0_CNT; //! timer 1 control register extern unsigned char T1_CR; //! timer 1 control / status register extern volatile unsigned char T1_CSR; //! timer 1 constant A register extern unsigned char T1_CORA; //! timer 1 constant B register extern unsigned char T1_CORB; //! timer 1 counter register extern volatile unsigned char T1_CNT; // // CR flag bitmasks // #define CR_ENABLE_IRQA 0x40 #define CR_ENABLE_IRQB 0x80 #define CR_ENABLE_IRQO 0x20 #define CR_CLEAR_NEVER 0x00 #define CR_CLEAR_ON_A 0x08 #define CR_CLEAR_ON_B 0x10 #define CR_CLEAR_ON_EXTERN 0x18 // I don't define speeds here because the STCR bits are involved, too. // Also, speeds differ for T0 and T1. // // CSR bitmasks // #define CSR_MATCH_A 0x40 #define CSR_MATCH_B 0x80 #define CSR_OVERFLOW 0x20 #define CSR_IGNORE_B 0x00 #define CSR_0_ON_B 0x04 #define CSR_1_ON_B 0x08 #define CSR_TOGGLE_ON_B 0x0c #define CSR_IGNORE_A 0x00 #define CSR_0_ON_A 0x01 #define CSR_1_ON_A 0x02 #define CSR_TOGGLE_ON_A 0x03 // // Serial port // //! serial receive data register extern volatile unsigned char S_RDR; //! serial transmit data register extern unsigned char S_TDR; //! serial mode register extern unsigned char S_MR; //! serial control register extern unsigned char S_CR; //! serial status register extern volatile unsigned char S_SR; //! serial baud rate register extern unsigned char S_BRR; //! serial / timer control register extern unsigned char S_TCR; // // register bitmasks // #define SMR_SYNC 0x80 // in sync mode, the other settings #define SMR_ASYNC 0x00 // have no effect. #define SMR_7BIT 0x40 #define SMR_8BIT 0x00 #define SMR_P_NONE 0x00 #define SMR_P_EVEN 0x20 #define SMR_P_ODD 0x30 #define SMR_1STOP 0x00 #define SMR_2STOP 0x08 #define SMR_MP 0x04 // multiprocessing -> no parity // for mp, mpe in STRC must be set #define SMR_CLOCK 0x00 // clock rate for baud rate generator #define SMR_CLOCK_4 0x01 // pclock / 4 #define SMR_CLOCK_16 0x02 // pclock / 16 #define SMR_CLOCK_64 0x03 // pclock / 64 #define SCR_TX_IRQ 0x80 // TIE transmit irq enable #define SCR_RX_IRQ 0x40 // RIE receive / recv err irq enable #define SCR_TRANSMIT 0x20 // enable transmission #define SCR_RECEIVE 0x10 // enable receiving #define SCR_MP_IRQ 0x08 // multiprocessing receive irq #define SCR_TE_IRQ 0x04 // TEI transmit end irq enable #define SCR_INT_CLOCK 0x00 // internal clock source #define SCR_EXT_CLOCK 0x02 // external clock source #define SCR_CLOCK_OUT 0x01 // output internal clock to SCK pin #define SSR_TRANS_EMPTY 0x80 // transmit buffer empty #define SSR_RECV_FULL 0x40 // receive buffer full #define SSR_OVERRUN_ERR 0x20 // overrun error #define SSR_FRAMING_ERR 0x10 // framing error #define SSR_PARITY_ERR 0x08 // parity error #define SSR_ERRORS 0x38 // all errors #define SSR_TRANS_END 0x04 // transmission end because buffer empty #define SSR_MP 0x02 // multiprocessor #define SSR_MP_TRANSFER 0x01 // multiprocessor bit transfer // // values for the bit rate register BRR // assuming CMR_CLOCK selected on 16 MHz processor // error <= 0.16% // #define B2400 207 #define B4800 103 #define B9600 51 #define B19200 25 #define B38400 12 // A/D converter // //! A/D converter data register A high extern volatile unsigned char AD_A_H; //! A/D converter data register A low /*! bits 0..5 reserved, probably zero */ extern volatile unsigned char AD_A_L; //! A/D converter data register B high extern volatile unsigned char AD_B_H; //! A/D converter data register B low /*! bits 0..5 reserved, probably zero */ extern volatile unsigned char AD_B_L; //! A/D converter data register C high extern volatile unsigned char AD_C_H; //! A/D converter data register C low /*! bits 0..5 reserved, probably zero */ extern volatile unsigned char AD_C_L; //! A/D converter data register D high extern volatile unsigned char AD_D_H; //! A/D converter data register D low /*! bits 0..5 reserved, probably zero */ extern volatile unsigned char AD_D_L; //! A/D converter data register A /*! bits 0..5 reserved, probably zero */ extern volatile unsigned AD_A; //! A/D converter data register B /*! bits 0..5 reserved, probably zero */ extern volatile unsigned AD_B; //! A/D converter data register C /*! bits 0..5 reserved, probably zero */ extern volatile unsigned AD_C; //! A/D converter data register D /*! bits 0..5 reserved, probably zero */ extern volatile unsigned AD_D; //! A/D converter control / status register extern volatile unsigned char AD_CSR; //! A/D converter control register extern unsigned char AD_CR; // // A/D CSR bitmasks // #define ADCSR_END 0x80 #define ADCSR_ENABLE_IRQ 0x40 #define ADCSR_START 0x20 #define ADCSR_SCAN 0x10 // enable scan mode #define ADCSR_TIME_266 0x00 // select A/D conversion time #define ADCSR_TIME_134 0x08 #define ADCSR_GROUP_0 0x00 // select scan group #define ADCSR_GROUP_1 0x04 #define ADCSR_AN_0 0x00 // first group of inputs to convert #define ADCSR_AN_1 0x01 #define ADCSR_AN_2 0x02 #define ADCSR_AN_3 0x03 // in scan mode: AN0-AN3 // // A/D CR bitmasks // #define ADCR_EXTERN 0x80 // allow external triggering // // system control register // FIXME: incomplete //! system control register extern unsigned char SYSCR; #define SYSCR_SOFTWARE_STANDBY 0x80 // software standby flag // // I/O ports // //! port 1 input pull-up control register extern unsigned char PORT1_PCR; //! port 2 input pull-up control register extern unsigned char PORT2_PCR; //! port 3 input pull-up control register extern unsigned char PORT3_PCR; //! port 1 data direction register extern unsigned char PORT1_DDR; //! port 1 I/O register extern volatile unsigned char PORT1; //! port 2 data direction register extern unsigned char PORT2_DDR; //! port 2 I/O register extern volatile unsigned char PORT2; //! port 3 data direction register extern unsigned char PORT3_DDR; //! port 3 I/O register extern volatile unsigned char PORT3; //! port 4 data direction register extern unsigned char PORT4_DDR; //! port 4 I/O register extern volatile unsigned char PORT4; //! port 5 data direction register extern unsigned char PORT5_DDR; //! port 5 I/O register extern volatile unsigned char PORT5; //! port 6 data direction register extern unsigned char PORT6_DDR; //! port 6 I/O register extern volatile unsigned char PORT6; //! port 7 input register extern volatile unsigned char PORT7; //! watch dog timer control register extern volatile unsigned int WDT_CSR; #define WDT_CSR_PASSWORD (0xA500) #define WDT_CSR_ENABLE (0x0020) #define WDT_CSR_MODE_WATCHDOG (0x0040) #define WDT_CSR_MODE_OVERFLOW (0x0000) #define WDT_CSR_WATCHDOG_NMI (0x0000) #define WDT_CSR_WATCHDOG_RES (0x0008) #define WDT_CSR_CLOCK_2 (0x0000) #define WDT_CSR_CLOCK_32 (0x0001) #define WDT_CSR_CLOCK_64 (0x0002) #define WDT_CSR_CLOCK_128 (0x0003) #define WDT_CSR_CLOCK_256 (0x0004) #define WDT_CSR_CLOCK_512 (0x0005) #define WDT_CSR_CLOCK_2048 (0x0006) #define WDT_CSR_CLOCK_4096 (0x0007) //! watch dog timer counter register extern volatile unsigned char WDT_CNT; #define WDT_CNT_PASSWORD (0x5A00) #define WDT_CNT_CLEAR (0x0000) #define WDT_CNT_MSEC_64 (0x0006) #ifdef __cplusplus } #endif #endif // __sys_h8_h__ brickos-0.9.0/include/sys/lcd.h0000644000175000017500000000533707535330364014102 0ustar cbcb/*! \file include/sys/lcd.h \brief Internal Interface: LCD control and constants \author Eddie C. Dost */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_lcd_h__ #define __sys_lcd_h__ #ifdef __cplusplus extern "C" { #endif #include #include /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// // Offsets and size of the LCD shadow buffer used to speed up // lcd_refresh() // #define LCD_SHORT_CMD 0 #define LCD_LONG_CMD 3 #define LCD_DATA_OFFSET 5 #define LCD_DATA_SIZE 9 // PCF8566 LCD driver commands // #define LCD_MODE_SET 0x40 #define LCD_ENABLE 0x08 #define LCD_DISABLE 0x00 // LCD i2c bus constants // #define LCD_DEV_ID 0x7c #define I2C_WRITE 0 #define I2C_READ 1 #define SCL 5 #define SDA 6 /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// extern unsigned char display_memory[]; //!< LCD display data buffer /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! initialize LCD driver extern void lcd_init(void); //! power on LCD display, also called from lcd_init() extern void lcd_power_on(void); //! power off LCD display extern void lcd_power_off(void); //! show LCD display contents to the world /*! display updates are realized exclusively by calling this function. */ extern void lcd_refresh(void); //! show LCD display contents to the world /*! display updates are realized on a byte basis by calling this function: the complete display will be updated after 9 calls. */ extern void lcd_refresh_next_byte(void) #ifdef CONF_RCX_COMPILER __attribute__ ((rcx_interrupt)) #endif ; #ifdef __cplusplus } #endif #endif // __sys_lcd_h__ brickos-0.9.0/include/sys/mm.h0000644000175000017500000000535607535330364013752 0ustar cbcb/*! \file include/sys/mm.h \brief Internal Interface: memory management \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_mm_h__ #define __sys_mm_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_MM #include #include /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #define MM_FREE 0x0000 //!< marker: block free #define MM_RESERVED 0xffff //!< marker: block reserved // as data generally nees to be word aligned, 1 unit ^= 2 bytes // #define MM_HEADER_SIZE 2 //!< 2 words header: pid, size #define MM_SPLIT_THRESH (MM_HEADER_SIZE+8) //!< split off if 8+ data bytes extern size_t mm_start; //!< end of kernel code + data extern size_t* mm_first_free; //!< ptr to first free block. // Macros for mm_init() // Always alternate FREE and RESERVED. // //! memory from addr on can be allocated /*! Macro for mm_init(). Always alternate MM_BLOCK_FREE and MM_BLOCK_RESERVED. */ #define MM_BLOCK_FREE(addr) \ next=(size_t*)(addr); \ *current=((((size_t)next)-(size_t)current)-2)>>1; \ *(next++)=MM_FREE; \ current=next; //! memory from addr on is reserved /*! Macro for mm_init(). Always alternate MM_BLOCK_FREE and MM_BLOCK_RESERVED. */ #define MM_BLOCK_RESERVED(addr) \ next=(size_t*)(((size_t)addr)-4); \ *current=((((size_t)next)-(size_t)current)-2)>>1; \ *(next++)=MM_RESERVED; \ current=next; /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! initialize memory management extern void mm_init(); //! free all blocks allocated by the current process extern void mm_reaper(); //! how many bytes of memory are free? extern int mm_free_mem(void); #endif // CONF_MM #ifdef __cplusplus } #endif #endif // __sys_mm_h__ brickos-0.9.0/include/sys/program.h0000644000175000017500000000654607775246712015023 0ustar cbcb/*! \file include/sys/program.h \brief Internal Interface: program data structures and functions \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __program_h__ #define __program_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_PROGRAM #include /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #define PROG_MAX 8 //!< maximum number of programs #ifndef DOXYGEN_SHOULD_SKIP_INTERNALS /** * The program control structure * @internal */ typedef struct { void *text; //!< origin of text segment void *data; //!< origin of data segment (imm. after text) void *bss; //!< origin of bss segment (imm. after data) void *data_orig; //!< origin of backup copy of data segment size_t text_size; //!< text segment size in bytes size_t data_size; //!< data segment size in bytes size_t bss_size; //!< bss segment size in bytes size_t stack_size; //!< stack segment size in bytes size_t start; //!< offset from text segment to start into. priority_t prio; //!< priority to run this program at size_t downloaded; //!< number of bytes downloaded so far. } program_t; /** * @internal */ typedef enum { CMDacknowledge, //!< 1: CMDdelete, //!< 1+ 1: b[nr] CMDcreate, //!< 1+12: b[nr] s[textsize] s[datasize] // s[bsssize] s[stacksize] // s[start] b[prio] CMDoffsets, //!< 1+ 7: b[nr] s[text] s[data] s[bss] CMDdata, //!< 1+>3: b[nr] s[offset] array[data] CMDrun, //!< 1+ 1: b[nr] CMDirmode, //!< 1+ 1: b[0=near/1=far] CMDsethost, //!< 1+ 1: b[hostaddr] CMDlast //!< ? } packet_cmd_t; #endif /* DOXYGEN_SHOULD_SKIP_INTERNALS */ /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// extern volatile unsigned cprog; //!< the current program /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! stop program extern void program_stop(int flag); //! check if a given program is valid. /*! \return 0 if invalid */ extern int program_valid(unsigned nr); //! initialize program support extern void program_init(); //! shutdown program support extern void program_shutdown(); #endif // CONF_PROGRAM #ifdef __cplusplus } #endif #endif // __program_h__ brickos-0.9.0/include/sys/time.h0000644000175000017500000000427707576365261014311 0ustar cbcb/*! \file include/sys/time.h \brief Internal Interface: system time functions \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_time_h__ #define __sys_time_h__ #ifdef __cplusplus extern "C" { #endif #include "../time.h" #ifdef CONF_TIME /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #ifdef CONF_TM #define TM_DEFAULT_SLICE 20 //!< default multitasking timeslice #endif /////////////////////////////////////////////////////////////////////// // // Global variables // /////////////////////////////////////////////////////////////////////// #ifdef CONF_TM //! return address for the task switcher // extern void* systime_tm_return; #endif /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! initialize system timer /*! task switcher initialized to empty handler, motors turned off */ void systime_init(void); //! shutdown system timer // void systime_shutdown(void); #ifdef CONF_TM //! set task switcher vector // void systime_set_switcher(void* switcher); //! set multitasking timeslice in ms // void systime_set_timeslice(unsigned char slice); #endif // CONF_TM time_t get_system_up_time(void); #endif // CONF_TIME #ifdef __cplusplus } #endif #endif // __sys_time_h__ brickos-0.9.0/include/sys/timeout.h0000644000175000017500000000377607535330364015033 0ustar cbcb/*! \file include/sys/timeout.h \brief Internal Interface: Powerdown Timer Routines \author Rossz Vamos-Wentworth */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga * Rossz Vmos-Wentworth */ #ifndef __sys_timeout_h__ #define __sys_timeout_h__ #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #define DEFAULT_SHUTOFF_TIME (15*60) /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// extern volatile unsigned int auto_shutoff_counter; extern unsigned int auto_shutoff_period; extern unsigned int auto_shutoff_secs; extern volatile unsigned int auto_shutoff_elapsed; extern volatile unsigned int idle_powerdown; /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// extern void shutoff_init(void); extern void shutoff_restart(void); extern void autoshutoff_check(void) #ifdef CONF_RCX_COMPILER __attribute__ ((rcx_interrupt)) #endif ; #ifdef __cplusplus } #endif #endif brickos-0.9.0/include/sys/tm.h0000644000175000017500000000554007544402045013750 0ustar cbcb/*! \file include/sys/tm.h \brief Internal Interface: task management \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_tm_h__ #define __sys_tm_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_TM #include "../tm.h" /////////////////////////////////////////////////////////////////////// // // Definitions // /////////////////////////////////////////////////////////////////////// #define SP_RETURN_OFFSET 10 //!< return address offset on stack in words. #define IDLE_STACK_SIZE 128 //!< should suffice for IRQ service /////////////////////////////////////////////////////////////////////// // // Variables // /////////////////////////////////////////////////////////////////////// extern tdata_t td_single; //!< single process process data extern tdata_t *ctid; //!< ptr to current process data extern volatile unsigned int nb_tasks; //!< number of tasks // nb_system_tasks is maintained in execi and kill/killall // T_KERNEL tasks are counted as they are started extern volatile unsigned int nb_system_tasks; // tm_timeslice is from kernel/systime.c extern volatile unsigned char tm_timeslice; //!< task time slice /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! init task management /* called in single tasking mode before task setup. */ extern void tm_init(void); //! start task management /*! called in single tasking mode after task setup */ extern void tm_start(void); //! the task switcher IRQ handler /*! located in the assembler process module */ extern void tm_switcher(void); //! the process scheduler /*! \param old_sp current task's current stack pointer \return new task's current stack pointer actual context switches performed by tm_switcher (assembler wrapper) */ extern size_t *tm_scheduler(size_t *old_sp); //! the idle task /*! infinite sleep instruction to conserve power */ extern int tm_idle_task(int,char**); #endif // CONF_TM #ifdef __cplusplus } #endif #endif // __sys_tm_h__ brickos-0.9.0/include/sys/vis.h0000644000175000017500000000264107535330364014134 0ustar cbcb/*! \file include/sys/vis.h \brief Internal Interface: visualization of BrickOS state \author Markus L. Noga */ /* * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is legOS code, released October 17, 1999. * * The Initial Developer of the Original Code is Markus L. Noga. * Portions created by Markus L. Noga are Copyright (C) 1999 * Markus L. Noga. All Rights Reserved. * * Contributor(s): Markus L. Noga */ #ifndef __sys_vis_h__ #define __sys_vis_h__ #ifdef __cplusplus extern "C" { #endif #include #ifdef CONF_VIS /////////////////////////////////////////////////////////////////////// // // Functions // /////////////////////////////////////////////////////////////////////// //! visualize sensor/motor state and selected program. void vis_handler(void) #ifdef CONF_RCX_COMPILER __attribute__((rcx_interrupt)) #endif ; #endif // CONF_VIS #ifdef __cplusplus } #endif #endif // __sys_vis_h__ brickos-0.9.0/Doxyfile0000644000175000017500000014243010173101721012411 0ustar cbcb# Doxyfile 1.4.0 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = "brickOS Kernel Developer" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = v0.9.0 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = doc # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, # Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, # Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, # Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, # Swedish, and Ukrainian. OUTPUT_LANGUAGE = English # This tag can be used to specify the encoding used in the generated output. # The encoding is not always determined by the language that is chosen, # but also whether or not the output is meant for Windows or non-Windows users. # In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES # forces the Windows encoding (this is the default for the Windows binary), # whereas setting the tag to NO uses a Unix-style encoding (the default for # all platforms other than Windows). USE_WINDOWS_ENCODING = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = YES # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = ./ # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explicit @brief command for a brief description. JAVADOC_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = YES # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = "sideeffect=\par Side Effects:\n" \ "index=\par Index:\n" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources # only. Doxygen will then generate output that is more tailored for Java. # For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = YES # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = YES # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. SHOW_DIRECTORIES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from the # version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the progam writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = kernel \ include \ boot \ doc/doxy-extras # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm FILE_PATTERNS = *.c \ *.C \ *.cpp \ *.h \ *.H \ *.dxy # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = demo \ demo\c++ # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html-kern # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = doc/html/header.htm # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = doc/html/footer-no-sf.htm # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = doc/html/doxygen.css # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = YES # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = YES # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = YES # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf-kern # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = YES # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_PREDEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = doc/ \ boot/ # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \ DOXYGEN_DOC_BUILD # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = NO #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = NO # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will # generate a call dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. CALL_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found on the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that a graph may be further truncated if the graph's # image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH # and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), # the graph is not depth-constrained. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, which results in a white background. # Warning: Depending on the platform used, enabling this option may lead to # badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO brickos-0.9.0/Doxyfile-c0000644000175000017500000014243110173101721012632 0ustar cbcb# Doxyfile 1.4.0 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = "brickOS C" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = v0.9.0 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = doc # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, # Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, # Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, # Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, # Swedish, and Ukrainian. OUTPUT_LANGUAGE = English # This tag can be used to specify the encoding used in the generated output. # The encoding is not always determined by the language that is chosen, # but also whether or not the output is meant for Windows or non-Windows users. # In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES # forces the Windows encoding (this is the default for the Windows binary), # whereas setting the tag to NO uses a Unix-style encoding (the default for # all platforms other than Windows). USE_WINDOWS_ENCODING = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = YES # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = ./doc/doxy-extras \ ./ # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explicit @brief command for a brief description. JAVADOC_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = YES # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = "sideeffect=\par Side Effects:\n" \ "index=\par Index:\n" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources # only. Doxygen will then generate output that is more tailored for Java. # For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. SHOW_DIRECTORIES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from the # version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the progam writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = include \ doc/doxy-extras # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm FILE_PATTERNS = *.h \ *.dxy # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = include/sys \ include/lnp/sys # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = YES # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = template.* \ demos-c++.dxy # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = demo # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html-c # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = doc/html/header.htm # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = doc/html/footer-no-sf.htm # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = doc/html/doxygen.css # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = YES # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = YES # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = YES # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf-c # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_PREDEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = include/sys \ include/lnp/sys \ boot # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = DOXYGEN_SHOULD_SKIP_INTERNALS \ DOXYGEN_SHOULD_SKIP_THIS \ DOXYGEN_DOC_BUILD # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = NO # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = NO # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = NO # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will # generate a call dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. CALL_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = NO # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found on the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that a graph may be further truncated if the graph's # image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH # and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), # the graph is not depth-constrained. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, which results in a white background. # Warning: Depending on the platform used, enabling this option may lead to # badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO brickos-0.9.0/Doxyfile-c++0000644000175000017500000014275210173101721012766 0ustar cbcb# Doxyfile 1.4.0 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = "brickOS C++" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = v0.9.0 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = doc # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, # Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, # Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, # Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, # Swedish, and Ukrainian. OUTPUT_LANGUAGE = English # This tag can be used to specify the encoding used in the generated output. # The encoding is not always determined by the language that is chosen, # but also whether or not the output is meant for Windows or non-Windows users. # In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES # forces the Windows encoding (this is the default for the Windows binary), # whereas setting the tag to NO uses a Unix-style encoding (the default for # all platforms other than Windows). USE_WINDOWS_ENCODING = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = YES # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = ./ \ ./doc/doxy-extras/ # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explicit @brief command for a brief description. JAVADOC_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = YES # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = "sideeffect=\par Side Effects:\n" \ "index=\par Index:\n" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources # only. Doxygen will then generate output that is more tailored for Java. # For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. SHOW_DIRECTORIES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from the # version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the progam writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = include \ doc/doxy-extras # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm FILE_PATTERNS = *.h \ *.H \ *.c \ *.cpp \ *.C \ *.dxy # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = include/sys \ include/lnp/sys # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = YES # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = template.* # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = demo \ demo/c++ # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html-c++ # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = doc/html/header.htm # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = doc/html/footer-no-sf.htm # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = doc/html/doxygen.css # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = YES # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = YES # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf-c++ # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = YES # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_PREDEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = include/sys/ \ include/lnp/sys/ \ doc/doxy-extras \ doc/ \ boot/ # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = DOXYGEN_SHOULD_SKIP_INTERNALS \ DOXYGEN_SHOULD_SKIP_THIS \ DOXYGEN_DOC_BUILD # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = NO #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = NO # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will # generate a call dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. CALL_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found on the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that a graph may be further truncated if the graph's # image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH # and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), # the graph is not depth-constrained. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, which results in a white background. # Warning: Depending on the platform used, enabling this option may lead to # badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO brickos-0.9.0/doc/0000755000175000017500000000000010517714007011455 5ustar cbcbbrickos-0.9.0/doc/doxy-extras/0000755000175000017500000000000010173102120013725 5ustar cbcbbrickos-0.9.0/doc/doxy-extras/demos-c++.dxy0000644000175000017500000000167707544273363016175 0ustar cbcb/// \file doc/doxy-extras/demos-c++.dxy /// \brief Main page for collecting our C++ examples /// \author Stephen M Moraco (stephmo@users.sourceforge.net) /// /// This file provides a simple catalog of our C++ example programs /// /// @page C++-Demos Example Programs in C++ /// /// \par Ex1: display battery voltage /// a simple demostration of reading the battery and writing to the LCD /// /// \par demo/batt.C /// /// \include batt.C /// /// \par Ex2: emitting light (Using Lamp from the Ultimate Accessory Set) /// a demostration of the controlling the Lamp /// /// \par demo/lampTest.C /// /// \include lampTest.C /// /// \par Ex3: generating sounds /// a simple demostration of the RCX playing music /// /// \par demo/sound.C /// /// \include sound.C /// activeSensor.C batt.C lampTest.C lightSensor.C motor.C raceTrack.C rotation.velocity.Sensor.C rotationSensor.C rover.C sensor.C sound.C temperatureSensor.C touch.pressed.Sensor.C touchSensor.C brickos-0.9.0/doc/doxy-extras/demos.dxy0000644000175000017500000000135607544273363015621 0ustar cbcb/// \file doc/doxy-extras/demos.dxy /// \brief Main page for collecting our C examples /// \author Stephen M Moraco (stephmo@users.sourceforge.net) /// /// This file provides a simple catalog of our example files /// /// @page C-Demos Example Programs in C /// /// \par Ex1: Our hello world example /// a simple demostration of how to write to the LCD /// /// \par demo/helloworld.c /// /// \include helloworld.c /// /// \par Ex2: generating sounds /// a simple demostration of the RCX playing music /// /// \par demo/sound.c /// /// \include sound.c /// /// \par Ex3: A line following robot /// a simple demostration of /// /// \par demo/linetrack.c /// /// \include linetrack.c /// ##incluce robots.c ##incluce rover.c ##incluce trailerbot.c brickos-0.9.0/doc/AvailableDocs.txt0000644000175000017500000000037110014276001014675 0ustar cbcbThere are a number of good docs available on the web but that are too large to include in the base tarball. Please see the brickos site for these docs including API (Application Programming Interface) documentation. http://brickos.sourceforge.net brickos-0.9.0/doc/INSTALL-cygwin.sgml0000644000175000017500000003044607640414651014761 0ustar cbcb
brickOS 0.2.6.10 Instructions for installing on Win9x/NT/2000/XP Paolo Masetti Version 1.3, 01 March, 2003 2001-2003Paolo Masetti. 1.3 01 Mar 2003 pm Update for brickOS 0.2.7.10 1.2 19 Sep 2002 smm Update for brickOS 0.2.7.08, formerly legOS 1.1 19 Apr 2002 smm Update for legOS 0.2.6 1.0 13 May 2001 pm Initial Release after legOS 0.2.5 This document is an adaptation of the original version written by Peter Van der Beken . Many thanks to Luis Villa for his HOW-TO for Linux and his effort in documenting brickOS. Many thanks to Markus L. Noga for conceiving and creating legOS. If you have opinions and corrections related to these instruction, you can write to Paolo Masetti . For every problems, use brickOS site reporting tools and forums or lugnet.robotics.rcx.legos on lugnet.com . These instruction work for me (I'm using NT Win2k Pro SP3). I can't be sure they'll do for you but I'm quite sure. They should get brickOS working on your own PC, but they should be used at your own risk as with any other program installation, you may crash your computer, lose files, and generally make a mess of things. So, neither he nor I will be responsible for what should happen. :-) These instructions give you a fully functional brickOS 0.2.6.10 (probably a newer version too). You will be able to recompile the entire kernel image, the tools (dll, firmdl3 & so on). You will have to download a lot of MB. If you do not like that, please use WinlegOS that is a good porting of the minimal requirement to compile and upload .lx files with Windows. Step by step instructions: 1. Install Cygwin Install Cygwin 1.3.x or newer version (1.3.20 as of this writing) from Cygwin Site: http://www.cygwin.com/ . You can install it on-line running the setup program directly from this url: Install Cygwin now . Save the file in a temporary directory and run it. You can download all the files for a later install, or install directly from Internet. Choice the best for you: IMG: Cygwin Setup Dialog: choose type of install. Install in the directory that you prefer. Do not worry about it, this version of cygwin will mount directories as *nix later. I use these choices: IMG: Cygwin Setup Dialog: select install options. Last setup I've tried let you choose which modules you need to download and setup. Here is a minimal list (but probably some modules could be removed too) that was tested and works: ash autoconf automake bash binutils cpio cygwin diff file fileutils findutils flex gcc grep less login make mingw patch sed shellutils tar textutils time w32api IMG: Cygwin Setup Dialog: install progress. 2. Build the Hitachi-H8 cross-compiler Open a cygwin bash shell window (you can open it using Start Programs Cygnus Solution Cygwin Bash Shell ) Make a new directory: $ mkdir /build where you will download the next files: c:\cygwin\build Download gcc 2.95.2 sources using this link -> gcc-2.95.2.tar.gz and save in c:\cygwin\build Download binutils 2.10.1 sources using this link -> binutils-2.10.1.tar.gz and save in c:\cygwin\build Download the building scripts from here (legos-buildgcc.zip) and put it in the same directory as above. Unzip them to produce a shell script (buildgcc.sh) and two diff files. Build the cross compiler: $ cd /build $ ./buildgcc.sh Ignore the warnings in compile process. It should work. 3. Install the brickOS files Get brickos-0.2.6.10.tar.gz from the "Latest Test Releases" section of our project web: http://sourceforge.net/projects/brickos . Drag a copy to C:\cygwin. Type: $ cd / $ tar xvfz brickos-0.2.6.10.tar.gz Lots of files will stream by as they install into their directories. This will create a brickos-0.2.6.10 directory. 4. TRY IT!!! Type: $ ln -s brickOS-0.2.6.10 brickOS $ cd /brickOS $ ./configure; make $ cd util $ make strip Now, Power on RCX. Put IR tower on COM1 $ ./firmdl3 ../boot/brickOS.srec $ ./dll ../demo/helloworld.lx Press RUN on RCX and enjoy! If you have the IR tower connected to a different com port you can change the default port with variable RCXTTY. This is the command: "export RCXTTY=COMx". NOTE: if you have a USB tower, please use "export RCXTTY=USB". You can get more help using commands "./firmdl3 --help" and "./dll": $ ./firmdl --help usage: firmdl3 [options] filename --debug show debug output, mostly raw bytes -f, --fast use fast 4x downloading (default) -s, --slow use slow 1x downloading --tty=TTY assume tower connected to TTY --tty=usb assume tower connected to USB -h, --help display this help and exit $ ./dll usage: dll [options] [command | file.lx] Options: -p<prognum> , --program=<prognum> set destination program to <prognum> -r<rcxaddr> , --rcxaddr=<rcxaddr> send to RCX host address <rcxaddr> -s<srcport> , --srcport=<srcport> send to RCX source port <srcport> -t<comport> , --tty=<comport> set IR Tower com port <comport> -t<usb> , --tty=<usb> set IR Tower USB mode -i<0/1> , --irmode=<0/1> set IR mode near(0)/far(1) on RCX -e , --execute execute program after download -v , --verbose verbose mode Commands: -d<prognum> , --delete=>prognum> delete program <prognum> from memory -n<hostaddr> , --node=>hostaddr> set LNP host address in brick Default COM port or USB support can be set using environment variable RCXTTY. Eg: set RCXTTY=COM2 set RCXTTY=USB Final Notes If it doesn't work, consult lugnet.robotics.rcx.legos on lugnet.com . Every command indicated is executed from the Cygwin environment. In the examples, the "$" is the prompt cygwin gives to you. You can use Notetab Light to edit files instead of WordPad or VI. It's available from: http://www.notetab.com . It preserves the unix line-endings, and it can change between unix and dos line-endings. Latest update: Paolo Masetti 01/03/2003. Update/generate/post as web content Stephen Moraco 01/05/2002. Initial Release: Paolo Masetti 13/05/2001. SGML Source for document created for Paolo by Stephen Moraco 19/07/2001.
brickos-0.9.0/doc/Makefile0000644000175000017500000000406010517714003013111 0ustar cbcb### ========================================================================== ### $Id: Makefile,v 1.9 2004/02/17 02:27:13 stephmo Exp $ ### FILE: doc/Makefile - build HTML documentation from SGML source ### brickOS - the independent LEGO Mindstorms OS ### -------------------------------------------------------------------------- DOCBASE = INSTALL-cygwin DOCSRC = $(DOCBASE).sgml TEXT_DOCS = AvailableDocs.txt \ Notes_on_intterupts \ Pros_and_Cons \ RCXmessageAPI.txt \ Sensors include ../Makefile.common # out default target when doing make in this directory docs-build: $(DOCBASE).html # nothing to do for these (documents not built when running top-level build) all install uninstall depend tag:: @# nothing to do here, but do this nothing silently docs-install: ${pkghtmldir} chkbuild -@cp -f ../[CLNRV]* ${pkgdocdir} 2>/dev/null cp -f ${TEXT_DOCS} ${pkgdocdir} cp -r images ${pkghtmldir} cp -f *.html ${pkghtmldir} mkdir -p ${pkghtmldir}/HOWTO cp HOWTO/*.html ${pkghtmldir}/HOWTO cp HOWTO.html ${pkghtmldir}/HOWTO @# oops copied extra files, remove them @rm -f $(pkghtmldir)/HOWTO/t1.html @rm -f $(pkghtmldir)/HOWTO.html chkbuild: @if [ ! -f $(DOCBASE).html ] ;then \ echo ""; \ echo "---------------------------------------------------------"; \ echo " Documents are not built. Please run 'make doc' then "; \ echo " rerun 'make doc-install' as root"; \ echo "---------------------------------------------------------"; \ echo ""; \ exit 2; \ fi ${pkghtmldir}: mkdir -p $@ # generate html and correct image path in top page $(DOCBASE).html: $(DOCSRC) sgmltools -b html $(DOCBASE) sed -e 's/\/docbook-dsssl/images/' $(DOCBASE)/top.html >$@ realclean:: rm -rf $(DOCBASE) rm -f $(DOCBASE).html clean: @# nothing to do here, but do this nothing silently realclean:: clean ### -------------------------------------------------------------------------- ### End of FILE: doc/Makefile ### ========================================================================== brickos-0.9.0/doc/Notes_on_intterupts0000644000175000017500000000072407530330674015475 0ustar cbcbMarkus says: Default IRQ handlers don't work, if disabling interrupts, always mask out the respective IRQ enable bits. For IRQs associated with certain bits in status registers, always clear these bits before enabling the IRQ. Mostly, the IRQ is only triggered when the status bits change. Therefore, always clear them at the end of an ISR, too. The ROM OCIA interrupt is pretty obnoxious - not only does it control motors, but it also plays with the sound, too. brickos-0.9.0/doc/Pros_and_Cons0000644000175000017500000000364507530330674014144 0ustar cbcb-- legOS - the independent LEGO Mindstorms OS -- doc/Pros_and_Cons - why use legOS? -- (c) 1998 by Markus L. Noga ------------------------------------------------------------------------ legOS cons: - System is unstable - this is beta. - gcc and binutils required. - C programming knowledge required. - No graphical interface on the host. - No spirit.ocx support. But spirit.ocx is Windows only, anyway, isn't it? What use would an OS for your RCX be if you didn't even have one on your workstation? legOS pros: - User tasks are executed as native code, not interpreted. - More memory. Forget 32 variables. Think 32k. - Full-featured language. Use the same gcc that compiles Linux. - Priority-based preemptive multitasking. - Real process synchronization with POSIX semaphores. - Fine-grained hardware control: * supports CPU power saving. * complete LCD control. * raw mode IR. Battling Creatures? You can force opponents to back up in fear. With "Powerdown" or "Erase firmware", a legOS machine wins even with three motors tied to its back. As Christmas heralds some spare time, I have already sketched out several possible legOS extensions. - C++ support (possibly even STL) - IR networking for multiple PCs and RCXs. Forget 1-byte messages. * UDP networking. * host programming library. * 4x faster task downloads. - ECM against standard RCX communication. In short, legOS isn't for you if - you are a beginner or - you prefer to control the RCX from your PC. legOS is for you if - you want complete control or - you write software that runs on the RCX (for example, neural networks trained by genetic algorithms). And, of cause, if you like to tinker with operating systems. Contributions, bugfixes and suggestions are always welcome. -- Markus L. Noga markus@noga.de INRIA Rhne-Alpes http://www.inrialpes.fr/ IPR Universitt Karlsruhe http://wwwipr.ira.uka.de/ brickos-0.9.0/doc/RCXmessageAPI.txt0000644000175000017500000000122607530340563014555 0ustar cbcbRCX Message API =============== unsigned char get_msg(); // wait for any message void clear_msg(); // set message buffer to 0 (invalid message) int send_msg(unsigned char msg); // send single byte msg, return 0 on success wait_event(msg_received, msg); // msg=0, wait for any message, // msg=1-255, wait for specific msg extern unsigned char lnp_rcx_message; // contains last message received or 0 if none ====================================================================================== Notes from Ted Hess patch Readme.txt - (Here for now. Will be moved to better doc shortly) -Stephen brickos-0.9.0/doc/Sensors0000644000175000017500000000442307530330674013044 0ustar cbcb-- legOS - the independent LEGO Mindstorms OS -- doc/Sensors - sensor documentation -- (c) 1998 by Markus L. Noga ------------------------------------------------------------------------ By default, sensor support is enabled and initialized by the kernel. To disable, comment out the NO_DIRECT_SENSORS line in include/config.h. The three inputs and battery voltage are monitored in sequence. A/D conversion time is 266 clock ticks per channel, resulting in a maximum theoretical update frequency of 16 kHz at a system clock of 16 MHz. However, the time required by the ISR lowers this value somewhat. 8-10 kHz should be a conservative bet. Sensor values can be read like any unsigned variable. Assignments will have undefined effects, as they periodically overwritten by the A/D conversion routine. The variable names are: SENSOR_1 SENSOR_2 SENSOR_3 BATTERY Active sensors -------------- The Mindstorms light and rotation sensors are active components. They require pulsed alimenation to operate. That is, power supply must be cut when performing A/D conversion on the respective channel. To enable this functionality, use ds_active(&SENSOR_n). Otherwise, the light sensor detects ambient light, while the rotation sensor doesn't work at all. To disable, use ds_passive(&SENSOR_n). A macro LIGHT(a) to scale active light sensor values to 0 .. LIGHT_MAX is supplied, as well as convenience macros LIGHT_1 LIGHT_2 LIGHT_3 The kernel initializes all sensors to passive mode on startup and restores this state on termination of the user module. Rotation sensors ---------------- Mindstorms rotation sensors provide different resistances to encode rotational position. With a finite state machine, this can be decoded into relative position. To enable this functionality, use ds_rotation_on(&SENSOR_n). To disable, use ds_rotation_off(&SENSOR_n). The decoded relative position can be read from these unsigned variables: ROTATION_1 ROTATION_2 ROTATION_3 Note that these are relative positions. By default, the sensor cannot identify absolute positions. If this information is supplied by external means, ds_rotation_set(&SENSOR_n,int pos) can be used to set an absolute position. The kernel disables rotation tracking by default. The absolute rotational position is undefined on startup. brickos-0.9.0/doc/index.html0000644000175000017500000000422410014276001013441 0ustar cbcb brickOS Documentation

brickOS Documentation

NOTE: We are in the progress of moving from the legOS name to brickOS. We have not yet regenerated all of the documentation to use our new name. This will take place over time, please bear with us.

The legOS HOWTO

This is the most comprehensive and wide-ranging of the legOS docs. The best place to start for a newbie. With the newest update, this now covers LNP is depth, including code examples. Many thanks to Mike Ash for providing this new section.

Kernel Documentation

Stig Neilsson has written kernel documentation, detailing exactly how the legOS kernel works. If you want to become a brickOS kernel hacker, this is the place to start. You can also get it as a PDF file here.

Auto-generated API docs

These are Application Programming Interface (API) docs that are automatically generated from brickOS source. We keep these up to date with each new release.  You may also see special versions of these documents accompanying test releases.
$Header: /cvsroot/brickos/brickos/doc/index.html,v 1.1 2004/02/17 02:27:13 stephmo Exp $
brickos-0.9.0/doc/html/0000755000175000017500000000000010173102120012402 5ustar cbcbbrickos-0.9.0/doc/html/doxygen.css0000644000175000017500000000426007544235561014623 0ustar cbcbH1 { text-align: center; } CAPTION { font-weight: bold } A.qindex {} A.qindexRef {} A.el { text-decoration: none; font-weight: bold } A.elRef { font-weight: bold } A.code { text-decoration: none; font-weight: normal; color: #4444ee } A.codeRef { font-weight: normal; color: #4444ee } A:hover { text-decoration: none; background-color: #f2f2ff } DL.el { margin-left: -1cm } DIV.fragment { width: 100%; border: none; background-color: #eeeeee } DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } TD.md { background-color: #afe6ef; font-weight: bold; } TD.mdname1 { background-color: #afe6ef; font-weight: bold; color: #602020; } TD.mdname { background-color: #afe6ef; font-weight: bold; color: #602020; width: 600px; } DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold } DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller } BODY { background: white } DIV.footBlock { text-align: center; margin-left: 16px; font-style: italic; font-size: smaller } TABLE.footBlock { text-align: center; width: 100% } TD.footBlock { background-color: #e4f7fa; padding-right : 10px; padding-top : 2px; padding-left : 10px; padding-bottom : 2px; margin-left : 0px; margin-right : 0px; margin-top : 2px; margin-bottom : 2px; width: 100% } TD.indexkey { background-color: #afe6ef; font-weight: bold; padding-right : 10px; padding-top : 2px; padding-left : 10px; padding-bottom : 2px; margin-left : 0px; margin-right : 0px; margin-top : 2px; margin-bottom : 2px } TD.indexvalue { background-color: #e4f7fa; font-style: italic; padding-right : 10px; padding-top : 2px; padding-left : 10px; padding-bottom : 2px; margin-left : 0px; margin-right : 0px; margin-top : 2px; margin-bottom : 2px } span.keyword { color: #008000 } span.keywordtype { color: #604020 } span.keywordflow { color: #e08000 } span.comment { color: #800000 } span.preprocessor { color: #806020 } span.stringliteral { color: #002080 } span.charliteral { color: #008080 } brickos-0.9.0/doc/html/footer-no-sf.htm0000644000175000017500000000104310173101721015436 0ustar cbcb
brickOS is released under the Mozilla Public License.
Original code copyright 1998-2005 by the authors.

Generated on $datetime for $projectname by doxygen $doxygenversion
brickos-0.9.0/doc/html/footer.htm0000644000175000017500000000145610173101721014426 0ustar cbcb
brickOS is released under the Mozilla Public License.
Original code copyright 1998-2005 by the authors.

Generated on $datetime for $projectname by doxygen $doxygenversion
This site generously hosted by  SourceForge Logo
brickos-0.9.0/doc/html/header.htm0000644000175000017500000000036207541725513014373 0ustar cbcb $title brickos-0.9.0/doc/images/0000755000175000017500000000000010173102120012703 5ustar cbcbbrickos-0.9.0/doc/images/Cygwin1.jpg0000644000175000017500000002034707530330674014760 0ustar cbcbJFIFLEAD Technologies Inc. V1.01 4"@.0&4LCPOKCIHT_yfTYr[HIijr}Qey>"">WIW  }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzw!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzI ?kWmCp1+|铓iRWdM3?m~<_J/畷1v/$1v/$׿1v/$1v/$1v/$1v/$w1v/$W1v/$7b_H.睿ף9ؿ_cbo]8?^!ݺp{(;ry|Q_GsGsn?GAظ?;^{$_kC|Qsg?;VE|Qs'_;NoE|RH9ؿSv/d7b(H9ؿv?d(H\_KGCbO| =v/$ȣ١s~'cE;Ru?GAK'(h9ؿhDE/f翢"fGw0er_Z++Mu*Y#*Aek]J:[ ͳwky8a{V6jogD fJdU _FYgCxldXFNzԹIn $Mol˖wKAdXNS#qzc68'?җ4_K![ +4*Wl2IkXv{id{cBlgoQ-΂FB*@,rszRm $vz\DL.dwe#+=ܭס)7ĿfN%߻ NӜtS ؁E8P( @8Pp@(€PR€(E8P( @( TQk* )٤w7?f9gfyVFr_kd=To=ơz*~bAZӨɔ[eK}R<_5 o9StubZ躍[@PS‡V/pPh=|]慙I,ēS#G. =C?Gr1G(F/#_!g(FJM ,^Ȏw2\ozwg{(dF6 ( ( ( ( ( ( ( ( ( (;T}O((s϶Mq#PկfcԏӢ'O%$?nloR ( ( ( ( ( ( ( (#y??ʀ8ʡ̟x?H̟ h fkb;b*SwrK)0&ׇtO1F{5ZUOXN;#hޛ>헑 w (!+` ր ;OOI"I^Uܰc`OPiTO8!Qt$1Lqp0:c>}M02*1d NF8!' .ـzy nX/-ܞ\9^HĂu UكOL.su)g [Y frP_=q\m::ےq۞|}"CB)~C`cr;,M%l HpNsO~$F3R;$*:g`Tg}(jR֥ ܫIF;hWao[cNJp8Lv{缅 F5)&`FqeA?{Adsk EY$Um =q tq A!*9޿!wj9g@Ǽ@ePO?ʤdnQ2d@ONy +O?®0?0M;D,?EeGw]( ( rQ6?J`4NM +eR[v.s8)7 n;A=H^ր[#ȱ@xCPiF=:;~tanAebshڴ^YGA, $9䞾MmSvQ<2?AH/7T$n;I ^ҀlUDx =#@{hrc''N ,|R;(#e`Y[pgvcԜh6V8cO->c:{Pi EJ)ܤʼncy=_A(KR IV*r2qGn:PlߦNs=ss<b!\9$=9O~k8&h+`3NO#OHugc9ˎ1-J պ31srg? ~GҀ2dAP@P@P@P@GqqB;>t* ( (#gvq@M$Iu<Szާ=>B4ȴo?,G'Fs鞣) (4mDpG_O^ ydeW+#:(IuTp3Ϡ#ހ*_M˰y":q%[4aovcٗb rzJOH`C3` bzܤqǾ9tZ%&dB @\jq8($Tg_q?Nz{sjtR .U01uh0D|3CO>_nZ>DcGے,0qב ^ KA 8'@P@P@P@GqqB;>t* ( ( "ƻTtNCs(;z> A"X#CIik#&yA pN2 6H||aq4CmlrZ2$rON8pZmU+ Kkaed!K@`?iKlKZX'Yoww =*FPk:dl(Ð08t* ( (#gvq@ "wCF=B%h2zqҐ@FYwh@:$:z'[$϶*_pq@K 0ʥP 1}Vvnn]a#*ݽɠ |S̻GzPjGnߕ ׮#=>{BXIB,G e pϨ㸠)kg9fyڅAi'8Yja6LSZ$I&0 JHr::2  epUatyҀO>]BHh8R %g(E6Idh>IKNApcz)`PCZMFKP Hp s ?.GxMNx8#C@O+]n@!샌|t* ( ( "ƻTtN5@V8Y+c'"].<l-09q}<3gn'GL(N+9mUd#8 s#3wGi<ˌm F:z t+ J|I`?q`쏡& 6[Vܲ^coB{wdz\1 -\r}ϧH`lO$zp0,{pK zcw [?2'=$G=09*c W@!@ ]=/+Θ#RF#cq倦7\K$X``鎞(iZB8V1iQkؒpI 2HQO ,@P@P@Ǽ@ePO?ʤch ( ( ( ( ( ( ( ( (#y??ʀ8ʡ̟x?H@P@P@P@P@P@P@P@P@P@GqqB;>t* ( ( ( ( ( ( ( ( ( =p**w2}U#@P@P@P@P@P@P@P@P@P@{TUdF6 ( (zLH@o΀1m0?\L`/oΐo΀3-fIfG.YYIMc>6?‹o4ݻev)|m?ϱOE?'Qp(AQx(E4 >P (bX?J`'oΐ Ɍ,Zπ?`\щ"Cѕ@y! 7r@L#x3'RTmP@P@:??ʀ@ g$ =p1< wXFPr$N^h$d%3:ށn%7vOQ@ H wih/}{=M0$k۟>p1DyP`\%s(KifQKH.SM fDSp2qo_l)3#a,?= 43{դ@8_KX䴖F LKr{r@i^?,53TF XӠnM( BXAcO_$~@ٙ<@<--&YR\G(WF}=PhV5wOL ?OT#G( ( C*B$}WR~jYQ`K3/)@ 5[59[Bh9J @Rfsh?,(m_wdb=;z,0NGSE?#ӿ穢`Hh$zw4X,/! K_7)P@\^[۪,*1$q0!Բږ_XR~jYQ`K/J,e? E?,(]^\y UdF6 ( ( ( ( ( ( ( ( ( (;hꗬrn_4W'@Iy?~ti^ğW'@Iy?~ti^ğW'@Iy?~ti^ğW'@Iy?~ti^ğW'@Iy?~ti^ğW'@Iy?~ti^ğW'@Iy?~ti^ğW'@Iy?~ti^ğW'@Iy?~ti^ğW'@Iy?~tF Ð{f+Pbrickos-0.9.0/doc/images/Cygwin2.jpg0000644000175000017500000003332207530330674014756 0ustar cbcbJFIF,,C  !"$"$CI" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?h?#MMdJK//'\Ͽ<}@ Wx?_6neٿ姙/~ .e{8е-\\I-!HrH׿ S[vqUN{F[?|w@ S᤼u@ V<#77 5+)|cm o9G$rGIfZmsj5$xQvtfwk4woړ+ ez/rvw3}{~BA]?|k@ T6G]+񍝇4_-Rox^ivW:6 o$qvi1:h^M5x}Hog{}:x #?2Y$2cg8`QmW+jSe@ Tc@ T=X=ς#uan.|=:Ka$̊?iq >򴫻r=KSMK_y\k 5vr#*_?~x/Okey$T_~W\x_^,o :K O],o^WY0 _=?'?K yU$tDXǦ'R'h^qIP(}b [ğI KğyUb*>P_;Y OYi\uf*>W^>ZGT? HT }b,Mo}?`kqTC<M*&گrQTPXuxo&ZI ~>w\Ub*_S!ΗK}Q}7f:ScRkyX4uKSno^+ھV? cERGY}Nj1]$fqKoS+]P?s]cڕEuU_ڞg#?{Wؼ3~g>m|ju#eze*Ԥ߉;[Km%ŖI%ƾ w5EKZ--ѥ;ݦϠhO%}*IJIH3\r>';@F?,3$﷓dO>#hUVaW5MZo NRr}O)sgo>ۣ̎H9#WyΨ\엷އsqq'$\I$ߺnmZȗյ>d|?2% Umb}Jg(OKC?I ſ?nWR| /ſ?n~xF4kgBO}% hO7R–GO7^E7o>H_S^)#OS)#Iݨw_p}J|I?Gԟ|I?G׶G+TSO?nSn?=mԩ? ?I ?zk<#Zk?I [7I(_ԩa [3IOW?z]?ڸ/>H@}[~ltQRpjc$?ԿWwEڸ*G=mK=-vTQRr?Kjm]Uj;ԩ nUG#}Js=#?.uEO~>H̹ԟ`ViVR0};kmoRc<>,q ԿvO벢&SF l".IjW^\^I꣓J>7yI=۰5 xj{GB>>(,I?wL+?EWo$LUUݍSͥxŚO1Ҥ6G?Azt?TzO׷]xUo{{ǘc\9oG-Qd_+oxdto]VGx/c_c]{sZo>ռe^WKWG;r ß .e~v (@((((((((((YHI<[o ?R^:Ԭ:-ɬ㷏>GOiM+_`zLt}Om1^#֖1kTW{8b}H#OYd9"լHOGd$`zLu'|9y>Giask住˷yI'XmweW6drG@ji6Em#̒Yh3ʮQEHQ@~-A7usIeq:v4/W8Gi\r ˉ-pI?矦^iUƓa6z}\Gry:i+a+O: :Օ^VdI96Gq'/d~g/R-;-@I,~b;K?74}I;y-;(._J//q[>$ҭm䲏\q [3ynmⶐGKG'WY?sgݖ~k!_q-4wOS;/GrIHW$ZE-mXoG'~_߿.?pxZo-*I5T$K9,$1#qY:]Z{4]VN4kkeZ_$18~AvMq}ۘ⷏>gOʧ-q[_D_6;($<8䣘Sچc]5+k+{g/.38C._O+xOHi[+~#?yH6;h8Am@5oiSB>]z`8 [;Mضmky"zt^g?ZOݷz5żZzOk)x${>eqgBro h-Yg/eqo/??ʏRׇ5-VV4 &P=ŔrI˒`<^?%ׄtHOKKB|Q^'9#qGJ|]mN Ѥ,o%G'Edo_.ۛ1/?Ri/i2i>_g(#v/ ?q˥}<gIȕm-:rX,͓ԯim㽎8//˒OΎ`-xFRԼ+j:Ϳ +i/m/˒HyZPGQ-$mh&:6c]|G+ż=Y5O hK T(q';/xvRI$d^j^_~/πe'JY<1\j[Cz͞u<2y[lF#y?yW#Gi=zD I,Vw%f~VG%YoL/<{/πe'/πe' ucmg}qh$8"-HH{?3˓}WKCУӒǙ|5?{-̒\O2I<3gy/$^-O7G$^-O7C ~&}8;/ryO벯<ž&NDRK;$ryν*@(7yI_.j?'+JdHS?UΧ״*VeQ@Q@Q@Q@/&:{V>/43WfӴmE-&;[$p}0d_LuzŏMc1xK[k7it@-yQ3[C"EZ\{K -.mA~oͤ/tE}i-Y\Ak\xw׆?}%]i]YxT; rW+<@'ï+Äِpx"8~ς<6m.uu`:wH$PH3Ӓ??rBWSoQ _%xo6EuTP+ _%xo6EBWSoWUErBWSoQ _%xo6EuTP+ _%xo6EBWSoWUErBWSoQ _%xo6EuTP+ _%xo6EBWSoWUErBWSoQ _%xo6EuTPFh.gۼ"HoI?ԮjD(Š( ȹה*(M"^RD5?UZ{GfXQEQEQEQE^ڍW\s<+>i 훟&O9G?') Ƈ?'fy V}s훟&O9G?'( 7?Lr훟&O9YQ4?n?7?Lr裘,hl32?n?gG0Xٹgdl32Ǿ}mm$cCfy Qs<+>9Ƈ?'fy V}s훟&O9G?'cew}YQ6?n?7?Lr裘,]?*HU*(QE (3M"^R7yIҙ>?EUjՙaEPEPEP^]MsjjVYKiXĻU>oI~g3xúOllo2HG%霒Q7OIaˋ(Ž<0_Og?vy~ۭG}$YG/~5imWӊO?͒X7xdO?i'l,dmi#M9uқæMqn$I?--ܖI/#Z?2 'SQa +F팿f3q͏vY$vO>Ur,=V;$Qr[_''ҝ'm76Gw30ߺ$>Vms˓I9+ 2\Iq=wGˏ$qr},4Jkk2swc~-˓gaSQ}Əٽzvg{ryq\yy-^rI$bAo$KrIG,uIu Koj:{$o\~dq?w3gkz>k'TS"yR #Z1@6wG'G̫̏Z_'&q]Kk'ΔdRyQJ1[j1cG\^\I3__XYjtWyO/G<i[o\\6I{yqs'm'%YOPs7~;Vx-`-N`ԞKkxΒI#<{3>_<#ev~N[Ijm`dOorJujj:yKoL?ѿ֦aemg2\I$I$r(EP\O_W&sQ)?U|QZS"G|G^読Vu?UZ,((((((((]ͬU䒩XJ?j+qy{gĶ{#8y/䓈gtҸe>3ռOXY1YW2y_yry?3dҸ[W>EyWν?G$g/:폊t-:=sMŝăF~$G%IZ[in#կRO8$W''O-4SEaxo?۾ӼGeGRGo'yrO_ +hx_^ ً 81^^c+}= ^?^II'ڟN('RM8(΅gsIO>_M?w:ƭojW4~TmtFwQEHx:燼1e\iGQy]s.= vD&,גI? q3O0Q\|uuO𥖻q~̎OJ3[+]@:5͞ghCƛ'.m(yq>c<&|̑ #AqO2;y1gkEyvN=[iљc̷?I'$]whΘ_29<w?gIER?.j?'+ȹה*()# O>#hUV:|G^読YQEQEQEQEQEQEQEP}b;)(㽷H]dIeglnovq\'CZMoy5;HOD^\q~gy4̡|0՞Ms:sqos,6Ekl~1/qyEW0.t'$wi9$x&7Ěb=~W'3Y[t2=-:V^o['#Yi֭P4 gh- cdS.n$O2JmJ׆.NMRY%ؒ8mOw_g<+Zg-̯~s''<\\?tP(@G-Ė\[Esy>,{<^P%gM;!5x-nl糹V\<$Ju:6e[F&5͵y\~dߙ&?#Ҋ,.RGgx͔Hn#Y<?$uo_ޕ_ WA^r@%?]nQHn3]%s\};秙4Oi}H\\II$r(7yI_.j?'+JdHS?UΧ״*VeQ@Q@Q@Q@4{G<toF״*SnY}\>}??\j,~o-.m失-$>\cOCۏ i:.u??'ydR nJ}Q?+Wsk~&7t*V~IKwbX~o[﹑mqGryHc4WQ$1je͗x埗="iR}\ 𾇩𾳫WzK'EǙ,I'=?^dӫ#~ \~odԯc]̽Hųbj+Cy,~gz~x{F+>.KGm,mo |!D?*F%[;;Oiz|Ig$q3(wl^o߇(u愳#Y_??h{b~9C4%?qOxģ\עF[E%:uq;3Y'%O3GZ>g.xϣ]jiYHEdn<#K9)ޏZؼ߅P gnG??d~ -r^hK;r?埙.~)I^^zyr>"KZIgOg.g{G/Jo.$R?'$a+Cy,~gz~-o@,vI,}2[x?ZG~UEݤK.8~OǗq8p=(qMqgյ=jI//.$?\E?$?iN u??4 +Yв~#̎OiW~}??~,Җ.|5i7$ἷ8[G,.~~]ex_*a˭TGm[gB2om0'2c"I#|'m\i}\ڇ^h#TI?y$qё RdWܖvj2E$G/c.?WL/|;Ե]Kƚ,eV;{;swOy#}qoORKˍiH5#??EUjՙaEPEPEPEPrvZMƥeedILO,kO,hO,kǰ,cG,c]u^=eK?eK먢# /2Xיi|xWH#U彖O$#~/{M\GF>*ߦO/^?=?v?ǟ 0V^7y^Okǰ>a/=|otܟcy |i{맗/~({Œ%|UM_׷z~>a/=|otܟ~E`%o4,nI$˒Oyj)`9Y~ƏY~ƺ)=eK?eK먢# /2X /2X]E`9Y~ư_ kV:Vmsqe'tK ȹה*(M"^R; ߈9{k޻UX>6QQZ|mC6hoE ڏfP 3j?X>6QQ@,ͨ?`mGE|mC6hoE ڏfP 3j?X>6QQ@,ͨ?`mGE|mC6hoE ڏfP 3j?X>6QQ@,ͨ?`mGE|mC6hoE ڏfP 3j?X>6QQ@,ͨ?`mGE|mC6hoE ڏfP 3j?X>6QQ@ |9ͼ$#&N+brickos-0.9.0/doc/images/Cygwin3.jpg0000644000175000017500000003160707530330674014763 0ustar cbcbJFIF,,C  !"$"$CI" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?h?#MMdJK//'\Ͽ<}@ Wx?_6neٿ姙/~ .e{8е-\\I-!HrH׿ S[vqUN{F[?|w@ S᤼u@ V<#77 5+)|cm o9G$rGIfZmsj5$xQvtfwk4woړ+ ez/rvw3}{~BA]?|k@ T6G]+񍝇4_-Rox^ivW:6 o$qvi1:h^M5x}Hog{}:x #?2Y$2cg8`QmW+jSe@ Tc@ T=X=ς#uan.|=:Ka$̊?iq >򴫻r=KSMK_y\k 5vr#*_?~x/Okey$T_~W\x_^,o :K O],o^WY0 _=?'?K yU$tDXǦ'R'h^qIP(}b [ğI KğyUb*>P_;Y OYi\uf*>W^>ZGT? HT }b,Mo}?`kqTC<M*&گrQTPXuxo&ZI ~>w\Ub*_S!ΗK}Q}7f:ScRkyX4uKSno^+ھV? cERGY}Nj1]$fqKoS+]P?s]cڕEuU_ڞg#?{Wؼ3~g>m|ju#eze*Ԥ߉;[Km%ŖI%ƾ w5EKZ--ѥ;ݦϠhO%}*IJIH3\r>';@F?,3$﷓dO>#hUVaW5MZo NRr}O)sgo>ۣ̎H9#WyΨ\엷އsqq'$\I$ߺnmZȗյ>d|?2% Umb}Jg(OKC?I ſ?nWR| /ſ?n~xF4kgBO}% hO7R–GO7^E7o>H_S^)#OS)#Iݨw_p}J|I?Gԟ|I?G׶G+TSO?nSn?=mԩ? ?I ?zk<#Zk?I [7I(_ԩa [3IOW?z]?ڸ/>H@}[~ltQRpjc$?ԿWwEڸ*G=mK=-vTQRr?Kjm]Uj;ԩ nUG#}Js=#?.uEO~>H̹ԟ`ViVR0};kmoRc<>,q ԿvO벢&SF l".IjW^\^I꣓J>7yI=۰5 xj{GB>>(,I?wL+?EWo$LUUݍSͥxŚO1Ҥ6G?Azt?TzO׷]xUo{{ǘc\9oG-Qd_+oxdto]VGx/c_c]{sZo>ռe^WKWG;r ß .e~v (@(/&oJͽfoꛣ?4zJR}1cqO3_IAmwe%W6rG$~drGQ˦iyehO//˓~?M;qxZo-*I5T$K9,$1#qY:]Z{4]VN4kkeZ_$18~AvMq}ۘ⷏>gOʧ-q[_D_6;($<8|#.,_ h6Z >%#iXH^h&$riE%qˎ?߇F^-vVnb9#DqctӸBF"ҬD8<O2?W(((((((((((7yI_.j?'+JdHS?^UPswđ[[<;g㹎Iku?U}ݔW\GBv,h|0ד\ӯ d#2By;$?z5"饬+_V=-c%TPyAEVjU"[]^-\ R&N|@?ן?i1y}?k >h3ʮQEHQ@$1 IY|KauwI@sIoGxN`[ \*Ky$;; fY[?3y׳D|Cq{[k;8g8%LI?e#C$yCÒiVLq&ivry~d:zFw 6Uҭ}o'HIϗW?k'v kjmP#iC&R hau?xsQқJ, 9sp珛MxkH{pOi\[:E&ԔSJ-M \:弗RWI/"kg`޲c()U߆@wO[i^ N?uHbyme *Σ{@HN7GWCOc#BV9R%dB+R <3Z4U5&xD(UYd"(Ԏ2Z|S> - 2]Ьmf/9mŷ-rأ!DLHQK-rÖuzz,- "16d=.Ӌ t.!SML˨]%#s3qev0`ۛ:$I>ѯ #:kd# 3|8.m3ZҬHo2k(R(#hO (,B0ZֵoKwK-n X&Bd6w}u'v>=qGiupRG/[+#1VS_ U.|)\kMo #bKƨ#¿i)?+1sĚ}3@{;@koT"6:e8`~Xjw,$wzq1 (_jт7t;"z Z赯xZŝ7BbFMJ'FT,YZUNYY|9hw~ED&g<' FesSo@5( ( ( ( ( (3M"^R7yIҙ>?EUjՙaEPEpcZm߱G+?y8Y,u nsq-J/..-6Gy[s$yP="=Η蹷Dyw x3(㸏̀Y-3~[VzK2//gˑ<$GI<9@z+~ jܱ:oPk%ϟow=ŝqĖ-?韙O_ZxIqocq?2G><P=(#nd(ITO i/?ҘNuCe'XnWk[9Tmu։Am7ckD1ÿ/O9G'~:Ŀ2W__}~?}[M?-Lu'~:Ŀ2Q ߎr/ `Uu}~?}[M?-Lu'~:Ŀ2Q ߎr/ `Uu}~?}[M?-Lu'~:Ŀ2Q ߎr/ `Uu}~?}[M?-Lu߲N_lzy_lO/e{yUn:U"oG։Am7c+C;kD1[MF?-Ltmh&:Ѣ3O iZ' h oG։Am7c(;kD1[MF?-Ltmh&:Ѣ3O iZ' h oRzm٬+k?rr'{I.j?'+ȹה*()# O>#hUV:|G^読YQES̓OEJwMM)-糼H,O/_uEsV Ŕ/gKVQVO*?.9$?.?Ikx O|\'~:Ŀ2Q ߎr/ rc?sj?ğ8g??;^%rou?5{s{q'|ˋ<$I1n r~֍:5edxW3?q]Ϟ$;unbT!|q!cĞ7MR7UzJO-3Z/ -ZWfqE_-3Z/ -Zg_[ʵEex4*iiao(?5U({WKL֋ 9GArQE Zg_[? h0j/U?5QkETQxAr-3Z/ -Zǰ h0iiao*^=kEKL֋ 9V_-3Z/ -^o,^˷Դۙ>'㽎I?ugL?OED7\O_W&sQ)?U|QULxj{GY?EUj̰((Gt[#?W2\'$<ryu\^S4\ipXi6W@FI-#uXh㽸XUq$~.?cX|@{ Klino*=>g<~䑏~_$%x]I+ؾټgo%?I?~vGmmyiyꤎfc%ƫtqI6߻Z~676_n8{,_Ӝ}Ao ?}Ao it?ity3.wg} xKQ xKW O Oəw/ xGU+Ant.,2K{y,JMMMMlVF#ZUwgݟ`zLt}Om1m?o lm?o lp`b;ݟ`zLt}Om1m?o lm?o l ;v}Om1 ?筷_ )t)t`b;} ?筷G$|' O OCg$`zLu-?/7G-?/7G#>ݟ`zLt}Om1m?o lm?o l ;v}Om1 ?筷_ )t)t`b;} ?筷G$|' O OCg$`zLu-?/7G-?/7G#>ݟ`zLt}Om1m?o lm?o l ;v}Om1I%KorξzuE zmؾog׺hNoy1I;xFXzGU:TS.j?'+ȹה*(G|G^読Vu?UZ,((+)~]b=wZӾerqrI'/̏>$W$uQ@*IOkKk ʎ#q.H#$˒9#URxCL{Kĺq.>H?̓drGoO_@.&8#G6َ8u7(%\MaS ȷ +P[_(%\M&WWo#0|s  W?m({ 5o;/0|s  W?m({ 5o;/0|s  W?m({ 5o;/0|s  W?m({ 5o;/0|s  W?m({ 5o;/0|s  W?m({ 5o;/0|s  W?m({ 5o;/0|s  W?m({ 5o;/0|s  W?m({ 5o;/0|s  W?m({ 5o;/0|s  W?m({ 5o;/0|s  W?m({ 5o;/0xƞ>#@gپM_<{rI,y?GL>WIjΚt8?.j?'+ȹה*(G|G^読Vu?UZ,((((((((((((((+oZɮ{DDiy^d/ʹ#J7J m[¿ >MGTwt8Oqˮ?s>յ=jI//.$?\E?$?iM6O~|z6rE)?V> W~,Җ.|5i7$ἷ8[G,.~~]ex_*a˭TGm[gB2om0'2c"I#|'z| /7Q;?$rK_V~dŏ3Y2x{Ú&to h:LyzU:_S &sQ)?U|Q_kEGUE:b״*UO>#hUV ( ( ( ( ( ( ( ( ( ( ( ( ( ( ?Bǁ># Gi~D˗PLvZJ?ZJ)=h?h?b/y?4? IG4? I^E`<7Ŀx~ u/2vRyruU]tBj\O_W&sQ)?U|QUL5o]*,ͨ( X>6Q ڏ?`mG 3j?(oG,ͨ(f|mC6hX>6Q ڏ?`mG 3j?(oG,ͨ(f|mC6hX>6Q ڏ?`mG 3j?(oG,ͨ(f|mC6hX>6Q ڏ?`mG 3j?(oG,ͨ(f|mC6hX>6Q ڏ?`mG 3j?(oG,ͨ(>?_j'QEbrickos-0.9.0/doc/images/caution.gif0000644000175000017500000000201707530330674015060 0ustar cbcbGIF87a!!11BBZZcckkss{{sss{s{cZcc19B191,uH_@Ȑ 6DHB $N$ 4>pиa (e|QGE(YaD`P 8j,XEJt@P?MeHL)%d)؝ JCgep`-[ tYb 16|o "ؕd=H)UDFW4  热-XċBݐ'ơ:o ;brickos-0.9.0/doc/images/home.gif0000644000175000017500000000174307530330674014353 0ustar cbcbGIF87a#!!))11BBJJccssƌΔΥ޵,#%H*\ȰC4p A24 @`42D@` P J F` I(%X`@p@ XAPJ``@:H:)֜\ E٠$P6-Y傐`U{ ֔&d@HAA+^!A.la\ͺ;brickos-0.9.0/doc/images/important.gif0000644000175000017500000000207107530330674015433 0ustar cbcbGIF87a)))999BB1BBBJJJRRRZZ)ccccRccckkBkkkssR{{{9{ZZc{c!9k{JRZZsRck!19R!)1Zc{1B19J!,HpA*ܲĆ ""Bae!A+3,|ҤcG,0$WRTC dd͔ML9& |ܰs 5WR@ARM< $J rSG 8Pܼ"i'c9,""LdOW`+D2ͫ2$>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~, HA*ثR:[1F{1J&R<(Zʓ[Hi&L5 :+ub)LS`QzRAJ5kr͚3F Ftn9 <Ҙ9Mu lFQE=5k-5Szҿw=QbsT¸$eJ{Jq\ǫ=@W˚Z!l3ƦR<-%3!c[B*'{ƚxyǨ^Sj lĊQ9o;6$H;brickos-0.9.0/doc/images/prev.gif0000644000175000017500000000166007530330674014375 0ustar cbcbGIF87a#!!))11BBJJRRkkssƌΔΥ֭,#)H*\ȰCH|bP(@":(P`D@ 4  Ӟ>A,J$ (u U0"A zh@#XA@ H@W߿; ;brickos-0.9.0/doc/images/tip.gif0000644000175000017500000000200507530330674014207 0ustar cbcbGIF87a  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~, HA*xX)J"Btvoa{&!%J,2M3QUQsj)TK!s W&tV{{BYTI7yFЛх*^Uh k`֔x˞ )Hv[?]m&V'^BxpBÀ#DẂV2 g-Oz3& kQ«k='ۘɔ=x"m|_@;brickos-0.9.0/doc/images/toc-blank.gif0000644000175000017500000000013707530330674015271 0ustar cbcbGIF89a , ɇ8۪`%_ƕtf;brickos-0.9.0/doc/images/toc-minus.gif0000644000175000017500000000151307530330674015334 0ustar cbcbGIF89a , 08P*LPÆ641:ܘPč?V"A;brickos-0.9.0/doc/images/toc-plus.gif0000644000175000017500000000151607530330674015167 0ustar cbcbGIF89a , 38P*LPC6tx0hH1LJ)6)qD ;brickos-0.9.0/doc/images/up.gif0000644000175000017500000000163207530330674014044 0ustar cbcbGIF87a#!!))11BBcckkƌΔ޵,##H*\p Dh` @ D(d ,(`KF@Pq̩PB "0PTrL jNjjMsB|4˶m€;brickos-0.9.0/doc/images/warning.gif0000644000175000017500000000203407530330674015062 0ustar cbcbGIF87a!)1BJRZks{{{RRZZ{{99JJ11))))))!!,yC p`6Da p#ǏQ\̈#E S@q#PL"K"NJSpT9@2C^!3 3sh@7 z {5kdeKv5+͚C рJYg0@,Sjuf 8@a@3T G;P}@NNI2C"t́ag}Q;m7fD>ou;w ;brickos-0.9.0/h8300.rcx0000644000175000017500000001127107623774005012202 0ustar cbcb/* * * legOS - the independent LEGO Mindstorms OS * h8300.rcx - linker command file * (c) 1999 by Markus L. Noga * */ OUTPUT_FORMAT("coff-h8300") OUTPUT_ARCH(h8300) ENTRY("_kmain") MEMORY { rom (r) : o = 0x0000, l = 0x8000 ram : o = 0x8000, l = 0x6f30 lcddata : o = 0xef30, l = 0x0020 /* display memory */ ram2 : o = 0xef50, l = 0x00b0 ram3 : o = 0xf002, l = 0x0b7e romdata : o = 0xfd80, l = 0x0040 /* port shadows, interrupt vectors */ ram4 : o = 0xfe00, l = 0x0100 eight : o = 0xff00, l = 0x0100 } SECTIONS { .rom : { /* used rom functions */ _rom_reset_vector = 0x0000; _reset = 0x03ae ; rom_memcpy = 0x042a ; lcd_show = 0x1b62 ; lcd_hide = 0x1e4a ; lcd_number = 0x1ff2 ; lcd_clear = 0x27ac ; power_init = 0x2964 ; sound_system = 0x299a ; power_off = 0x2a62 ; sound_playing = 0x3ccc ; _rom_dummy_handler = 0x046a ; _rom_ocia_handler = 0x04cc ; _rom_ocia_return = 0x04d4 ; } > rom .text : { ___text = . ; *(.text) /* must start with text for clean entry */ *(.rodata) *(.strings) *(.vectors) /* vectors region (dummy) */ ___text_end = . ; _etext = . ; } > ram .tors : { ___ctors = . ; *(.ctors) ___ctors_end = . ; ___dtors = . ; *(.dtors) ___dtors_end = . ; } > ram .data : { ___data = . ; *(.data) *(.tiny) ___data_end = . ; __edata = . ; } > ram .bss : { ___bss = . ; _bss_start = . ; *(.bss) *(COMMON) ___bss_end = ALIGN(2) ; _mm_start = ALIGN(2) ; /* start memory management here */ _end = ALIGN(2) ; } >ram .text.hi : AT (_bss_start) { ___text_hi = . ; *(.text.hi) ___etext_hi = . ; } > ram3 .lcddata : { _display_memory = 0xef43 - 0xef30 ; } > lcddata .romdata : { /* shadow registers */ _rom_port1_ddr = 0x00 ; _rom_port2_ddr = 0x01 ; _rom_port3_ddr = 0x02 ; _rom_port4_ddr = 0x03 ; _rom_port5_ddr = 0x04 ; _rom_port6_ddr = 0x05 ; _rom_port7_pin = 0x06 ; /* interrupt vectors */ _reset_vector = 0x10 ; _nmi_vector = 0x12 ; _irq0_vector = 0x14 ; _irq1_vector = 0x16 ; _irq2_vector = 0x18 ; _icia_vector = 0x1a ; _icib_vector = 0x1c ; _icic_vector = 0x1e ; _icid_vector = 0x20 ; _ocia_vector = 0x22 ; _ocib_vector = 0x24 ; _fovi_vector = 0x26 ; _cmi0a_vector = 0x28 ; _cmi0b_vector = 0x2a ; _ovi0_vector = 0x2c ; _cmi1a_vector = 0x2e ; _cmi1b_vector = 0x30 ; _ovi1_vector = 0x32 ; _eri_vector = 0x34 ; _rxi_vector = 0x36 ; _txi_vector = 0x38 ; _tei_vector = 0x3a ; _ad_vector = 0x3c ; _wovf_vector = 0x3e ; } > romdata .stack : { _stack = . ; *(.stack) } > ram4 .eight : { *(.eight) /* memory-mapped motor controller */ _motor_controller = 0x80 ; /* on-chip module registers (relative to 0xff00) */ _T_IER = 0x90 ; _T_CSR = 0x91 ; _T_CNT = 0x92 ; _T_OCRA = 0x94 ; _T_OCRB = 0x94 ; _T_CR = 0x96 ; _T_OCR = 0x97 ; _T_ICRA = 0x98 ; _T_ICRB = 0x9a ; _T_ICRC = 0x9c ; _T_ICRD = 0x9e ; _WDT_CSR = 0xa8 ; _WDT_CNT = 0xa9 ; _PORT1_PCR = 0xac ; _PORT2_PCR = 0xad ; _PORT3_PCR = 0xae ; _PORT1_DDR = 0xb0 ; _PORT2_DDR = 0xb1 ; _PORT1 = 0xb2 ; _PORT2 = 0xb3 ; _PORT3_DDR = 0xb4 ; _PORT4_DDR = 0xb5 ; _PORT3 = 0xb6 ; _PORT4 = 0xb7 ; _PORT5_DDR = 0xb8 ; _PORT6_DDR = 0xb9 ; _PORT5 = 0xba ; _PORT6 = 0xbb ; _PORT7 = 0xbe ; _STCR = 0xc3 ; _SYSCR = 0xc4 ; _T0_CR = 0xc8 ; _T0_CSR = 0xc9 ; _T0_CORA = 0xca ; _T0_CORB = 0xcb ; _T0_CNT = 0xcc ; _T1_CR = 0xd0 ; _T1_CSR = 0xd1 ; _T1_CORA = 0xd2 ; _T1_CORB = 0xd3 ; _T1_CNT = 0xd4 ; _S_MR = 0xd8 ; _S_BRR = 0xd9 ; _S_CR = 0xda ; _S_TDR = 0xdb ; _S_SR = 0xdc ; _S_RDR = 0xdd ; _AD_A = 0xe0 ; _AD_A_H = 0xe0 ; _AD_A_L = 0xe1 ; _AD_B = 0xe2 ; _AD_B_H = 0xe2 ; _AD_B_L = 0xe3 ; _AD_C = 0xe4 ; _AD_C_H = 0xe4 ; _AD_C_L = 0xe5 ; _AD_D = 0xe6 ; _AD_D_H = 0xe6 ; _AD_D_L = 0xe7 ; _AD_CSR = 0xe8 ; _AD_CR = 0xe9 ; /* end of on-chip module registers */ } > eight .stab 0 (NOLOAD) : { [ .stab ] } .stabstr 0 (NOLOAD) : { [ .stabstr ] } } /* SECTIONS */ brickos-0.9.0/configure0000755000175000017500000001044310004651531012612 0ustar cbcb#!/bin/sh -p # $Id: configure,v 1.10 2004/01/25 05:25:45 stephmo Exp $ # # Generator for brickOS host-OS-dependend Makefile variables # # 15.10.02 - Version 1.0 M. Obenland # obenland@t-online.de # # 21.10.02 - Version 1.0 Updates S. Moraco # stephen@debian.org # # 31.10.02 - Version 1.0a Changed name separation routine # to use dirname / basename to handle # 'gcc' in pathname M. Obenland # obenland@t-online.de # # 01.06.03 - Version 1.10 Changed array of search paths to a list # for compatibility with POSIX /bin/sh # F. Gifford fgiff@users.sourceforge.net # echo "" echo "Welcome to the brickOS Makefile configurator." echo "Attempting to find the Hitachi gcc compiler. (This may take some time.)" echo "" # # check for known files in known locations, first, # so can avoid expensive search # # known PATHs in which h8*gcc may be found TOOL_PATH="/usr/local/bin /usr/bin /usr/h8300-hitachi-hms/bin /usr/local/crossgcc/h8300-hitachi-hms/bin" # known PREFIXs of h8*gcc TOOL_PREFIX="h8300-hms- h8300hms- h8300-hitachi-hms-" HMSFULL="" # for each path, do... for TOOL_PATH_CANDIDATE in $TOOL_PATH do # for each basename prefix. do... for TOOL_PREFIX_CANDIDATE in $TOOL_PREFIX do GCCBASE="$TOOL_PATH_CANDIDATE/${TOOL_PREFIX_CANDIDATE}gcc" #echo "(DBG)Testing GCCBASE=[$GCCBASE]" # for each suffix (.exe and empty str), do... for EXT in ".exe" "" do GCCFSPEC="${GCCBASE}$EXT" if test -f "$GCCFSPEC" then HMSFULL="$GCCFSPEC" break # have answer, exit inner loop fi done if test -n "$HMSFULL" then break # have answer, exit middle fi done if test -n "$HMSFULL" then break # have answer, exit outer loop fi done # # if didn't find in expected location... # search filesystem for full name of hitachi gcc compiler and path # if test -z "$HMSFULL" then HMSFULL=`find / -type f \( -name 'h8*gcc' -o -name 'h8*gcc.exe' \) -print` fi # # if no compiler is found, exit # if test -z "$HMSFULL" then echo "No hitachi gcc compiler found, please install compiler and try again." exit 1 fi # # Toolprefix is full path and compiler name without 'gcc' # DIRNAME=`dirname $HMSFULL` BASENAME=`basename $HMSFULL` TOOLPREFIX=$DIRNAME/$(echo $BASENAME | sed "s/gcc.*//") echo " - Toolprefix = "$TOOLPREFIX # # look for .exe in the compiler name. This indicates Windows environment # which means that CYGWIN or DJGPP toolset is being used # case "$HMSFULL" in *.exe) echo " - Found Cygwin/DJGPP system" SED_SFLAG=1 EXT=.exe CC=gcc CFLAGS=-D_WIN32 CFLG_PE='+' ;; *) echo " - Found Linux/Unix system" SED_SFLAG="" EXT="" CC=cc CFLAGS="-O2 -Wall" CFLG_PE="" ;; esac echo "" MAKEDEPEND="\$(CC) -M" BRICKOS_ROOT=`pwd` CURR_MAKEFILE=Makefile.common NEW_MAKEFILE=${CURR_MAKEFILE}.new PRIOR_MAKEFILE=${CURR_MAKEFILE}.bak cat $CURR_MAKEFILE | awk -v sedFlag=$SED_FLAG \ -v ext=$EXT \ -v cc=$CC \ -v cflags="$CFLAGS" \ -v toolPrefix="$TOOLPREFIX" \ -v mkdep="$MAKEDEPEND" \ -v brickosRoot=$BRICKOS_ROOT \ -v cflgPleq=$CFLG_PE \ ' BEGIN { inInsert=0 sep="# -------------------------------------------------------" } ($2 == "END-configuration") { inInsert=0 print sep print "TOOLPREFIX=" toolPrefix print "SED_SFLAG=" sedFlag print "EXT=" ext print "CC=" cc print "CFLAGS" cflgPleq "=" cflags print "MAKEDEPEND=" mkdep print "BRICKOS_ROOT=" brickosRoot print sep } (inInsert) { next } ($2 == "BEGIN-configuration") { inInsert=1 } { print $0 } END { }' >$NEW_MAKEFILE cmp -s $CURR_MAKEFILE $NEW_MAKEFILE RET_CODE=$? if test $RET_CODE -eq 1 then rm -f $PRIOR_MAKEFILE mv $CURR_MAKEFILE $PRIOR_MAKEFILE mv $NEW_MAKEFILE $CURR_MAKEFILE else rm -f $NEW_MAKEFILE echo "configure: no configuration changes needed, nothing done." echo "" fi touch .configured.flg # tell Make system we are now configured exit 0 brickos-0.9.0/debian/0000775000175000017500000000000010517714404012135 5ustar cbcbbrickos-0.9.0/debian/README.Source0000664000175000017500000000054710517714404014262 0ustar cbcbThe upstream source package is modified as follows, and repacked as the "dfsg" version: remove doc/HOWTO.sgml adjust doc/Makefile This file is licensed under the Linux Documenation Project (LDP) Copying License which does not allow modification and hence cannot be included in Debian. -- Christoph Berg Wed, 25 Oct 2006 19:03:13 +0200