├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── README_zh.md ├── SConstruct ├── TODO.md ├── app ├── app_start.c └── system_start.c ├── cpu ├── linux │ ├── include │ │ └── hw_include.h │ └── port.c ├── or1ksim │ ├── cache.c │ ├── hw_timer.c │ ├── include │ │ ├── board.h │ │ ├── hw_include.h │ │ ├── hw_timer.h │ │ ├── interrupt.h │ │ ├── or1200-utils.h │ │ ├── ptrace.h │ │ ├── spr-defs.h │ │ ├── stack_ready.h │ │ ├── support.h │ │ └── uart.h │ ├── interrupt.c │ ├── reset.S │ ├── stack_ready.c │ ├── support.c │ └── uart.c └── riscv │ └── sifive_e │ ├── constants.s │ ├── crtm.s │ ├── default.lds │ ├── macros.s │ ├── port.s │ ├── support.c │ └── uart.c ├── kernel ├── device.c ├── fsm.c ├── idle.c ├── include │ ├── device.h │ ├── fsm.h │ ├── list.h │ ├── mem_block.h │ ├── pt.h │ ├── queue.h │ └── var_define.h ├── list.c ├── mem_block.c ├── mutex.c ├── prio_sched.c ├── queue.c ├── semaphore.c ├── task.c ├── timer.c └── var_define.c ├── libc ├── include │ ├── lib.h │ └── printf.h ├── lib.c └── printf.c ├── middleware ├── shell_parser │ ├── LICENSE │ ├── README │ ├── _list.c │ ├── _list.h │ ├── example.c │ ├── shell.c │ └── shell.h └── uip │ ├── README │ ├── apps │ ├── README │ ├── dhcpc │ │ ├── Makefile.dhcpc │ │ ├── dhcpc.c │ │ └── dhcpc.h │ ├── hello-world │ │ ├── Makefile.hello-world │ │ ├── hello-world.c │ │ └── hello-world.h │ ├── resolv │ │ ├── Makefile.resolv │ │ ├── resolv.c │ │ └── resolv.h │ ├── smtp │ │ ├── Makefile.smtp │ │ ├── makestrings │ │ ├── smtp-strings │ │ ├── smtp-strings.c │ │ ├── smtp-strings.h │ │ ├── smtp.c │ │ └── smtp.h │ ├── telnetd │ │ ├── Makefile.telnetd │ │ ├── shell.c │ │ ├── shell.h │ │ ├── telnetd.c │ │ └── telnetd.h │ ├── webclient │ │ ├── Makefile.webclient │ │ ├── makestrings │ │ ├── webclient-strings │ │ ├── webclient-strings.c │ │ ├── webclient-strings.h │ │ ├── webclient.c │ │ └── webclient.h │ └── webserver │ │ ├── .httpd-fsdata.c.swp │ │ ├── Makefile.webserver │ │ ├── http-strings │ │ ├── http-strings.c │ │ ├── http-strings.h │ │ ├── httpd-cgi.c │ │ ├── httpd-cgi.h │ │ ├── httpd-fs.c │ │ ├── httpd-fs.h │ │ ├── httpd-fs │ │ ├── 404.html │ │ ├── fade.png │ │ ├── files.shtml │ │ ├── footer.html │ │ ├── header.html │ │ ├── index.html │ │ ├── processes.shtml │ │ ├── stats.shtml │ │ ├── style.css │ │ └── tcp.shtml │ │ ├── httpd-fsdata.c │ │ ├── httpd-fsdata.h │ │ ├── httpd.c │ │ ├── httpd.h │ │ ├── makefsdata │ │ ├── makestrings │ │ └── webserver.h │ ├── doc │ ├── Doxyfile │ ├── Makefile │ ├── README │ ├── doxygen.sty │ ├── example-mainloop-with-arp.c │ ├── example-mainloop-without-arp.c │ ├── examples.txt │ ├── header.tex │ ├── html │ │ ├── a00036.html │ │ ├── a00037.html │ │ ├── a00038.html │ │ ├── a00039.html │ │ ├── a00040.html │ │ ├── a00041.html │ │ ├── a00042.html │ │ ├── a00043.html │ │ ├── a00044.html │ │ ├── a00045.html │ │ ├── a00046.html │ │ ├── a00047.html │ │ ├── a00048.html │ │ ├── a00049.html │ │ ├── a00050.html │ │ ├── a00051.html │ │ ├── a00077.html │ │ ├── a00078.html │ │ ├── a00079.html │ │ ├── a00080.html │ │ ├── a00081.html │ │ ├── a00082.html │ │ ├── a00083.html │ │ ├── a00084.html │ │ ├── a00085.html │ │ ├── a00086.html │ │ ├── a00087.html │ │ ├── a00088.html │ │ ├── a00089.html │ │ ├── a00090.html │ │ ├── a00091.html │ │ ├── a00092.html │ │ ├── a00093.html │ │ ├── a00094.html │ │ ├── a00095.html │ │ ├── a00096.html │ │ ├── a00097.html │ │ ├── a00100.html │ │ ├── a00101.html │ │ ├── a00102.html │ │ ├── a00103.html │ │ ├── a00104.html │ │ ├── a00105.html │ │ ├── a00107.html │ │ ├── a00110.html │ │ ├── a00111.html │ │ ├── a00112.html │ │ ├── a00113.html │ │ ├── a00114.html │ │ ├── a00120.html │ │ ├── a00121.html │ │ ├── a00123.html │ │ ├── a00124.html │ │ ├── a00125.html │ │ ├── a00127.html │ │ ├── a00128.html │ │ ├── a00129.html │ │ ├── a00130.html │ │ ├── a00131.html │ │ ├── a00132.html │ │ ├── a00134.html │ │ ├── a00135.html │ │ ├── a00136.html │ │ ├── a00137.html │ │ ├── a00138.html │ │ ├── a00139.html │ │ ├── a00140.html │ │ ├── a00141.html │ │ ├── a00142.html │ │ ├── a00143.html │ │ ├── a00144.html │ │ ├── a00145.html │ │ ├── a00146.html │ │ ├── a00147.html │ │ ├── a00148.html │ │ ├── a00149.html │ │ ├── a00150.html │ │ ├── a00151.html │ │ ├── a00152.html │ │ ├── a00153.html │ │ ├── a00154.html │ │ ├── a00155.html │ │ ├── a00156.html │ │ ├── a00157.html │ │ ├── a00158.html │ │ ├── a00159.html │ │ ├── a00160.html │ │ ├── a00161.html │ │ ├── a00162.html │ │ ├── a00163.html │ │ ├── a00164.html │ │ ├── a00168.html │ │ ├── a00169.html │ │ ├── a00170.html │ │ ├── a00171.html │ │ ├── a00172.html │ │ ├── a00173.html │ │ ├── a00174.html │ │ ├── a00175.html │ │ ├── a00176.html │ │ ├── a00177.html │ │ ├── a00178.html │ │ ├── a00179.html │ │ ├── a00180.html │ │ ├── a00181.html │ │ ├── a00182.html │ │ ├── a00183.html │ │ ├── a00184.html │ │ ├── a00185.html │ │ ├── a00186.html │ │ ├── a00187.html │ │ ├── a00188.html │ │ ├── a00189.html │ │ ├── a00190.html │ │ ├── a00191.html │ │ ├── a00192.html │ │ ├── a00193.html │ │ ├── a00194.html │ │ ├── a00195.html │ │ ├── a00196.html │ │ ├── a00197.html │ │ ├── a00198.html │ │ ├── a00199.html │ │ ├── a00200.html │ │ ├── a00201.html │ │ ├── a00202.html │ │ ├── a00203.html │ │ ├── a00204.html │ │ ├── a00205.html │ │ ├── a00206.html │ │ ├── a00207.html │ │ ├── annotated.html │ │ ├── classes.html │ │ ├── doxygen.css │ │ ├── doxygen.png │ │ ├── examples.html │ │ ├── files.html │ │ ├── ftv2blank.png │ │ ├── ftv2doc.png │ │ ├── ftv2folderclosed.png │ │ ├── ftv2folderopen.png │ │ ├── ftv2lastnode.png │ │ ├── ftv2link.png │ │ ├── ftv2mlastnode.png │ │ ├── ftv2mnode.png │ │ ├── ftv2node.png │ │ ├── ftv2plastnode.png │ │ ├── ftv2pnode.png │ │ ├── ftv2vertline.png │ │ ├── functions.html │ │ ├── functions_vars.html │ │ ├── globals.html │ │ ├── globals_0x61.html │ │ ├── globals_0x62.html │ │ ├── globals_0x64.html │ │ ├── globals_0x65.html │ │ ├── globals_0x66.html │ │ ├── globals_0x68.html │ │ ├── globals_0x69.html │ │ ├── globals_0x6c.html │ │ ├── globals_0x6d.html │ │ ├── globals_0x6e.html │ │ ├── globals_0x70.html │ │ ├── globals_0x72.html │ │ ├── globals_0x73.html │ │ ├── globals_0x74.html │ │ ├── globals_0x75.html │ │ ├── globals_0x77.html │ │ ├── globals_defs.html │ │ ├── globals_defs_0x61.html │ │ ├── globals_defs_0x62.html │ │ ├── globals_defs_0x64.html │ │ ├── globals_defs_0x65.html │ │ ├── globals_defs_0x66.html │ │ ├── globals_defs_0x68.html │ │ ├── globals_defs_0x69.html │ │ ├── globals_defs_0x6c.html │ │ ├── globals_defs_0x6d.html │ │ ├── globals_defs_0x6e.html │ │ ├── globals_defs_0x70.html │ │ ├── globals_defs_0x72.html │ │ ├── globals_defs_0x73.html │ │ ├── globals_defs_0x74.html │ │ ├── globals_defs_0x75.html │ │ ├── globals_defs_0x77.html │ │ ├── globals_func.html │ │ ├── globals_type.html │ │ ├── globals_vars.html │ │ ├── hierarchy.html │ │ ├── index.hhc │ │ ├── index.hhk │ │ ├── index.hhp │ │ ├── index.html │ │ ├── main.html │ │ ├── modules.html │ │ ├── tab_b.gif │ │ ├── tab_l.gif │ │ ├── tab_r.gif │ │ ├── tabs.css │ │ └── tree.html │ ├── mobisys2003.pdf │ ├── pt-doc.txt │ ├── sicslogo.pdf │ ├── uip-code-style.c │ ├── uip-code-style.txt │ ├── uip-doc.txt │ └── uip-refman.pdf │ ├── fos │ ├── Makefile │ ├── clock-arch.c │ ├── clock-arch.h │ ├── main.c │ ├── tapdev.c │ ├── tapdev.h │ └── uip-conf.h │ ├── lib │ ├── memb.c │ └── memb.h │ ├── uip-1.0-changelog.txt │ └── uip │ ├── Makefile.include │ ├── clock.h │ ├── lc-addrlabels.h │ ├── lc-switch.h │ ├── lc.h │ ├── psock.c │ ├── psock.h │ ├── pt.h │ ├── timer.c │ ├── timer.h │ ├── uip-fw.c │ ├── uip-fw.h │ ├── uip-neighbor.c │ ├── uip-neighbor.h │ ├── uip-split.c │ ├── uip-split.h │ ├── uip.c │ ├── uip.h │ ├── uip_arch.h │ ├── uip_arp.c │ ├── uip_arp.h │ ├── uiplib.c │ ├── uiplib.h │ └── uipopt.h └── start.sh /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: 3 | - gcc 4 | script: 5 | - make 6 | - sudo ./fos 7 | notifications: 8 | email: 9 | - sjyangv0@gmail.com 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FOS( Fast Operating System ) 2 | ========== 3 | 4 | [中文页](README_zh.md) 5 | [![Build Status](https://secure.travis-ci.org/php/php-src.png?branch=master)](https://travis-ci.org/dreamflyforever/fos) 6 | 7 | It's an open soruce project about code RTOS(Real Time Operating Systems), named FOS, alias Chinese Operating System, not COPY OTHER SYSTEM, supported ISA openrisc, riscv & linux. 8 | 9 | Now it's function will be complete step by step, I hope more and more people will be to make it better. 10 | 11 | --------------------------------------------------------------------------- 12 | 13 | To build the FOS, tools need: scons and system gcc. 14 | 15 | CD to the RTOS directory and run: 16 | `scons` 17 | 18 | This will produce execution files named 'fos'. 19 | 20 | To run the FOS for linux, run the shell script: 21 | `./start.sh` 22 | 23 | --------------------------------------------------------------------------- 24 | 25 | SOURCE TREE: 26 | 27 | * kernel : Core kernel sources 28 | * app : User application sources 29 | * cpu : CPU architecture ports 30 | * libc : C function library. 31 | * middleware : The component for FOS 32 | * SConstruct and config.py : Compile tools 33 | * start_or1ksim.sh : Run the system in the or1ksim 34 | 35 | Contributions: 36 | ============== 37 | This software was written by Shanjin Yang. 38 | 39 | License: GPL. 40 | 41 | Any question please contact . 42 | -------------------------------------------------------------------------------- /README_zh.md: -------------------------------------------------------------------------------- 1 | FOS( Fast Operating System ) 2 | ========== 3 | [![Build Status](https://secure.travis-ci.org/php/php-src.png?branch=master)](https://travis-ci.org/dreamflyforever/fos) 4 | 5 | FOS是一款全新的开源实时操作系统(RTOS)。支持优先级抢占,FIFO(先进先出),RR(时间片轮) 6 | 三种调度算法。 7 | 8 | 它具备高度轻便可移植性(移植到不同的硬件平台),代码清晰,模块化,低耦合,可读性强。 9 | 同时也适用于硬件资源非常紧缺的情况,可以裁剪内核为FSM(有限状态机),仅仅200B的内存 10 | 占用空间。 11 | 12 | 由于FOS底层对接了LINUX的用户栈,线程切换接口,心跳定时器,网络/dev/tap,用户可以在 13 | linux平台上直接运行FOS,单步调试FOS,可以很方便清楚的看到FOS的线程调度,锁使用的具 14 | 体情况,极度高效学习操作系统原理。 15 | 16 | 功能: 17 | 1. 支持多任务运行, 支持基于优先级任务调度,支持同等优先级FIFO调度。 18 | 2. 支持message queue。 19 | 3. 支持信号量, 支持互斥锁, 支持优先级置顶算法。 20 | 4. 支持软定时器、延时函数。 21 | 5. 支持一个int的bit个数的任务数。 22 | 6. 支持0中断延迟时间。 23 | 7. 简化整个软件框架。只用old_task和new_task维护任务切换。 24 | 8. 系统支持优先启动任何任务,包括低优先级任务。 25 | 9. 支持创建任务时指明是否可以运行。 26 | 10. 支持shell组件。 27 | 11. 支持uip协议栈。 28 | 12. 支持文件系统。 29 | 30 | 相比其他RTOS优势: 31 | 32 | 1. 调度算法采用速度最快的first bit search算法 33 | 2. 用户接口采用posix 34 | 3. 解决传统mutex优先级继承问题 35 | 4. 采用中断上下部增加实时性 36 | 5. 添加状态机框架满足应用软件设计需要 37 | 6. 文件组织结构优化,比如所需的c文件只要包含一个头文件既可,避免头文件污染 38 | 39 | --------------------------------------------------------------------------- 40 | 41 | **快速搭建** 42 | 下载源码到linux平台,直接make,不需要任何库依赖,FOS还支持scons的构建方式,可以直接 43 | 执行scons(系统需要安装scons),生成的fos就可以直接运行,因为用到了linux的NAT方式,执 44 | 行fos时候用sudo最高执行权限。所以只要系统支持make和gcc,就可以运行FOS。 45 | 46 | --------------------------------------------------------------------------- 47 | 48 | **源码结构** 49 | 50 | * kernel : 内核代码,包括线程管理,信号量,互斥锁,任务调度算法, 定时器,消息队列,设备管理, 内存管理, 事件驱动管理 51 | * app : 用户层逻辑代码 52 | * cpu : 芯片移植代码,包括线程栈,任务切换,定时器,中断,数据类型 53 | * libc : 基本的C库 54 | * middleware : 组建,包括key-value存储,shell命令行,UIP网络协议 55 | * SConstruct and config.py : 构建系统工具 56 | * start_or1ksim.sh : or1ksim芯片模拟器运行 57 | 58 | --------------------------------------------------------------------------- 59 | 60 | **文档** 61 | [文档中心](https://blog.csdn.net/oYangShanJin) 62 | 63 | --------------------------------------------------------------------------- 64 | 65 | **贡献** 66 | 杨善锦(Jim) 67 | 68 | License: GPL. 69 | 70 | 任何问题欢迎联系 <1150660744@qq.com> or 微信 : dreamflyforever. 71 | -------------------------------------------------------------------------------- /SConstruct: -------------------------------------------------------------------------------- 1 | env = Environment(CPPPATH = ['kernel/include', 'cpu/linux/include', 'libc/include', 'middleware/uip/uip', 'middleware/uip/fos', 'middleware/uip/apps/webserver']) 2 | src = Glob('libc/*.c') 3 | src = src + Glob('cpu/*.S') 4 | src = src + Glob('kernel/*.c') 5 | src = src + Glob('cpu/linux/*.c') 6 | src = src + Glob('app/*.c') 7 | src = src + Glob('middleware/shell_parser/*.c') 8 | env.Library('foslib',src, CFLAGS = ['-g', '-fcolor-diagnostics'], CC = 'clang') 9 | #env.SharedLibrary('foslib',src, CFLAGS = ['-g', '-fcolor-diagnostics', '-Werror'], CC = 'clang') 10 | #for uip port 11 | src = Glob('middleware/uip/apps/webserver/*.c') 12 | src = src + Glob('middleware/uip/lib/*.c') 13 | src = src + Glob('middleware/uip/uip/*.c') 14 | src = src + Glob('middleware/uip/fos/*.c') 15 | env.Program('fos', 16 | src, 17 | LIBS = 'foslib', 18 | LIBPATH = ['.'], 19 | CCFLAGS = '-DHELLOSCONS', 20 | CFLAGS = ['-g', '-fcolor-diagnostics', '-fpack-struct', '-fno-strict-aliasing', '-Wno-unused-variable', '-Os', '-Wall'], 21 | CC = 'clang') 22 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | Support: 2 | ============== 3 | - `1`. Task manage. 4 | - `2`. Schedule method. Support FIFO/timeslice/priotity method. 5 | - `3`. IPC. Support semaphore/mutex/message queue. 6 | - `4`. Support tiny file system. 7 | - `5`. System exception handle. 8 | - `6`. Support block memory manage. 9 | - `7`. Support interrupt manage. 10 | - `8`. Support the task number of a word size. 11 | - `9`. Support shell. 12 | - `10`. Support uip. 13 | - `11`. Port to flatform: s3c2440/openrisc/linux 14 | - `12`. Support device manage. 15 | - `13`. Support software time. 16 | - `14` 0 delay interrupt time 17 | - `15` add fsm/hsm as low priority task framework 18 | - `14` delay interrupt time 19 | 20 | WIP: 21 | ================= 22 | - `1`. Memory overflow check. 23 | - `5`. Port to amp/smp. 24 | - `6`. JS engin. 25 | - `7`. Port to posix interface. 26 | - `8`. Support misra/osek. 27 | - `9`. Seprate user and kernel space. 28 | - `10`. Dynamic load application. 29 | - `11`. High precise timer. 30 | - `12`. Add some wifi/bluetooth/usb stack. 31 | - `13`. Support mpu. 32 | - `14`. Trace every callback function. 33 | - `15`. Low power handle. 34 | - `16`. Port to mainstream CPUs. 35 | - `17`. Read system config to user. 36 | -------------------------------------------------------------------------------- /app/system_start.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by Shanjin Yang. 16 | * 4. The name of the author may not be used to endorse or promote 17 | * products derived from this software without specific prior 18 | * written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 21 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 26 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * This file is part of the FOS. 33 | * 34 | * The latest version of FOS download by 35 | * 36 | */ 37 | 38 | #include 39 | 40 | /*Init hardware and system resource*/ 41 | void system_init() 42 | { 43 | hw_interrupt_init(); 44 | 45 | uart_init(); 46 | 47 | os_printf("FOS Copyright by Shanjin Yang\n\n"); 48 | 49 | prio_ready_queue_init(); 50 | 51 | tick_queue_init(); 52 | 53 | device_queue_init(); 54 | 55 | old_task = NULL; 56 | 57 | /*Create idle task */ 58 | task_create(&idle_tcb, (U8 *) "idle_task", idle_task, NULL, idle_stack, 59 | IDLE_STACK_SIZE, 31, 1); 60 | 61 | /*ethoc_initialize(0, 0x92000000);*/ 62 | } 63 | 64 | int main(void) 65 | { 66 | system_init(); 67 | 68 | #ifdef SHELL 69 | extern void shell_init(); 70 | shell_init(); 71 | #endif 72 | 73 | extern void uip_thread_init(); 74 | uip_thread_init(); 75 | 76 | extern void app_main(); 77 | app_main(); 78 | 79 | hw_timer_init(); 80 | 81 | /*Which task run first*/ 82 | BOOL result = start_which_task(&idle_tcb); 83 | OS_ASSERT(result); 84 | 85 | /*Never reach here*/ 86 | for (;;) { 87 | os_printf("hello"); 88 | }; 89 | 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /cpu/linux/include/hw_include.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Shanjin Yang. All rights reserved. 3 | * 4 | * Shanjin Yang 5 | * Shanghai, China 6 | * 7 | * 8 | * The license and distribution terms for this file may be 9 | * found in the file LICENSE in this distribution or at 10 | * https://github.com/yangshanjin/fos/blob/master/LICENSE. 11 | */ 12 | 13 | #ifndef __PORT__H__ 14 | #define __PORT__H__ 15 | 16 | #include 17 | #include 18 | 19 | #define handle_error(msg) \ 20 | do { perror(msg); exit(EXIT_FAILURE); } while (0) 21 | 22 | #define printf_to_uart printf 23 | #define STACK unsigned int 24 | 25 | typedef void (*_TASK_ENTRY) (void *); 26 | 27 | STACK *stack_init(STACK * stack_ptr, U32 stack_size, _TASK_ENTRY p_task, 28 | void *arg, void *task_exit); 29 | 30 | void hw_timer_init(); 31 | void hw_interrupt_init(); 32 | void uart_init(); 33 | void interrupt_enable(int sr_cpu); 34 | int interrupt_disable(); 35 | void hw_timer_clear_interrupt(); 36 | 37 | #define cpu_disable() interrupt_disable() 38 | #define cpu_enable(status) interrupt_enable(status) 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /cpu/linux/port.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Shanjin Yang. All rights reserved. 3 | * 4 | * Shanjin Yang 5 | * Shanghai, China 6 | * 7 | * 8 | * The license and distribution terms for this file may be 9 | * found in the file LICENSE in this distribution or at 10 | * https://github.com/yangshanjin/fos/blob/master/LICENSE. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | /*initialize user thread stack to store or pop switch-content*/ 20 | STACK *stack_init(STACK * stack_ptr, U32 stack_size, TASK_ENTRY p_task, 21 | void *arg, void *task_exit) 22 | { 23 | if ((stack_ptr == NULL) || (stack_size <= 0) || (p_task == NULL) 24 | || (task_exit == NULL)) 25 | assert(0); 26 | 27 | ucontext_t *stack = (ucontext_t *) malloc(sizeof(ucontext_t)); 28 | assert(stack); 29 | memset(stack, 0, sizeof(ucontext_t)); 30 | 31 | if (getcontext(stack) == -1) 32 | handle_error("getcontext"); 33 | 34 | stack->uc_link = NULL; 35 | stack->uc_stack.ss_sp = stack_ptr; 36 | stack->uc_stack.ss_size = stack_size; 37 | stack->uc_stack.ss_flags = 0; 38 | makecontext(stack, (void (*)(void))p_task, 1, arg); 39 | return (STACK *) stack; 40 | } 41 | 42 | /*swap stack pointer to run new thread*/ 43 | void port_schedule() 44 | { 45 | if (swapcontext 46 | ((ucontext_t *) old_task->stack_ptr, 47 | (ucontext_t *) new_task->stack_ptr) == -1) { 48 | handle_error("swapcontext"); 49 | } 50 | } 51 | 52 | /*first start thread*/ 53 | void start_schedule(TCB * tcb) 54 | { 55 | if (setcontext((ucontext_t *) tcb->stack_ptr) == -1) { 56 | handle_error("swapcontext"); 57 | } 58 | } 59 | 60 | /*initialize system heartbeat, function hardware_timer will run loop*/ 61 | void hw_timer_init() 62 | { 63 | struct itimerval t; 64 | t.it_interval.tv_usec = TICKS_PER_SECOND * 100; 65 | t.it_interval.tv_sec = 0; 66 | t.it_value.tv_usec = 0; 67 | t.it_value.tv_sec = 1; 68 | 69 | if (setitimer(ITIMER_REAL, &t, NULL) < 0) { 70 | printf("error\n"); 71 | } 72 | signal(SIGALRM, hardware_timer); 73 | } 74 | 75 | void hw_interrupt_init() 76 | { 77 | } 78 | 79 | void uart_init() 80 | { 81 | } 82 | 83 | void interrupt_enable(int sr_cpu) 84 | { 85 | } 86 | 87 | int interrupt_disable() 88 | { 89 | return 0; 90 | } 91 | 92 | void hw_timer_clear_interrupt() 93 | { 94 | } 95 | -------------------------------------------------------------------------------- /cpu/or1ksim/hw_timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * This file is part of the FOS. 6 | * 7 | * The latest version of FOS download by 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | /*======================[ CPU Tick timer functions ]============================= */ 15 | 16 | /* Enable tick timer and interrupt generation */ 17 | /* Set restart mode */ 18 | void hw_timer_init(void){ 19 | // clear timer interrupt 20 | mtspr(SPR_TTMR, mfspr(SPR_TTMR) & ~(SPR_TTMR_IP)); 21 | 22 | // set OR1200 to accept exceptions 23 | mtspr(SPR_SR, mfspr(SPR_SR) | SPR_SR_TEE); 24 | 25 | //set initial value, and restart mode 26 | mtspr(SPR_TTMR, SPR_TTMR_IE | SPR_TTMR_RT | ((SYS_CLK/TICKS_PER_SECOND) & SPR_TTMR_TP)); 27 | 28 | }; 29 | 30 | /* Disable tick timer and interrupt generation */ 31 | void hw_timer_disable(void){ 32 | // disable timer: clear it all ! 33 | mtspr(SPR_SR, mfspr(SPR_SR) & ~SPR_SR_TEE); 34 | mtspr(SPR_TTMR, 0); 35 | 36 | }; 37 | 38 | /* disable timer interrupt */ 39 | void hw_timer_disable_interrupt(void){ 40 | mtspr(SPR_TTMR, mfspr(SPR_TTMR) & ~(SPR_TTMR_IE)); 41 | }; 42 | 43 | /* clear tick interrupt */ 44 | void hw_timer_clear_interrupt(void){ 45 | mtspr(SPR_TTMR, mfspr(SPR_TTMR) & ~(SPR_TTMR_IP)); 46 | }; 47 | 48 | /* 49 | 50 | // Reset timer mode register to interrupt with same interval 51 | mtspr(SPR_TTMR, SPR_TTMR_IE | SPR_TTMR_RT | ((SYS_CLK/RAW_TICKS_PER_SECOND) & SPR_TTMR_TP)); 52 | 53 | */ 54 | -------------------------------------------------------------------------------- /cpu/or1ksim/include/board.h: -------------------------------------------------------------------------------- 1 | #ifndef __BOARD_H__ 2 | #define __BOARD_H__ 3 | 4 | /* SYSTEM CLOCK */ 5 | #define SYS_CLK 40000000 // 40MHz 6 | 7 | /* UART */ 8 | #define UART_BAUD_RATE 38400 9 | #define UART_BASE 0x90000000 10 | #define UART_IRQ 2 11 | 12 | /* SimpleGPIO */ 13 | #define GPIO_BASE 0x93000000 14 | 15 | /* SimpleSpi */ 16 | #define SPI_BASE 0x94000000 17 | #define SPI_IRQ 5 18 | #define SPI_NUM_CORES 1 19 | #define SPI_BASE_ADDRESSES_CSV SPI_BASE 20 | 21 | /* I2cMaster */ 22 | #define I2C_BASE 0x91000000 23 | #define I2C_IRQ 3 24 | #define I2C_RATE 100000 /* 100K */ 25 | #define I2C_MASTER_SLAVE_NUM_CORES 1 26 | #define I2C_MASTER_SLAVE_BASE_ADDRESSES_CSV I2C_BASE 27 | 28 | /* Ethernet */ 29 | #define ETHERNET_BASE 0x92000000 30 | #define ETHERNET_IRQ 4 31 | 32 | #endif /* _BOARD_H_ */ 33 | -------------------------------------------------------------------------------- /cpu/or1ksim/include/hw_include.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by Shanjin Yang. 16 | * 4. The name of the author may not be used to endorse or promote 17 | * products derived from this software without specific prior 18 | * written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 21 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 26 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * This file is part of the FOS. 33 | * 34 | * The latest version of FOS download by 35 | * 36 | */ 37 | 38 | #ifndef __HW_INCLUDE_H__ 39 | #define __HW_INCLUDE_H__ 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /cpu/or1ksim/include/hw_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * This file is part of the FOS. 6 | * 7 | * The latest version of FOS download by 8 | * 9 | */ 10 | 11 | #ifndef __HW_TIMER_H_ 12 | #define __HW_TIMER_H_ 13 | 14 | void hw_timer_init(void); 15 | void hw_timer_disable(void); 16 | void hw_timer_disable_interrupt(void); 17 | void hw_timer_clear_interrupt(void); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /cpu/or1ksim/include/interrupt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by Shanjin Yang. 16 | * 4. The name of the author may not be used to endorse or promote 17 | * products derived from this software without specific prior 18 | * written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 21 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 26 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * This file is part of the FOS. 33 | * 34 | * The latest version of FOS download by 35 | * 36 | */ 37 | 38 | #ifndef __INTERRUPT_H__ 39 | #define __INTERRUPT_H__ 40 | 41 | #define MAX_INT_HANDLERS 32 42 | 43 | struct ihnd { 44 | void (*handler)(void *); 45 | void *arg; 46 | }; 47 | 48 | extern struct ihnd int_handlers[MAX_INT_HANDLERS]; 49 | 50 | U32 interrupt_disable(void); 51 | void interrupt_enable(U32 cpu_sr); 52 | int hw_interrupt_install(unsigned long vect, void (* handler)(void *), void *arg); 53 | int hw_interrupt_mask(unsigned long vect); 54 | int hw_interrupt_unmask(unsigned long vect); 55 | void usr_handle(); 56 | int hw_interrupt_init(); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /cpu/or1ksim/include/or1200-utils.h: -------------------------------------------------------------------------------- 1 | #ifndef _OR1200_UTILS_H_ 2 | #define _OR1200_UTILS_H_ 3 | 4 | /* type defines */ 5 | typedef unsigned int uint; 6 | #if defined (__GNUC__) 7 | typedef unsigned char bool; 8 | typedef signed char int8; 9 | typedef signed short int16; 10 | typedef signed long int32; 11 | typedef unsigned char uint8; 12 | typedef unsigned short uint16; 13 | typedef unsigned long uint32; 14 | typedef unsigned char char8; 15 | typedef unsigned short char16; 16 | #else 17 | #error Undefined compiler used ! 18 | #endif 19 | 20 | /* nullpointer is defined if not already done */ 21 | #ifndef NULL 22 | #define NULL (void *)0 23 | #endif 24 | 25 | /* define min and max for all types */ 26 | #define INT8_MAX 0x7F 27 | #define UINT8_MAX 0xFF 28 | #define INT16_MAX 0x7FFF 29 | #define UINT16_MAX 0xFFFF 30 | #define INT32_MAX 0x7FFFFFFF 31 | #define UINT32_MAX 0xFFFFFFFF 32 | 33 | #ifndef TRUE 34 | #define FALSE 0 35 | #define TRUE !FALSE 36 | #endif 37 | 38 | /* l.nop constants */ 39 | #define NOP_NOP 0x0000 /* Normal nop instruction */ 40 | #define NOP_EXIT 0x0001 /* End of simulation */ 41 | #define NOP_REPORT 0x0002 /* Simple report */ 42 | #define NOP_PRINTF 0x0003 /* Simprintf instruction */ 43 | #define NOP_PUTC 0x0004 /* Simulation putc instruction */ 44 | #define NOP_REPORT_FIRST 0x0400 /* Report with number */ 45 | #define NOP_REPORT_LAST 0x03ff /* Report with number */ 46 | 47 | #endif /* _OR1200_UTILS_H_ */ 48 | -------------------------------------------------------------------------------- /cpu/or1ksim/include/ptrace.h: -------------------------------------------------------------------------------- 1 | #ifndef _PTRACE_H_ 2 | #define _PTRACE_H_ 3 | 4 | /* 5 | * Offsets used by 'ptrace' system call interface. 6 | */ 7 | #define PT_PC 0x0 8 | #define PT_SR 0x4 9 | #define PT_GPR2 0x8 10 | #define PT_GPR3 0xc 11 | #define PT_GPR4 0x10 12 | #define PT_GPR5 0x14 13 | #define PT_GPR6 0x18 14 | #define PT_GPR7 0x1c 15 | #define PT_GPR8 0x20 16 | #define PT_GPR9 0x24 17 | #define PT_GPR10 0x28 18 | #define PT_GPR11 0x2c 19 | #define PT_GPR12 0x30 20 | #define PT_GPR13 0x34 21 | #define PT_GPR14 0x38 22 | #define PT_GPR15 0x3c 23 | #define PT_GPR16 0x40 24 | #define PT_GPR17 0x44 25 | #define PT_GPR18 0x48 26 | #define PT_GPR19 0x4c 27 | #define PT_GPR20 0x50 28 | #define PT_GPR21 0x54 29 | #define PT_GPR22 0x58 30 | #define PT_GPR23 0x5c 31 | #define PT_GPR24 0x60 32 | #define PT_GPR25 0x64 33 | #define PT_GPR26 0x68 34 | #define PT_GPR27 0x6c 35 | #define PT_GPR28 0x70 36 | #define PT_GPR29 0x74 37 | #define PT_GPR30 0x78 38 | #define PT_GPR31 0x7c 39 | 40 | #endif /* _PTRACE_H_ */ 41 | -------------------------------------------------------------------------------- /cpu/or1ksim/include/stack_ready.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * This file is part of the FOS. 6 | * 7 | * The latest version of FOS download by 8 | * 9 | */ 10 | 11 | #ifndef __STACK_READY__ 12 | #define __STACK_READY__ 13 | 14 | typedef void (*TASK_ENTRY)(void *p_arg); 15 | typedef void (*TASK_EXIT)(void *p_arg); 16 | #define STACK_COPY unsigned int 17 | #define U32 unsigned int 18 | void *stack_init( STACK_COPY *p_stk_base, U32 stk_size, TASK_ENTRY p_task, void * arg, TASK_EXIT task_exit); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /cpu/or1ksim/include/support.h: -------------------------------------------------------------------------------- 1 | #ifndef _SUPPORT_H_ 2 | #define _SUPPORT_H_ 3 | 4 | 5 | /* include common defines for or1200 */ 6 | #include 7 | 8 | /* Max and min functions */ 9 | #ifndef MIN 10 | #define MIN(a,b) (((a)<(b))?(a):(b)) 11 | #endif 12 | 13 | #define MAX(a,b) (((a)>(b))?(a):(b)) 14 | 15 | /* Register access macros */ 16 | #define REG8(add) *((volatile unsigned char *)(add)) 17 | #define REG16(add) *((volatile unsigned short *)(add)) 18 | #define REG32(add) *((volatile unsigned long *)(add)) 19 | 20 | /* For writing into SPR. */ 21 | void mtspr(unsigned long spr, unsigned long value); 22 | 23 | /* For reading SPR. */ 24 | unsigned long mfspr(unsigned long spr); 25 | 26 | 27 | 28 | #endif /* _SUPPORT_H_ */ 29 | -------------------------------------------------------------------------------- /cpu/or1ksim/stack_ready.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * This file is part of the FOS. 6 | * 7 | * The latest version of FOS download by 8 | * 9 | */ 10 | 11 | #include 12 | 13 | void *stack_init( STACK_COPY *p_stk_base, U32 stk_size, TASK_ENTRY p_task, void 14 | * arg, TASK_EXIT task_exit) 15 | { 16 | U32 *stk; 17 | U32 temp = (U32)(p_stk_base + stk_size - 128); 18 | stk = (U32 *)temp; 19 | stk--; 20 | *stk-- = (U32)31; /* r31 = 0 */ 21 | *stk-- = (U32)30; /* r30 = 0 */ 22 | *stk-- = (U32)29; /* r29 = 0 */ 23 | *stk-- = (U32)28; /* r28 = 0 */ 24 | *stk-- = (U32)27; /* r27 = 0 */ 25 | *stk-- = (U32)26; /* r26 = 0 */ 26 | *stk-- = (U32)25; /* r25 = 0 */ 27 | *stk-- = (U32)24; /* r24 = 0 */ 28 | *stk-- = (U32)23; /* r23 = 0 */ 29 | *stk-- = (U32)22; /* r22 = 0 */ 30 | *stk-- = (U32)21; /* r21 = 0 */ 31 | *stk-- = (U32)20; /* r20 = 0 */ 32 | *stk-- = (U32)19; /* r19 = 0 */ 33 | *stk-- = (U32)18; /* r18 = 0 */ 34 | *stk-- = (U32)17; /* r17 = 0 */ 35 | *stk-- = (U32)16; /* r16 = 0 */ 36 | *stk-- = (U32)15; /* r15 = 0 */ 37 | *stk-- = (U32)14; /* r14 = 0 */ 38 | *stk-- = (U32)13; /* r13 = 0 */ 39 | *stk-- = (U32)12; /* r12 = 0 */ 40 | *stk-- = (U32)11; /* r11 = 0 return value */ 41 | *stk-- = (U32)10; /* r10 = 0 */ 42 | *stk-- = (U32)task_exit; /* r09 = 0 link register, task_exit is for task return*/ 43 | *stk-- = (U32)8; /* r08 = 0 function paramters*/ 44 | *stk-- = (U32)7; /* r07 = 0 */ 45 | *stk-- = (U32)6; /* r06 = 0 */ 46 | *stk-- = (U32)5; /* r05 = 0 */ 47 | *stk-- = (U32)4; /* r04 = 0 */ 48 | *stk-- = (U32)arg; /* r03 = arg0 */ 49 | *stk-- = (U32)2; /* r02 = frame pointer */ 50 | *stk-- = (U32)(SPR_SR_IEE | SPR_SR_TEE | SPR_SR_SM); /* status word */ 51 | *stk = (U32)(p_task); /* program counter */ 52 | 53 | return ((U32 *)stk); 54 | } 55 | 56 | void port_schedule() 57 | { 58 | __asm__ ("l.sys 0"); 59 | __asm__ ("l.nop"); 60 | } 61 | -------------------------------------------------------------------------------- /cpu/or1ksim/support.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * This file is part of the FOS. 6 | * 7 | * The latest version of FOS download by 8 | * 9 | */ 10 | 11 | #include 12 | 13 | /* For writing into SPR. */ 14 | void mtspr(unsigned long spr, unsigned long value) 15 | { 16 | asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value)); 17 | } 18 | 19 | /* For reading SPR. */ 20 | unsigned long mfspr(unsigned long spr) 21 | { 22 | unsigned long value; 23 | asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr)); 24 | return value; 25 | } 26 | -------------------------------------------------------------------------------- /cpu/riscv/sifive_e/constants.s: -------------------------------------------------------------------------------- 1 | # See LICENSE for license details. 2 | 3 | .equ MAX_HARTS, 4 4 | .equ SAVE_REGS, 16 5 | .equ STACK_SIZE, 1024 6 | .equ STACK_SHIFT, 10 7 | .equ CONTEXT_SIZE, (SAVE_REGS * REGBYTES) 8 | 9 | .globl _text_start 10 | .globl _text_end 11 | .globl _rodata_start 12 | .globl _rodata_end 13 | .globl _data_start 14 | .globl _data_end 15 | .globl _bss_start 16 | .globl _bss_end 17 | .global _memory_start; 18 | .global _memory_end; 19 | -------------------------------------------------------------------------------- /cpu/riscv/sifive_e/crtm.s: -------------------------------------------------------------------------------- 1 | # See LICENSE for license details. 2 | 3 | .include "macros.s" 4 | .include "constants.s" 5 | 6 | # 7 | # start of trap handler 8 | # 9 | 10 | .section .text.init,"ax",@progbits 11 | .globl _start 12 | 13 | _start: 14 | # setup default trap vector 15 | la t0, trap_vector 16 | csrw mtvec, t0 17 | 18 | # set up stack pointer based on hartid 19 | csrr t0, mhartid 20 | slli t0, t0, STACK_SHIFT 21 | la sp, stacks + STACK_SIZE 22 | add sp, sp, t0 23 | 24 | # park all harts excpet hart 0 25 | csrr a0, mhartid 26 | bnez a0, park 27 | 28 | # jump to _main 29 | j _main 30 | 31 | # sleeping harts mtvec calls trap_fn upon receiving IPI 32 | park: 33 | wfi 34 | j park 35 | 36 | .align 2 37 | trap_vector: 38 | # Save registers. 39 | addi sp, sp, -CONTEXT_SIZE 40 | sxsp ra, 0 41 | sxsp a0, 1 42 | sxsp a1, 2 43 | sxsp a2, 3 44 | sxsp a3, 4 45 | sxsp a4, 5 46 | sxsp a5, 6 47 | sxsp a6, 7 48 | sxsp a7, 8 49 | sxsp t0, 9 50 | sxsp t1, 10 51 | sxsp t2, 11 52 | sxsp t3, 12 53 | sxsp t4, 13 54 | sxsp t5, 14 55 | sxsp t6, 15 56 | 57 | # Invoke the handler. 58 | mv a0, sp 59 | csrr a1, mcause 60 | csrr a2, mepc 61 | jal trap_handler 62 | 63 | # Restore registers. 64 | lxsp ra, 0 65 | lxsp a0, 1 66 | lxsp a1, 2 67 | lxsp a2, 3 68 | lxsp a3, 4 69 | lxsp a4, 5 70 | lxsp a5, 6 71 | lxsp a6, 7 72 | lxsp a7, 8 73 | lxsp t0, 9 74 | lxsp t1, 10 75 | lxsp t2, 11 76 | lxsp t3, 12 77 | lxsp t4, 13 78 | lxsp t5, 14 79 | lxsp t6, 15 80 | addi sp, sp, CONTEXT_SIZE 81 | 82 | # Return 83 | mret 84 | 85 | .bss 86 | .align 4 87 | .global stacks 88 | stacks: 89 | .skip STACK_SIZE * MAX_HARTS 90 | -------------------------------------------------------------------------------- /cpu/riscv/sifive_e/default.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH( "riscv" ) 2 | 3 | ENTRY( _start ) 4 | 5 | MEMORY 6 | { 7 | flash (rxai!w) : ORIGIN = 0x20400000, LENGTH = 128M 8 | ram (wxa!ri) : ORIGIN = 0x80000000, LENGTH = 64K 9 | } 10 | 11 | PHDRS 12 | { 13 | text PT_LOAD; 14 | data PT_LOAD; 15 | bss PT_LOAD; 16 | } 17 | 18 | SECTIONS 19 | { 20 | .text : { 21 | PROVIDE(_text_start = .); 22 | *(.text.init) *(.text .text.*) 23 | PROVIDE(_text_end = .); 24 | } >flash AT>flash :text 25 | 26 | .rodata : { 27 | PROVIDE(_rodata_start = .); 28 | *(.rodata .rodata.*) 29 | PROVIDE(_rodata_end = .); 30 | } >flash AT>flash :text 31 | 32 | .data : { 33 | . = ALIGN(4096); 34 | PROVIDE(_data_start = .); 35 | *(.sdata .sdata.*) *(.data .data.*) 36 | PROVIDE(_data_end = .); 37 | } >ram AT>ram :data 38 | 39 | .bss :{ 40 | PROVIDE(_bss_start = .); 41 | *(.sbss .sbss.*) *(.bss .bss.*) 42 | PROVIDE(_bss_end = .); 43 | } >ram AT>ram :bss 44 | 45 | PROVIDE(_memory_start = ORIGIN(ram)); 46 | PROVIDE(_memory_end = ORIGIN(ram) + LENGTH(ram)); 47 | } 48 | -------------------------------------------------------------------------------- /cpu/riscv/sifive_e/macros.s: -------------------------------------------------------------------------------- 1 | # See LICENSE for license details. 2 | 3 | .equ REGBYTES, 4 4 | 5 | .macro lx a, b 6 | lw \a, \b 7 | .endm 8 | 9 | .macro sx a, b 10 | sw \a, \b 11 | .endm 12 | 13 | .macro lxsp a, b 14 | lw \a, ((\b)*REGBYTES)(sp) 15 | .endm 16 | 17 | .macro sxsp a, b 18 | sw \a, ((\b)*REGBYTES)(sp) 19 | .endm 20 | 21 | .macro .ptr a 22 | .4byte \a 23 | .endm 24 | -------------------------------------------------------------------------------- /kernel/idle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by Shanjin Yang. 16 | * 4. The name of the author may not be used to endorse or promote 17 | * products derived from this software without specific prior 18 | * written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 21 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 26 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * This file is part of the FOS. 33 | * 34 | * The latest version of FOS download by 35 | * 36 | */ 37 | 38 | #include 39 | 40 | TCB idle_tcb; 41 | U32 idle_stack[IDLE_STACK_SIZE]; 42 | 43 | /*Idle task*/ 44 | void idle_task(void *arg) 45 | { 46 | for (;;) { 47 | /*do low power action or low priority thing, then schedule*/ 48 | schedule(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /kernel/include/device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : device.h 3 | * This file is part of FOS 4 | * 5 | * Copyright (c) 2013, Shanjin Yang. 6 | * All rights reserved. 7 | * 8 | * The license and distribution terms for this file: GPL 9 | * 10 | * Author Date content 11 | * Shanjin Yang 2015-3-30 the first version 12 | * Shanjin Yang 2017-6-14 modify the open and close API, add handle of 13 | * the many times device-init. 14 | */ 15 | 16 | #ifndef __DEVICE_H__ 17 | #define __DEVICE_H__ 18 | 19 | typedef int (*FUNC) (char * buff, U8 size); 20 | 21 | typedef struct OPERATIONS_STR { 22 | int (*open) (char *arg, U8 flag); 23 | int (*read) (char * buff, U8 size); 24 | int (*write) (char * buff, U8 size); 25 | int (*ioctrl) (U8 cmd, void *arg); 26 | int (*close) (); 27 | } OPERATIONS; 28 | 29 | typedef struct DEVICE_STR { 30 | LIST list; 31 | BOOL enable; 32 | const char *name; 33 | OPERATIONS *ops; 34 | U8 open_count; 35 | U8 flag; 36 | } DEVICE; 37 | 38 | extern DEVICE device_queue_head; 39 | 40 | void device_queue_init(void); 41 | int device_register(DEVICE * device, const char * name, OPERATIONS * ops); 42 | int device_unregister(DEVICE * device); 43 | int ops_init(OPERATIONS * ops, 44 | int (*open)(char *arg, U8 flag), 45 | FUNC write, 46 | FUNC read, 47 | int (*ioctrl)(U8 cmd, void *arg), 48 | int (*close)() 49 | ); 50 | int device_open(DEVICE * device, char * name, U8 flag); 51 | int device_read(DEVICE * device, char * buff, U8 size); 52 | int device_write(DEVICE * device, char * buff, U8 size); 53 | int device_ioctrl(DEVICE * device, U8 cmd, void *arg); 54 | int device_close(DEVICE * device); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /kernel/include/fsm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * It's a part of smartfsm, by Shanjin Yang. 3 | * Email: sjyangv0@qq.com 4 | * 5 | */ 6 | 7 | #define ERROR_PRINTF printf("error: %d\n", __LINE__) 8 | 9 | #define STATE_OBJ_MALLOC_AND_INSERT(token, state, func, state_name) \ 10 | STATE_DIS *state_obj_##token = (STATE_DIS *)malloc(sizeof(STATE_DIS)); \ 11 | state_obj_##token->state = state; \ 12 | state_obj_##token->name = state_name; \ 13 | state_obj_##token->func = func;\ 14 | list_insert( &(state_obj->node), &(state_obj_##token->node)) 15 | 16 | #define SET_STATE_DEFAULT_FUNC(function) fsm_default.func = function 17 | #define MSG_LEN 1024 18 | 19 | typedef void (*FUNC_PTR)(void *p_arg); 20 | 21 | typedef struct fsm_s { 22 | int state; 23 | FUNC_PTR func; 24 | U8 *name; 25 | U8 message[MSG_LEN]; 26 | } FSM; 27 | 28 | typedef struct state_dis_s { 29 | LIST node; 30 | int state; 31 | FUNC_PTR func; 32 | U8 *name; 33 | } STATE_DIS; 34 | 35 | extern FSM *fsm_obj; 36 | extern FSM fsm_default; 37 | 38 | int state_init(int state, FUNC_PTR func, U8 *name); 39 | int state_add(int state, FUNC_PTR func, U8 *name); 40 | int state_remove(int state); 41 | int state_tran(int state, void *message); 42 | int fsm_init(); 43 | void fsm_while(FSM *obj); 44 | int state_default(int state, FUNC_PTR func, U8 *name); 45 | -------------------------------------------------------------------------------- /kernel/include/mem_block.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : mem_block.c 3 | * This file is part of FOS 4 | * 5 | * Copyright (c) 2013, Shanjin Yang. 6 | * All rights reserved. 7 | * 8 | * The license and distribution terms for this file: GPL 9 | * 10 | * date modified content 11 | * 2014-11-8 Shanjin Yang the first version 12 | * 2020-08-5 Shanjin Yang 13 | */ 14 | 15 | #ifndef __MEM_BLOCK_H__ 16 | #define __MEM_BLOCK_H__ 17 | 18 | typedef struct MEM_POOL { 19 | LIST head; 20 | U32 size; 21 | U32 valid; 22 | void *valid_ptr; 23 | } MEM_POOL; 24 | 25 | typedef struct MEM_BLOCK { 26 | LIST list; 27 | void *ptr; 28 | U8 if_valid; 29 | U32 flag; 30 | } MEM_BLOCK; 31 | 32 | U8 mem_create(MEM_POOL *ptr, void *start, U32 sum, U32 block_size); 33 | 34 | void *mem_alloca(MEM_POOL *ptr, U32 size); 35 | 36 | void *mem_free(MEM_POOL *ptr, void *address); 37 | #endif 38 | -------------------------------------------------------------------------------- /kernel/include/pt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Protothread implement 3 | * cutdown memory need, only 2 bytes to keep the thread next address, 4 | * but not keep the context, so be careful to use it. 5 | */ 6 | 7 | #define PT_CREATE(p, arg) \ 8 | if (p == NULL) { \ 9 | return 0; \ 10 | } \ 11 | p(arg); 12 | 13 | #define BEGIN 0 14 | #define BLOCK 2 15 | 16 | #define PT_INIT() \ 17 | static int event = BEGIN;\ 18 | switch (event) \ 19 | {\ 20 | case BEGIN: \ 21 | { 22 | 23 | /*notic: use `\` means on the one line*/ 24 | #define PT_BLOCK(condition) \ 25 | }\ 26 | event = __LINE__;\ 27 | break; \ 28 | case __LINE__: \ 29 | {\ 30 | if (!condition) \ 31 | return BLOCK\ 32 | 33 | 34 | #define PT_DEINIT() \ 35 | }\ 36 | break; \ 37 | default:\ 38 | print("event: %d\n", event); \ 39 | break;\ 40 | } 41 | 42 | #define PT_RESUME(p) \ 43 | p(NULL); 44 | 45 | 46 | #if 0 47 | #define print(format, ...) \ 48 | {printf("[%s : %s : %d] ", \ 49 | __FILE__, __func__, __LINE__); \ 50 | printf(format, ##__VA_ARGS__);} 51 | 52 | /*test potothread*/ 53 | #include "stdio.h" 54 | int phread_one(void *arg) 55 | { 56 | PT_INIT(); 57 | print("block\n") 58 | PT_BLOCK(1); 59 | print("run\n"); 60 | PT_DEINIT(); 61 | return 0; 62 | } 63 | 64 | int phread_two(void *arg) 65 | { 66 | PT_INIT(); 67 | print("run\n"); 68 | PT_RESUME(phread_one); 69 | print("resume\n"); 70 | PT_DEINIT(); 71 | return 0; 72 | } 73 | 74 | int main() 75 | { 76 | int event = BEGIN; 77 | PT_CREATE(phread_one, &event); 78 | PT_CREATE(phread_two, &event); 79 | return 0; 80 | } 81 | #endif 82 | -------------------------------------------------------------------------------- /kernel/include/queue.h: -------------------------------------------------------------------------------- 1 | #ifndef __QUEUE_H__ 2 | #define __QUEUE_H__ 3 | 4 | #include 5 | 6 | /*Last In, First Out*/ 7 | #define LIFO 0 8 | /*First In, First Out*/ 9 | #define FIFO 1 10 | 11 | typedef struct QUEUE_STR { 12 | /*For block task */ 13 | LIST list; 14 | /*For message list */ 15 | LIST msg_head; 16 | U32 length; 17 | /*Judge message max number */ 18 | U32 count; 19 | U8 *name; 20 | } QUEUE; 21 | 22 | typedef struct MSG_STR { 23 | LIST list; 24 | U8 type; 25 | U32 length; 26 | U8 *buff; 27 | } MSG; 28 | 29 | enum {FULL = 10, EMPTY}; 30 | 31 | U8 msg_queue_create(QUEUE * entry, U32 length, U8 * name); 32 | 33 | U8 msg_put(QUEUE * entry, MSG * msg, U8 method); 34 | 35 | U8 msg_get(QUEUE * entry, void *buffer); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /kernel/mem_block.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : mem_block.c 3 | * This file is part of FOS 4 | * 5 | * Copyright (c) 2013, Shanjin Yang. 6 | * All rights reserved. 7 | * 8 | * The license and distribution terms for this file: GPL 9 | * 10 | * date modified content 11 | * 2014-11-8 Shanjin Yang the first version 12 | * 2020-08-5 Shanjin Yang 13 | */ 14 | 15 | #include 16 | 17 | U8 mem_create(MEM_POOL *ptr, void *start, U32 sum, U32 block_size) 18 | { 19 | ptr->size = block_size; 20 | /*figure up how many block*/ 21 | ptr->valid = sum/block_size; 22 | /*record the begain address*/ 23 | ptr->valid_ptr = start; 24 | list_init(&(ptr->head)); 25 | } 26 | 27 | void *mem_alloca(MEM_POOL *ptr, U32 size) 28 | { 29 | int n; 30 | int cpu_status; 31 | void *address = NULL; 32 | MEM_BLOCK mb; 33 | cpu_status = critical_section_enter(); 34 | /*figure up how many block need*/ 35 | n = size/ptr->size; 36 | ptr->valid = ptr->valid - n -1; 37 | if (ptr->valid > 0) { 38 | address = ptr->valid_ptr; 39 | /*figure up next begain address*/ 40 | ptr->valid_ptr = (char *)ptr->valid_ptr + ptr->valid * ptr->size; 41 | mb.flag = n + 1; 42 | /*mean block is useless for the next search*/ 43 | mb.if_valid = 0; 44 | mb.ptr = address; 45 | list_insert_behind(&(ptr->head), &mb.list); 46 | } 47 | critical_section_exit(cpu_status); 48 | return address; 49 | } 50 | 51 | void *mem_free(MEM_POOL *ptr, void *address) 52 | { 53 | LIST *tmp; 54 | tmp = &(ptr->head); 55 | MEM_BLOCK *mb; 56 | int cpu_status; 57 | cpu_status = critical_section_enter(); 58 | /*search the address, and flag available*/ 59 | while (!is_list_last(tmp)) { 60 | mb = list_entry(tmp->next, MEM_BLOCK, list); 61 | tmp = tmp->next; 62 | if (mb->ptr == address) { 63 | mb->if_valid = 1; 64 | return TRUE; 65 | } 66 | } 67 | critical_section_exit(cpu_status); 68 | return FALSE; 69 | } 70 | 71 | #if 0 72 | int main() 73 | { 74 | char g_mem[100000]; 75 | MEM_POOL mp; 76 | mem_create(&mp, &g_mem, 100, 10); 77 | char *a = mem_alloca(&mp, 9); 78 | mem_free(&mp, a); 79 | } 80 | #endif 81 | -------------------------------------------------------------------------------- /kernel/var_define.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by Shanjin Yang. 16 | * 4. The name of the author may not be used to endorse or promote 17 | * products derived from this software without specific prior 18 | * written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 21 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 26 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * This file is part of the FOS. 33 | * 34 | * The latest version of FOS download by 35 | * 36 | */ 37 | 38 | #include 39 | 40 | TCB task_prio_queue[SYSTEM_WORD]; 41 | TCB *new_task; 42 | TCB *old_task; 43 | 44 | BOOL schedule_is_lock; 45 | 46 | U32 task_prio_map; 47 | -------------------------------------------------------------------------------- /libc/include/lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * This file is part of the FOS. 6 | * 7 | * The latest version of FOS download by 8 | * 9 | */ 10 | 11 | #ifndef __LIB_H__ 12 | #define __LIB_H__ 13 | 14 | #ifndef NULL 15 | #define NULL ((void *)0) 16 | #endif 17 | 18 | /* memcpy */ 19 | void *fos_memcpy( void* s1, void* s2, unsigned int n); 20 | 21 | /* strlen */ 22 | unsigned int fos_strlen(const char*s); 23 | 24 | /* memchr */ 25 | void *fos_memchr(const void *s, int c, unsigned int n); 26 | 27 | /* Seed for LFSR function used in rand() */ 28 | /* This seed was derived from running the LFSR with a seed of 1 - helps skip the 29 | first iterations which outputs the value shifting through. */ 30 | /* Pseudo-random number generation */ 31 | unsigned long int fos_rand (); 32 | 33 | void *fos_memset(void *src, unsigned char byte, unsigned int count); 34 | 35 | int fos_strcmp(const char *cs, const char *ct); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /libc/include/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * This file is part of the FOS. 6 | * 7 | * The latest version of FOS download by 8 | * 9 | */ 10 | 11 | #ifndef _PRINTF_H_ 12 | #define _PRINTF_H_ 13 | 14 | int sprintf(char* str, const char *fmt, ...); 15 | 16 | #define PRINTFBUFFER_SIZE 512 17 | extern char PRINTFBUFFER[PRINTFBUFFER_SIZE]; // Declare a global printf buffer 18 | 19 | int printf_to_uart(const char *fmt, ...); 20 | int printf_to_sim(const char *fmt, ...); 21 | 22 | int putchar_to_uart(int c); 23 | int putchar_to_sim(int c); 24 | 25 | int puts_to_uart(const char *str); 26 | int puts_to_sim(const char *str); 27 | 28 | /* for os_printf */ 29 | //#define os_printf printf_to_uart 30 | #define putchar putchar_to_uart 31 | #define puts puts_to_uart 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libc/lib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * This file is part of the FOS. 6 | * 7 | * The latest version of FOS download by 8 | * 9 | */ 10 | 11 | /* Based C function lib */ 12 | #include 13 | #include 14 | 15 | void *fos_memcpy( void* s1, void* s2, unsigned int n) 16 | { 17 | char* r1 = (char *) s1; 18 | const char* r2 = (const char*) s2; 19 | while (n) { 20 | *r1++ = *r2++; 21 | --n; 22 | } 23 | return s1; 24 | } 25 | 26 | unsigned int fos_strlen(const char*s) 27 | { 28 | const char* p; 29 | for (p=s; *p; p++); 30 | return p - s; 31 | } 32 | 33 | void *fos_memchr(const void *s, int c, unsigned int n) 34 | { 35 | const unsigned char *r = (const unsigned char *) s; 36 | #define np n 37 | while (np) { 38 | if (*r == ((unsigned char)c)) { 39 | return (void *) r; /* silence the warning */ 40 | } 41 | ++r; 42 | --np; 43 | } 44 | return NULL; 45 | } 46 | 47 | unsigned long int fos_rand () 48 | { 49 | static unsigned long int lfsr = 0x14b6bc3c; 50 | static int period = 0; 51 | /* taps: 32 31 29 1; characteristic polynomial: x^32 + x^31 + x^29 + x + 1 */ 52 | lfsr = (lfsr >> 1) ^ (unsigned long int)((0 - (lfsr & 1u)) & 0xd0000001u); 53 | ++period; 54 | return lfsr; 55 | } 56 | 57 | void *fos_memset(void *src, unsigned char byte, unsigned int count) 58 | { 59 | char *xs = src; 60 | 61 | while (count--) { 62 | 63 | *xs++ = byte; 64 | } 65 | 66 | return src; 67 | } 68 | 69 | int fos_strcmp(const char *cs, const char *ct) 70 | { 71 | unsigned char c1, c2; 72 | 73 | while (1) { 74 | c1 = *cs++; 75 | c2 = *ct++; 76 | if (c1 != c2) 77 | return c1 < c2 ? -1 : 1; 78 | if (!c1) 79 | break; 80 | } 81 | return 0; 82 | } 83 | 84 | #define isdigit(c) ((unsigned)((c) - '0') < 10) 85 | 86 | static int skip_atoi(const char **s) 87 | { 88 | register int i=0; 89 | while (isdigit(**s)) 90 | i = i * 10 + *((*s)++) - '0'; 91 | 92 | return i; 93 | } 94 | #define ZEROPAD (1 << 0) /* pad with zero */ 95 | #define SIGN (1 << 1) /* unsigned/signed long */ 96 | #define PLUS (1 << 2) /* show plus */ 97 | #define SPACE (1 << 3) /* space if plus */ 98 | #define LEFT (1 << 4) /* left justified */ 99 | #define SPECIAL (1 << 5) /* 0x */ 100 | #define LARGE (1 << 6) /* use 'ABCDEF' instead of 'abcdef' */ 101 | 102 | U32 divide(long int *n, U32 base) 103 | { 104 | U32 res; 105 | 106 | /* optimized for processor which does not support divide instructions. */ 107 | if (base == 10) 108 | { 109 | res = ((U32)*n) % 10U; 110 | *n = ((U32)*n) / 10U; 111 | } 112 | else 113 | { 114 | res = ((U32)*n) % 16U; 115 | *n = ((U32)*n) / 16U; 116 | } 117 | 118 | return res; 119 | } 120 | -------------------------------------------------------------------------------- /libc/printf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void itoa(unsigned long val,char *buf,unsigned radix) 5 | { 6 | char *p;/*pointer to traverse string*/ 7 | char *firstdig;/*pointer to first digit*/ 8 | char temp;/*temp char*/ 9 | unsigned digval;/*value of digit*/ 10 | 11 | p = buf; 12 | firstdig = p;/*save pointer to first digit*/ 13 | 14 | do { 15 | digval =(unsigned)(val % radix); 16 | val /= radix;/*get next digit*/ 17 | 18 | /*convert to ascii and store */ 19 | if(digval > 9) 20 | *p++ = (char)(digval - 10 + 'a');/*a letter*/ 21 | else 22 | *p++ = (char)(digval + '0');/*a digit*/ 23 | } while(val > 0); 24 | 25 | /*We now have the digit of the number in the buffer,but in reverse 26 | order.Thus we reverse them now.*/ 27 | 28 | *p-- = '\0';/*terminate string;p points to last digit*/ 29 | 30 | do { 31 | temp = *p; 32 | *p = *firstdig; 33 | *firstdig = temp;/*swap *p and *firstdig*/ 34 | --p; 35 | ++firstdig;/*advance to next two digits*/ 36 | } while(firstdig < p);/*repeat until halfway*/ 37 | } 38 | 39 | /*putc is change to uart_putc*/ 40 | int print( const char *format, ...) 41 | { 42 | va_list arg; 43 | int done = 0; 44 | 45 | va_start (arg, format); 46 | 47 | while ( *format != '\0') { 48 | if ( *format == '%') { 49 | if ( *(format+1) == 'c' ) { 50 | char c = (char)va_arg(arg, int); 51 | putc(c, stdout); 52 | } else if( *(format+1) == 'd' || *(format+1) == 'i') { 53 | char store[20]; 54 | int i = va_arg(arg, int); 55 | char* str = store; 56 | itoa(i, store, 10); 57 | while( *str != '\0') putc(*str++, stdout); 58 | } else if( *(format+1) == 'o') { 59 | char store[20]; 60 | int i = va_arg(arg, int); 61 | char* str = store; 62 | itoa(i, store, 8); 63 | while( *str != '\0') putc(*str++, stdout); 64 | } else if( *(format+1) == 'x') { 65 | char store[20]; 66 | int i = va_arg(arg, int); 67 | char* str = store; 68 | itoa(i, store, 16); 69 | while( *str != '\0') putc(*str++, stdout); 70 | } else if( *(format+1) == 's' ) { 71 | char* str = va_arg(arg, char*); 72 | while( *str != '\0') putc(*str++, stdout); 73 | } 74 | format += 2; 75 | } else { 76 | putc(*format++, stdout); 77 | } 78 | } 79 | 80 | va_end (arg); 81 | 82 | return done; 83 | } 84 | -------------------------------------------------------------------------------- /middleware/shell_parser/README: -------------------------------------------------------------------------------- 1 | shell_parser 2 | ============ 3 | 4 | Parser the input command, and execute the corresponding function in the kernel. 5 | User is easy to add his function in the kernel. 6 | -------------------------------------------------------------------------------- /middleware/shell_parser/_list.c: -------------------------------------------------------------------------------- 1 | #include "_list.h" 2 | 3 | void _list_init(_LIST * node) 4 | { 5 | node->next = NULL; 6 | } 7 | 8 | void _list_insert(_LIST * head, _LIST * node) 9 | { 10 | node->next = head->next; 11 | head->next = node; 12 | } 13 | 14 | int _is_list_empty(_LIST * node) 15 | { 16 | return node->next == NULL ? 1 : 0; 17 | } 18 | -------------------------------------------------------------------------------- /middleware/shell_parser/_list.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIST_H_A_ 2 | #define __LIST_H_A_ 3 | 4 | #include 5 | 6 | #ifndef NULL 7 | #define NULL (void *)0 8 | #endif 9 | 10 | typedef struct _LIST { 11 | struct _LIST *next; 12 | } _LIST; 13 | 14 | #define _list_entry(node, type, member) ((type *)((U8 *)(node) - (U32)(&((type *)0)->member))) 15 | 16 | void _list_init(_LIST * node); 17 | 18 | void _list_insert(_LIST * head, _LIST * node); 19 | 20 | int _is_list_empty(_LIST * node); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /middleware/shell_parser/example.c: -------------------------------------------------------------------------------- 1 | /* 2 | * discription: example for The shell parser 3 | * 4 | * Copyright (c) 2013, Shanjin Yang. 5 | * All rights reserved. 6 | * 7 | * GPL license 8 | * 9 | * author time content 10 | * Shanjin Yang 2014.9.19 first version 11 | * Shanjin Yang 2014.10.11 port to FOS 12 | */ 13 | 14 | #include "shell.h" 15 | 16 | void help(void *arg) 17 | { 18 | SYMBOL *sym_tmp; 19 | _LIST *tmp = &sym_head.list; 20 | 21 | for (; !_is_list_empty(tmp); tmp = tmp->next) { 22 | sym_tmp = _list_entry(tmp->next, SYMBOL, list); 23 | printf("symbol --%s\n", sym_tmp->name); 24 | } 25 | } 26 | 27 | void version(void *arg) 28 | { 29 | printf("First Version\n"); 30 | } 31 | 32 | void fuck(void *arg) 33 | { 34 | printf("bla bla!!!\n"); 35 | } 36 | 37 | #if LINUX 38 | #include 39 | #include 40 | static char* find_value(char* str) 41 | { 42 | int count = 0; 43 | const char* split = ": \r"; 44 | char* p = strtok(str, split); 45 | 46 | while(NULL != p) { 47 | if(NULL == strchr(split, p[0]) && ++count == 3) { 48 | return p; 49 | } 50 | 51 | p = strtok(NULL, split); 52 | } 53 | 54 | return ""; 55 | } 56 | 57 | void show_memory_use(void *arg) 58 | { 59 | FILE* reader; 60 | char str[512]; 61 | 62 | sprintf(str, "/proc/%d/status", getpid()); 63 | reader = fopen(str, "r"); 64 | 65 | if(NULL == reader) 66 | return; 67 | 68 | while(!feof(reader)) { 69 | fgets(str, sizeof(str), reader); 70 | 71 | if(NULL != strstr(str, "VmSize")) 72 | { 73 | printf(">>>>>>>>>>>>> VmSize: %sB <<<<<<<<<<<<<<<\n", find_value(str)); 74 | } 75 | } 76 | 77 | fclose(reader); 78 | } 79 | #endif 80 | 81 | void shell_thread(void *arg) 82 | { 83 | U8 i; 84 | 85 | while (TRUE) { 86 | printf("$ "); 87 | /*catch input string */ 88 | for (i = 0, buff_cmd[i] = getchar(); buff_cmd[i] != '\n'; 89 | i++, buff_cmd[i] = getchar()) ; 90 | 91 | /*input enter key will go to restart */ 92 | if (buff_cmd[0] == '\n') 93 | goto restart; 94 | 95 | /*end of input string */ 96 | buff_cmd[i] = '\0'; 97 | 98 | /*parser input string */ 99 | if (!parser(buff_cmd)) 100 | printf("%s: command not found\n", buff_cmd); 101 | 102 | memset(buff_cmd, 0, 128); 103 | 104 | restart: 105 | os_delay(1); 106 | } 107 | } 108 | 109 | #define STACK_SHELL_SIZE 4 * 1024 110 | TCB tcb_shell; 111 | U32 stack_shell[STACK_SHELL_SIZE]; 112 | void shell_init() 113 | { 114 | export(help, (U8 *) "help"); 115 | export(version, (U8 *) "version"); 116 | export(fuck, (U8 *) "show"); 117 | export(show_memory_use, (U8 *) "show memory use"); 118 | 119 | task_create(&tcb_shell, (U8 *) "shell_task", shell_thread, NULL, 120 | stack_shell, STACK_SHELL_SIZE, 30, 1); 121 | } 122 | -------------------------------------------------------------------------------- /middleware/shell_parser/shell.c: -------------------------------------------------------------------------------- 1 | /* 2 | * discription: The shell parser 3 | * 4 | * Copyright (c) 2013, Shanjin Yang. 5 | * All rights reserved. 6 | * 7 | * GPL license 8 | * 9 | * author time content 10 | * Shanjin Yang 2014.9.19 first version 11 | * Shanjin Yang 2014.10.11 port to FOS 12 | */ 13 | 14 | #include "shell.h" 15 | 16 | /*The buff for input commad*/ 17 | U8 buff_cmd[128]; 18 | 19 | SYMBOL sym_head; 20 | 21 | void symbol__list_init(SYMBOL * sym) 22 | { 23 | _list_init(&sym->list); 24 | } 25 | 26 | void symbol__list_insert(SYMBOL * sym) 27 | { 28 | _list_insert(&sym_head.list, &sym->list); 29 | } 30 | 31 | SYMBOL _malloc[10]; 32 | void export(FUNC_PTR func, U8 * name) 33 | { 34 | /*the destination of token is just to malloc different memory object */ 35 | //SYMBOL * token(func) = malloc(sizeof(SYMBOL)); 36 | static int temp = 0; 37 | SYMBOL *token(func) = &_malloc[temp]; 38 | temp++; 39 | token(func)->func = func; 40 | token(func)->name = name; 41 | symbol__list_insert(token(func)); 42 | } 43 | 44 | int parser(U8 * cmd) 45 | { 46 | SYMBOL *sym_tmp; 47 | _LIST *tmp = &sym_head.list; 48 | 49 | for (; !_is_list_empty(tmp); tmp = tmp->next) { 50 | sym_tmp = _list_entry(tmp->next, SYMBOL, list); 51 | if (!strcmp((const char *)cmd, (const char *)sym_tmp->name)) { 52 | sym_tmp->func(NULL); 53 | return TRUE; 54 | } 55 | } 56 | return FALSE; 57 | } 58 | -------------------------------------------------------------------------------- /middleware/shell_parser/shell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Shanjin Yang. 3 | * All rights reserved. 4 | * 5 | * GPL license 6 | * 7 | * author time content 8 | * Shanjin Yang 2014.9.19 first version 9 | * Shanjin Yang 2014.10.11 port to FOS 10 | */ 11 | #ifndef __SHELL_H__ 12 | #define __SHELL_H__ 13 | 14 | #include "_list.h" 15 | 16 | #define token(abc) func_##abc 17 | 18 | extern U8 buff_cmd[128]; 19 | //typedef void (*FUNC_PTR)(void); 20 | 21 | typedef struct SYMBOL { 22 | _LIST list; 23 | FUNC_PTR func; 24 | void *arg; 25 | U8 *name; 26 | } SYMBOL; 27 | 28 | extern SYMBOL sym_head; 29 | 30 | void symbol_list_init(); 31 | void symbol_list_insert(); 32 | void symbol_list_delete(); 33 | 34 | void export(FUNC_PTR func, U8 * name); 35 | 36 | int parser(U8 * cmd); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /middleware/uip/README: -------------------------------------------------------------------------------- 1 | Remove compile warning by Shanjin Yang. 2 | 3 | uIP is a very small implementation of the TCP/IP stack that is written 4 | by Adam Dunkels . More information can be obtained 5 | at the uIP homepage at http://www.sics.se/~adam/uip/. 6 | 7 | This is version $Name: uip-1-0 $. 8 | 9 | The directory structure look as follows: 10 | 11 | apps/ - Example applications 12 | doc/ - Documentation 13 | lib/ - Library code used by some applications 14 | uip/ - uIP TCP/IP stack code 15 | unix/ - uIP as a user space process under FreeBSD or Linux 16 | -------------------------------------------------------------------------------- /middleware/uip/apps/README: -------------------------------------------------------------------------------- 1 | This directory contains a few example applications. They are not all 2 | heavily tested, however. 3 | -------------------------------------------------------------------------------- /middleware/uip/apps/dhcpc/Makefile.dhcpc: -------------------------------------------------------------------------------- 1 | APP_SOURCES += dhcpc.c timer.c 2 | -------------------------------------------------------------------------------- /middleware/uip/apps/dhcpc/dhcpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Swedish Institute of Computer Science 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * @(#)$Id: dhcpc.h,v 1.3 2006/06/11 21:46:37 adam Exp $ 32 | */ 33 | #ifndef __DHCPC_H__ 34 | #define __DHCPC_H__ 35 | 36 | #include "timer.h" 37 | #include "pt.h" 38 | 39 | struct dhcpc_state { 40 | struct pt pt; 41 | char state; 42 | struct uip_udp_conn *conn; 43 | struct timer timer; 44 | u16_t ticks; 45 | const void *mac_addr; 46 | int mac_len; 47 | 48 | u8_t serverid[4]; 49 | 50 | u16_t lease_time[2]; 51 | u16_t ipaddr[2]; 52 | u16_t netmask[2]; 53 | u16_t dnsaddr[2]; 54 | u16_t default_router[2]; 55 | }; 56 | 57 | void dhcpc_init(const void *mac_addr, int mac_len); 58 | void dhcpc_request(void); 59 | 60 | void dhcpc_appcall(void); 61 | 62 | void dhcpc_configured(const struct dhcpc_state *s); 63 | 64 | typedef struct dhcpc_state uip_udp_appstate_t; 65 | #define UIP_UDP_APPCALL dhcpc_appcall 66 | 67 | 68 | #endif /* __DHCPC_H__ */ 69 | -------------------------------------------------------------------------------- /middleware/uip/apps/hello-world/Makefile.hello-world: -------------------------------------------------------------------------------- 1 | APP_SOURCES += hello-world.c 2 | -------------------------------------------------------------------------------- /middleware/uip/apps/hello-world/hello-world.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \addtogroup apps 3 | * @{ 4 | */ 5 | 6 | /** 7 | * \defgroup helloworld Hello, world 8 | * @{ 9 | * 10 | * A small example showing how to write applications with 11 | * \ref psock "protosockets". 12 | */ 13 | 14 | /** 15 | * \file 16 | * Header file for an example of how to write uIP applications 17 | * with protosockets. 18 | * \author 19 | * Adam Dunkels 20 | */ 21 | 22 | #ifndef __HELLO_WORLD_H__ 23 | #define __HELLO_WORLD_H__ 24 | 25 | /* Since this file will be included by uip.h, we cannot include uip.h 26 | here. But we might need to include uipopt.h if we need the u8_t and 27 | u16_t datatypes. */ 28 | #include "uipopt.h" 29 | 30 | #include "psock.h" 31 | 32 | /* Next, we define the uip_tcp_appstate_t datatype. This is the state 33 | of our application, and the memory required for this state is 34 | allocated together with each TCP connection. One application state 35 | for each TCP connection. */ 36 | typedef struct hello_world_state { 37 | struct psock p; 38 | char inputbuffer[10]; 39 | char name[40]; 40 | } uip_tcp_appstate_t; 41 | 42 | /* Finally we define the application function to be called by uIP. */ 43 | void hello_world_appcall(void); 44 | #ifndef UIP_APPCALL 45 | #define UIP_APPCALL hello_world_appcall 46 | #endif /* UIP_APPCALL */ 47 | 48 | void hello_world_init(void); 49 | 50 | #endif /* __HELLO_WORLD_H__ */ 51 | /** @} */ 52 | /** @} */ 53 | -------------------------------------------------------------------------------- /middleware/uip/apps/resolv/Makefile.resolv: -------------------------------------------------------------------------------- 1 | APP_SOURCES += resolv.c 2 | -------------------------------------------------------------------------------- /middleware/uip/apps/resolv/resolv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \addtogroup resolv 3 | * @{ 4 | */ 5 | /** 6 | * \file 7 | * DNS resolver code header file. 8 | * \author Adam Dunkels 9 | */ 10 | 11 | /* 12 | * Copyright (c) 2002-2003, Adam Dunkels. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions 17 | * are met: 18 | * 1. Redistributions of source code must retain the above copyright 19 | * notice, this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 3. The name of the author may not be used to endorse or promote 24 | * products derived from this software without specific prior 25 | * written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 29 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 31 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 35 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | * This file is part of the uIP TCP/IP stack. 40 | * 41 | * $Id: resolv.h,v 1.4 2006/06/11 21:46:37 adam Exp $ 42 | * 43 | */ 44 | #ifndef __RESOLV_H__ 45 | #define __RESOLV_H__ 46 | 47 | typedef int uip_udp_appstate_t; 48 | void resolv_appcall(void); 49 | #define UIP_UDP_APPCALL resolv_appcall 50 | 51 | #include "uipopt.h" 52 | 53 | /** 54 | * Callback function which is called when a hostname is found. 55 | * 56 | * This function must be implemented by the module that uses the DNS 57 | * resolver. It is called when a hostname is found, or when a hostname 58 | * was not found. 59 | * 60 | * \param name A pointer to the name that was looked up. \param 61 | * ipaddr A pointer to a 4-byte array containing the IP address of the 62 | * hostname, or NULL if the hostname could not be found. 63 | */ 64 | void resolv_found(char *name, u16_t *ipaddr); 65 | 66 | /* Functions. */ 67 | void resolv_conf(u16_t *dnsserver); 68 | u16_t *resolv_getserver(void); 69 | void resolv_init(void); 70 | u16_t *resolv_lookup(char *name); 71 | void resolv_query(char *name); 72 | 73 | #endif /* __RESOLV_H__ */ 74 | 75 | /** @} */ 76 | -------------------------------------------------------------------------------- /middleware/uip/apps/smtp/Makefile.smtp: -------------------------------------------------------------------------------- 1 | APP_SOURCES += smtp.c smtp-strings.c memb.c 2 | -------------------------------------------------------------------------------- /middleware/uip/apps/smtp/makestrings: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | 4 | sub stringify { 5 | my $name = shift(@_); 6 | open(OUTPUTC, "> $name.c"); 7 | open(OUTPUTH, "> $name.h"); 8 | 9 | open(FILE, "$name"); 10 | 11 | while() { 12 | if(/(.+) "(.+)"/) { 13 | $var = $1; 14 | $data = $2; 15 | 16 | $datan = $data; 17 | $datan =~ s/\\r/\r/g; 18 | $datan =~ s/\\n/\n/g; 19 | $datan =~ s/\\01/\01/g; 20 | $datan =~ s/\\0/\0/g; 21 | 22 | printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1); 23 | printf(OUTPUTC "/* \"$data\" */\n"); 24 | printf(OUTPUTC "{"); 25 | for($j = 0; $j < length($datan); $j++) { 26 | printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1))); 27 | } 28 | printf(OUTPUTC "};\n"); 29 | 30 | printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1); 31 | 32 | } 33 | } 34 | close(OUTPUTC); 35 | close(OUTPUTH); 36 | } 37 | stringify("smtp-strings"); 38 | 39 | exit 0; 40 | 41 | -------------------------------------------------------------------------------- /middleware/uip/apps/smtp/smtp-strings: -------------------------------------------------------------------------------- 1 | smtp_220 "220" 2 | smtp_helo "HELO " 3 | smtp_mail_from "MAIL FROM: " 4 | smtp_rcpt_to "RCPT TO: " 5 | smtp_data "DATA\r\n" 6 | smtp_to "To: " 7 | smtp_from "From: " 8 | smtp_subject "Subject: " 9 | smtp_quit "QUIT\r\n" 10 | smtp_crnl "\r\n" 11 | smtp_crnlperiodcrnl "\r\n.\r\n" -------------------------------------------------------------------------------- /middleware/uip/apps/smtp/smtp-strings.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: smtp-strings.c,v 1.3 2006/06/11 21:46:37 adam Exp $ 34 | */ 35 | const char smtp_220[4] = 36 | /* "220" */ 37 | {0x32, 0x32, 0x30, }; 38 | const char smtp_helo[6] = 39 | /* "HELO " */ 40 | {0x48, 0x45, 0x4c, 0x4f, 0x20, }; 41 | const char smtp_mail_from[12] = 42 | /* "MAIL FROM: " */ 43 | {0x4d, 0x41, 0x49, 0x4c, 0x20, 0x46, 0x52, 0x4f, 0x4d, 0x3a, 0x20, }; 44 | const char smtp_rcpt_to[10] = 45 | /* "RCPT TO: " */ 46 | {0x52, 0x43, 0x50, 0x54, 0x20, 0x54, 0x4f, 0x3a, 0x20, }; 47 | const char smtp_data[7] = 48 | /* "DATA\r\n" */ 49 | {0x44, 0x41, 0x54, 0x41, 0xd, 0xa, }; 50 | const char smtp_to[5] = 51 | /* "To: " */ 52 | {0x54, 0x6f, 0x3a, 0x20, }; 53 | const char smtp_cc[5] = 54 | /* "Cc: " */ 55 | {0x43, 0x63, 0x3a, 0x20, }; 56 | const char smtp_from[7] = 57 | /* "From: " */ 58 | {0x46, 0x72, 0x6f, 0x6d, 0x3a, 0x20, }; 59 | const char smtp_subject[10] = 60 | /* "Subject: " */ 61 | {0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3a, 0x20, }; 62 | const char smtp_quit[7] = 63 | /* "QUIT\r\n" */ 64 | {0x51, 0x55, 0x49, 0x54, 0xd, 0xa, }; 65 | const char smtp_crnl[3] = 66 | /* "\r\n" */ 67 | {0xd, 0xa, }; 68 | const char smtp_crnlperiodcrnl[6] = 69 | /* "\r\n.\r\n" */ 70 | {0xd, 0xa, 0x2e, 0xd, 0xa, }; 71 | -------------------------------------------------------------------------------- /middleware/uip/apps/smtp/smtp-strings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: smtp-strings.h,v 1.3 2006/06/11 21:46:37 adam Exp $ 34 | */ 35 | extern const char smtp_220[4]; 36 | extern const char smtp_helo[6]; 37 | extern const char smtp_mail_from[12]; 38 | extern const char smtp_rcpt_to[10]; 39 | extern const char smtp_data[7]; 40 | extern const char smtp_to[5]; 41 | extern const char smtp_cc[5]; 42 | extern const char smtp_from[7]; 43 | extern const char smtp_subject[10]; 44 | extern const char smtp_quit[7]; 45 | extern const char smtp_crnl[3]; 46 | extern const char smtp_crnlperiodcrnl[6]; 47 | -------------------------------------------------------------------------------- /middleware/uip/apps/smtp/smtp.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * \addtogroup smtp 4 | * @{ 5 | */ 6 | 7 | 8 | /** 9 | * \file 10 | * SMTP header file 11 | * \author Adam Dunkels 12 | */ 13 | 14 | /* 15 | * Copyright (c) 2002, Adam Dunkels. 16 | * All rights reserved. 17 | * 18 | * Redistribution and use in source and binary forms, with or without 19 | * modification, are permitted provided that the following conditions 20 | * are met: 21 | * 1. Redistributions of source code must retain the above copyright 22 | * notice, this list of conditions and the following disclaimer. 23 | * 2. Redistributions in binary form must reproduce the above copyright 24 | * notice, this list of conditions and the following disclaimer in the 25 | * documentation and/or other materials provided with the distribution. 26 | * 3. The name of the author may not be used to endorse or promote 27 | * products derived from this software without specific prior 28 | * written permission. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 31 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 34 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 36 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 37 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 38 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 39 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 40 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | * 42 | * This file is part of the uIP TCP/IP stack. 43 | * 44 | * $Id: smtp.h,v 1.4 2006/06/11 21:46:37 adam Exp $ 45 | * 46 | */ 47 | #ifndef __SMTP_H__ 48 | #define __SMTP_H__ 49 | 50 | #include "uipopt.h" 51 | 52 | /** 53 | * Error number that signifies a non-error condition. 54 | */ 55 | #define SMTP_ERR_OK 0 56 | 57 | /** 58 | * Callback function that is called when an e-mail transmission is 59 | * done. 60 | * 61 | * This function must be implemented by the module that uses the SMTP 62 | * module. 63 | * 64 | * \param error The number of the error if an error occured, or 65 | * SMTP_ERR_OK. 66 | */ 67 | void smtp_done(unsigned char error); 68 | 69 | void smtp_init(void); 70 | 71 | /* Functions. */ 72 | void smtp_configure(char *localhostname, u16_t *smtpserver); 73 | unsigned char smtp_send(char *to, char *from, 74 | char *subject, char *msg, 75 | u16_t msglen); 76 | #define SMTP_SEND(to, cc, from, subject, msg) \ 77 | smtp_send(to, cc, from, subject, msg, strlen(msg)) 78 | 79 | void smtp_appcall(void); 80 | 81 | struct smtp_state { 82 | u8_t state; 83 | char *to; 84 | char *from; 85 | char *subject; 86 | char *msg; 87 | u16_t msglen; 88 | 89 | u16_t sentlen, textlen; 90 | u16_t sendptr; 91 | 92 | }; 93 | 94 | 95 | #ifndef UIP_APPCALL 96 | #define UIP_APPCALL smtp_appcall 97 | #endif 98 | typedef struct smtp_state uip_tcp_appstate_t; 99 | 100 | 101 | #endif /* __SMTP_H__ */ 102 | 103 | /** @} */ 104 | -------------------------------------------------------------------------------- /middleware/uip/apps/telnetd/Makefile.telnetd: -------------------------------------------------------------------------------- 1 | APP_SOURCES += telnetd.c shell.c memb.c 2 | -------------------------------------------------------------------------------- /middleware/uip/apps/telnetd/telnetd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer in the documentation and/or other materials provided 13 | * with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: telnetd.h,v 1.2 2006/06/07 09:43:54 adam Exp $ 33 | * 34 | */ 35 | #ifndef __TELNETD_H__ 36 | #define __TELNETD_H__ 37 | 38 | #include "uipopt.h" 39 | 40 | void telnetd_appcall(void); 41 | 42 | #ifndef TELNETD_CONF_LINELEN 43 | #define TELNETD_CONF_LINELEN 40 44 | #endif 45 | #ifndef TELNETD_CONF_NUMLINES 46 | #define TELNETD_CONF_NUMLINES 16 47 | #endif 48 | 49 | struct telnetd_state { 50 | char *lines[TELNETD_CONF_NUMLINES]; 51 | char buf[TELNETD_CONF_LINELEN]; 52 | char bufptr; 53 | u8_t numsent; 54 | u8_t state; 55 | }; 56 | 57 | typedef struct telnetd_state uip_tcp_appstate_t; 58 | 59 | #ifndef UIP_APPCALL 60 | #define UIP_APPCALL telnetd_appcall 61 | #endif 62 | 63 | #endif /* __TELNETD_H__ */ 64 | -------------------------------------------------------------------------------- /middleware/uip/apps/webclient/Makefile.webclient: -------------------------------------------------------------------------------- 1 | APP_SOURCES += webclient-strings.c webclient.c 2 | -------------------------------------------------------------------------------- /middleware/uip/apps/webclient/makestrings: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | 4 | sub stringify { 5 | my $name = shift(@_); 6 | open(OUTPUTC, "> $name.c"); 7 | open(OUTPUTH, "> $name.h"); 8 | 9 | open(FILE, "$name"); 10 | 11 | while() { 12 | if(/(.+) "(.+)"/) { 13 | $var = $1; 14 | $data = $2; 15 | 16 | $datan = $data; 17 | $datan =~ s/\\r/\r/g; 18 | $datan =~ s/\\n/\n/g; 19 | $datan =~ s/\\01/\01/g; 20 | $datan =~ s/\\0/\0/g; 21 | 22 | printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1); 23 | printf(OUTPUTC "/* \"$data\" */\n"); 24 | printf(OUTPUTC "{"); 25 | for($j = 0; $j < length($datan); $j++) { 26 | printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1))); 27 | } 28 | printf(OUTPUTC "0 };\n"); 29 | 30 | printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1); 31 | 32 | } 33 | } 34 | close(OUTPUTC); 35 | close(OUTPUTH); 36 | } 37 | stringify("webclient-strings"); 38 | 39 | exit 0; 40 | 41 | -------------------------------------------------------------------------------- /middleware/uip/apps/webclient/webclient-strings: -------------------------------------------------------------------------------- 1 | http_http "http://" 2 | http_200 "200 " 3 | http_301 "301 " 4 | http_302 "302 " 5 | http_get "GET " 6 | http_10 "HTTP/1.0" 7 | http_11 "HTTP/1.1" 8 | http_content_type "content-type: " 9 | http_texthtml "text/html" 10 | http_location "location: " 11 | http_host "host: " 12 | http_crnl "\r\n" 13 | http_index_html "/index.html" 14 | http_404_html "/404.html" 15 | http_content_type_html "Content-type: text/html\r\n\r\n" 16 | http_content_type_css "Content-type: text/css\r\n\r\n" 17 | http_content_type_text "Content-type: text/text\r\n\r\n" 18 | http_content_type_png "Content-type: image/png\r\n\r\n" 19 | http_content_type_gif "Content-type: image/gif\r\n\r\n" 20 | http_content_type_jpg "Content-type: image/jpeg\r\n\r\n" 21 | http_content_type_binary "Content-type: application/octet-stream\r\n\r\n" 22 | http_html ".html" 23 | http_shtml ".shtml" 24 | http_htm ".htm" 25 | http_css ".css" 26 | http_png ".png" 27 | http_gif ".gif" 28 | http_jpg ".jpg" 29 | http_text ".text" 30 | http_txt ".txt" 31 | http_user_agent_fields "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n" 32 | -------------------------------------------------------------------------------- /middleware/uip/apps/webclient/webclient-strings.h: -------------------------------------------------------------------------------- 1 | extern const char http_http[8]; 2 | extern const char http_200[5]; 3 | extern const char http_301[5]; 4 | extern const char http_302[5]; 5 | extern const char http_get[5]; 6 | extern const char http_10[9]; 7 | extern const char http_11[9]; 8 | extern const char http_content_type[15]; 9 | extern const char http_texthtml[10]; 10 | extern const char http_location[11]; 11 | extern const char http_host[7]; 12 | extern const char http_crnl[3]; 13 | extern const char http_index_html[12]; 14 | extern const char http_404_html[10]; 15 | extern const char http_content_type_html[28]; 16 | extern const char http_content_type_css [27]; 17 | extern const char http_content_type_text[28]; 18 | extern const char http_content_type_png [28]; 19 | extern const char http_content_type_gif [28]; 20 | extern const char http_content_type_jpg [29]; 21 | extern const char http_content_type_binary[43]; 22 | extern const char http_html[6]; 23 | extern const char http_shtml[7]; 24 | extern const char http_htm[5]; 25 | extern const char http_css[5]; 26 | extern const char http_png[5]; 27 | extern const char http_gif[5]; 28 | extern const char http_jpg[5]; 29 | extern const char http_text[6]; 30 | extern const char http_txt[5]; 31 | extern const char http_user_agent_fields[77]; 32 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/.httpd-fsdata.c.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/apps/webserver/.httpd-fsdata.c.swp -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/Makefile.webserver: -------------------------------------------------------------------------------- 1 | APP_SOURCES += httpd.c http-strings.c httpd-fs.c httpd-cgi.c 2 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/http-strings: -------------------------------------------------------------------------------- 1 | http_http "http://" 2 | http_200 "200 " 3 | http_301 "301 " 4 | http_302 "302 " 5 | http_get "GET " 6 | http_10 "HTTP/1.0" 7 | http_11 "HTTP/1.1" 8 | http_content_type "content-type: " 9 | http_texthtml "text/html" 10 | http_location "location: " 11 | http_host "host: " 12 | http_crnl "\r\n" 13 | http_index_html "/index.html" 14 | http_404_html "/404.html" 15 | http_referer "Referer:" 16 | http_header_200 "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" 17 | http_header_404 "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" 18 | http_content_type_plain "Content-type: text/plain\r\n\r\n" 19 | http_content_type_html "Content-type: text/html\r\n\r\n" 20 | http_content_type_css "Content-type: text/css\r\n\r\n" 21 | http_content_type_text "Content-type: text/text\r\n\r\n" 22 | http_content_type_png "Content-type: image/png\r\n\r\n" 23 | http_content_type_gif "Content-type: image/gif\r\n\r\n" 24 | http_content_type_jpg "Content-type: image/jpeg\r\n\r\n" 25 | http_content_type_binary "Content-type: application/octet-stream\r\n\r\n" 26 | http_html ".html" 27 | http_shtml ".shtml" 28 | http_htm ".htm" 29 | http_css ".css" 30 | http_png ".png" 31 | http_gif ".gif" 32 | http_jpg ".jpg" 33 | http_text ".txt" 34 | http_txt ".txt" 35 | 36 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/http-strings.h: -------------------------------------------------------------------------------- 1 | extern const char http_http[8]; 2 | extern const char http_200[5]; 3 | extern const char http_301[5]; 4 | extern const char http_302[5]; 5 | extern const char http_get[5]; 6 | extern const char http_10[9]; 7 | extern const char http_11[9]; 8 | extern const char http_content_type[15]; 9 | extern const char http_texthtml[10]; 10 | extern const char http_location[11]; 11 | extern const char http_host[7]; 12 | extern const char http_crnl[3]; 13 | extern const char http_index_html[12]; 14 | extern const char http_404_html[10]; 15 | extern const char http_referer[9]; 16 | extern const char http_header_200[84]; 17 | extern const char http_header_404[91]; 18 | extern const char http_content_type_plain[29]; 19 | extern const char http_content_type_html[28]; 20 | extern const char http_content_type_css [27]; 21 | extern const char http_content_type_text[28]; 22 | extern const char http_content_type_png [28]; 23 | extern const char http_content_type_gif [28]; 24 | extern const char http_content_type_jpg [29]; 25 | extern const char http_content_type_binary[43]; 26 | extern const char http_html[6]; 27 | extern const char http_shtml[7]; 28 | extern const char http_htm[5]; 29 | extern const char http_css[5]; 30 | extern const char http_png[5]; 31 | extern const char http_gif[5]; 32 | extern const char http_jpg[5]; 33 | extern const char http_text[5]; 34 | extern const char http_txt[5]; 35 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-cgi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \addtogroup httpd 3 | * @{ 4 | */ 5 | 6 | /** 7 | * \file 8 | * Web server script interface header file 9 | * \author 10 | * Adam Dunkels 11 | * 12 | */ 13 | 14 | 15 | 16 | /* 17 | * Copyright (c) 2001, Adam Dunkels. 18 | * All rights reserved. 19 | * 20 | * Redistribution and use in source and binary forms, with or without 21 | * modification, are permitted provided that the following conditions 22 | * are met: 23 | * 1. Redistributions of source code must retain the above copyright 24 | * notice, this list of conditions and the following disclaimer. 25 | * 2. Redistributions in binary form must reproduce the above copyright 26 | * notice, this list of conditions and the following disclaimer in the 27 | * documentation and/or other materials provided with the distribution. 28 | * 3. The name of the author may not be used to endorse or promote 29 | * products derived from this software without specific prior 30 | * written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 33 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 36 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 38 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 40 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 41 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 42 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | * 44 | * This file is part of the uIP TCP/IP stack. 45 | * 46 | * $Id: httpd-cgi.h,v 1.2 2006/06/11 21:46:38 adam Exp $ 47 | * 48 | */ 49 | 50 | #ifndef __HTTPD_CGI_H__ 51 | #define __HTTPD_CGI_H__ 52 | 53 | #include "psock.h" 54 | #include "httpd.h" 55 | 56 | typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *)); 57 | 58 | httpd_cgifunction httpd_cgi(char *name); 59 | 60 | struct httpd_cgi_call { 61 | const char *name; 62 | const httpd_cgifunction function; 63 | }; 64 | 65 | /** 66 | * \brief HTTPD CGI function declaration 67 | * \param name The C variable name of the function 68 | * \param str The string name of the function, used in the script file 69 | * \param function A pointer to the function that implements it 70 | * 71 | * This macro is used for declaring a HTTPD CGI 72 | * function. This function is then added to the list of 73 | * HTTPD CGI functions with the httpd_cgi_add() function. 74 | * 75 | * \hideinitializer 76 | */ 77 | #define HTTPD_CGI_CALL(name, str, function) \ 78 | static PT_THREAD(function(struct httpd_state *, char *)); \ 79 | static const struct httpd_cgi_call name = {str, function} 80 | 81 | void httpd_cgi_init(void); 82 | #endif /* __HTTPD_CGI_H__ */ 83 | 84 | /** @} */ 85 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: httpd-fs.h,v 1.1 2006/06/07 09:13:08 adam Exp $ 34 | */ 35 | #ifndef __HTTPD_FS_H__ 36 | #define __HTTPD_FS_H__ 37 | 38 | #define HTTPD_FS_STATISTICS 1 39 | 40 | struct httpd_fs_file { 41 | char *data; 42 | int len; 43 | }; 44 | 45 | /* file must be allocated by caller and will be filled in 46 | by the function. */ 47 | int httpd_fs_open(const char *name, struct httpd_fs_file *file); 48 | 49 | #ifdef HTTPD_FS_STATISTICS 50 | #if HTTPD_FS_STATISTICS == 1 51 | u16_t httpd_fs_count(char *name); 52 | #endif /* HTTPD_FS_STATISTICS */ 53 | #endif /* HTTPD_FS_STATISTICS */ 54 | 55 | void httpd_fs_init(void); 56 | 57 | #endif /* __HTTPD_FS_H__ */ 58 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |

404 - file not found

5 |

Go here instead.

6 |
7 | 8 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs/fade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/apps/webserver/httpd-fs/fade.png -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs/files.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 |

File statistics

3 |
4 | 5 | 6 | 9 | 10 | 13 | 14 | 17 | 18 | 21 | 22 | 25 | 26 | 29 | 30 | 33 |
/index.html%! file-stats /index.html 7 |
/files.shtml%! file-stats /files.shtml 11 |
/tcp.shtml%! file-stats /tcp.shtml 15 |
/stats.shtml%! file-stats /stats.shtml 19 |
/style.css%! file-stats /style.css 23 |
/404.html%! file-stats /404.html 27 |
/fade.png%! file-stats /fade.png 31 |
34 |
35 | %!: /footer.html 36 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs/footer.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to the uIP web server! 5 | 6 | 7 | 8 | 9 | 17 | 18 |
19 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to the uIP web server! 5 | 6 | 7 | 8 | 9 | 17 | 18 |
19 |

20 | These web pages are served by a small web server running on top of 21 | the uIP embedded TCP/IP 22 | stack. 23 |

24 |

25 | Click on the links above for web server statistics. 26 |

27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs/processes.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 |

System processes


3 | 4 | %! processes 5 | %!: /footer.html -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs/stats.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 |

Network statistics

3 |
4 |
IDNamePriorityPoll handlerEvent handlerProcstate
5 |
 6 | IP           Packets received
 7 |              Packets sent
 8 | 	     Packets dropped
 9 | IP errors    IP version/header length
10 |              IP length, high byte
11 |              IP length, low byte
12 |              IP fragments
13 |              Header checksum
14 |              Wrong protocol
15 | ICMP	     Packets received
16 |              Packets sent
17 |              Packets dropped
18 |              Type errors
19 | TCP          Packets received
20 |              Packets sent
21 |              Packets dropped
22 |              Checksum errors
23 |              Data packets without ACKs
24 |              Resets
25 |              Retransmissions
26 | 	     No connection avaliable
27 | 	     Connection attempts to closed ports
28 | 
%! net-stats
29 | 
30 | 31 | %!: /footer.html 32 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs/style.css: -------------------------------------------------------------------------------- 1 | h1 2 | { 3 | text-align: center; 4 | font-size:14pt; 5 | font-family:arial,helvetica; 6 | font-weight:bold; 7 | padding:10px; 8 | } 9 | 10 | body 11 | { 12 | 13 | background-color: #fffeec; 14 | color:black; 15 | 16 | font-size:8pt; 17 | font-family:arial,helvetica; 18 | } 19 | 20 | .menu 21 | { 22 | margin: 4px; 23 | width:60%; 24 | 25 | padding:2px; 26 | 27 | border: solid 1px; 28 | background-color: #fffcd2; 29 | text-align:left; 30 | 31 | font-size:9pt; 32 | font-family:arial,helvetica; 33 | } 34 | 35 | div.menubox 36 | { 37 | width: 25%; 38 | border: 0; 39 | float: left; 40 | text-align: center; 41 | } 42 | 43 | .contentblock 44 | { 45 | margin: 4px; 46 | width:60%; 47 | 48 | padding:2px; 49 | 50 | border: 1px dotted; 51 | background-color: white; 52 | 53 | font-size:8pt; 54 | font-family:arial,helvetica; 55 | 56 | } 57 | 58 | p.intro 59 | { 60 | margin-left:20px; 61 | margin-right:20px; 62 | 63 | font-size:10pt; 64 | /* font-weight:bold; */ 65 | font-family:arial,helvetica; 66 | } 67 | 68 | p.clink 69 | { 70 | font-size:12pt; 71 | font-family:courier,monospace; 72 | text-align:center; 73 | } 74 | 75 | p.clink9 76 | { 77 | font-size:9pt; 78 | font-family:courier,monospace; 79 | text-align:center; 80 | } 81 | 82 | 83 | p 84 | { 85 | padding-left:10px; 86 | } 87 | 88 | p.right 89 | { 90 | text-align:right; 91 | } 92 | 93 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fs/tcp.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 |

Current connections


3 | 4 | %! tcp-connections 5 | %!: /footer.html -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd-fsdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: httpd-fsdata.h,v 1.1 2006/06/07 09:13:08 adam Exp $ 34 | */ 35 | #ifndef __HTTPD_FSDATA_H__ 36 | #define __HTTPD_FSDATA_H__ 37 | 38 | #include "uip.h" 39 | 40 | struct httpd_fsdata_file { 41 | const struct httpd_fsdata_file *next; 42 | const unsigned char *name; 43 | const unsigned char *data; 44 | const int len; 45 | #ifdef HTTPD_FS_STATISTICS 46 | #if HTTPD_FS_STATISTICS == 1 47 | u16_t count; 48 | #endif /* HTTPD_FS_STATISTICS */ 49 | #endif /* HTTPD_FS_STATISTICS */ 50 | }; 51 | 52 | struct httpd_fsdata_file_noconst { 53 | struct httpd_fsdata_file *next; 54 | char *name; 55 | char *data; 56 | int len; 57 | #ifdef HTTPD_FS_STATISTICS 58 | #if HTTPD_FS_STATISTICS == 1 59 | u16_t count; 60 | #endif /* HTTPD_FS_STATISTICS */ 61 | #endif /* HTTPD_FS_STATISTICS */ 62 | }; 63 | 64 | #endif /* __HTTPD_FSDATA_H__ */ 65 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/httpd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2005, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote 14 | * products derived from this software without specific prior 15 | * written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 18 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack. 30 | * 31 | * $Id: httpd.h,v 1.2 2006/06/11 21:46:38 adam Exp $ 32 | * 33 | */ 34 | 35 | #ifndef __HTTPD_H__ 36 | #define __HTTPD_H__ 37 | 38 | #include "psock.h" 39 | #include "httpd-fs.h" 40 | 41 | struct httpd_state { 42 | unsigned char timer; 43 | struct psock sin, sout; 44 | struct pt outputpt, scriptpt; 45 | char inputbuf[50]; 46 | char filename[20]; 47 | char state; 48 | struct httpd_fs_file file; 49 | int len; 50 | char *scriptptr; 51 | int scriptlen; 52 | 53 | unsigned short count; 54 | }; 55 | 56 | void httpd_init(void); 57 | void httpd_appcall(void); 58 | 59 | void httpd_log(char *msg); 60 | void httpd_log_file(u16_t *requester, char *file); 61 | 62 | #endif /* __HTTPD_H__ */ 63 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/makefsdata: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | open(OUTPUT, "> httpd-fsdata.c"); 4 | 5 | chdir("httpd-fs"); 6 | 7 | opendir(DIR, "."); 8 | @files = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR); 9 | closedir(DIR); 10 | 11 | foreach $file (@files) { 12 | 13 | if(-d $file && $file !~ /^\./) { 14 | print "Processing directory $file\n"; 15 | opendir(DIR, $file); 16 | @newfiles = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR); 17 | closedir(DIR); 18 | printf "Adding files @newfiles\n"; 19 | @files = (@files, map { $_ = "$file/$_" } @newfiles); 20 | next; 21 | } 22 | } 23 | 24 | foreach $file (@files) { 25 | if(-f $file) { 26 | 27 | print "Adding file $file\n"; 28 | 29 | open(FILE, $file) || die "Could not open file $file\n"; 30 | 31 | $file =~ s-^-/-; 32 | $fvar = $file; 33 | $fvar =~ s-/-_-g; 34 | $fvar =~ s-\.-_-g; 35 | # for AVR, add PROGMEM here 36 | print(OUTPUT "static const unsigned char data".$fvar."[] = {\n"); 37 | print(OUTPUT "\t/* $file */\n\t"); 38 | for($j = 0; $j < length($file); $j++) { 39 | printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1))); 40 | } 41 | printf(OUTPUT "0,\n"); 42 | 43 | 44 | $i = 0; 45 | while(read(FILE, $data, 1)) { 46 | if($i == 0) { 47 | print(OUTPUT "\t"); 48 | } 49 | printf(OUTPUT "%#02x, ", unpack("C", $data)); 50 | $i++; 51 | if($i == 10) { 52 | print(OUTPUT "\n"); 53 | $i = 0; 54 | } 55 | } 56 | print(OUTPUT "0};\n\n"); 57 | close(FILE); 58 | push(@fvars, $fvar); 59 | push(@pfiles, $file); 60 | } 61 | } 62 | 63 | for($i = 0; $i < @fvars; $i++) { 64 | $file = $pfiles[$i]; 65 | $fvar = $fvars[$i]; 66 | 67 | if($i == 0) { 68 | $prevfile = "NULL"; 69 | } else { 70 | $prevfile = "file" . $fvars[$i - 1]; 71 | } 72 | print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, "); 73 | print(OUTPUT "data$fvar + ". (length($file) + 1) .", "); 74 | print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n"); 75 | } 76 | 77 | print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n"); 78 | print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n"); 79 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/makestrings: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | 4 | sub stringify { 5 | my $name = shift(@_); 6 | open(OUTPUTC, "> $name.c"); 7 | open(OUTPUTH, "> $name.h"); 8 | 9 | open(FILE, "$name"); 10 | 11 | while() { 12 | if(/(.+) "(.+)"/) { 13 | $var = $1; 14 | $data = $2; 15 | 16 | $datan = $data; 17 | $datan =~ s/\\r/\r/g; 18 | $datan =~ s/\\n/\n/g; 19 | $datan =~ s/\\01/\01/g; 20 | $datan =~ s/\\0/\0/g; 21 | 22 | printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1); 23 | printf(OUTPUTC "/* \"$data\" */\n"); 24 | printf(OUTPUTC "{"); 25 | for($j = 0; $j < length($datan); $j++) { 26 | printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1))); 27 | } 28 | printf(OUTPUTC "};\n"); 29 | 30 | printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1); 31 | 32 | } 33 | } 34 | close(OUTPUTC); 35 | close(OUTPUTH); 36 | } 37 | stringify("http-strings"); 38 | 39 | exit 0; 40 | 41 | -------------------------------------------------------------------------------- /middleware/uip/apps/webserver/webserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer in the documentation and/or other materials provided 13 | * with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: webserver.h,v 1.2 2006/06/11 21:46:38 adam Exp $ 33 | * 34 | */ 35 | #ifndef __WEBSERVER_H__ 36 | #define __WEBSERVER_H__ 37 | 38 | #include "httpd.h" 39 | 40 | typedef struct httpd_state uip_tcp_appstate_t; 41 | /* UIP_APPCALL: the name of the application function. This function 42 | must return void and take no arguments (i.e., C type "void 43 | appfunc(void)"). */ 44 | #ifndef UIP_APPCALL 45 | #define UIP_APPCALL httpd_appcall 46 | #endif 47 | 48 | 49 | #endif /* __WEBSERVER_H__ */ 50 | -------------------------------------------------------------------------------- /middleware/uip/doc/Makefile: -------------------------------------------------------------------------------- 1 | all: htmldoc pdfdoc 2 | 3 | htmldoc: 4 | doxygen Doxyfile 5 | 6 | pdfdoc: htmldoc 7 | cd latex; make refman.pdf && mv refman.pdf ../uip-refman.pdf 8 | -------------------------------------------------------------------------------- /middleware/uip/doc/README: -------------------------------------------------------------------------------- 1 | The files in this directory comprise the uIP documentation. The files 2 | are: 3 | 4 | html/ The uIP reference manual in HTML format. 5 | 6 | uip-refman.pdf The uIP reference manual in a printable PDF version. 7 | 8 | mobisys2003.pdf Conference paper about uIP from the First 9 | International Conference on Mobile Systems, 10 | Applications and Services (MobiSys), San 11 | Francisco, May 2003. 12 | 13 | -------------------------------------------------------------------------------- /middleware/uip/doc/doxygen.sty: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e} 2 | \ProvidesPackage{doxygen} 3 | \RequirePackage{calc} 4 | \RequirePackage{array} 5 | \pagestyle{fancyplain} 6 | \newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}} 7 | \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} 8 | \lhead[\fancyplain{}{\bfseries\thepage}] 9 | {\fancyplain{}{\bfseries\rightmark}} 10 | \rhead[\fancyplain{}{\bfseries\leftmark}] 11 | {\fancyplain{}{\bfseries\thepage}} 12 | \rfoot[\fancyplain{}{\bfseries\scriptsize Generated on Wed Jun 7 11:37:14 2006 for uIP 1.0-rc0 by doxygen\lfoot[]{\fancyplain{}{\bfseries\scriptsize Generated on Wed Jun 7 11:37:14 2006 for uIP 1.0-rc0 by doxygen}} 13 | \cfoot{} 14 | \newenvironment{CompactList} 15 | {\begin{list}{}{ 16 | \setlength{\leftmargin}{0.5cm} 17 | \setlength{\itemsep}{0pt} 18 | \setlength{\parsep}{0pt} 19 | \setlength{\topsep}{0pt} 20 | \renewcommand{\makelabel}{}}} 21 | {\end{list}} 22 | \newenvironment{CompactItemize} 23 | { 24 | \begin{itemize} 25 | \setlength{\itemsep}{-3pt} 26 | \setlength{\parsep}{0pt} 27 | \setlength{\topsep}{0pt} 28 | \setlength{\partopsep}{0pt} 29 | } 30 | {\end{itemize}} 31 | \newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp} 32 | \newlength{\tmplength} 33 | \newenvironment{TabularC}[1] 34 | { 35 | \setlength{\tmplength} 36 | {\linewidth/(#1)-\tabcolsep*2-\arrayrulewidth*(#1+1)/(#1)} 37 | \par\begin{tabular*}{\linewidth} 38 | {*{#1}{|>{\PBS\raggedright\hspace{0pt}}p{\the\tmplength}}|} 39 | } 40 | {\end{tabular*}\par} 41 | \newcommand{\entrylabel}[1]{ 42 | {\parbox[b]{\labelwidth-4pt}{\makebox[0pt][l]{\textbf{#1}}\\}}} 43 | \newenvironment{Desc} 44 | {\begin{list}{} 45 | { 46 | \settowidth{\labelwidth}{40pt} 47 | \setlength{\leftmargin}{\labelwidth} 48 | \setlength{\parsep}{0pt} 49 | \setlength{\itemsep}{-4pt} 50 | \renewcommand{\makelabel}{\entrylabel} 51 | } 52 | } 53 | {\end{list}} 54 | \newenvironment{Indent} 55 | {\begin{list}{}{\setlength{\leftmargin}{0.5cm}} 56 | \item[]\ignorespaces} 57 | {\unskip\end{list}} 58 | \setlength{\parindent}{0cm} 59 | \setlength{\parskip}{0.2cm} 60 | \addtocounter{secnumdepth}{1} 61 | \sloppy 62 | \usepackage[T1]{fontenc} 63 | -------------------------------------------------------------------------------- /middleware/uip/doc/example-mainloop-with-arp.c: -------------------------------------------------------------------------------- 1 | #include "uip.h" 2 | #include "uip_arp.h" 3 | #include "network-device.h" 4 | #include "httpd.h" 5 | #include "timer.h" 6 | 7 | #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) 8 | 9 | /*---------------------------------------------------------------------------*/ 10 | int 11 | main(void) 12 | { 13 | int i; 14 | uip_ipaddr_t ipaddr; 15 | struct timer periodic_timer, arp_timer; 16 | 17 | timer_set(&periodic_timer, CLOCK_SECOND / 2); 18 | timer_set(&arp_timer, CLOCK_SECOND * 10); 19 | 20 | network_device_init(); 21 | uip_init(); 22 | 23 | uip_ipaddr(ipaddr, 192,168,0,2); 24 | uip_sethostaddr(ipaddr); 25 | 26 | httpd_init(); 27 | 28 | while(1) { 29 | uip_len = network_device_read(); 30 | if(uip_len > 0) { 31 | if(BUF->type == htons(UIP_ETHTYPE_IP)) { 32 | uip_arp_ipin(); 33 | uip_input(); 34 | /* If the above function invocation resulted in data that 35 | should be sent out on the network, the global variable 36 | uip_len is set to a value > 0. */ 37 | if(uip_len > 0) { 38 | uip_arp_out(); 39 | network_device_send(); 40 | } 41 | } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { 42 | uip_arp_arpin(); 43 | /* If the above function invocation resulted in data that 44 | should be sent out on the network, the global variable 45 | uip_len is set to a value > 0. */ 46 | if(uip_len > 0) { 47 | network_device_send(); 48 | } 49 | } 50 | 51 | } else if(timer_expired(&periodic_timer)) { 52 | timer_reset(&periodic_timer); 53 | for(i = 0; i < UIP_CONNS; i++) { 54 | uip_periodic(i); 55 | /* If the above function invocation resulted in data that 56 | should be sent out on the network, the global variable 57 | uip_len is set to a value > 0. */ 58 | if(uip_len > 0) { 59 | uip_arp_out(); 60 | network_device_send(); 61 | } 62 | } 63 | 64 | #if UIP_UDP 65 | for(i = 0; i < UIP_UDP_CONNS; i++) { 66 | uip_udp_periodic(i); 67 | /* If the above function invocation resulted in data that 68 | should be sent out on the network, the global variable 69 | uip_len is set to a value > 0. */ 70 | if(uip_len > 0) { 71 | uip_arp_out(); 72 | network_device_send(); 73 | } 74 | } 75 | #endif /* UIP_UDP */ 76 | 77 | /* Call the ARP timer function every 10 seconds. */ 78 | if(timer_expired(&arp_timer)) { 79 | timer_reset(&arp_timer); 80 | uip_arp_timer(); 81 | } 82 | } 83 | } 84 | return 0; 85 | } 86 | /*---------------------------------------------------------------------------*/ 87 | -------------------------------------------------------------------------------- /middleware/uip/doc/example-mainloop-without-arp.c: -------------------------------------------------------------------------------- 1 | #include "uip.h" 2 | #include "uip_arp.h" 3 | #include "network-device.h" 4 | #include "httpd.h" 5 | #include "timer.h" 6 | 7 | /*---------------------------------------------------------------------------*/ 8 | int 9 | main(void) 10 | { 11 | int i; 12 | uip_ipaddr_t ipaddr; 13 | struct timer periodic_timer; 14 | 15 | timer_set(&periodic_timer, CLOCK_SECOND / 2); 16 | 17 | network_device_init(); 18 | uip_init(); 19 | 20 | uip_ipaddr(ipaddr, 192,168,0,2); 21 | uip_sethostaddr(ipaddr); 22 | 23 | httpd_init(); 24 | 25 | while(1) { 26 | uip_len = network_device_read(); 27 | if(uip_len > 0) { 28 | uip_input(); 29 | /* If the above function invocation resulted in data that 30 | should be sent out on the network, the global variable 31 | uip_len is set to a value > 0. */ 32 | if(uip_len > 0) { 33 | network_device_send(); 34 | } 35 | } else if(timer_expired(&periodic_timer)) { 36 | timer_reset(&periodic_timer); 37 | for(i = 0; i < UIP_CONNS; i++) { 38 | uip_periodic(i); 39 | /* If the above function invocation resulted in data that 40 | should be sent out on the network, the global variable 41 | uip_len is set to a value > 0. */ 42 | if(uip_len > 0) { 43 | network_device_send(); 44 | } 45 | } 46 | 47 | #if UIP_UDP 48 | for(i = 0; i < UIP_UDP_CONNS; i++) { 49 | uip_udp_periodic(i); 50 | /* If the above function invocation resulted in data that 51 | should be sent out on the network, the global variable 52 | uip_len is set to a value > 0. */ 53 | if(uip_len > 0) { 54 | network_device_send(); 55 | } 56 | } 57 | #endif /* UIP_UDP */ 58 | } 59 | } 60 | return 0; 61 | } 62 | /*---------------------------------------------------------------------------*/ 63 | -------------------------------------------------------------------------------- /middleware/uip/doc/examples.txt: -------------------------------------------------------------------------------- 1 | /** 2 | \defgroup apps Applications 3 | @{ 4 | 5 | The uIP distribution contains a number of example applications that 6 | can be either used directory or studied when learning to develop 7 | applications for uIP. 8 | 9 | */ 10 | 11 | /** \example hello-world.c */ 12 | /** \example hello-world.h */ 13 | 14 | /** \example smtp.c */ 15 | /** \example smtp.h */ 16 | 17 | /** \example webclient.c */ 18 | /** \example webclient.h */ 19 | 20 | /** \example example-mainloop-with-arp.c */ 21 | /** \example example-mainloop-without-arp.c */ 22 | 23 | /** \example telnetd.c */ 24 | /** \example telnetd.h */ 25 | 26 | /** \example resolv.c */ 27 | /** \example resolv.h */ 28 | 29 | /** \example dhcpc.c */ 30 | /** \example dhcpc.h */ 31 | 32 | /** \example uip-conf.h */ 33 | 34 | /** @} */ 35 | -------------------------------------------------------------------------------- /middleware/uip/doc/header.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper]{book} 2 | \usepackage{a4wide} 3 | \usepackage{makeidx} 4 | \usepackage{fancyhdr} 5 | \usepackage{graphicx} 6 | \usepackage{multicol} 7 | \usepackage{float} 8 | \usepackage{textcomp} 9 | \usepackage{alltt} 10 | \usepackage{times} 11 | \ifx\pdfoutput\undefined 12 | \usepackage[ps2pdf, 13 | pagebackref=true, 14 | colorlinks=true, 15 | linkcolor=blue 16 | ]{hyperref} 17 | \usepackage{pspicture} 18 | \else 19 | \usepackage[pdftex, 20 | pagebackref=true, 21 | colorlinks=true, 22 | linkcolor=blue 23 | ]{hyperref} 24 | \fi 25 | \usepackage{doxygen} 26 | \makeindex 27 | \setcounter{tocdepth}{1} 28 | \renewcommand{\footrulewidth}{0.4pt} 29 | \begin{document} 30 | \begin{titlepage} 31 | \vspace*{5cm} 32 | \begin{center} 33 | {\Huge The uIP Embedded TCP/IP Stack}\\ 34 | \vspace*{1cm} 35 | {\LARGE The uIP 1.0 Reference Manual}\\ 36 | \vspace*{3cm} 37 | {\Large June 2006}\\ 38 | \vspace*{2cm} 39 | \includegraphics[width=6cm]{../sicslogo.pdf}\\ 40 | \vspace*{1cm} 41 | {\Large Adam Dunkels}\\ 42 | {\Large \texttt{adam@sics.se}}\\ 43 | \vspace*{1cm} 44 | {\LARGE Swedish Institute of Computer Science}\\ 45 | \vspace*{0.5cm} 46 | 47 | \end{center} 48 | \end{titlepage} 49 | \clearemptydoublepage 50 | \pagenumbering{roman} 51 | \tableofcontents 52 | \clearemptydoublepage 53 | \pagenumbering{arabic} 54 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00079.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: httpd_cgi_call Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

httpd_cgi_call Struct Reference
24 | 25 | [Web server] 26 |


Detailed Description

27 | 28 |

29 | 30 |

31 | Definition at line 60 of file httpd-cgi.h.

LocalRemoteStateRetransmissionsTimerFlags
32 | 33 | 34 | 36 | 37 | 39 | 40 |

Data Fields

35 | const char * name
38 | const httpd_cgifunction function
41 |
Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  42 | 43 | doxygen 1.4.6
44 | 45 | 46 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00083.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: psock_buf Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

psock_buf Struct Reference
24 | 25 | [Protosockets library] 26 |


Detailed Description

27 | 28 |

29 | 30 |

31 | Definition at line 95 of file psock.h. 32 | 33 | 34 | 36 | 37 | 39 | 40 |

Data Fields

35 | u8_tptr
38 | unsigned short left
41 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  42 | 43 | doxygen 1.4.6
44 | 45 | 46 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00084.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: pt Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

pt Struct Reference
24 | 25 | [Protothreads] 26 |


Detailed Description

27 |
Examples:
28 | 29 |

30 | dhcpc.h.

31 |

32 | 33 |

34 | Definition at line 54 of file pt.h. 35 | 36 | 37 | 39 | 40 |

Data Fields

38 | lc_t lc
41 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  42 | 43 | doxygen 1.4.6
44 | 45 | 46 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00087.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: timer Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

timer Struct Reference
24 | 25 | [Timer library] 26 |

#include <timer.h> 27 |

28 |


Detailed Description

29 | A timer. 30 |

31 | This structure is used for declaring a timer. The timer must be set with timer_set() before it can be used.

Examples:
32 | 33 |

34 | dhcpc.h, example-mainloop-with-arp.c, example-mainloop-without-arp.c, and webclient.h.

35 |

36 | 37 |

38 | Definition at line 74 of file timer.h. 39 | 40 | 41 | 43 | 44 | 46 | 47 |

Data Fields

42 | clock_time_t start
45 | clock_time_t interval
48 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  49 | 50 | doxygen 1.4.6
51 | 52 | 53 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00089.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip_eth_addr Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

uip_eth_addr Struct Reference
24 | 25 | [The uIP TCP/IP stack] 26 |

#include <uip.h> 27 |

28 |


Detailed Description

29 | Representation of a 48-bit Ethernet address. 30 |

31 | 32 |

33 | Definition at line 1542 of file uip.h. 34 | 35 | 36 | 38 | 39 |

Data Fields

37 | u8_t addr [6]
40 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  41 | 42 | doxygen 1.4.6
43 | 44 | 45 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00092.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip_neighbor_addr Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

uip_neighbor_addr Struct Reference


Detailed Description

24 | 25 |

26 | 27 |

28 | Definition at line 47 of file uip-neighbor.h. 29 | 30 | 31 | 33 | 34 |

Data Fields

32 | uip_eth_addr addr
35 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  36 | 37 | doxygen 1.4.6
38 | 39 | 40 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00100.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: apps/hello-world/hello-world.c File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

apps/hello-world/hello-world.c File Reference


Detailed Description

22 | An example of how to write uIP applications with protosockets. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file hello-world.c. 28 |

29 | #include "hello-world.h"
30 | #include "uip.h"
31 | #include <string.h>
32 | 33 |

34 | Go to the source code of this file. 35 | 36 | 37 | 39 | 40 | 42 | 43 |

Functions

38 | void hello_world_init (void)
41 | void hello_world_appcall (void)
44 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  45 | 46 | doxygen 1.4.6
47 | 48 | 49 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00112.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: apps/webserver/httpd-cgi.c File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

apps/webserver/httpd-cgi.c File Reference


Detailed Description

22 | Web server script interface. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file httpd-cgi.c. 28 |

29 | #include "uip.h"
30 | #include "psock.h"
31 | #include "httpd.h"
32 | #include "httpd-cgi.h"
33 | #include "httpd-fs.h"
34 | #include <stdio.h>
35 | #include <string.h>
36 | 37 |

38 | Go to the source code of this file. 39 | 40 | 41 | 43 | 44 |

Functions

42 | httpd_cgifunction httpd_cgi (char *name)
45 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  46 | 47 | doxygen 1.4.6
48 | 49 | 50 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00113.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: apps/webserver/httpd-cgi.h File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

apps/webserver/httpd-cgi.h File Reference


Detailed Description

22 | Web server script interface header file. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file httpd-cgi.h. 28 |

29 | #include "psock.h"
30 | #include "httpd.h"
31 | 32 |

33 | Go to the source code of this file. 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 45 | 46 |

Data Structures

struct  httpd_cgi_call

Defines

#define HTTPD_CGI_CALL(name, str, function)
 HTTPD CGI function declaration.

Functions

44 | httpd_cgifunction httpd_cgi (char *name)
47 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  48 | 49 | doxygen 1.4.6
50 | 51 | 52 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00125.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip/lc.h File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

uip/lc.h File Reference


Detailed Description

22 | Local continuations. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file lc.h. 28 |

29 | #include "lc-switch.h"
30 | 31 |

32 | Go to the source code of this file. 33 | 34 |
35 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  36 | 37 | doxygen 1.4.6
38 | 39 | 40 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/a00134.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip/uip-split.h File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

uip/uip-split.h File Reference


Detailed Description

22 | Module for splitting outbound TCP segments in two to avoid the delayed ACK throughput degradation. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file uip-split.h. 28 |

29 | 30 |

31 | Go to the source code of this file. 32 | 33 | 34 | 35 | 36 | 37 |

Functions

void uip_split_output (void)
 Handle outgoing packets.
38 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  39 | 40 | doxygen 1.4.6
41 | 42 | 43 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/doxygen.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/examples.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Examples 4 | 5 | 6 | 7 | 8 |
9 |
16 |

uIP 1.0 Examples

Here is a list of all examples: 34 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  35 | 36 | doxygen 1.4.6
37 | 38 | 39 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2blank.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2doc.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2folderclosed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2folderclosed.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2folderopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2folderopen.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2lastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2lastnode.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2link.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2mlastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2mlastnode.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2mnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2mnode.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2node.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2plastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2plastnode.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2pnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2pnode.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/ftv2vertline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/ftv2vertline.png -------------------------------------------------------------------------------- /middleware/uip/doc/html/globals.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 | Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation: 54 |

55 |

- _ -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/globals_0x65.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 | Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation: 54 |

55 |

- e -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/globals_0x66.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 | Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation: 54 |

55 |

- f -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/globals_defs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- _ -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/globals_defs_0x65.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- e -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/globals_defs_0x66.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- f -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/globals_defs_0x72.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- r -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/globals_type.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |   31 |

32 |

43 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  44 | 45 | doxygen 1.4.6
46 | 47 | 48 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/hierarchy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Hierarchical Index 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

uIP 1.0 Class Hierarchy

This inheritance list is sorted roughly, but not completely, alphabetically: 46 |
Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  47 | 48 | doxygen 1.4.6
49 | 50 | 51 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/modules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Module Index 4 | 5 | 6 | 7 | 8 |
9 |
16 |

uIP 1.0 Modules

Here is a list of all modules: 47 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  48 | 49 | doxygen 1.4.6
50 | 51 | 52 | -------------------------------------------------------------------------------- /middleware/uip/doc/html/tab_b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/tab_b.gif -------------------------------------------------------------------------------- /middleware/uip/doc/html/tab_l.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/tab_l.gif -------------------------------------------------------------------------------- /middleware/uip/doc/html/tab_r.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/html/tab_r.gif -------------------------------------------------------------------------------- /middleware/uip/doc/html/tabs.css: -------------------------------------------------------------------------------- 1 | /* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ 2 | 3 | DIV.tabs 4 | { 5 | float : left; 6 | width : 100%; 7 | background : url("tab_b.gif") repeat-x bottom; 8 | margin-bottom : 4px; 9 | } 10 | 11 | DIV.tabs UL 12 | { 13 | margin : 0px; 14 | padding-left : 10px; 15 | list-style : none; 16 | } 17 | 18 | DIV.tabs LI, DIV.tabs FORM 19 | { 20 | display : inline; 21 | margin : 0px; 22 | padding : 0px; 23 | } 24 | 25 | DIV.tabs FORM 26 | { 27 | float : right; 28 | } 29 | 30 | DIV.tabs A 31 | { 32 | float : left; 33 | background : url("tab_r.gif") no-repeat right top; 34 | border-bottom : 1px solid #84B0C7; 35 | font-size : x-small; 36 | font-weight : bold; 37 | text-decoration : none; 38 | } 39 | 40 | DIV.tabs A:hover 41 | { 42 | background-position: 100% -150px; 43 | } 44 | 45 | DIV.tabs A:link, DIV.tabs A:visited, 46 | DIV.tabs A:active, DIV.tabs A:hover 47 | { 48 | color: #1A419D; 49 | } 50 | 51 | DIV.tabs SPAN 52 | { 53 | float : left; 54 | display : block; 55 | background : url("tab_l.gif") no-repeat left top; 56 | padding : 5px 9px; 57 | white-space : nowrap; 58 | } 59 | 60 | DIV.tabs INPUT 61 | { 62 | float : right; 63 | display : inline; 64 | font-size : 1em; 65 | } 66 | 67 | DIV.tabs TD 68 | { 69 | font-size : x-small; 70 | font-weight : bold; 71 | text-decoration : none; 72 | } 73 | 74 | 75 | 76 | /* Commented Backslash Hack hides rule from IE5-Mac \*/ 77 | DIV.tabs SPAN {float : none;} 78 | /* End IE5-Mac hack */ 79 | 80 | DIV.tabs A:hover SPAN 81 | { 82 | background-position: 0% -150px; 83 | } 84 | 85 | DIV.tabs LI#current A 86 | { 87 | background-position: 100% -150px; 88 | border-width : 0px; 89 | } 90 | 91 | DIV.tabs LI#current SPAN 92 | { 93 | background-position: 0% -150px; 94 | padding-bottom : 6px; 95 | } 96 | 97 | DIV.nav 98 | { 99 | background : none; 100 | border : none; 101 | border-bottom : 1px solid #84B0C7; 102 | } 103 | -------------------------------------------------------------------------------- /middleware/uip/doc/mobisys2003.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/mobisys2003.pdf -------------------------------------------------------------------------------- /middleware/uip/doc/sicslogo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/sicslogo.pdf -------------------------------------------------------------------------------- /middleware/uip/doc/uip-code-style.txt: -------------------------------------------------------------------------------- 1 | /** 2 | \example uip-code-style.c 3 | */ 4 | -------------------------------------------------------------------------------- /middleware/uip/doc/uip-refman.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamflyforever/fos/cdd2b8c8fdcfe5f73bbcfba5d4dacbc5cf5d4908/middleware/uip/doc/uip-refman.pdf -------------------------------------------------------------------------------- /middleware/uip/fos/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2001, Adam Dunkels. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions 6 | # are met: 7 | # 1. Redistributions of source code must retain the above copyright 8 | # notice, this list of conditions and the following disclaimer. 9 | # 2. Redistributions in binary form must reproduce the above copyright 10 | # notice, this list of conditions and the following disclaimer in the 11 | # documentation and/or other materials provided with the distribution. 12 | # 3. The name of the author may not be used to endorse or promote 13 | # products derived from this software without specific prior 14 | # written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 17 | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 20 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 22 | # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # This file is part of the uIP TCP/IP stack. 29 | # 30 | # $Id: Makefile,v 1.13 2006/06/11 21:55:03 adam Exp $ 31 | # 32 | 33 | all: uip 34 | 35 | CC = gcc # clang 36 | AR = ar 37 | APPS = webserver 38 | CFLAGS = -Wall -g -I../uip -I. -fpack-struct -fno-strict-aliasing -Wno-unused-but-set-variable -Os 39 | -include ../uip/Makefile.include 40 | 41 | uip: $(addprefix $(OBJECTDIR)/, main.o tapdev.o clock-arch.o) apps.a uip.a 42 | 43 | clean: 44 | rm -fr *.o *~ *core uip $(OBJECTDIR) *.a 45 | -------------------------------------------------------------------------------- /middleware/uip/fos/clock-arch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * $Id: clock-arch.c,v 1.2 2006/06/12 08:00:31 adam Exp $ 32 | */ 33 | 34 | /** 35 | * \file 36 | * Implementation of architecture-specific clock functionality 37 | * \author 38 | * Adam Dunkels 39 | */ 40 | 41 | #include "clock-arch.h" 42 | #include 43 | 44 | /*---------------------------------------------------------------------------*/ 45 | clock_time_t 46 | clock_time(void) 47 | { 48 | struct timeval tv; 49 | struct timezone tz; 50 | 51 | gettimeofday(&tv, &tz); 52 | 53 | return tv.tv_sec * 1000 + tv.tv_usec / 1000; 54 | } 55 | /*---------------------------------------------------------------------------*/ 56 | -------------------------------------------------------------------------------- /middleware/uip/fos/clock-arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * $Id: clock-arch.h,v 1.2 2006/06/12 08:00:31 adam Exp $ 32 | */ 33 | 34 | #ifndef __CLOCK_ARCH_H__ 35 | #define __CLOCK_ARCH_H__ 36 | 37 | typedef int clock_time_t; 38 | #define CLOCK_CONF_SECOND 1000 39 | 40 | #endif /* __CLOCK_ARCH_H__ */ 41 | -------------------------------------------------------------------------------- /middleware/uip/fos/tapdev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by Adam Dunkels. 16 | * 4. The name of the author may not be used to endorse or promote 17 | * products derived from this software without specific prior 18 | * written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 21 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 26 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * This file is part of the uIP TCP/IP stack. 33 | * 34 | * $Id: tapdev.h,v 1.1 2002/01/10 06:22:56 adam Exp $ 35 | * 36 | */ 37 | 38 | #ifndef __TAPDEV_H__ 39 | #define __TAPDEV_H__ 40 | 41 | void tapdev_init(void); 42 | unsigned int tapdev_read(void); 43 | void tapdev_send(void); 44 | 45 | #endif /* __TAPDEV_H__ */ 46 | -------------------------------------------------------------------------------- /middleware/uip/uip/Makefile.include: -------------------------------------------------------------------------------- 1 | 2 | 3 | ifdef APPS 4 | APPDIRS = $(foreach APP, $(APPS), ../apps/$(APP)) 5 | -include $(foreach APP, $(APPS), ../apps/$(APP)/Makefile.$(APP)) 6 | CFLAGS += $(addprefix -I../apps/,$(APPS)) 7 | endif 8 | 9 | ifndef CCDEP 10 | CCDEP = $(CC) 11 | endif 12 | ifndef CCDEPCFLAGS 13 | CCDEPCFLAGS = $(CFLAGS) 14 | endif 15 | ifndef OBJECTDIR 16 | OBJECTDIR = obj 17 | endif 18 | 19 | ifeq (${wildcard $(OBJECTDIR)},) 20 | DUMMY := ${shell mkdir $(OBJECTDIR)} 21 | endif 22 | 23 | 24 | vpath %.c . ../uip ../lib $(APPDIRS) 25 | 26 | $(OBJECTDIR)/%.o: %.c 27 | $(CC) $(CFLAGS) -c $< -o $@ 28 | 29 | $(OBJECTDIR)/%.d: %.c 30 | @set -e; rm -f $@; \ 31 | $(CCDEP) -MM $(CCDEPCFLAGS) $< > $@.$$$$; \ 32 | sed 's,\($*\)\.o[ :]*,$(OBJECTDIR)/\1.o $@ : ,g' < $@.$$$$ > $@; \ 33 | rm -f $@.$$$$ 34 | 35 | UIP_SOURCES=uip.c uip_arp.c uiplib.c psock.c timer.c uip-neighbor.c 36 | 37 | 38 | ifneq ($(MAKECMDGOALS),clean) 39 | -include $(addprefix $(OBJECTDIR)/,$(UIP_SOURCES:.c=.d) \ 40 | $(APP_SOURCES:.c=.d)) 41 | endif 42 | 43 | uip.a: ${addprefix $(OBJECTDIR)/, $(UIP_SOURCES:.c=.o)} 44 | $(AR) rcf $@ $^ 45 | 46 | apps.a: ${addprefix $(OBJECTDIR)/, $(APP_SOURCES:.c=.o)} 47 | $(AR) rcf $@ $^ 48 | -------------------------------------------------------------------------------- /middleware/uip/uip/clock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup clock Clock interface 3 | * 4 | * The clock interface is the interface between the \ref timer "timer library" 5 | * and the platform specific clock functionality. The clock 6 | * interface must be implemented for each platform that uses the \ref 7 | * timer "timer library". 8 | * 9 | * The clock interface does only one this: it measures time. The clock 10 | * interface provides a macro, CLOCK_SECOND, which corresponds to one 11 | * second of system time. 12 | * 13 | * \sa \ref timer "Timer library" 14 | * 15 | * @{ 16 | */ 17 | 18 | /* 19 | * Copyright (c) 2004, Swedish Institute of Computer Science. 20 | * All rights reserved. 21 | * 22 | * Redistribution and use in source and binary forms, with or without 23 | * modification, are permitted provided that the following conditions 24 | * are met: 25 | * 1. Redistributions of source code must retain the above copyright 26 | * notice, this list of conditions and the following disclaimer. 27 | * 2. Redistributions in binary form must reproduce the above copyright 28 | * notice, this list of conditions and the following disclaimer in the 29 | * documentation and/or other materials provided with the distribution. 30 | * 3. Neither the name of the Institute nor the names of its contributors 31 | * may be used to endorse or promote products derived from this software 32 | * without specific prior written permission. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 35 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 36 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 37 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 38 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 40 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 41 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 42 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 43 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 44 | * SUCH DAMAGE. 45 | * 46 | * This file is part of the uIP TCP/IP stack 47 | * 48 | * Author: Adam Dunkels 49 | * 50 | * $Id: clock.h,v 1.3 2006/06/11 21:46:39 adam Exp $ 51 | */ 52 | #ifndef __CLOCK_H__ 53 | #define __CLOCK_H__ 54 | 55 | #include "clock-arch.h" 56 | 57 | /** 58 | * Initialize the clock library. 59 | * 60 | * This function initializes the clock library and should be called 61 | * from the main() function of the system. 62 | * 63 | */ 64 | void clock_init(void); 65 | 66 | /** 67 | * Get the current clock time. 68 | * 69 | * This function returns the current system clock time. 70 | * 71 | * \return The current clock time, measured in system ticks. 72 | */ 73 | clock_time_t clock_time(void); 74 | 75 | /** 76 | * A second, measured in system clock time. 77 | * 78 | * \hideinitializer 79 | */ 80 | #ifdef CLOCK_CONF_SECOND 81 | #define CLOCK_SECOND CLOCK_CONF_SECOND 82 | #else 83 | #define CLOCK_SECOND (clock_time_t)32 84 | #endif 85 | 86 | #endif /* __CLOCK_H__ */ 87 | 88 | /** @} */ 89 | -------------------------------------------------------------------------------- /middleware/uip/uip/lc-addrlabels.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: lc-addrlabels.h,v 1.3 2006/06/12 08:00:30 adam Exp $ 34 | */ 35 | 36 | /** 37 | * \addtogroup lc 38 | * @{ 39 | */ 40 | 41 | /** 42 | * \file 43 | * Implementation of local continuations based on the "Labels as 44 | * values" feature of gcc 45 | * \author 46 | * Adam Dunkels 47 | * 48 | * This implementation of local continuations is based on a special 49 | * feature of the GCC C compiler called "labels as values". This 50 | * feature allows assigning pointers with the address of the code 51 | * corresponding to a particular C label. 52 | * 53 | * For more information, see the GCC documentation: 54 | * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html 55 | * 56 | * Thanks to dividuum for finding the nice local scope label 57 | * implementation. 58 | */ 59 | 60 | #ifndef __LC_ADDRLABELS_H__ 61 | #define __LC_ADDRLABELS_H__ 62 | 63 | /** \hideinitializer */ 64 | typedef void * lc_t; 65 | 66 | #define LC_INIT(s) s = NULL 67 | 68 | 69 | #define LC_RESUME(s) \ 70 | do { \ 71 | if(s != NULL) { \ 72 | goto *s; \ 73 | } \ 74 | } while(0) 75 | 76 | #define LC_SET(s) \ 77 | do { ({ __label__ resume; resume: (s) = &&resume; }); }while(0) 78 | 79 | #define LC_END(s) 80 | 81 | #endif /* __LC_ADDRLABELS_H__ */ 82 | 83 | /** @} */ 84 | -------------------------------------------------------------------------------- /middleware/uip/uip/lc-switch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: lc-switch.h,v 1.2 2006/06/12 08:00:30 adam Exp $ 34 | */ 35 | 36 | /** 37 | * \addtogroup lc 38 | * @{ 39 | */ 40 | 41 | /** 42 | * \file 43 | * Implementation of local continuations based on switch() statment 44 | * \author Adam Dunkels 45 | * 46 | * This implementation of local continuations uses the C switch() 47 | * statement to resume execution of a function somewhere inside the 48 | * function's body. The implementation is based on the fact that 49 | * switch() statements are able to jump directly into the bodies of 50 | * control structures such as if() or while() statmenets. 51 | * 52 | * This implementation borrows heavily from Simon Tatham's coroutines 53 | * implementation in C: 54 | * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html 55 | */ 56 | 57 | #ifndef __LC_SWITCH_H__ 58 | #define __LC_SWITCH_H__ 59 | 60 | /* WARNING! lc implementation using switch() does not work if an 61 | LC_SET() is done within another switch() statement! */ 62 | 63 | /** \hideinitializer */ 64 | typedef unsigned short lc_t; 65 | 66 | #define LC_INIT(s) s = 0; 67 | 68 | #define LC_RESUME(s) switch(s) { case 0: 69 | 70 | #define LC_SET(s) s = __LINE__; case __LINE__: 71 | 72 | #define LC_END(s) } 73 | 74 | #endif /* __LC_SWITCH_H__ */ 75 | 76 | /** @} */ 77 | -------------------------------------------------------------------------------- /middleware/uip/uip/timer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup timer Timer library 3 | * 4 | * The timer library provides functions for setting, resetting and 5 | * restarting timers, and for checking if a timer has expired. An 6 | * application must "manually" check if its timers have expired; this 7 | * is not done automatically. 8 | * 9 | * A timer is declared as a \c struct \c timer and all access to the 10 | * timer is made by a pointer to the declared timer. 11 | * 12 | * \note The timer library uses the \ref clock "Clock library" to 13 | * measure time. Intervals should be specified in the format used by 14 | * the clock library. 15 | * 16 | * @{ 17 | */ 18 | 19 | 20 | /** 21 | * \file 22 | * Timer library header file. 23 | * \author 24 | * Adam Dunkels 25 | */ 26 | 27 | /* 28 | * Copyright (c) 2004, Swedish Institute of Computer Science. 29 | * All rights reserved. 30 | * 31 | * Redistribution and use in source and binary forms, with or without 32 | * modification, are permitted provided that the following conditions 33 | * are met: 34 | * 1. Redistributions of source code must retain the above copyright 35 | * notice, this list of conditions and the following disclaimer. 36 | * 2. Redistributions in binary form must reproduce the above copyright 37 | * notice, this list of conditions and the following disclaimer in the 38 | * documentation and/or other materials provided with the distribution. 39 | * 3. Neither the name of the Institute nor the names of its contributors 40 | * may be used to endorse or promote products derived from this software 41 | * without specific prior written permission. 42 | * 43 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 44 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 46 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 49 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 50 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 51 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 52 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 53 | * SUCH DAMAGE. 54 | * 55 | * This file is part of the uIP TCP/IP stack 56 | * 57 | * Author: Adam Dunkels 58 | * 59 | * $Id: timer.h,v 1.3 2006/06/11 21:46:39 adam Exp $ 60 | */ 61 | #ifndef __TIMER_H__ 62 | #define __TIMER_H__ 63 | 64 | #include "clock.h" 65 | 66 | /** 67 | * A timer. 68 | * 69 | * This structure is used for declaring a timer. The timer must be set 70 | * with timer_set() before it can be used. 71 | * 72 | * \hideinitializer 73 | */ 74 | struct timer { 75 | clock_time_t start; 76 | clock_time_t interval; 77 | }; 78 | 79 | void timer_set(struct timer *t, clock_time_t interval); 80 | void timer_reset(struct timer *t); 81 | void timer_restart(struct timer *t); 82 | int timer_expired(struct timer *t); 83 | 84 | #endif /* __TIMER_H__ */ 85 | 86 | /** @} */ 87 | -------------------------------------------------------------------------------- /middleware/uip/uip/uip-neighbor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * $Id: uip-neighbor.h,v 1.2 2006/06/12 08:00:30 adam Exp $ 32 | */ 33 | 34 | /** 35 | * \file 36 | * Header file for database of link-local neighbors, used by 37 | * IPv6 code and to be used by future ARP code. 38 | * \author 39 | * Adam Dunkels 40 | */ 41 | 42 | #ifndef __UIP_NEIGHBOR_H__ 43 | #define __UIP_NEIGHBOR_H__ 44 | 45 | #include "uip.h" 46 | 47 | struct uip_neighbor_addr { 48 | #if UIP_NEIGHBOR_CONF_ADDRTYPE 49 | UIP_NEIGHBOR_CONF_ADDRTYPE addr; 50 | #else 51 | struct uip_eth_addr addr; 52 | #endif 53 | }; 54 | 55 | void uip_neighbor_init(void); 56 | void uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr); 57 | void uip_neighbor_update(uip_ipaddr_t ipaddr); 58 | struct uip_neighbor_addr *uip_neighbor_lookup(uip_ipaddr_t ipaddr); 59 | void uip_neighbor_periodic(void); 60 | 61 | #endif /* __UIP-NEIGHBOR_H__ */ 62 | -------------------------------------------------------------------------------- /middleware/uip/uip/uiplib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Adam Dunkels and the Swedish Institute of 3 | * Computer Science. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: uiplib.c,v 1.2 2006/06/12 08:00:31 adam Exp $ 33 | * 34 | */ 35 | 36 | 37 | #include "uip.h" 38 | #include "uiplib.h" 39 | 40 | 41 | /*-----------------------------------------------------------------------------------*/ 42 | unsigned char 43 | uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr) 44 | { 45 | unsigned char tmp; 46 | char c; 47 | unsigned char i, j; 48 | 49 | tmp = 0; 50 | 51 | for(i = 0; i < 4; ++i) { 52 | j = 0; 53 | do { 54 | c = *addrstr; 55 | ++j; 56 | if(j > 4) { 57 | return 0; 58 | } 59 | if(c == '.' || c == 0) { 60 | *ipaddr = tmp; 61 | ++ipaddr; 62 | tmp = 0; 63 | } else if(c >= '0' && c <= '9') { 64 | tmp = (tmp * 10) + (c - '0'); 65 | } else { 66 | return 0; 67 | } 68 | ++addrstr; 69 | } while(c != '.' && c != 0); 70 | } 71 | return 1; 72 | } 73 | 74 | /*-----------------------------------------------------------------------------------*/ 75 | -------------------------------------------------------------------------------- /middleware/uip/uip/uiplib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * Various uIP library functions. 4 | * \author 5 | * Adam Dunkels 6 | * 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2002, Adam Dunkels. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above 19 | * copyright notice, this list of conditions and the following 20 | * disclaimer in the documentation and/or other materials provided 21 | * with the distribution. 22 | * 3. The name of the author may not be used to endorse or promote 23 | * products derived from this software without specific prior 24 | * written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 27 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 30 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 34 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * This file is part of the uIP TCP/IP stack 39 | * 40 | * $Id: uiplib.h,v 1.1 2006/06/07 09:15:19 adam Exp $ 41 | * 42 | */ 43 | #ifndef __UIPLIB_H__ 44 | #define __UIPLIB_H__ 45 | 46 | /** 47 | * \addtogroup uipconvfunc 48 | * @{ 49 | */ 50 | 51 | /** 52 | * Convert a textual representation of an IP address to a numerical representation. 53 | * 54 | * This function takes a textual representation of an IP address in 55 | * the form a.b.c.d and converts it into a 4-byte array that can be 56 | * used by other uIP functions. 57 | * 58 | * \param addrstr A pointer to a string containing the IP address in 59 | * textual form. 60 | * 61 | * \param addr A pointer to a 4-byte array that will be filled in with 62 | * the numerical representation of the address. 63 | * 64 | * \retval 0 If the IP address could not be parsed. 65 | * \retval Non-zero If the IP address was parsed. 66 | */ 67 | unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr); 68 | 69 | /** @} */ 70 | 71 | #endif /* __UIPLIB_H__ */ 72 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | sudo ./fos 2 | --------------------------------------------------------------------------------