***************************************************************************** *** Files Organization *** ***************************************************************************** --{root} - ChibiOS/RT directory. +--readme.txt - This file. +--documentation.html - Shortcut to the web documentation page. +--todo.txt - Current plan (development/unstable versions only). +--license.txt - GPL license text. +--exception.txt - GPL exception text (stable releases only). +--boards/ - Board support files. +--demos/ - Demo projects. +--docs/ - Documentation. | +--html/ - Local HTML documentation (after rebuild). | +--reports/ - Test reports. | +--src/ - Documentation source files (required for rebuild). | +--rsc/ - Documentation resource files (required for rebuild). | +--Doxyfile - Doxygen project file (required for rebuild). | +--index.html - Local documentation access (after rebuild). +--ext/ - External libraries, not part of ChibiOS/RT. +--os/ - ChibiOS/RT files. | +--hal/ - Hardware Abstraction Layer. | | +--include/ - HAL high level headers. | | +--src/ - HAL high level source. | | +--platforms/ - HAL low level drivers implementations. | | | +--AT91SAM7/ - Drivers for AT91SAM7 platform. | | | +--AVR/ - Drivers for AVR platform. | | | +--LPC11xx/ - Drivers for LPC11xx platform. | | | +--LPC13xx/ - Drivers for LPC13xx platform. | | | +--LPC214x/ - Drivers for LPC214x platform. | | | +--MSP430/ - Drivers for MSP430 platform. | | | +--SPC56x/ - Drivers for SPC56x/MPC563xx platforms. | | | +--STM32/ - Drivers for STM32 platform. | | | +--STM8L/ - Drivers for STM8L platform. | | | +--STM8S/ - Drivers for STM8S platform. | | | +--Posix/ - Drivers for x86 Linux/OSX simulator platform. | | | +--Win32/ - Drivers for x86 Win32 simulator platform. | | +--templates/ - Driver template files. | | +--meta/ - Driver meta templates. | +--ports/ - Port files for the various architectures. | | +--GCC/ - Ports for the GCC compiler. | | | +--ARM/ - Port files for ARM7 and ARM9 architectures. | | | +--ARMCMx/ - Port files for ARMCMx architectures (ARMv6/7-M). | | | +--PPC/ - Port files for PowerPC architecture. | | | +--AVR/ - Port files for AVR architecture. | | | +--MSP430/ - Port files for MSP430 architecture. | | | +--SIMIA32/ - Port files for SIMIA32 simulator architecture. | | +--IAR/ - Ports for the IAR compiler. | | | +--ARMCMx/ - Port files for ARMCMx architectures (ARMv6/7-M). | | +--RVCT/ - Ports for the Keil RVCT compiler. | | | +--ARMCMx/ - Port files for ARMCMx architectures (ARMv6/7-M). | | +--cosmic/ - Ports for the Cosmic compiler. | | | +--STM8/ - Port files for STM8 architecture. | | +--RC/ - Ports for the Raisonance compiler. | | +--STM8/ - Port files for STM8 architecture. | +--kernel/ - Kernel portable files. | | +--include/ - Kernel headers. | | +--src/ - Kernel source. | | +--templates/ - Kernel port template files. | +--various/ - Various portable support files. +--test/ - Kernel test suite source code. | +--coverage/ - Code coverage project. +--testhal/ - HAL integration test demos. +--LPC11xx/ - LPC11xx HAL test demos. +--LPC13xx/ - LPC13xx HAL test demos. +--STM32/ - STM32 HAL test demos. +--STM8S/ - STM8S HAL test demos. ***************************************************************************** *** Releases *** ***************************************************************************** *** 2.3.4 *** - FIX: Fixed wrong macro check in STM32 UART driver (bug 3311999)(backported to 2.2.6). - FIX: Fixed wrong macro definition in ARMv6-M architecture files (bug 3310084). - NEW: FatFs demo for the STM32F103ZG using the SDC driver. - NEW: Now the STM32 SDC driver supports unaligned buffers transparently. Optimized the driver for single block read and write operations. Optimized the driver state machine. - NEW: Finished the reorganization of the Cortex-Mx ports, now also the IAR and RVCT ports support the new Compact mode. - NEW: Added to the ARMv6-M sub-port an option to use the PendSV exception instead of NMI for preemption (backported to 2.2.5). *** 2.3.3 *** - FIX: Fixed race condition in output queues (bug 3303908)(backported to 2.2.4). - FIX: Fixed CH_USE_HEAP and CH_USE_MALLOC_HEAP conflict (bug 3303841) (backported to 2.2.4). - FIX: Fixed timeout problem in the lwIP interface layer (bug 3302420) (backported to 2.2.4). - NEW: Reorganization of the Cortex-Mx ports in order to reduced code and comments duplication in the various headers (backported to 2.2.5). - NEW: Improved the ARMv7-M sub-port now there are two modes: Compact and Advanced. The advanced mode is equivalent to the previous versions, the compact mode is new and makes the kernel *much* smaller and generally faster but does not support fast interrupts (backported to 2.2.5). - NEW: Now the port layer exports info regarding the compiler and the port options. The info are printed into the test reports. - CHANGE: Renamed the macros IDLE_THREAD_STACK_SIZE and INT_REQUIRED_STACK to PORT_IDLE_THREAD_STACK_SIZE and PORT_INT_REQUIRED_STACK for consistency. - CHANGE: Removed the "old" Cortex-M3 port from the code, the current port has no drawbacks and the old port is now just a maintenance cost. - CHANGE: Removed the CH_CURRP_REGISTER_CACHE option, it is GCC-specific so it does not belong to the kernel options. The feature will be eventually reimplemented as a port-specific option. - CHANGE: chiQGetFullI() and chOQGetFullI() become macros. The queues subsystem has been optimized and is no more dependent on semaphores. Note that the queues callbacks invocation policy has been slightly changed, see the documentation (backported to 2.2.4). *** 2.3.2 *** - FIX: Fixed invalid BRR() macro in AVR serial driver (bug 3299306)(backported to 2.2.4). - FIX: Fixed missing IRQ vectors amicable names for STM32 XL devices (bug 3298889)(backported to 2.2.4). - FIX: Fixed wrong identifier in AVR serial driver (bug 3292084)(backported to 2.2.4). - FIX: Fixed wrong macro check for STM32 XL devices (bug 3291898)(backported to 2.2.4). - FIX: Fixed SPI driver restart in STM32 SPI driver implementation, also applied the same fix to the STM8S SPI driver (bug 3288758)(backported to 2.2.4). - FIX: Fixed missing state transition in ADC driver (bug 3288149)(backported to 2.2.4). - FIX: Fixed missing state transition in SPI driver (bug 3288112)(backported to 2.2.4). - FIX: Fixed spurious characters generated by Serial over USB driver (bug 3276379). - NEW: Added an option to the kernel to not spawn the Idle Thread from within chSysInit(), this way the application can spawn a custom idle thread or even use the main() thread as idle thread (backported to 2.2.4). - NEW: Added new SDC driver model, Secure Digital Card. - NEW: SDC driver implementation for STM32. - NEW: Updated the STM32 header file to the latest version 3.4.0, had to fix a bug regarding the STM32 XL sub-family. - NEW: New unified GCC startup file for Cortex-Mx processors, it is written in C instead of asm and supports constructors/destructors. Improved the Cortex-Mx linker scripts in all the GCC demos. - NEW: Now it is possible to share DMA channels in the STM32 HAL thanks to a centralized manager. Channels are allocated when the driver is started and released when it is stopped. - NEW: Added an STM32 C++ demo for the GNU compiler. - NEW: Added an STM32F103ZG demo for the STM3210E-EVAL evaluation board. - OPT: STM32 PWM driver implementation simplified. - CHANGE: Now pwmChangePeriod() does not implicitly disable the active PWM channels. - CHANGE: Renamed the chSemSetCounterI() function to chSemAddCounterI() and changed its behavior. - CHANGE: Modified the STM32 USB-CDC test demo to spawn a shell over the USB serial connection. *** 2.3.1 *** - FIX: Fixed insufficient idle thread stack in Cortex-M0-GCC port (bug 3226671) (backported to 2.2.3). - FIX: Fixed stack checking in Cortex-M0-GCC port (bug 3226657)(backported to 2.2.3). - FIX: Fixed wrong checks in PAL driver (bug 3224681)(backported to 2.2.3). - FIX: Fixed wrong checks in I/O Queues (bug 3219197)(backported to 2.2.3). - FIX: Fixed invalid assertion in adcConvert() (bug 3205410)(backported to 2.2.3). - NEW: Improvements to the PWM driver model: - Easier configuration similar to the GPT driver initializati
/*******************************************************************************************[Map.h]
Copyright (c) 2006-2010, Niklas Sorensson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************************************/
#ifndef Minisat_Map_h
#define Minisat_Map_h
#include "IntTypes.h"
#include "Vec.h"
namespace Minisat {
//=================================================================================================
// Default hash/equals functions
//
template<class K> struct Hash { uint32_t operator()(const K& k) const { return hash(k); } };
template<class K> struct Equal { bool operator()(const K& k1, const K& k2) const { return k1 == k2; } };
template<class K> struct DeepHash { uint32_t operator()(const K* k) const { return hash(*k); } };
template<class K> struct DeepEqual { bool operator()(const K* k1, const K* k2) const { return *k1 == *k2; } };
static inline uint32_t hash(uint32_t x){ return x; }
static inline uint32_t hash(uint64_t x){ return (uint32_t)x; }
static inline uint32_t hash(int32_t x) { return (uint32_t)x; }
static inline uint32_t hash(int64_t x) { return (uint32_t)x; }
//=================================================================================================
// Some primes
//
static const int nprimes = 25;
static const int primes [nprimes] = { 31, 73, 151, 313, 643, 1291, 2593, 5233, 10501, 21013, 42073, 84181, 168451, 337219, 674701, 1349473, 2699299, 5398891, 10798093, 21596719, 43193641, 86387383, 172775299, 345550609, 691101253 };
//=================================================================================================
// Hash table implementation of Maps
//
template<class K, class D, class H = Hash<K>, class E = Equal<K> >
class Map {
public:
struct Pair { K key; D data; };
private:
H hash;
E equals;
vec<Pair>* table;
int cap;
int size;
// Don't allow copying (error prone):
Map<K,D,H,E>& operator = (Map<K,D,H,E>& other);
Map (Map<K,D,H,E>& other);
bool checkCap(int new_size) const { return new_size > cap; }
int32_t index (const K& k) const { return hash(k) % cap; }
void _insert (const K& k, const D& d) {
vec<Pair>& ps = table[index(k)];
ps.push(); ps.last().key = k; ps.last().data = d; }
void rehash () {
const vec<Pair>* old = table;
int old_cap = cap;
int newsize = primes[0];
for (int i = 1; newsize <= cap && i < nprimes; i++)
newsize = primes[i];
table = new vec<Pair>[newsize];
cap = newsize;
for (int i = 0; i < old_cap; i++){
for (int j = 0; j < old[i].size(); j++){
_insert(old[i][j].key, old[i][j].data); }}
delete [] old;
// printf(" --- rehashing, old-cap=%d, new-cap=%d\n", cap, newsize);
}
public:
Map () : table(NULL), cap(0), size(0) {}
Map (const H& h, const E& e) : hash(h), equals(e), table(NULL), cap(0), size(0){}
~Map () { delete [] table; }
// PRECONDITION: the key must already exist in the map.
const D& operator [] (const K& k) const
{
assert(size != 0);
const D* res = NULL;
const vec<Pair>& ps = table[index(k)];
for (int i = 0; i < ps.size(); i++)
if (equals(ps[i].key, k))
res = &ps[i].data;
assert(res != NULL);
return *res;
}
// PRECONDITION: the key must already exist in the map.
D& operator [] (const K& k)
{
assert(size != 0);
D* res = NULL;
vec<Pair>& ps = table[index(k)];
for (int i = 0; i < ps.size(); i++)
if (equals(ps[i].key, k))
res = &ps[i].data;
assert(res != NULL);
return *res;
}
// PRECONDITION: the key must *NOT* exist in the map.
void insert (const K& k, const D& d) { if (checkCap(size+1)) rehash(); _insert(k, d); size++; }
bool peek (const K& k, D& d) const {
if (size == 0) return false;
const vec<Pair>& ps = table[index(k)];
for (int i = 0; i < ps.size(); i++)
if (equals(ps[i].key, k)){
d = ps[i].data;
return true; }
return false;
}
bool has (const K& k) const {
if (size == 0) return false;
const vec<Pair>& ps = table[index(k)];
for (int i = 0; i < ps.size(); i++)
if (equals(ps[i].key, k))
return true;
return false;
}
// PRECONDITION: the key must exist in the map.
void remove(const K& k) {
assert(table != NULL);
vec<Pair>& ps = table[index(k)];
int j = 0;
for (; j < ps.size() && !equals(ps[j].key, k); j++);
assert(j < ps.size());
ps[j] = ps.last();
ps.pop();
size--;
}
void clear () {
cap = size = 0;
delete [] table;
table = NULL;
}
int elems() const { return size; }
int bucket_count() const { return cap; }
// NOTE: the hash and equality objects are not moved by this method:
void moveTo(Map& other){
delete [] other.table;
other.table = table;
other.cap = cap;
other.size = size;
table = NULL;
size = cap = 0;
}
// NOTE: given a bit more time, I could make a more C++-style iterator out of this:
const vec<Pair>& bucket(int i) const { return table[i]; }
};
//=================================================================================================
}
#endif