From 1c5c8798c7d3cc41954e4fb8fc072f51f9c12d81 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 19 Jun 2017 09:38:18 +0200 Subject: [PATCH] Removing old/unused libs --- core/contiki-lib.h | 1 - core/lib/gcr.c | 162 ------- core/lib/gcr.h | 51 -- core/lib/me.c | 116 ----- core/lib/me.h | 75 --- core/lib/me_tabs.c | 121 ----- core/lib/me_tabs.h | 40 -- core/lib/mmem.c | 164 ------- core/lib/mmem.h | 93 ---- core/lib/petsciiconv.c | 119 ----- core/lib/petsciiconv.h | 79 --- core/lib/print-stats.c | 82 ---- core/lib/print-stats.h | 45 -- core/lib/settings.c | 475 ------------------- core/lib/settings.h | 352 -------------- core/net/ipv6/websocket.c | 1 - drivers/cpu/msp430/Makefile.msp430 | 2 +- examples/settings-example/Makefile | 5 - examples/settings-example/settings-example.c | 151 ------ 19 files changed, 1 insertion(+), 2133 deletions(-) delete mode 100644 core/lib/gcr.c delete mode 100644 core/lib/gcr.h delete mode 100644 core/lib/me.c delete mode 100644 core/lib/me.h delete mode 100644 core/lib/me_tabs.c delete mode 100644 core/lib/me_tabs.h delete mode 100644 core/lib/mmem.c delete mode 100644 core/lib/mmem.h delete mode 100644 core/lib/petsciiconv.c delete mode 100644 core/lib/petsciiconv.h delete mode 100644 core/lib/print-stats.c delete mode 100644 core/lib/print-stats.h delete mode 100644 core/lib/settings.c delete mode 100644 core/lib/settings.h delete mode 100644 examples/settings-example/Makefile delete mode 100644 examples/settings-example/settings-example.c diff --git a/core/contiki-lib.h b/core/contiki-lib.h index 7ff67fbb0..01837a0ab 100644 --- a/core/contiki-lib.h +++ b/core/contiki-lib.h @@ -37,7 +37,6 @@ #include "contiki.h" #include "lib/list.h" #include "lib/memb.h" -#include "lib/mmem.h" #include "lib/random.h" #endif /* CONTIKI_LIB_H_ */ diff --git a/core/lib/gcr.c b/core/lib/gcr.c deleted file mode 100644 index 36ee98ea2..000000000 --- a/core/lib/gcr.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Implementation of GCR coding/decoding - * \author - * Joakim Eriksson - * - */ - -/* GCR conversion table - used for converting ordinary byte to 10-bits */ -/* (or 4 bits to 5) */ -static const unsigned char GCR_encode[16] = { - 0x0a, 0x0b, 0x12, 0x13, - 0x0e, 0x0f, 0x16, 0x17, - 0x09, 0x19, 0x1a, 0x1b, - 0x0d, 0x1d, 0x1e, 0x15 -}; - -/* 5 bits > 4 bits (0xff => invalid) */ -static const unsigned char GCR_decode[32] = { - 0xff, 0xff, 0xff, 0xff, // 0 - 3invalid... - 0xff, 0xff, 0xff, 0xff, // 4 - 7 invalid... - 0xff, 0x08, 0x00, 0x01, // 8 invalid... 9 = 8, a = 0, b = 1 - 0xff, 0x0c, 0x04, 0x05, // c invalid... d = c, e = 4, f = 5 - - 0xff, 0xff, 0x02, 0x03, // 10-11 invalid... - 0xff, 0x0f, 0x06, 0x07, // 14 invalid... - 0xff, 0x09, 0x0a, 0x0b, // 18 invalid... - 0xff, 0x0d, 0x0e, 0xff, // 1c, 1f invalid... - }; - -static unsigned char gcr_bits = 0; -static unsigned short gcr_val = 0; - -/* Call before starting encoding or decoding */ -void gcr_init(void) { - gcr_val = 0; - gcr_bits = 0; -} - -/* Use this to check if encoding / decoding is complete for now */ -unsigned char gcr_finished(void) { - return gcr_bits == 0; -} - -/* Encode one character - and store in bits - get encoded with get_encoded */ -void gcr_encode(unsigned char raw_data) { - gcr_val |= - ((GCR_encode[raw_data >> 4u] << 5u ) | - GCR_encode[raw_data & 0xf]) << gcr_bits; - gcr_bits += 10; -} - -/* Gets the current char of the encoded stream */ -unsigned char gcr_get_encoded(unsigned char *raw_data) { - if (gcr_bits >= 8) { - *raw_data = (unsigned char) (gcr_val & 0xff); - gcr_val = gcr_val >> 8u; - gcr_bits = gcr_bits - 8; - return 1; - } - return 0; -} - -/* Decode one char - result can be get from get_decoded */ -void gcr_decode(unsigned char gcr_data) { - gcr_val |= gcr_data << gcr_bits; - gcr_bits += 8; -} - -/* check if the current decoded stream is correct */ -unsigned char gcr_valid(void) { - if (gcr_bits >= 10) { - unsigned short val = gcr_val & 0x3ff; - if ((GCR_decode[val >> 5u] << 4u) == 0xff || - (GCR_decode[val & 0x1f]) == 0xff) { - return 0; - } - } - return 1; -} - -/* gets the decoded stream - if any char is available */ -unsigned char gcr_get_decoded(unsigned char *raw_data) { - if (gcr_bits >= 10) { - unsigned short val = gcr_val & 0x3ff; - *raw_data = (unsigned char) ((GCR_decode[val >> 5] << 4) | - (GCR_decode[val & 0x1f])); - gcr_val = gcr_val >> 10; - gcr_bits = gcr_bits - 10; - return 1; - } - return 0; -} - -/* -static const char encoded[] = { - 0x4a, 0x25, 0xa5, 0xfc, 0x96, 0xff, 0xff, 0xb5, 0xd4, 0x5a, 0xea, 0xff, 0xff, 0xaa, 0xd3, 0xff -}; - -int main(int argc, char **argv) { - // unsigned char c[] = "testing gcr 1 2 3 4 5 6..."; - unsigned char c[] = { 0, 8, 0xe0, 0x2b, 0xac, 0x10, 0x01, 0x11, 0x50, 0xff, 0xf4, 0xa4, 0x00 }; - unsigned char c2[200]; - int pos = 0, pos2 = 0, i = 0; - - printf("Testing GCR on: %s \n", c); - - gcr_init(); - for (i = 0; i < sizeof(c); i++) { - gcr_encode(c[i]); - while(gcr_get_encoded(&c2[pos])) { - printf("%02x=>%02x ", c[i], c2[pos]); - pos++; - } - } - printf("\n"); - printf("Encoded result %d chars (from %d) \n", pos, i); - gcr_init(); - for (i = 0; i < pos; i++) { - gcr_decode(c2[i]); - if(!gcr_valid()) { - printf("GCR: not valid\n"); - } - while(gcr_get_decoded(&c[pos2])) { - pos2++; - } - } - printf("GCR: %s\n",c); -} -*/ diff --git a/core/lib/gcr.h b/core/lib/gcr.h deleted file mode 100644 index 10c36550d..000000000 --- a/core/lib/gcr.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2006-10-02 - * Updated : $Date: 2006/10/05 09:23:41 $ - * $Revision: 1.1 $ - */ - -#ifndef GCR_H_ -#define GCR_H_ - -void gcr_init(); -unsigned char gcr_finished(); - -void gcr_encode(unsigned char raw_data); - -void gcr_decode(unsigned char gcr_data); -unsigned char gcr_get_encoded(unsigned char *raw_data); -unsigned char gcr_get_decoded(unsigned char *raw_data); -unsigned char gcr_valid(); - -#endif /* GCR_H_ */ diff --git a/core/lib/me.c b/core/lib/me.c deleted file mode 100644 index 33f487a83..000000000 --- a/core/lib/me.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** \addtogroup me - * @{ */ - -/** - * \file - * Implementation of the table-driven Manchester encoding and decoding. - * \author - * Adam Dunkels - */ - -#include "me_tabs.h" - -/*---------------------------------------------------------------------------*/ -/** - * Manchester encode an 8-bit byte. - * - * This function Manchester encodes an 8-bit byte into a 16-bit - * word. The function me_decode() does the inverse operation. - * - * \param c The byte to be encoded - * - * \retval The encoded word. - */ -/*---------------------------------------------------------------------------*/ -unsigned short -me_encode(unsigned char c) -{ - return me_encode_tab[c]; -} -/*---------------------------------------------------------------------------*/ -/** - * Decode a Manchester encoded 16-bit word. - * - * This function decodes a Manchester encoded 16-bit word into a 8-bit - * byte. The function does not check for parity errors in the encoded - * byte. - * - * \param m The 16-bit Manchester encoded word - * \return The decoded 8-bit byte - */ -/*---------------------------------------------------------------------------*/ -unsigned char -me_decode16(unsigned short m) -{ - unsigned char m1, m2, c; - - m1 = m >> 8; - m2 = m & 0xff; - - c = (me_decode_tab[m1] << 4) | - me_decode_tab[m2]; - return c; -} -/*---------------------------------------------------------------------------*/ -/** - * Decode a Manchester encoded 8-bit byte. - * - * This function decodes a Manchester encoded 8-bit byte into 4 - * decoded bits.. The function does not check for parity errors in the - * encoded byte. - * - * \param m The 8-bit Manchester encoded byte - * \return The decoded 4 bits - */ -/*---------------------------------------------------------------------------*/ -unsigned char -me_decode8(unsigned char m) -{ - return me_decode_tab[m]; -} -/*---------------------------------------------------------------------------*/ -/** - * Check if an encoded byte is valid. - */ -/*---------------------------------------------------------------------------*/ -unsigned char -me_valid(unsigned char m) -{ - return me_valid_tab[m]; -} -/*---------------------------------------------------------------------------*/ - -/** @} */ - diff --git a/core/lib/me.h b/core/lib/me.h deleted file mode 100644 index 44abcee61..000000000 --- a/core/lib/me.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** \addtogroup lib - @{ */ - -/** - * \defgroup me Table-driven Manchester encoding and decoding - * - * Manchester encoding is a bit encoding scheme which translates each - * bit into two bits: the original bit and the inverted bit. - * - * Manchester encoding is used for transmitting ones and zeroes - * between two computers. The Manchester encoding reduces the receive - * oscillator drift by making sure that no consecutive ones or zeroes - * are ever transmitted. - * - * The table driven method of Manchester encoding and decoding uses - * two tables with 256 entries. One table is a direct mapping of an - * 8-bit byte into a 16-bit Manchester encoding of the byte. The - * second table is a mapping of a Manchester encoded 8-bit byte to 4 - * decoded bits. - * - * @{ - */ - -/** - * \file - * Header file for the table-driven Manchester encoding and decoding - * \author - * Adam Dunkels - * - */ - -#ifndef ME_H_ -#define ME_H_ - -unsigned char me_valid(unsigned char m); -unsigned short me_encode(unsigned char c); -unsigned char me_decode16(unsigned short m); -unsigned char me_decode8(unsigned char m); - -#endif /* ME_H_ */ - -/** @} */ -/** @} */ diff --git a/core/lib/me_tabs.c b/core/lib/me_tabs.c deleted file mode 100644 index dab8d6038..000000000 --- a/core/lib/me_tabs.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -const unsigned short me_encode_tab[256] = { -0x5555, 0x5556, 0x5559, 0x555a, 0x5565, 0x5566, 0x5569, 0x556a, 0x5595, -0x5596, 0x5599, 0x559a, 0x55a5, 0x55a6, 0x55a9, 0x55aa, 0x5655, 0x5656, -0x5659, 0x565a, 0x5665, 0x5666, 0x5669, 0x566a, 0x5695, 0x5696, 0x5699, -0x569a, 0x56a5, 0x56a6, 0x56a9, 0x56aa, 0x5955, 0x5956, 0x5959, 0x595a, -0x5965, 0x5966, 0x5969, 0x596a, 0x5995, 0x5996, 0x5999, 0x599a, 0x59a5, -0x59a6, 0x59a9, 0x59aa, 0x5a55, 0x5a56, 0x5a59, 0x5a5a, 0x5a65, 0x5a66, -0x5a69, 0x5a6a, 0x5a95, 0x5a96, 0x5a99, 0x5a9a, 0x5aa5, 0x5aa6, 0x5aa9, -0x5aaa, 0x6555, 0x6556, 0x6559, 0x655a, 0x6565, 0x6566, 0x6569, 0x656a, -0x6595, 0x6596, 0x6599, 0x659a, 0x65a5, 0x65a6, 0x65a9, 0x65aa, 0x6655, -0x6656, 0x6659, 0x665a, 0x6665, 0x6666, 0x6669, 0x666a, 0x6695, 0x6696, -0x6699, 0x669a, 0x66a5, 0x66a6, 0x66a9, 0x66aa, 0x6955, 0x6956, 0x6959, -0x695a, 0x6965, 0x6966, 0x6969, 0x696a, 0x6995, 0x6996, 0x6999, 0x699a, -0x69a5, 0x69a6, 0x69a9, 0x69aa, 0x6a55, 0x6a56, 0x6a59, 0x6a5a, 0x6a65, -0x6a66, 0x6a69, 0x6a6a, 0x6a95, 0x6a96, 0x6a99, 0x6a9a, 0x6aa5, 0x6aa6, -0x6aa9, 0x6aaa, 0x9555, 0x9556, 0x9559, 0x955a, 0x9565, 0x9566, 0x9569, -0x956a, 0x9595, 0x9596, 0x9599, 0x959a, 0x95a5, 0x95a6, 0x95a9, 0x95aa, -0x9655, 0x9656, 0x9659, 0x965a, 0x9665, 0x9666, 0x9669, 0x966a, 0x9695, -0x9696, 0x9699, 0x969a, 0x96a5, 0x96a6, 0x96a9, 0x96aa, 0x9955, 0x9956, -0x9959, 0x995a, 0x9965, 0x9966, 0x9969, 0x996a, 0x9995, 0x9996, 0x9999, -0x999a, 0x99a5, 0x99a6, 0x99a9, 0x99aa, 0x9a55, 0x9a56, 0x9a59, 0x9a5a, -0x9a65, 0x9a66, 0x9a69, 0x9a6a, 0x9a95, 0x9a96, 0x9a99, 0x9a9a, 0x9aa5, -0x9aa6, 0x9aa9, 0x9aaa, 0xa555, 0xa556, 0xa559, 0xa55a, 0xa565, 0xa566, -0xa569, 0xa56a, 0xa595, 0xa596, 0xa599, 0xa59a, 0xa5a5, 0xa5a6, 0xa5a9, -0xa5aa, 0xa655, 0xa656, 0xa659, 0xa65a, 0xa665, 0xa666, 0xa669, 0xa66a, -0xa695, 0xa696, 0xa699, 0xa69a, 0xa6a5, 0xa6a6, 0xa6a9, 0xa6aa, 0xa955, -0xa956, 0xa959, 0xa95a, 0xa965, 0xa966, 0xa969, 0xa96a, 0xa995, 0xa996, -0xa999, 0xa99a, 0xa9a5, 0xa9a6, 0xa9a9, 0xa9aa, 0xaa55, 0xaa56, 0xaa59, -0xaa5a, 0xaa65, 0xaa66, 0xaa69, 0xaa6a, 0xaa95, 0xaa96, 0xaa99, 0xaa9a, -0xaaa5, 0xaaa6, 0xaaa9, 0xaaaa, }; -const unsigned char me_decode_tab[256] = { -0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x2, -0x2, 0x3, 0x3, 0x2, 0x2, 0x3, 0x3, 0x0, 0x0, -0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x2, 0x2, 0x3, -0x3, 0x2, 0x2, 0x3, 0x3, 0x4, 0x4, 0x5, 0x5, -0x4, 0x4, 0x5, 0x5, 0x6, 0x6, 0x7, 0x7, 0x6, -0x6, 0x7, 0x7, 0x4, 0x4, 0x5, 0x5, 0x4, 0x4, -0x5, 0x5, 0x6, 0x6, 0x7, 0x7, 0x6, 0x6, 0x7, -0x7, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, -0x2, 0x2, 0x3, 0x3, 0x2, 0x2, 0x3, 0x3, 0x0, -0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x2, 0x2, -0x3, 0x3, 0x2, 0x2, 0x3, 0x3, 0x4, 0x4, 0x5, -0x5, 0x4, 0x4, 0x5, 0x5, 0x6, 0x6, 0x7, 0x7, -0x6, 0x6, 0x7, 0x7, 0x4, 0x4, 0x5, 0x5, 0x4, -0x4, 0x5, 0x5, 0x6, 0x6, 0x7, 0x7, 0x6, 0x6, -0x7, 0x7, 0x8, 0x8, 0x9, 0x9, 0x8, 0x8, 0x9, -0x9, 0xa, 0xa, 0xb, 0xb, 0xa, 0xa, 0xb, 0xb, -0x8, 0x8, 0x9, 0x9, 0x8, 0x8, 0x9, 0x9, 0xa, -0xa, 0xb, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xc, -0xd, 0xd, 0xc, 0xc, 0xd, 0xd, 0xe, 0xe, 0xf, -0xf, 0xe, 0xe, 0xf, 0xf, 0xc, 0xc, 0xd, 0xd, -0xc, 0xc, 0xd, 0xd, 0xe, 0xe, 0xf, 0xf, 0xe, -0xe, 0xf, 0xf, 0x8, 0x8, 0x9, 0x9, 0x8, 0x8, -0x9, 0x9, 0xa, 0xa, 0xb, 0xb, 0xa, 0xa, 0xb, -0xb, 0x8, 0x8, 0x9, 0x9, 0x8, 0x8, 0x9, 0x9, -0xa, 0xa, 0xb, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, -0xc, 0xd, 0xd, 0xc, 0xc, 0xd, 0xd, 0xe, 0xe, -0xf, 0xf, 0xe, 0xe, 0xf, 0xf, 0xc, 0xc, 0xd, -0xd, 0xc, 0xc, 0xd, 0xd, 0xe, 0xe, 0xf, 0xf, -0xe, 0xe, 0xf, 0xf, }; -const unsigned char me_valid_tab[256] = { -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, -0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, -0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x0, 0x0, }; diff --git a/core/lib/me_tabs.h b/core/lib/me_tabs.h deleted file mode 100644 index 0566aa0ad..000000000 --- a/core/lib/me_tabs.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef ME_TABS_H_ -#define ME_TABS_H_ - -extern const unsigned short me_encode_tab[256]; -extern const unsigned char me_decode_tab[256]; -extern const unsigned char me_valid_tab[256]; - -#endif /* ME_TABS_H_ */ - diff --git a/core/lib/mmem.c b/core/lib/mmem.c deleted file mode 100644 index 20c7390fd..000000000 --- a/core/lib/mmem.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \addtogroup mmem - * @{ - */ - -/** - * \file - * Implementation of the managed memory allocator - * \author - * Adam Dunkels - * - */ - - -#include "mmem.h" -#include "list.h" -#include "contiki-conf.h" -#include - -#ifdef MMEM_CONF_SIZE -#define MMEM_SIZE MMEM_CONF_SIZE -#else -#define MMEM_SIZE 4096 -#endif - -LIST(mmemlist); -unsigned int avail_memory; -static char memory[MMEM_SIZE]; - -/*---------------------------------------------------------------------------*/ -/** - * \brief Allocate a managed memory block - * \param m A pointer to a struct mmem. - * \param size The size of the requested memory block - * \return Non-zero if the memory could be allocated, zero if memory - * was not available. - * \author Adam Dunkels - * - * This function allocates a chunk of managed memory. The - * memory allocated with this function must be deallocated - * using the mmem_free() function. - * - * \note This function does NOT return a pointer to the - * allocated memory, but a pointer to a structure that - * contains information about the managed memory. The - * macro MMEM_PTR() is used to get a pointer to the - * allocated memory. - * - */ -int -mmem_alloc(struct mmem *m, unsigned int size) -{ - /* Check if we have enough memory left for this allocation. */ - if(avail_memory < size) { - return 0; - } - - /* We had enough memory so we add this memory block to the end of - the list of allocated memory blocks. */ - list_add(mmemlist, m); - - /* Set up the pointer so that it points to the first available byte - in the memory block. */ - m->ptr = &memory[MMEM_SIZE - avail_memory]; - - /* Remember the size of this memory block. */ - m->size = size; - - /* Decrease the amount of available memory. */ - avail_memory -= size; - - /* Return non-zero to indicate that we were able to allocate - memory. */ - return 1; -} -/*---------------------------------------------------------------------------*/ -/** - * \brief Deallocate a managed memory block - * \param m A pointer to the managed memory block - * \author Adam Dunkels - * - * This function deallocates a managed memory block that - * previously has been allocated with mmem_alloc(). - * - */ -void -mmem_free(struct mmem *m) -{ - struct mmem *n; - - if(m->next != NULL) { - /* Compact the memory after the allocation that is to be removed - by moving it downwards. */ - memmove(m->ptr, m->next->ptr, - &memory[MMEM_SIZE - avail_memory] - (char *)m->next->ptr); - - /* Update all the memory pointers that points to memory that is - after the allocation that is to be removed. */ - for(n = m->next; n != NULL; n = n->next) { - n->ptr = (void *)((char *)n->ptr - m->size); - } - } - - avail_memory += m->size; - - /* Remove the memory block from the list. */ - list_remove(mmemlist, m); -} -/*---------------------------------------------------------------------------*/ -/** - * \brief Initialize the managed memory module - * \author Adam Dunkels - * - * This function initializes the managed memory module and - * should be called before any other function from the - * module. - * - */ -void -mmem_init(void) -{ - static int inited = 0; - if(inited) { - return; - } - list_init(mmemlist); - avail_memory = MMEM_SIZE; - inited = 1; -} -/*---------------------------------------------------------------------------*/ - -/** @} */ diff --git a/core/lib/mmem.h b/core/lib/mmem.h deleted file mode 100644 index e075f585b..000000000 --- a/core/lib/mmem.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -/** - * \addtogroup mem - * @{ - */ - -/** - * \defgroup mmem Managed memory allocator - * - * The managed memory allocator is a fragmentation-free memory - * manager. It keeps the allocated memory free from fragmentation by - * compacting the memory when blocks are freed. A program that uses - * the managed memory module cannot be sure that allocated memory - * stays in place. Therefore, a level of indirection is used: access - * to allocated memory must always be done using a special macro. - * - * \note This module has not been heavily tested. - * @{ - */ - -/** - * \file - * Header file for the managed memory allocator - * \author - * Adam Dunkels - * - */ - -#ifndef MMEM_H_ -#define MMEM_H_ - -/*---------------------------------------------------------------------------*/ -/** - * \brief Get a pointer to the managed memory - * \param m A pointer to the struct mmem - * \return A pointer to the memory block, or NULL if memory could - * not be allocated. - * \author Adam Dunkels - * - * This macro is used to get a pointer to a memory block - * allocated with mmem_alloc(). - * - * \hideinitializer - */ -#define MMEM_PTR(m) (struct mmem *)(m)->ptr - -struct mmem { - struct mmem *next; - unsigned int size; - void *ptr; -}; - -/* XXX: tagga minne med "interrupt usage", vilke gör att man är - speciellt varsam under free(). */ - -int mmem_alloc(struct mmem *m, unsigned int size); -void mmem_free(struct mmem *); -void mmem_init(void); - -#endif /* MMEM_H_ */ - -/** @} */ -/** @} */ diff --git a/core/lib/petsciiconv.c b/core/lib/petsciiconv.c deleted file mode 100644 index a6eda5979..000000000 --- a/core/lib/petsciiconv.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2002, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki desktop environment for the C64. - * - * - */ - -/* -static unsigned char petscii2ascii[128] = { - 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x14,0x09,0x0d,0x11,0x93,0x0a,0x0e,0x0f, - 0x10,0x0b,0x12,0x13,0x08,0x15,0x16,0x17, - 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, - 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, - 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, - 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67, - 0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f, - 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77, - 0x78,0x79,0x7a,0x5b,0x5c,0x5d,0x7e,0x5f, - 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7, - 0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf, - 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7, - 0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0x7e,0xdf -}; -*/ - -static unsigned char ascii2petscii[128] = { - 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x14,0x09,0x0d,0x11,0x93,0x0a,0x0e,0x0f, - 0x10,0x0b,0x12,0x13,0x08,0x15,0x16,0x17, - 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, - 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, - 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, - 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x40,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7, - 0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf, - 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7, - 0xd8,0xd9,0xda,0x5b,0x5c,0x5d,0x5e,0x5f, - 0xc0,0x41,0x42,0x43,0x44,0x45,0x46,0x47, - 0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, - 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57, - 0x58,0x59,0x5a,0xdb,0xdd,0xdd,0x5e,0xdf, -}; - -/*-----------------------------------------------------------------------------------*/ -void -petsciiconv_toascii(char *buf, unsigned int len) -{ - unsigned int i; - char *ptr; - char c; - - ptr = buf; - for(i = len; i > 0; --i) { - c = *ptr; - if(c == 0x0a) { - c = 0x0d; - } else if(c == 0x0d) { - c = 0x0a; - } - if(c != 0x40) { - switch (c & 0xe0) { - case 0x40: - case 0x60: - c ^= 0x20; - break; - case 0xc0: - c ^= 0x80; - break; - } - } - *ptr = c & 0x7f; - ++ptr; - } -} -/*-----------------------------------------------------------------------------------*/ -void -petsciiconv_topetscii(char *buf, unsigned int len) -{ - unsigned int i; - char *ptr; - - ptr = buf; - for(i = len; i > 0; --i) { - *ptr = ascii2petscii[*ptr & 0x7f]; - ++ptr; - } -} -/*-----------------------------------------------------------------------------------*/ diff --git a/core/lib/petsciiconv.h b/core/lib/petsciiconv.h deleted file mode 100644 index ba6b5ef5c..000000000 --- a/core/lib/petsciiconv.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2002, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki desktop environment for the C64. - * - * - */ - -/** - * \file - * PETSCII/ASCII conversion functions. - * \author Adam Dunkels - * - * The Commodore based Contiki targets all have a special character - * encoding called PETSCII which differs from the ASCII encoding that - * normally is used for representing characters. - * - * \note For targets that do not use PETSCII encoding the C compiler - * define WITH_ASCII should be used to avoid the PETSCII converting - * functions. - * - */ - -#ifndef PETSCIICONV_H_ -#define PETSCIICONV_H_ - -#ifdef WITH_PETSCII - -#include "contiki-conf.h" - -/** - * Convert a text buffer from PETSCII to ASCII. - * - * \param buf A pointer to the buffer which is to be converted. - * \param len The length of the buffer to be converted. - */ -void petsciiconv_toascii(char *buf, unsigned int len); -/** - * Convert a text buffer from ASCII to PETSCII. - * - * \param buf A pointer to the buffer which is to be converted. - * \param len The length of the buffer to be converted. - */ -void petsciiconv_topetscii(char *buf, unsigned int len); - -#else /* WITH_PETSCII */ - -#define petsciiconv_toascii(buf, len) -#define petsciiconv_topetscii(buf, len) - -#endif /* WITH_PETSCII */ - -#endif /* PETSCIICONV_H_ */ diff --git a/core/lib/print-stats.c b/core/lib/print-stats.c deleted file mode 100644 index 8119271f9..000000000 --- a/core/lib/print-stats.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Convenience function for printing system statistics - * \author - * Adam Dunkels - */ - -#include "lib/print-stats.h" -#include "net/linkaddr.h" -#include "sys/energest.h" -#include "sys/clock.h" - -#include - -#define PRINTA(...) printf(__VA_ARGS__) - -/*---------------------------------------------------------------------------*/ -void -print_stats(void) -{ -#if RIMESTATS_CONF_ENABLED - PRINTA("S %d.%d clock %lu tx %lu rx %lu rtx %lu rrx %lu rexmit %lu acktx %lu noacktx %lu ackrx %lu timedout %lu badackrx %lu toolong %lu tooshort %lu badsynch %lu badcrc %lu contentiondrop %lu sendingdrop %lu lltx %lu llrx %lu\n", - linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1], - clock_seconds(), - RIMESTATS_GET(tx), RIMESTATS_GET(rx), - RIMESTATS_GET(reliabletx), RIMESTATS_GET(reliablerx), - RIMESTATS_GET(rexmit), RIMESTATS_GET(acktx), RIMESTATS_GET(noacktx), - RIMESTATS_GET(ackrx), RIMESTATS_GET(timedout), RIMESTATS_GET(badackrx), - RIMESTATS_GET(toolong), RIMESTATS_GET(tooshort), - RIMESTATS_GET(badsynch), RIMESTATS_GET(badcrc), - RIMESTATS_GET(contentiondrop), RIMESTATS_GET(sendingdrop), - RIMESTATS_GET(lltx), RIMESTATS_GET(llrx)); -#endif /* RIMESTATS_CONF_ENABLED */ -#if ENERGEST_CONF_ON - PRINTA("E %d.%d clock %lu cpu %lu lpm %lu irq %lu gled %lu yled %lu rled %lu tx %lu listen %lu sensors %lu serial %lu\n", - linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1], - clock_seconds(), - energest_total_time[ENERGEST_TYPE_CPU].current, - energest_total_time[ENERGEST_TYPE_LPM].current, - energest_total_time[ENERGEST_TYPE_IRQ].current, - energest_total_time[ENERGEST_TYPE_LED_GREEN].current, - energest_total_time[ENERGEST_TYPE_LED_YELLOW].current, - energest_total_time[ENERGEST_TYPE_LED_RED].current, - energest_total_time[ENERGEST_TYPE_TRANSMIT].current, - energest_total_time[ENERGEST_TYPE_LISTEN].current, - energest_total_time[ENERGEST_TYPE_SENSORS].current, - energest_total_time[ENERGEST_TYPE_SERIAL].current); -#endif /* ENERGEST_CONF_ON */ -} -/*---------------------------------------------------------------------------*/ diff --git a/core/lib/print-stats.h b/core/lib/print-stats.h deleted file mode 100644 index 32ef3205e..000000000 --- a/core/lib/print-stats.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Convenience function for printing system statistics - * \author - * Adam Dunkels - */ - -#ifndef PRINT_STATS_H_ -#define PRINT_STATS_H_ - -void print_stats(void); - -#endif /* PRINT_STATS_H_ */ diff --git a/core/lib/settings.c b/core/lib/settings.c deleted file mode 100644 index 1b97b28b5..000000000 --- a/core/lib/settings.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - * Copyright (c) 2013, Robert Quattlebaum. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#ifdef SETTINGS_CONF_SKIP_CONVENIENCE_FUNCS -#undef SETTINGS_CONF_SKIP_CONVENIENCE_FUNCS -#endif - -#define SETTINGS_CONF_SKIP_CONVENIENCE_FUNCS 1 - -#include "contiki.h" -#include "settings.h" -#include "dev/eeprom.h" - -#if CONTIKI_CONF_SETTINGS_MANAGER - -#if !EEPROM_CONF_SIZE -#error CONTIKI_CONF_SETTINGS_MANAGER has been set, but EEPROM_CONF_SIZE hasnt! -#endif - -#ifndef EEPROM_END_ADDR -#define EEPROM_END_ADDR (EEPROM_CONF_SIZE - 1) -#endif - -#ifndef SETTINGS_MAX_SIZE -/** The maximum amount EEPROM dedicated to settings. */ -#define SETTINGS_MAX_SIZE (127) /**< Defaults to 127 bytes */ -#endif - -#ifndef SETTINGS_TOP_ADDR -/** The top address in EEPROM that settings should use. Inclusive. */ -#define SETTINGS_TOP_ADDR (settings_iter_t)(EEPROM_END_ADDR) -#endif - -#ifndef SETTINGS_BOTTOM_ADDR -/** The lowest address in EEPROM that settings should use. Inclusive. */ -#define SETTINGS_BOTTOM_ADDR (SETTINGS_TOP_ADDR + 1 - SETTINGS_MAX_SIZE) -#endif - -typedef struct { -#if SETTINGS_CONF_SUPPORT_LARGE_VALUES - uint8_t size_extra; -#endif - uint8_t size_low; - uint8_t size_check; - settings_key_t key; -} item_header_t; - -/*****************************************************************************/ -// MARK: - Public Travesal Functions -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -settings_iter_t -settings_iter_begin() -{ - return settings_iter_is_valid(SETTINGS_TOP_ADDR) ? SETTINGS_TOP_ADDR : 0; -} - -/*---------------------------------------------------------------------------*/ -settings_iter_t -settings_iter_next(settings_iter_t ret) -{ - if(ret) { - /* A settings iterator always points to the first byte - * after the actual key-value pair in memory. This means that - * the address of our value in EEPROM just happens - * to be the address of our next iterator. - */ - ret = settings_iter_get_value_addr(ret); - return settings_iter_is_valid(ret) ? ret : 0; - } - return SETTINGS_INVALID_ITER; -} - -/*---------------------------------------------------------------------------*/ -uint8_t -settings_iter_is_valid(settings_iter_t iter) -{ - item_header_t header = { 0 }; - - if(iter == EEPROM_NULL) { - return 0; - } - - if(iter < SETTINGS_BOTTOM_ADDR + sizeof(header)) { - return 0; - } - - eeprom_read(iter - sizeof(header), (uint8_t *)&header, sizeof(header)); - - if((uint8_t) header.size_check != (uint8_t) ~ header.size_low) { - return 0; - } - - if(iter < SETTINGS_BOTTOM_ADDR + sizeof(header) + settings_iter_get_value_length(iter)) { - return 0; - } - - return 1; -} - -/*---------------------------------------------------------------------------*/ -settings_key_t -settings_iter_get_key(settings_iter_t iter) -{ - item_header_t header; - - eeprom_read(iter - sizeof(header), (uint8_t *)&header, sizeof(header)); - - if((uint8_t) header.size_check != (uint8_t)~header.size_low) { - return SETTINGS_INVALID_KEY; - } - - return header.key; -} - -/*---------------------------------------------------------------------------*/ -settings_length_t -settings_iter_get_value_length(settings_iter_t iter) -{ - item_header_t header; - - settings_length_t ret = 0; - - eeprom_read(iter - sizeof(header), (uint8_t *)&header, sizeof(header) ); - - if((uint8_t)header.size_check == (uint8_t)~header.size_low) { - ret = header.size_low; - -#if SETTINGS_CONF_SUPPORT_LARGE_VALUES - if(ret & (1 << 7)) { - ret = ((ret & ~(1 << 7)) << 7) | header.size_extra; - } -#endif - } - - return ret; -} - -/*---------------------------------------------------------------------------*/ -eeprom_addr_t -settings_iter_get_value_addr(settings_iter_t iter) -{ - settings_length_t len = settings_iter_get_value_length(iter); -#if SETTINGS_CONF_SUPPORT_LARGE_VALUES - len += (len >= 128); -#endif - return iter - sizeof(item_header_t) - len; -} - -/*---------------------------------------------------------------------------*/ -settings_length_t -settings_iter_get_value_bytes(settings_iter_t iter, void *bytes, - settings_length_t max_length) -{ - max_length = MIN(max_length, settings_iter_get_value_length(iter)); - - eeprom_read(settings_iter_get_value_addr(iter), bytes, max_length); - - return max_length; -} - -/*---------------------------------------------------------------------------*/ -settings_status_t -settings_iter_delete(settings_iter_t iter) -{ - settings_status_t ret = SETTINGS_STATUS_FAILURE; - - settings_iter_t next = settings_iter_next(iter); - - if(!next) { - /* Special case: we are the last item. we can get away with - * just wiping out our own header. - */ - item_header_t header; - - memset(&header, 0xFF, sizeof(header)); - - eeprom_write(iter - sizeof(header), (uint8_t *)&header, sizeof(header)); - - ret = SETTINGS_STATUS_OK; - } - - /* This case requires the settings store to be shifted. - * Currently unimplemented. TODO: Writeme! - */ - ret = SETTINGS_STATUS_UNIMPLEMENTED; - - return ret; -} - -/*****************************************************************************/ -// MARK: - Public Functions -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -uint8_t -settings_check(settings_key_t key, uint8_t index) -{ - uint8_t ret = 0; - - settings_iter_t iter; - - for(iter = settings_iter_begin(); iter; iter = settings_iter_next(iter)) { - if(settings_iter_get_key(iter) == key) { - if(!index) { - ret = 1; - break; - } else { - index--; - } - } - } - - return ret; -} - -/*---------------------------------------------------------------------------*/ -settings_status_t -settings_get(settings_key_t key, uint8_t index, uint8_t *value, - settings_length_t * value_size) -{ - settings_status_t ret = SETTINGS_STATUS_NOT_FOUND; - - settings_iter_t iter; - - for(iter = settings_iter_begin(); iter; iter = settings_iter_next(iter)) { - if(settings_iter_get_key(iter) == key) { - if(!index) { - /* We found it! */ - *value_size = settings_iter_get_value_bytes(iter, - (void *)value, - *value_size); - ret = SETTINGS_STATUS_OK; - break; - } else { - /* Nope, keep looking */ - index--; - } - } - } - - return ret; -} - -/*---------------------------------------------------------------------------*/ -settings_status_t -settings_add(settings_key_t key, const uint8_t *value, - settings_length_t value_size) -{ - settings_status_t ret = SETTINGS_STATUS_FAILURE; - - settings_iter_t iter; - - item_header_t header; - - /* Find the last item. */ - for(iter = settings_iter_begin(); settings_iter_next(iter); - iter = settings_iter_next(iter)) { - /* This block intentionally left blank. */ - } - - if(iter) { - /* Value address of item is the same as the iterator for next item. */ - iter = settings_iter_get_value_addr(iter); - } else { - /* This will be the first setting! */ - iter = SETTINGS_TOP_ADDR; - } - - if(iter < SETTINGS_BOTTOM_ADDR + value_size + sizeof(header)) { - /* This value is too big to store. */ - ret = SETTINGS_STATUS_OUT_OF_SPACE; - goto bail; - } - - header.key = key; - - if(value_size < 0x80) { - /* If the value size is less than 128, then - * we can get away with only using one byte - * to store the size. - */ - header.size_low = value_size; - } -#if SETTINGS_CONF_SUPPORT_LARGE_VALUES - else if(value_size <= SETTINGS_MAX_VALUE_SIZE) { - /* If the value size is larger than or equal to 128, - * then we need to use two bytes. Store - * the most significant 7 bits in the first - * size byte (with MSB set) and store the - * least significant bits in the second - * byte (with LSB clear) - */ - header.size_low = (value_size >> 7) | 0x80; - header.size_extra = value_size & ~0x80; - } -#endif - else { - /* Value size way too big! */ - ret = SETTINGS_STATUS_VALUE_TOO_BIG; - goto bail; - } - - header.size_check = ~header.size_low; - - /* Write the header first */ - eeprom_write(iter - sizeof(header), (uint8_t *)&header, sizeof(header)); - - /* Sanity check, remove once confident */ - if(settings_iter_get_value_length(iter) != value_size) { - goto bail; - } - - /* Now write the data */ - eeprom_write(settings_iter_get_value_addr(iter), (uint8_t *)value, value_size); - - /* This should be the last item. If this is not the case, - * then we need to clear out the phantom setting. - */ - if((iter = settings_iter_next(iter))) { - memset(&header, 0xFF, sizeof(header)); - - eeprom_write(iter - sizeof(header),(uint8_t *)&header, sizeof(header)); - } - - ret = SETTINGS_STATUS_OK; - -bail: - return ret; -} - -/*---------------------------------------------------------------------------*/ -settings_status_t -settings_set(settings_key_t key, const uint8_t *value, - settings_length_t value_size) -{ - settings_status_t ret = SETTINGS_STATUS_FAILURE; - - settings_iter_t iter; - - for(iter = settings_iter_begin(); iter; iter = settings_iter_next(iter)) { - if(settings_iter_get_key(iter) == key) { - break; - } - } - - if((iter == EEPROM_NULL) || !settings_iter_is_valid(iter)) { - ret = settings_add(key, value, value_size); - goto bail; - } - - if(value_size != settings_iter_get_value_length(iter)) { - /* Requires the settings store to be shifted. Currently unimplemented. */ - ret = SETTINGS_STATUS_UNIMPLEMENTED; - goto bail; - } - - /* Now write the data */ - eeprom_write(settings_iter_get_value_addr(iter), - (uint8_t *)value, value_size); - - ret = SETTINGS_STATUS_OK; - -bail: - return ret; -} - -/*---------------------------------------------------------------------------*/ -settings_status_t -settings_delete(settings_key_t key, uint8_t index) -{ - settings_status_t ret = SETTINGS_STATUS_NOT_FOUND; - - settings_iter_t iter; - - for(iter = settings_iter_begin(); iter; iter = settings_iter_next(iter)) { - if(settings_iter_get_key(iter) == key) { - if(!index) { - /* We found it! */ - ret = settings_iter_delete(iter); - break; - } else { - /* Nope, keep looking */ - index--; - } - } - } - - return ret; -} - -/*---------------------------------------------------------------------------*/ -void -settings_wipe(void) -{ - /* Simply making the first item invalid will effectively - * clear the key-value store. - */ - const uint32_t x = 0xFFFFFF; - - eeprom_write(SETTINGS_TOP_ADDR - sizeof(x), (uint8_t *)&x, sizeof(x)); -} - -/*****************************************************************************/ -// MARK: - Other Functions -/*****************************************************************************/ - -#if DEBUG -#include -/*---------------------------------------------------------------------------*/ -void -settings_debug_dump(void) -{ - settings_iter_t iter; - - printf("{\n"); - for(iter = settings_iter_begin(); iter; iter = settings_iter_next(iter)) { - settings_length_t len = settings_iter_get_value_length(iter); - eeprom_addr_t addr = settings_iter_get_value_addr(iter); - uint8_t byte; - - union { - settings_key_t key; - char bytes[0]; - } u; - - u.key = settings_iter_get_key(iter); - - printf("\t\"%c%c\" = <", u.bytes[0], u.bytes[1]); - - for(; len; len--, addr++) { - eeprom_read(addr, &byte, 1); - printf("%02X", byte); - if(len != 1) { - printf(" "); - } - } - - printf(">;\n"); - } - printf("}\n"); -} -#endif /* DEBUG */ - -#endif /* CONTIKI_CONF_SETTINGS_MANAGER */ diff --git a/core/lib/settings.h b/core/lib/settings.h deleted file mode 100644 index bef6d0461..000000000 --- a/core/lib/settings.h +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright (c) 2013, Robert Quattlebaum - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#ifndef CONTIKI_SETTINGS_H_ -#define CONTIKI_SETTINGS_H_ - -/** @file settings.h - * @brief Settings Manager - * @author Robert Quattlebaum - */ - -/** @addtogroup lib - * @{ */ - -/** @defgroup settings_lib Settings Manager - * - * The settings manager is an EEPROM-based key-value store. Keys - * are 16-bit integers and values may be up to 16,383 bytes long. - * It is intended to be used to store configuration-related information, - * like network settings, radio channels, etc. - * - * ## Features ## - * - * * Robust data format which requires no initialization. - * * Supports multiple values with the same key. - * * Data can be appended without erasing EEPROM. - * * Max size of settings data can be easily increased in the future, - * as long as it doesn't overlap with application data. - * - * ## Data Format ## - * - * The format was inspired by OLPC manufacturing data, as described here: - * - * - * Since the beginning of EEPROM often contains application-specific - * information, the best place to store settings is at the end of - * EEPROM. Because we are starting at the end of EEPROM, it makes sense - * to grow the list of key-value pairs downward, toward the start of - * EEPROM. - * - * Each key-value pair is stored in memory in the following format: - * - * | Order | Size | Name | Description | - * | -------- | -------- | ---------- | ------------------------------- | - * | 0 | 2 | key | | - * | -2 | 1 | size_check | One's-complement of next byte | - * | -3 | 1 or 2 | size | The size of the value, in bytes | - * | -4 or -5 | variable | value | | - * - * The end of the key-value pairs is denoted by the first invalid entry. - * An invalid entry has any of the following attributes: - * - * * The size_check byte doesn't match the one's compliment - * of the size byte (or size_low byte). - * * The key has a value of 0x0000. - * - * @{ */ - -#include -#include -#include "dev/eeprom.h" -#include "sys/cc.h" - -/*****************************************************************************/ -// MARK: - Types - -typedef enum { - SETTINGS_STATUS_OK = 0, - SETTINGS_STATUS_FAILURE, - SETTINGS_STATUS_INVALID_ARGUMENT, - SETTINGS_STATUS_NOT_FOUND, - SETTINGS_STATUS_OUT_OF_SPACE, - SETTINGS_STATUS_VALUE_TOO_BIG, - SETTINGS_STATUS_UNIMPLEMENTED, -} settings_status_t; - -typedef uint16_t settings_key_t; - -typedef uint16_t settings_length_t; - -/*****************************************************************************/ -// MARK: - Settings Keys - -/** Two-character constant macro */ -#define TCC(a,b) ((a)+(b)*256) - -/* All-capital-letter constants are always contiki-defined. */ -#define SETTINGS_KEY_EUI64 TCC('E','8') /**< EUI64 Address, 8 bytes */ -#define SETTINGS_KEY_EUI48 TCC('E','6') /*!< MAC Address, 6 bytes */ -#define SETTINGS_KEY_CHANNEL TCC('C','H') /*!< Channel number, uint8_t */ -#define SETTINGS_KEY_TXPOWER TCC('T','P') /*!< Transmit power, uint8_t */ -#define SETTINGS_KEY_PAN_ID TCC('P','N') /*!< PAN ID, uint16_t */ -#define SETTINGS_KEY_PAN_ADDR TCC('P','A') /*!< PAN address, uint16_t */ -#define SETTINGS_KEY_AES128KEY TCC('S','K') /*!< AES128 key, 16 bytes */ -#define SETTINGS_KEY_AES128ENABLED TCC('S','E') /*!< AES128 enabled, bool */ -#define SETTINGS_KEY_HOSTNAME TCC('H','N') /*!< Hostname, C-String */ -#define SETTINGS_KEY_DOMAINNAME TCC('D','N') /*!< Domainname, C-String */ - -/*****************************************************************************/ -// MARK: - Experimental Settings Keys - -#define SETTINGS_KEY_RDC_INDEX TCC('R','D') /*!< RDC index, uint8_t */ -#define SETTINGS_KEY_CHANNEL_MASK TCC('C','M') /*!< Channel mask, uint16_t */ - -/*****************************************************************************/ -// MARK: - Constants - -/** Use this when you want to retrieve the last item */ -#define SETTINGS_LAST_INDEX 0xFF -/** Returned when key is invalid. */ -#define SETTINGS_INVALID_KEY 0xFFFF -/** Returned if no (further) element was found. */ -#define SETTINGS_INVALID_ITER EEPROM_NULL - -#ifndef SETTINGS_CONF_SUPPORT_LARGE_VALUES -#define SETTINGS_CONF_SUPPORT_LARGE_VALUES 0 -#endif - -#if SETTINGS_CONF_SUPPORT_LARGE_VALUES -#define SETTINGS_MAX_VALUE_SIZE 0x3FFF /* 16383 bytes */ -#else -#define SETTINGS_MAX_VALUE_SIZE 0x7F /* 127 bytes */ -#endif - -/*****************************************************************************/ -// MARK: - Settings accessors - -/** Fetches the value associated with the given key. */ -extern settings_status_t settings_get(settings_key_t key, uint8_t index, - uint8_t *value, - settings_length_t * value_size); - -/** Adds the given key-value pair to the end of the settings store. */ -extern settings_status_t settings_add(settings_key_t key, - const uint8_t *value, - settings_length_t value_size); - -/** Checks to see if the given key exists. */ -extern uint8_t settings_check(settings_key_t key, uint8_t index); - -/** Reinitializes all of the EEPROM used by settings. */ -extern void settings_wipe(void); - -/** Sets the value for the given key. If the key already exists in - * the settings store, then its value will be replaced. - */ -extern settings_status_t settings_set(settings_key_t key, - const uint8_t *value, - settings_length_t value_size); - -/** Removes the given key (at the given index) from the settings store. */ -extern settings_status_t settings_delete(settings_key_t key, uint8_t index); - -/*****************************************************************************/ -// MARK: - Settings traversal functions - -typedef eeprom_addr_t settings_iter_t; - -/** Will return \ref SETTINGS_INVALID_ITER if the settings store is empty. */ -extern settings_iter_t settings_iter_begin(void); - -/** Will return \ref SETTINGS_INVALID_ITER if at the end of settings list. */ -extern settings_iter_t settings_iter_next(settings_iter_t iter); - -extern uint8_t settings_iter_is_valid(settings_iter_t iter); - -extern settings_key_t settings_iter_get_key(settings_iter_t iter); - -extern settings_length_t settings_iter_get_value_length(settings_iter_t iter); - -extern eeprom_addr_t settings_iter_get_value_addr(settings_iter_t iter); - -extern settings_length_t settings_iter_get_value_bytes(settings_iter_t item, - void *bytes, - settings_length_t - max_length); - -extern settings_status_t settings_iter_delete(settings_iter_t item); - -/*****************************************************************************/ -// MARK: - inline convenience functions - -/* Unfortunately, some platforms don't properly drop unreferenced functions, - * so on these broken platforms we can save a significant amount - * of space by skipping the definition of the convenience functions. - */ -#if !SETTINGS_CONF_SKIP_CONVENIENCE_FUNCS - -static CC_INLINE const char * -settings_get_cstr(settings_key_t key, uint8_t index, char *c_str, - settings_length_t c_str_size) -{ - /* Save room for the zero termination. */ - c_str_size--; - - if(settings_get(key, index, (uint8_t *)c_str, &c_str_size) == SETTINGS_STATUS_OK) { - /* Zero terminate. */ - c_str[c_str_size] = 0; - } else { - c_str = NULL; - } - return c_str; -} - -static CC_INLINE settings_status_t -settings_set_cstr(settings_key_t key, const char* c_str) -{ - return settings_set(key, (const uint8_t *)c_str, strlen(c_str)); -} - -static CC_INLINE settings_status_t -settings_add_cstr(settings_key_t key, const char* c_str) -{ - return settings_add(key, (const uint8_t *)c_str, strlen(c_str)); -} - -static CC_INLINE uint8_t -settings_get_bool_with_default(settings_key_t key, uint8_t index, - uint8_t default_value) -{ - uint8_t ret = default_value; - settings_length_t sizeof_uint8 = sizeof(uint8_t); - - settings_get(key, index, (uint8_t *)&ret, &sizeof_uint8); - return !!ret; -} - -static CC_INLINE uint8_t -settings_get_uint8(settings_key_t key, uint8_t index) -{ - uint8_t ret = 0; - settings_length_t sizeof_uint8 = sizeof(uint8_t); - - settings_get(key, index, (uint8_t *)&ret, &sizeof_uint8); - return ret; -} - -static CC_INLINE settings_status_t -settings_add_uint8(settings_key_t key, uint8_t value) -{ - return settings_add(key, (const uint8_t *)&value, sizeof(uint8_t)); -} - -static CC_INLINE settings_status_t -settings_set_uint8(settings_key_t key, uint8_t value) -{ - return settings_set(key, (const uint8_t *)&value, sizeof(uint8_t)); -} - -static CC_INLINE uint16_t -settings_get_uint16(settings_key_t key, uint8_t index) -{ - uint16_t ret = 0; - settings_length_t sizeof_uint16 = sizeof(uint16_t); - - settings_get(key, index, (uint8_t *)&ret, &sizeof_uint16); - return ret; -} - -static CC_INLINE settings_status_t -settings_add_uint16(settings_key_t key, uint16_t value) -{ - return settings_add(key, (const uint8_t *)&value, sizeof(uint16_t)); -} - -static CC_INLINE settings_status_t -settings_set_uint16(settings_key_t key, uint16_t value) -{ - return settings_set(key, (const uint8_t *)&value, sizeof(uint16_t)); -} - -static CC_INLINE uint32_t -settings_get_uint32(settings_key_t key, uint8_t index) -{ - uint32_t ret = 0; - settings_length_t sizeof_uint32 = sizeof(uint32_t); - - settings_get(key, index, (uint8_t *)&ret, &sizeof_uint32); - return ret; -} - -static CC_INLINE settings_status_t -settings_add_uint32(settings_key_t key, uint32_t value) -{ - return settings_add(key, (const uint8_t *)&value, sizeof(uint32_t)); -} - -static CC_INLINE settings_status_t -settings_set_uint32(settings_key_t key, uint32_t value) -{ - return settings_set(key, (const uint8_t *)&value, sizeof(uint32_t)); -} - -#if __int64_t_defined -static CC_INLINE uint64_t -settings_get_uint64(settings_key_t key, uint8_t index) -{ - uint64_t ret = 0; - settings_length_t sizeof_uint64 = sizeof(uint64_t); - - settings_get(key, index, (uint8_t *)&ret, &sizeof_uint64); - return ret; -} - -static CC_INLINE settings_status_t -settings_add_uint64(settings_key_t key, uint64_t value) -{ - return settings_add(key, (const uint8_t *)&value, sizeof(uint64_t)); -} - -static CC_INLINE settings_status_t -settings_set_uint64(settings_key_t key, uint64_t value) -{ - return settings_set(key, (const uint8_t *)&value, sizeof(uint64_t)); -} -#endif /* __int64_t_defined */ - -#endif /* !SETTINGS_CONF_SKIP_CONVENIENCE_FUNCS */ - -#endif /* !defined(CONTIKI_SETTINGS_H_) */ - -/** @} */ -/** @} */ diff --git a/core/net/ipv6/websocket.c b/core/net/ipv6/websocket.c index 28f78896b..7d0c75914 100644 --- a/core/net/ipv6/websocket.c +++ b/core/net/ipv6/websocket.c @@ -34,7 +34,6 @@ #include #include "contiki-net.h" -#include "lib/petsciiconv.h" #include "websocket.h" diff --git a/drivers/cpu/msp430/Makefile.msp430 b/drivers/cpu/msp430/Makefile.msp430 index ab7db3cbc..ff6ce5634 100644 --- a/drivers/cpu/msp430/Makefile.msp430 +++ b/drivers/cpu/msp430/Makefile.msp430 @@ -36,7 +36,7 @@ CONTIKI_CPU_DIRS = $(CONTIKI_CPU_FAM_DIR) . dev MSP430 = msp430.c flash.c clock.c leds.c leds-arch.c \ watchdog.c lpm.c rtimer-arch.c -UIPDRIVERS = me.c me_tabs.c slip.c crc16.c +UIPDRIVERS = slip.c crc16.c ifndef CPU_HAS_MSP430X # include mtarch.c only in the non-large memory model case, because diff --git a/examples/settings-example/Makefile b/examples/settings-example/Makefile deleted file mode 100644 index 540adff63..000000000 --- a/examples/settings-example/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -CONTIKI_PROJECT = settings-example -all: $(CONTIKI_PROJECT) -CFLAGS += -DCONTIKI_CONF_SETTINGS_MANAGER=1 -CONTIKI = ../.. -include $(CONTIKI)/Makefile.include diff --git a/examples/settings-example/settings-example.c b/examples/settings-example/settings-example.c deleted file mode 100644 index 023e1f3df..000000000 --- a/examples/settings-example/settings-example.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2013, Robert Quattlebaum. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * @file settings-example.c - * @brief Contiki example showing how to use the settings manager. - * @author Robert Quattlebaum - */ - -#include "contiki.h" -#include "lib/settings.h" - -#include /* For printf() */ - -/*---------------------------------------------------------------------------*/ -PROCESS(settings_example_process, "Settings Example Process"); -AUTOSTART_PROCESSES(&settings_example_process); - -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(settings_example_process, ev, data) -{ - int i; - settings_status_t status; - settings_iter_t iter; - char hostname[30]; - uint16_t panid; - uint16_t channel; - - PROCESS_BEGIN(); - - /*************************************************************************/ - /* Basic setting of parameters */ - - status = settings_set_uint16(SETTINGS_KEY_PAN_ID, 0xABCD); - if(SETTINGS_STATUS_OK != status) { - printf("settings-example: `set` failed: %d\n", status); - } - - status = settings_set_uint8(SETTINGS_KEY_CHANNEL, 26); - if(SETTINGS_STATUS_OK != status) { - printf("settings-example: `set` failed: %d\n", status); - } - - status = settings_set_cstr(SETTINGS_KEY_HOSTNAME, "contiki.local"); - if(SETTINGS_STATUS_OK != status) { - printf("settings-example: `set` failed: %d\n", status); - } - - /*************************************************************************/ - /* Basic getting of parameters */ - - panid = settings_get_uint16(SETTINGS_KEY_PAN_ID, 0); - if(0xABCD != panid) { - printf("settings-example: `get` failed: value mismatch.\n"); - } - - channel = settings_get_uint16(SETTINGS_KEY_CHANNEL, 0); - if(26 != channel) { - printf("settings-example: `get` failed: value mismatch.\n"); - } - - if(!settings_get_cstr(SETTINGS_KEY_HOSTNAME, 0, hostname, sizeof(hostname))) { - printf("settings-example: `get` failed: settings_get_cstr returned NULL\n"); - } else if(strcmp(hostname, "contiki.local") != 0) { - printf("settings-example: `get` failed: value mismatch.\n"); - } - - /*************************************************************************/ - /* Adding multiple values with the same key */ - - for(i = 0; i < 10; i++) { - settings_add_uint8(TCC('e','x'), i + 20); - } - - /*************************************************************************/ - /* Reading multiple values with the same key */ - - for(i = 0; i < 10; i++) { - if(settings_get_uint8(TCC('e', 'x'), i) != i + 20) { - printf("settings-example: `get` failed: value mismatch.\n"); - } - } - - /*************************************************************************/ - /* Iterating thru all settings */ - - for(iter = settings_iter_begin(); iter; iter = settings_iter_next(iter)) { - settings_length_t len = settings_iter_get_value_length(iter); - eeprom_addr_t addr = settings_iter_get_value_addr(iter); - uint8_t byte; - - union { - settings_key_t key; - char bytes[0]; - } u; - - u.key = settings_iter_get_key(iter); - - if(u.bytes[0] >= 32 && u.bytes[0] < 127 - && u.bytes[1] >= 32 && u.bytes[1] < 127 - ) { - printf("settings-example: [%c%c] = <",u.bytes[0],u.bytes[1]); - } else { - printf("settings-example: <0x%04X> = <",u.key); - } - - for(; len; len--, addr++) { - eeprom_read(addr, &byte, 1); - printf("%02X", byte); - if(len != 1) { - printf(" "); - } - } - - printf(">\n"); - } - - printf("settings-example: Done.\n"); - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/