├── .dockerignore ├── .github └── workflows │ ├── docker.yml │ └── doxygen.yml ├── .gitignore ├── Doxyfile ├── README.md ├── devkitxenon ├── LICENSE ├── app.lds ├── examples │ └── xenon │ │ ├── file │ │ └── browser │ │ │ ├── Makefile │ │ │ └── source │ │ │ └── main.c │ │ └── graphics │ │ └── cube │ │ ├── Makefile │ │ ├── files │ │ ├── README │ │ ├── ps.hlsl │ │ ├── ps.psu │ │ ├── vs.hlsl │ │ └── vs.vsu │ │ ├── genffs.py │ │ └── source │ │ ├── engine.c │ │ ├── engine.h │ │ ├── ffs_content.c │ │ ├── main.c │ │ ├── xee.c │ │ └── xee.h └── rules ├── libxenon.dockerfile ├── libxenon ├── LICENSE ├── README ├── drivers │ ├── console │ │ ├── console.c │ │ ├── console.h │ │ ├── font_8x16.h │ │ ├── telnet_console.c │ │ └── telnet_console.h │ ├── crypt │ │ ├── des.c │ │ ├── des.h │ │ ├── hmac_sha1.c │ │ ├── hmac_sha1.h │ │ ├── rc4.c │ │ ├── rc4.h │ │ ├── sha.h │ │ └── sha1.c │ ├── diskio │ │ ├── ata.c │ │ ├── ata.h │ │ └── disc_io.h │ ├── elf │ │ ├── elf.c │ │ ├── elf.h │ │ ├── elf_abi.h │ │ └── elf_run.S │ ├── input │ │ ├── input.c │ │ └── input.h │ ├── iso9660 │ │ ├── iso9660.c │ │ └── iso9660.h │ ├── libfdt │ │ ├── fdt.c │ │ ├── fdt.h │ │ ├── fdt_ro.c │ │ ├── fdt_rw.c │ │ ├── fdt_strerror.c │ │ ├── fdt_sw.c │ │ ├── fdt_wip.c │ │ ├── libfdt.h │ │ ├── libfdt_env.h │ │ └── libfdt_internal.h │ ├── lwip │ │ ├── CHANGELOG │ │ ├── UPGRADING │ │ ├── api │ │ │ ├── api_lib.c │ │ │ ├── api_msg.c │ │ │ ├── err.c │ │ │ ├── netbuf.c │ │ │ ├── netdb.c │ │ │ ├── netifapi.c │ │ │ ├── sockets.c │ │ │ └── tcpip.c │ │ ├── core │ │ │ ├── def.c │ │ │ ├── dhcp.c │ │ │ ├── dns.c │ │ │ ├── init.c │ │ │ ├── ipv4 │ │ │ │ ├── autoip.c │ │ │ │ ├── icmp.c │ │ │ │ ├── igmp.c │ │ │ │ ├── inet.c │ │ │ │ ├── inet_chksum.c │ │ │ │ ├── ip.c │ │ │ │ ├── ip_addr.c │ │ │ │ └── ip_frag.c │ │ │ ├── ipv6 │ │ │ │ ├── README │ │ │ │ ├── icmp6.c │ │ │ │ ├── inet6.c │ │ │ │ ├── ip6.c │ │ │ │ └── ip6_addr.c │ │ │ ├── mem.c │ │ │ ├── memp.c │ │ │ ├── netif.c │ │ │ ├── pbuf.c │ │ │ ├── raw.c │ │ │ ├── snmp │ │ │ │ ├── asn1_dec.c │ │ │ │ ├── asn1_enc.c │ │ │ │ ├── mib2.c │ │ │ │ ├── mib_structs.c │ │ │ │ ├── msg_in.c │ │ │ │ └── msg_out.c │ │ │ ├── stats.c │ │ │ ├── sys.c │ │ │ ├── tcp.c │ │ │ ├── tcp_in.c │ │ │ ├── tcp_out.c │ │ │ ├── timers.c │ │ │ └── udp.c │ │ ├── include │ │ │ ├── ipv4 │ │ │ │ └── lwip │ │ │ │ │ ├── autoip.h │ │ │ │ │ ├── icmp.h │ │ │ │ │ ├── igmp.h │ │ │ │ │ ├── inet.h │ │ │ │ │ ├── inet_chksum.h │ │ │ │ │ ├── ip.h │ │ │ │ │ ├── ip_addr.h │ │ │ │ │ └── ip_frag.h │ │ │ ├── ipv6 │ │ │ │ └── lwip │ │ │ │ │ ├── icmp.h │ │ │ │ │ ├── inet.h │ │ │ │ │ ├── ip.h │ │ │ │ │ └── ip_addr.h │ │ │ ├── lwip │ │ │ │ ├── api.h │ │ │ │ ├── api_msg.h │ │ │ │ ├── arch.h │ │ │ │ ├── debug.h │ │ │ │ ├── def.h │ │ │ │ ├── dhcp.h │ │ │ │ ├── dns.h │ │ │ │ ├── err.h │ │ │ │ ├── init.h │ │ │ │ ├── mem.h │ │ │ │ ├── memp.h │ │ │ │ ├── memp_std.h │ │ │ │ ├── netbuf.h │ │ │ │ ├── netdb.h │ │ │ │ ├── netif.h │ │ │ │ ├── netifapi.h │ │ │ │ ├── opt.h │ │ │ │ ├── pbuf.h │ │ │ │ ├── raw.h │ │ │ │ ├── sio.h │ │ │ │ ├── snmp.h │ │ │ │ ├── snmp_asn1.h │ │ │ │ ├── snmp_msg.h │ │ │ │ ├── snmp_structs.h │ │ │ │ ├── sockets.h │ │ │ │ ├── stats.h │ │ │ │ ├── sys.h │ │ │ │ ├── tcp.h │ │ │ │ ├── tcp_impl.h │ │ │ │ ├── tcpip.h │ │ │ │ ├── timers.h │ │ │ │ └── udp.h │ │ │ ├── netif │ │ │ │ ├── etharp.h │ │ │ │ ├── loopif.h │ │ │ │ ├── ppp_oe.h │ │ │ │ └── slipif.h │ │ │ └── posix │ │ │ │ ├── netdb.h │ │ │ │ └── sys │ │ │ │ └── socket.h │ │ ├── netif │ │ │ ├── FILES │ │ │ ├── etharp.c │ │ │ ├── ethernetif.c │ │ │ ├── loopif.c │ │ │ ├── ppp │ │ │ │ ├── auth.c │ │ │ │ ├── auth.h │ │ │ │ ├── chap.c │ │ │ │ ├── chap.h │ │ │ │ ├── chpms.c │ │ │ │ ├── chpms.h │ │ │ │ ├── fsm.c │ │ │ │ ├── fsm.h │ │ │ │ ├── ipcp.c │ │ │ │ ├── ipcp.h │ │ │ │ ├── lcp.c │ │ │ │ ├── lcp.h │ │ │ │ ├── magic.c │ │ │ │ ├── magic.h │ │ │ │ ├── md5.c │ │ │ │ ├── md5.h │ │ │ │ ├── pap.c │ │ │ │ ├── pap.h │ │ │ │ ├── ppp.c │ │ │ │ ├── ppp.h │ │ │ │ ├── ppp_impl.h │ │ │ │ ├── ppp_oe.c │ │ │ │ ├── pppdebug.h │ │ │ │ ├── randm.c │ │ │ │ ├── randm.h │ │ │ │ ├── vj.c │ │ │ │ ├── vj.h │ │ │ │ └── vjbsdhdr.h │ │ │ └── slipif.c │ │ └── xenon │ │ │ ├── include │ │ │ └── arch │ │ │ │ ├── cc.h │ │ │ │ ├── cpu.h │ │ │ │ ├── init.h │ │ │ │ ├── lib.h │ │ │ │ ├── perf.h │ │ │ │ └── sys_arch.h │ │ │ ├── netif │ │ │ └── enet.c │ │ │ └── src │ │ │ ├── lib.c │ │ │ ├── perf.c │ │ │ └── sys_arch.c │ ├── network │ │ ├── network.c │ │ └── network.h │ ├── newlib │ │ ├── newlib.c │ │ └── xenon_syscalls.c │ ├── nocfe │ │ ├── cfe.h │ │ ├── lib_malloc.c │ │ ├── lib_malloc.h │ │ ├── lib_queue.c │ │ ├── lib_queue.h │ │ └── lib_types.h │ ├── pci │ │ ├── io.c │ │ └── io.h │ ├── ppc │ │ ├── atomic.S │ │ ├── atomic.h │ │ ├── c_except.c │ │ ├── cache.S │ │ ├── cache.h │ │ ├── except.S │ │ ├── register.h │ │ ├── timebase.h │ │ ├── vm.c │ │ ├── vm.h │ │ └── xenonsprs.h │ ├── time │ │ ├── time.c │ │ └── time.h │ ├── usb │ │ ├── README │ │ ├── dev_usb_asix.c │ │ ├── dev_usb_catc.c │ │ ├── dev_usb_klsi.c │ │ ├── dev_usb_pegasus.c │ │ ├── dev_usb_rtek.c │ │ ├── dummy.c │ │ ├── klsi_fw.h │ │ ├── ohci.c │ │ ├── ohci.h │ │ ├── tinyehci │ │ │ ├── ehci-mem.c │ │ │ ├── ehci.c │ │ │ ├── ehci.h │ │ │ ├── ehci_defs.h │ │ │ ├── ehci_types.h │ │ │ ├── tinyehci.c │ │ │ ├── tinyehci.h │ │ │ ├── usb.h │ │ │ ├── usb2.c │ │ │ ├── usb_os.c │ │ │ ├── usbstorage.c │ │ │ └── usbstorage.h │ │ ├── usbchap9.h │ │ ├── usbctrl.c │ │ ├── usbd.c │ │ ├── usbd.h │ │ ├── usbdebug.c │ │ ├── usbdevs.c │ │ ├── usbeth.c │ │ ├── usbeth.h │ │ ├── usbhack.c │ │ ├── usbhack.h │ │ ├── usbhack.mk │ │ ├── usbhid.c │ │ ├── usbhub.c │ │ ├── usbmain.c │ │ ├── usbmain.h │ │ ├── usbmass.c │ │ └── usbserial.c │ ├── utils │ │ ├── debug.c │ │ ├── gmon.c │ │ ├── gmon.h │ │ └── mf-simplecheck.c │ ├── xb360 │ │ ├── xb360.c │ │ └── xb360.h │ ├── xenon_nand │ │ ├── xenon_config.c │ │ ├── xenon_config.h │ │ ├── xenon_sfcx.c │ │ └── xenon_sfcx.h │ ├── xenon_post │ │ ├── xenon_post.c │ │ └── xenon_post.h │ ├── xenon_smc │ │ ├── xenon_gpio.c │ │ ├── xenon_gpio.h │ │ ├── xenon_smc.c │ │ └── xenon_smc.h │ ├── xenon_soc │ │ ├── cpusleep.S │ │ ├── xenon_io.h │ │ ├── xenon_power.c │ │ ├── xenon_power.h │ │ ├── xenon_secotp.c │ │ └── xenon_secotp.h │ ├── xenon_sound │ │ ├── sound.c │ │ └── sound.h │ ├── xenon_uart │ │ ├── xenon_uart.c │ │ └── xenon_uart.h │ └── xenos │ │ ├── edram.c │ │ ├── edram.h │ │ ├── ucode.c │ │ ├── xe.c │ │ ├── xe.h │ │ ├── xe_internal.h │ │ ├── xenos.c │ │ ├── xenos.h │ │ ├── xenos_edid.c │ │ ├── xenos_edid.h │ │ ├── xenos_videomodes.h │ │ └── xenos_videomodesdata.h ├── include │ ├── byteswap.h │ ├── cache.h │ ├── debug.h │ ├── lwipopts.h │ ├── machine │ │ └── powerpc │ │ │ ├── machine │ │ │ └── _types.h │ │ │ └── sys │ │ │ ├── lock.h │ │ │ └── stdio.h │ ├── mf-runtime.h │ ├── sys │ │ ├── dirent.h │ │ ├── iosupport.h │ │ └── statvfs.h │ └── xetypes.h ├── ports │ ├── bzip2 │ │ └── bzip2-1.0.6.diff │ └── xenon │ │ ├── Makefile │ │ ├── bin2s.c │ │ ├── crt0.s │ │ ├── crt1.s │ │ ├── crti.s │ │ └── crtn.s └── startup │ └── xenon │ ├── argv.c │ ├── crt1.c │ └── startup_from_xell.S ├── toolchain.dockerfile └── toolchain ├── binutils-2.22.diff ├── binutils-2.28-vmx128.diff ├── binutils-2.28.diff ├── binutils-2.32.diff ├── build-xenon-toolchain ├── gcc-4.7.1.diff ├── gcc-6.3.0.diff ├── gcc-9.2.0.diff ├── newlib-1.20.0.diff ├── newlib-2.5.0.diff └── newlib-3.1.0.diff /.dockerignore: -------------------------------------------------------------------------------- 1 | toolchain/build/ 2 | toolchain/build.log 3 | netbeans/ 4 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: docker 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build_toolchain: 11 | runs-on: ubuntu-latest 12 | steps: 13 | 14 | - name: Check Out Repo 15 | uses: actions/checkout@v4 16 | 17 | - name: "Run slugify" 18 | id: slugify 19 | uses: eltimn/slugify-action@v2.0.2 20 | 21 | - name: Login to Docker Hub 22 | uses: docker/login-action@v3 23 | with: 24 | username: ${{ secrets.DOCKER_HUB_USERNAME }} 25 | password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} 26 | 27 | - name: Set up Docker Buildx 28 | id: buildx 29 | uses: docker/setup-buildx-action@v3 30 | 31 | - name: Cache Docker layers 32 | uses: actions/cache@v4 33 | with: 34 | path: | 35 | /tmp/.buildx-cache-toolchain 36 | /tmp/.buildx-cache-libxenon 37 | key: ${{ runner.os }}-buildx-${{ github.sha }} 38 | restore-keys: | 39 | ${{ runner.os }}-buildx- 40 | 41 | - uses: dorny/paths-filter@v3 42 | id: filter 43 | with: 44 | filters: | 45 | toolchain: 46 | - 'toolchain/**' 47 | - 'toolchain.dockerfile' 48 | 49 | - name: Build and push Toolchain 50 | id: docker_build_toolchain 51 | uses: docker/build-push-action@v6 52 | if: steps.filter.outputs.toolchain == 'true' 53 | with: 54 | context: ./ 55 | file: ./toolchain.dockerfile 56 | builder: ${{ steps.buildx.outputs.name }} 57 | push: ${{ github.event_name != 'pull_request' }} 58 | tags: free60/toolchain:${{steps.slugify.outputs.branch}}-${{steps.slugify.outputs.sha}},free60/toolchain:latest 59 | cache-from: type=local,src=/tmp/.buildx-cache-toolchain 60 | cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-toolchain-new 61 | 62 | - name: Build and push LibXenon 63 | id: docker_build_libxenon 64 | uses: docker/build-push-action@v6 65 | with: 66 | context: ./ 67 | file: ./libxenon.dockerfile 68 | builder: ${{ steps.buildx.outputs.name }} 69 | push: ${{ github.event_name != 'pull_request' }} 70 | tags: free60/libxenon:${{steps.slugify.outputs.branch}}-${{steps.slugify.outputs.sha}},free60/libxenon:latest 71 | cache-from: type=local,src=/tmp/.buildx-cache-libxenon 72 | cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-libxenon-new 73 | 74 | - name: Image digest 75 | run: | 76 | echo toolchain image ${{ steps.docker_build_toolchain.outputs.digest }} 77 | echo libxenon image ${{ steps.docker_build_libxenon.outputs.digest }} 78 | 79 | # Temp fix 80 | # https://github.com/docker/build-push-action/issues/252 81 | # https://github.com/moby/buildkit/issues/1896 82 | - name: Move cache 83 | run: | 84 | rm -rf /tmp/.buildx-cache-toolchain 85 | rm -rf /tmp/.buildx-cache-libxenon 86 | mv /tmp/.buildx-cache-toolchain-new /tmp/.buildx-cache-toolchain 87 | mv /tmp/.buildx-cache-libxenon-new /tmp/.buildx-cache-libxenon 88 | -------------------------------------------------------------------------------- /.github/workflows/doxygen.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | 7 | jobs: 8 | build_documentation: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - name: Build documentation 15 | uses: mattnotmitt/doxygen-action@v1.9.5 16 | 17 | - name: Deploy to github pages 18 | uses: peaceiris/actions-gh-pages@v4 19 | with: 20 | github_token: ${{ secrets.GITHUB_TOKEN }} 21 | publish_dir: ./docs/html 22 | destination_dir: docs 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | *.a 4 | toolchain/build 5 | toolchain/build.log 6 | toolchain/*.tar.gz 7 | toolchain/*.tar.bz2 8 | toolchain/*.tar.xz 9 | docs/ 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LibXenon 2 | [![GitHub Workflow - Docker](https://img.shields.io/github/actions/workflow/status/Free60Project/libxenon/docker.yml?label=docker)](https://github.com/Free60Project/libxenon/actions?query=workflow%3Adocker) 3 | [![GitHub pages - documentation](https://img.shields.io/github/actions/workflow/status/Free60Project/libxenon/doxygen.yml?label=documentation)](https://free60project.github.io/libxenon/) 4 | [![Docker pulls (LibXenon)](https://img.shields.io/docker/pulls/free60/libxenon?label=docker%20pulls%20%28libxenon%29)](https://hub.docker.com/r/free60/libxenon) 5 | [![Docker pulls (Toolchain)](https://img.shields.io/docker/pulls/free60/toolchain?label=docker%20pulls%20%28toolchain%29)](https://hub.docker.com/r/free60/toolchain) 6 | 7 | LibXenon provides a bare-metal homebrew library for the Xbox 360 gaming console. 8 | 9 | ## Prebuilt images 10 | 11 | Check out (https://hub.docker.com/u/free60) 12 | 13 | Example usage 14 | 15 | ``` 16 | host $ cd libxenon-homebrew-app/ 17 | host $ docker run -it -v $PWD:/app free60/libxenon:latest 18 | docker $ cd /app 19 | docker $ make 20 | ``` 21 | 22 | ## Manual build 23 | 24 | ### Requirements 25 | 26 | Dependencies for Linux distributions using the `dnf` or `apt` package managers will automatically be installed for you. These include: 27 | 28 | - flex 29 | - bison 30 | - gcc-multilib 31 | - libgmp3-dev 32 | - libmpfr-dev 33 | - libmpc-dev 34 | - texinfo 35 | - git-core 36 | - build-essential 37 | - wget 38 | - file 39 | 40 | If you are not using a Linux system with either the `dnf` or `apt` package manager, ensure the above equivalents are installed before running the main driving script to setup LibXenon, which is named `toolchain/build-xenon-toolchain`. See below on how to use it. 41 | 42 | ### Prefix 43 | 44 | By default the prefix is set to `/usr/local/xenon`. If you want to choose your own prefix, prepend it to the `./build-xenon-toolchain` invocation, i.e. `PREFIX="/home/username/xenon" ./build-xenon-toolchain toolchain`. 45 | 46 | ### Installing the toolchain 47 | 48 | ``` 49 | ./build-xenon-toolchain toolchain 50 | ``` 51 | 52 | ### Installing the libxenon library 53 | 54 | ``` 55 | ./build-xenon-toolchain libxenon 56 | ``` 57 | 58 | ### Installing auxiliary libs (libxenon, bin2s, zlib, libpng, bzip2, freetype, filesystems) 59 | 60 | ``` 61 | ./build-xenon-toolchain libs 62 | ``` 63 | 64 | ### Environment variables 65 | 66 | After installation of the toolchain, the following environment variables need to be populated: 67 | 68 | ``` 69 | DEVKITXENON="/usr/local/xenon" 70 | PATH="${PATH:+${PATH}:}"$DEVKITXENON"/bin:"$DEVKITXENON"/usr/bin" 71 | ``` 72 | `DEVKITXENON` depends on your chosen installation prefix location. The default value is `/usr/local/xenon` unless you changed it. 73 | 74 | You may edit your ~/.bashrc to set these in every shell automatically. Alternatively, you may execute `./build-xenon-toolchain env-cmd` to install a command named `xenon-env`. When you run that command, it will set those variables in a new shell. -------------------------------------------------------------------------------- /devkitxenon/LICENSE: -------------------------------------------------------------------------------- 1 | there's some stuff stolen from devkitPRO (http://www.devkitpro.org/), mainly 2 | makefile magic. 3 | 4 | so the makefile stuff is GPLed. 5 | libxenon, of course, is not; that one is BSD. example codes are BSD as well. 6 | -------------------------------------------------------------------------------- /devkitxenon/app.lds: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | SECTIONS 3 | { 4 | . = 0x80000000; 5 | .text : { *(.except*); *(.pagetable); pagetable_end = .; *(.init*); *(.fini*); *(.text*); } 6 | .elfldr : { elfldr_start = .;*(.elfldr); elfldr_end = .;} 7 | 8 | .data : { *(.data*) } 9 | .sdata : { *(.sdata*) } 10 | .rodata : { *(.rodata*)} 11 | 12 | .ctors : { __CTOR_LIST__ = .; *(.ctors); __CTOR_END__ = .; } 13 | .dtors : {__DTOR_LIST__ = .; *(.dtors); __DTOR_END__ = .; } 14 | 15 | .eh_frame_hdr : { *(.eh_frame_hdr) } 16 | .eh_frame ALIGN(0x4): { PROVIDE (__eh_frame_start = .); KEEP (*(.eh_frame)) LONG (0); } 17 | .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) } 18 | 19 | bss_start = .; 20 | .bss : { *(.bss.beginning.lower); *(.bss.beginning.upper); *(.bss*) } 21 | .sbss : { *(.sbss .sbss.*) } 22 | bss_end = .; 23 | 24 | heap_begin = .; 25 | . = 0x9E000000; 26 | __libc_stack_end = . ; 27 | heap_end = .; 28 | . = 0xa0000000; 29 | } 30 | -------------------------------------------------------------------------------- /devkitxenon/examples/xenon/graphics/cube/files/README: -------------------------------------------------------------------------------- 1 | Shaders must be compiled. This can be done with Tser's Shadercompiler, which 2 | uses the XNA Framework. This requires Windows, Visual Studio Express 2008 3 | (C#), and XNA 3.0. (It also works with older XNA releases) 4 | 5 | You can get the shader compiler from 6 | 7 | http://minilgos.perso.sfr.fr/xenkit/rshadercompiler.zip 8 | 9 | You need to create a new project, add the Reference to Microsoft.XNA, and 10 | insert the Program.cs. 11 | 12 | Once you built the .exe, compile with 13 | 14 | shadercompiler.exe vs.hlsl vs.vsu /vs 15 | shadercompiler.exe ps.hlsl ps.psu /ps 16 | 17 | Have fun! 18 | -------------------------------------------------------------------------------- /devkitxenon/examples/xenon/graphics/cube/files/ps.hlsl: -------------------------------------------------------------------------------- 1 | float4 lightDirection: register(c0); 2 | 3 | /* 4 | define the ps input. 5 | this must match the vertex shader output, except for oPosition (and other fixed-function 6 | things like fog) 7 | */ 8 | 9 | struct Input 10 | { 11 | float3 oNormal: NORMAL; 12 | float4 oUV: TEXCOORD0; 13 | }; 14 | 15 | sampler s; 16 | 17 | float4 main(Input input): COLOR 18 | { 19 | float4 tex = tex2D(s, input.oUV); 20 | float4 res; 21 | res.rgb = dot(input.oNormal, lightDirection) * tex; 22 | res.a = tex.a; 23 | return res; 24 | } 25 | -------------------------------------------------------------------------------- /devkitxenon/examples/xenon/graphics/cube/files/ps.psu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Free60Project/libxenon/08811c2f36919d0a0cc5d2ec2a71fff267e331f3/devkitxenon/examples/xenon/graphics/cube/files/ps.psu -------------------------------------------------------------------------------- /devkitxenon/examples/xenon/graphics/cube/files/vs.hlsl: -------------------------------------------------------------------------------- 1 | float4x4 modelView: register (c0); 2 | float4x3 modelWorld: register (c4); 3 | 4 | /* 5 | define the vs input. 6 | technically, there aren't restrictions on that, other than that all referenced 7 | semantics must be available in the vertex buffer format. 8 | if they are not, shader instantiation will fail. Neither the order nor the actual 9 | format does matter. Both will be fixed up on shader load anyway. 10 | */ 11 | 12 | struct Input 13 | { 14 | float4 vPos: POSITION; 15 | float4 vNormal: NORMAL; 16 | float4 vUV: TEXCOORD0; 17 | }; 18 | 19 | /* 20 | define the vs output and ps input. 21 | This *must* match the ps input, as we do not patch shaders to match. 22 | However, in the pixel shader, you can leave out oPos etc. 23 | */ 24 | 25 | struct Output 26 | { 27 | float4 oPos: POSITION; 28 | float3 oNormal: NORMAL; 29 | float4 oUV: TEXCOORD0; 30 | }; 31 | 32 | Output main(Input input) 33 | { 34 | Output output; 35 | output.oPos = mul(transpose(modelView), input.vPos); 36 | output.oNormal = mul(transpose(modelWorld), input.vNormal.xyz); 37 | output.oUV = input.vUV; 38 | return output; 39 | } 40 | -------------------------------------------------------------------------------- /devkitxenon/examples/xenon/graphics/cube/files/vs.vsu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Free60Project/libxenon/08811c2f36919d0a0cc5d2ec2a71fff267e331f3/devkitxenon/examples/xenon/graphics/cube/files/vs.vsu -------------------------------------------------------------------------------- /devkitxenon/examples/xenon/graphics/cube/genffs.py: -------------------------------------------------------------------------------- 1 | #!/bin/python 2 | import string, glob 3 | 4 | BASEDIR = "data/" 5 | 6 | gfilelist = ["*su"] 7 | #["color.psu", "color.vsu", "texture.psu", "texture.vsu", "shaders/bm_*.vsu", "shaders/bm_*.psu", "test.kx", "shaders/gen/*su"] 8 | 9 | filelist = [] 10 | for f in gfilelist: 11 | filelist += glob.glob(BASEDIR + f) 12 | 13 | files = {} 14 | for f in filelist: 15 | files[f] = open(f, "rb").read() 16 | 17 | used = set() 18 | 19 | def filter_fn(f): 20 | global used 21 | res = "" 22 | for c in f: 23 | if c in string.letters: 24 | res += c 25 | ores = res 26 | cnt =0 27 | while res in used: 28 | res = ores + "_%d" % cnt 29 | cnt += 1 30 | used.add(res) 31 | return res 32 | 33 | flookup = {} 34 | 35 | for f in filelist: 36 | cfn = filter_fn(f) 37 | flookup[f] = cfn 38 | print "static unsigned char content_%s[] = {" % cfn 39 | i = 0 40 | for c in files[f]: 41 | print "0x%02x," % ord(c), 42 | 43 | if i & 15 == 15: 44 | print 45 | 46 | i += 1 47 | print "};" 48 | 49 | print """ 50 | 51 | struct ffs_s 52 | { 53 | const char *filename; 54 | int size; 55 | void *content; 56 | } ffs_files[] = {""" 57 | 58 | for f in files: 59 | print ' {"%s", %d, content_%s},' % (f[len(BASEDIR):], len(files[f]), flookup[f]) 60 | 61 | print ' {0, 0, 0},' 62 | 63 | print "};" 64 | -------------------------------------------------------------------------------- /devkitxenon/examples/xenon/graphics/cube/source/xee.c: -------------------------------------------------------------------------------- 1 | #include "xee.h" 2 | #include 3 | #include 4 | #include 5 | 6 | void M_Load44(struct XenosDevice *xe, int base, eMatrix44 *matrix) 7 | { 8 | Xe_SetVertexShaderConstantF(xe, base, (float*)matrix, 4); 9 | } 10 | 11 | void M_Load43(struct XenosDevice *xe, int base, eMatrix43 *matrix) 12 | { 13 | Xe_SetVertexShaderConstantF(xe, base, (float*)matrix, 3); 14 | } 15 | 16 | const eMatrix44 g_ident = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}; 17 | 18 | void M_BuildPersp(eMatrix44 *m, float fovy, float aspect, float f, float n) 19 | { 20 | float cot = 1.0f / tanf(fovy * 0.5F); 21 | float tmp = 1.0f / (f-n); 22 | 23 | eMatrix44 _m = { 24 | {cot / aspect, 0, 0, 0}, 25 | {0, cot, 0, 0}, 26 | {0, 0, -n * tmp, 1}, 27 | {0, 0, -(f*n) * tmp, 0}}; 28 | memcpy(m, _m, sizeof(_m)); 29 | } 30 | 31 | void M_Dump(const char *name, eMatrix44 *m) 32 | { 33 | int i, j; 34 | printf("-- %s:\n", name); 35 | for (i=0; i<4; ++i) 36 | { 37 | for (j=0; j<4; ++j) 38 | printf("%3.3f ", (*m)[i][j]); 39 | printf("\n"); 40 | } 41 | } 42 | 43 | eMatrix44 g_proj; 44 | 45 | void M_LoadMV(struct XenosDevice *xe, int where) 46 | { 47 | eMatrix44 res, worldview; 48 | memcpy(worldview, g_ident, sizeof(eMatrix44)); 49 | memcpy(worldview, &matrix_stack[matrix_top], sizeof(eMatrix43)); 50 | 51 | multiply_matrix_44(res, g_proj, worldview); 52 | 53 | res[0][3] = -res[0][3]; 54 | res[1][3] = -res[1][3]; 55 | res[2][3] = -res[2][3]; 56 | res[3][3] = -res[3][3]; 57 | M_Load44(xe, where, &res); 58 | } 59 | 60 | void M_LoadMW(struct XenosDevice *xe, int where) 61 | { 62 | eMatrix44 world; 63 | memcpy(world, g_ident, sizeof(eMatrix44)); 64 | memcpy(world, &matrix_stack[matrix_top], sizeof(eMatrix43)); 65 | M_Load44(xe, where, world); 66 | } 67 | -------------------------------------------------------------------------------- /devkitxenon/examples/xenon/graphics/cube/source/xee.h: -------------------------------------------------------------------------------- 1 | #ifndef __xee_h 2 | #define __xee_h 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include "engine.h" 10 | 11 | void M_Load44(struct XenosDevice *xe, int base, eMatrix44 *matrix); 12 | void M_Load43(struct XenosDevice *xe, int base, eMatrix43 *matrix); 13 | 14 | extern const eMatrix44 g_ident; 15 | void M_BuildPersp(eMatrix44 *m, float fovy, float aspect, float f, float n); 16 | void M_Dump(const char *name, eMatrix44 *m); 17 | 18 | extern eMatrix44 g_proj; 19 | void M_LoadMV(struct XenosDevice *xe, int where); 20 | void M_LoadMW(struct XenosDevice *xe, int where); 21 | 22 | #ifdef __cplusplus 23 | }; 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /devkitxenon/rules: -------------------------------------------------------------------------------- 1 | # parts taken from devkitppc 2 | 3 | PREFIX := xenon- 4 | 5 | export AS := $(PREFIX)as 6 | export CC := $(PREFIX)gcc 7 | export CXX := $(PREFIX)g++ 8 | export AR := $(PREFIX)ar 9 | export OBJCOPY := $(PREFIX)objcopy 10 | 11 | LDSCRIPT := $(DEVKITXENON)/app.lds 12 | 13 | %.a: 14 | @echo [$(notdir $@)] 15 | @rm -f $@ 16 | @$(AR) -rc $@ $^ 17 | 18 | %.o: %.cpp 19 | @echo [$(notdir $<)] 20 | @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ 21 | 22 | %.o: %.cc 23 | @echo [$(notdir $<)] 24 | @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ 25 | 26 | %.o: %.c 27 | @echo [$(notdir $<)] 28 | @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@ 29 | 30 | %.o: %.m 31 | @echo [$(notdir $<)] 32 | @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(OBJCFLAGS) -c $< -o $@ 33 | 34 | %.o: %.s 35 | @echo ($(notdir $<)] 36 | @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ 37 | 38 | %.o: %.S 39 | @echo [$(notdir $<)] 40 | @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ 41 | 42 | %.elf: 43 | @echo linking ... $(notdir $@) 44 | @$(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -n -T $(LDSCRIPT) -o $@ 45 | 46 | %.elf32: %.elf 47 | @echo converting and stripping ... $(notdir $@) 48 | @$(OBJCOPY) -O elf32-powerpc --adjust-vma 0x80000000 $< $@ 49 | @$(PREFIX)strip $@ 50 | 51 | #--------------------------------------------------------------------------------- 52 | # canned command sequence for binary data 53 | #--------------------------------------------------------------------------------- 54 | define bin2o 55 | bin2s $< | $(AS) -a32 -o $(@) 56 | echo "extern const u8" `(echo $( `(echo $(> `(echo $(> `(echo $( 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | extern uint32_t console_color[2]; 11 | extern uint32_t console_oldbg, console_oldfg; 12 | 13 | #define CONSOLE_COLOR_RED 0x0000FF00 14 | #define CONSOLE_COLOR_BLUE 0xD8444E00 15 | #define CONSOLE_COLOR_GREEN 0x00800000 16 | #define CONSOLE_COLOR_BLACK 0x00000000 17 | #define CONSOLE_COLOR_WHITE 0xFFFFFF00 18 | #define CONSOLE_COLOR_GREY 0xC0C0C000 19 | #define CONSOLE_COLOR_BROWN 0x00339900 20 | #define CONSOLE_COLOR_PURPLE 0xFF009900 21 | #define CONSOLE_COLOR_YELLOW 0x00FFFF00 22 | #define CONSOLE_COLOR_ORANGE 0x0066FF00 23 | #define CONSOLE_COLOR_PINK 0xFF66FF00 24 | 25 | #define CONSOLE_WARN CONSOLE_COLOR_YELLOW 26 | #define CONSOLE_ERR CONSOLE_COLOR_ORANGE 27 | 28 | #define PRINT_COL(bg, fg, s, ...) { \ 29 | console_oldbg = console_color[0]; console_oldfg = console_color[1]; \ 30 | console_set_colors(bg,fg); \ 31 | printf(s, ##__VA_ARGS__); \ 32 | console_set_colors(console_oldbg,console_oldfg); } 33 | 34 | #define PRINT_WARN(s, ...) PRINT_COL(console_color[0],CONSOLE_WARN, s, ##__VA_ARGS__) 35 | #define PRINT_ERR(s, ...) PRINT_COL(console_color[0],CONSOLE_ERR, s, ##__VA_ARGS__) 36 | 37 | void console_set_colors(unsigned int background, unsigned int foreground); // can be called before init 38 | void console_get_dimensions(unsigned int * width,unsigned int * height); 39 | void console_putch(const char c); 40 | void console_clrscr(); 41 | void console_clrline(); 42 | void console_init(void); 43 | void console_close(void); 44 | 45 | #ifdef __cplusplus 46 | }; 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libxenon/drivers/console/font_8x16.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Free60Project/libxenon/08811c2f36919d0a0cc5d2ec2a71fff267e331f3/libxenon/drivers/console/font_8x16.h -------------------------------------------------------------------------------- /libxenon/drivers/console/telnet_console.h: -------------------------------------------------------------------------------- 1 | #ifndef __console_telnet_console_h 2 | #define __console_telnet_console_h 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void telnet_console_init(); 9 | void telnet_console_tx_print(const char *buf, int bc); 10 | void telnet_console_close(); 11 | 12 | #ifdef __cplusplus 13 | }; 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /libxenon/drivers/crypt/hmac_sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hmac_sha1.h 3 | * 4 | * Version 1.0.0 5 | * 6 | * Written by Aaron D. Gifford 7 | * 8 | * Copyright 1998, 2000 Aaron D. Gifford. All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of the copyright holder nor the names of contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef HEADER_HMAC_SHA1_H 36 | #define HEADER_HMAC_SHA1_H 37 | 38 | /* 39 | * Include SHA-1 stuff - CHOOSE WHICH SOURCE to use for the SHA1 functions 40 | * 41 | * Use the below include if your system has a library with SHA1 and be sure 42 | * to link to the library: 43 | */ 44 | 45 | /* #include */ 46 | 47 | /* 48 | * Or you can use Steve Reid's public domain SHA1 implementation: 49 | */ 50 | 51 | #include "sha.h" 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | #define HMAC_SHA1_DIGEST_LENGTH 20 58 | #define HMAC_SHA1_BLOCK_LENGTH 64 59 | 60 | /* The HMAC_SHA1 structure: */ 61 | typedef struct _HMAC_SHA1_CTX { 62 | unsigned char ipad[HMAC_SHA1_BLOCK_LENGTH]; 63 | unsigned char opad[HMAC_SHA1_BLOCK_LENGTH]; 64 | SHA_CTX shactx; 65 | unsigned char key[HMAC_SHA1_BLOCK_LENGTH]; 66 | unsigned int keylen; 67 | unsigned int hashkey; 68 | } HMAC_SHA1_CTX; 69 | 70 | #ifndef NOPROTO 71 | void HMAC_SHA1_Init(HMAC_SHA1_CTX *ctx); 72 | void HMAC_SHA1_UpdateKey(HMAC_SHA1_CTX *ctx, unsigned char *key, unsigned int keylen); 73 | void HMAC_SHA1_EndKey(HMAC_SHA1_CTX *ctx); 74 | void HMAC_SHA1_StartMessage(HMAC_SHA1_CTX *ctx); 75 | void HMAC_SHA1_UpdateMessage(HMAC_SHA1_CTX *ctx, unsigned char *data, unsigned int datalen); 76 | void HMAC_SHA1_EndMessage(unsigned char *out, HMAC_SHA1_CTX *ctx); 77 | void HMAC_SHA1_Done(HMAC_SHA1_CTX *ctx); 78 | void HMAC_SHA1(void *secret, void *data, void *res, int len); 79 | #else 80 | void HMAC_SHA1_Init(); 81 | void HMAC_SHA1_UpdateKey(); 82 | void HMAC_SHA1_EndKey(); 83 | void HMAC_SHA1_StartMessage(); 84 | void HMAC_SHA1_UpdateMessage(); 85 | void HMAC_SHA1_EndMessage(); 86 | void HMAC_SHA1_Done(); 87 | #endif 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /libxenon/drivers/crypt/rc4.c: -------------------------------------------------------------------------------- 1 | //#include "stdafx.h" 2 | #include "rc4.h" 3 | 4 | 5 | void rc4_init(unsigned char *state, unsigned char *key, int len) 6 | { 7 | //FYI state = unsigned char rc4[0x100]; 8 | 9 | int i, j=0, t; 10 | 11 | for (i=0; i < 256; ++i) 12 | state[i] = i; 13 | 14 | for (i=0; i < 256; ++i) { 15 | j = (j + state[i] + key[i % len]) % 256; 16 | t = state[i]; 17 | state[i] = state[j]; 18 | state[j] = t; 19 | } 20 | } 21 | 22 | void rc4_crypt(unsigned char *state, unsigned char *data, int len) 23 | { 24 | //FYI state = unsigned char rc4[0x100]; 25 | 26 | int i=0,j=0,x,t; 27 | 28 | for (x=0; x < len; ++x) { 29 | i = (i + 1) % 256; 30 | j = (j + state[i]) % 256; 31 | t = state[i]; 32 | state[i] = state[j]; 33 | state[j] = t; 34 | *data++ ^= state[(state[i] + state[j]) % 256]; 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /libxenon/drivers/crypt/rc4.h: -------------------------------------------------------------------------------- 1 | #ifndef _RC4_H_ 2 | #define _RC4_H_ 3 | 4 | void rc4_init(unsigned char *state, unsigned char *key, int len); 5 | void rc4_crypt(unsigned char *state, unsigned char *data, int len); 6 | 7 | #endif // _RC4_H_ 8 | 9 | -------------------------------------------------------------------------------- /libxenon/drivers/crypt/sha.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sha.h 3 | * 4 | * Originally taken from the public domain SHA1 implementation 5 | * written by by Steve Reid 6 | * 7 | * Modified by Aaron D. Gifford 8 | * 9 | * NO COPYRIGHT - THIS IS 100% IN THE PUBLIC DOMAIN 10 | * 11 | * The original unmodified version is available at: 12 | * ftp://ftp.funet.fi/pub/crypt/hash/sha/sha1.c 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef __SHA1_H__ 28 | #define __SHA1_H__ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* Define this if your machine is LITTLE_ENDIAN, otherwise #undef it: */ 35 | #undef LITTLE_ENDIAN 36 | 37 | /* Make sure you define these types for your architecture: */ 38 | typedef unsigned int sha1_quadbyte; /* 4 byte type */ 39 | typedef unsigned char sha1_byte; /* single byte type */ 40 | 41 | /* 42 | * Be sure to get the above definitions right. For instance, on my 43 | * x86 based FreeBSD box, I define LITTLE_ENDIAN and use the type 44 | * "unsigned long" for the quadbyte. On FreeBSD on the Alpha, however, 45 | * while I still use LITTLE_ENDIAN, I must define the quadbyte type 46 | * as "unsigned int" instead. 47 | */ 48 | 49 | #define SHA1_BLOCK_LENGTH 64 50 | #define SHA1_DIGEST_LENGTH 20 51 | 52 | /* The SHA1 structure: */ 53 | typedef struct _SHA_CTX { 54 | sha1_quadbyte state[5]; 55 | sha1_quadbyte count[2]; 56 | sha1_byte buffer[SHA1_BLOCK_LENGTH]; 57 | } SHA_CTX; 58 | 59 | #ifndef NOPROTO 60 | void SHA1_Init(SHA_CTX *context); 61 | void SHA1_Update(SHA_CTX *context, sha1_byte *data, unsigned int len); 62 | void SHA1_Final(sha1_byte digest[SHA1_DIGEST_LENGTH], SHA_CTX* context); 63 | #else 64 | void SHA1_Init(); 65 | void SHA1_Update(); 66 | void SHA1_Final(); 67 | #endif 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /libxenon/drivers/diskio/ata.h: -------------------------------------------------------------------------------- 1 | #ifndef H_ATA 2 | #define H_ATA 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif /* __cplusplus */ 9 | 10 | #define XENON_ATA_REG_DATA 0 11 | #define XENON_ATA_REG_ERROR 1 12 | #define XENON_ATA_REG_FEATURES 1 13 | #define XENON_ATA_REG_SECTORS 2 14 | #define XENON_ATA_REG_SECTNUM 3 15 | #define XENON_ATA_REG_CYLLSB 4 16 | #define XENON_ATA_REG_CYLMSB 5 17 | #define XENON_ATA_REG_LBALOW 3 18 | #define XENON_ATA_REG_LBAMID 4 19 | #define XENON_ATA_REG_LBAHIGH 5 20 | #define XENON_ATA_REG_DISK 6 21 | #define XENON_ATA_REG_CMD 7 22 | #define XENON_ATA_REG_STATUS 7 23 | 24 | #define XENON_ATA_REG2_CONTROL 0 25 | 26 | #include "disc_io.h" 27 | 28 | enum xenon_ata_commands { 29 | XENON_ATA_CMD_READ_SECTORS = 0x20, 30 | XENON_ATA_CMD_READ_SECTORS_EXT = 0x24, 31 | XENON_ATA_CMD_READ_DMA_EXT = 0x25, 32 | XENON_ATA_CMD_WRITE_SECTORS = 0x30, 33 | XENON_ATA_CMD_WRITE_SECTORS_EXT = 0x34, 34 | XENON_ATA_CMD_IDENTIFY_DEVICE = 0xEC, 35 | XENON_ATA_CMD_IDENTIFY_PACKET_DEVICE = 0xA1, 36 | XENON_ATA_CMD_PACKET = 0xA0, 37 | XENON_ATA_CMD_SET_FEATURES = 0xEF, 38 | }; 39 | 40 | enum { 41 | XENON_ATA_CHS = 0, 42 | XENON_ATA_LBA, 43 | XENON_ATA_LBA48 44 | }; 45 | 46 | #define XENON_DISK_SECTOR_SIZE 0x200 47 | #define XENON_CDROM_SECTOR_SIZE 2048 48 | 49 | enum { 50 | XENON_ATA_DMA_TABLE_OFS = 4, 51 | XENON_ATA_DMA_STATUS = 2, 52 | XENON_ATA_DMA_CMD = 0, 53 | XENON_ATA_DMA_WR = (1 << 3), 54 | XENON_ATA_DMA_START = (1 << 0), 55 | XENON_ATA_DMA_INTR = (1 << 2), 56 | XENON_ATA_DMA_ERR = (1 << 1), 57 | XENON_ATA_DMA_ACTIVE = (1 << 0), 58 | }; 59 | 60 | #define MAX_PRDS 16 61 | 62 | struct xenon_ata_dma_prd { 63 | uint32_t address; 64 | uint32_t size_flags; 65 | } __attribute__((packed)); 66 | 67 | struct xenon_ata_device { 68 | uint32_t ioaddress; 69 | uint32_t ioaddress2; 70 | 71 | int atapi; 72 | 73 | int addressing_mode; 74 | 75 | uint16_t cylinders; 76 | uint16_t heads; 77 | uint16_t sectors_per_track; 78 | 79 | uint32_t size; 80 | struct bdev *bdev; 81 | 82 | struct xenon_ata_dma_prd * prds; 83 | }; 84 | 85 | struct xenon_atapi_read { 86 | uint8_t code; 87 | uint8_t reserved1; 88 | uint32_t lba; 89 | uint8_t reserved2; 90 | uint16_t length; 91 | uint8_t reserved3[3]; 92 | } __attribute__((packed)); 93 | 94 | int xenon_ata_init(); 95 | int xenon_atapi_init(); 96 | void xenon_atapi_set_modeb(void); 97 | int xenon_atapi_get_dvd_key_tsh943a(unsigned char *dvdkey); 98 | int xenon_atapi_set_dvd_key(unsigned char *dvdkey); 99 | 100 | extern struct xenon_ata_device ata; 101 | extern struct xenon_ata_device atapi; 102 | 103 | #ifdef __cplusplus 104 | } 105 | #endif /* __cplusplus */ 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /libxenon/drivers/diskio/disc_io.h: -------------------------------------------------------------------------------- 1 | /* 2 | disc_io.h 3 | Interface template for low level disc functions. 4 | 5 | Copyright (c) 2006 Michael "Chishm" Chisholm 6 | Based on code originally written by MightyMax 7 | 8 | Redistribution and use in source and binary forms, with or without modification, 9 | are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation and/or 15 | other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 21 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef OGC_DISC_IO_INCLUDE 31 | #define OGC_DISC_IO_INCLUDE 32 | 33 | #include 34 | #include 35 | 36 | #define MAXDEVICES 16 37 | #define DISKIO_ERROR_NO_MEDIA -8 38 | 39 | #define FEATURE_MEDIUM_CANREAD 0x00000001 40 | #define FEATURE_MEDIUM_CANWRITE 0x00000002 41 | #define FEATURE_XENON_ATA 0x00000100 42 | #define FEATURE_XENON_ATAPI 0x00000200 43 | #define FEATURE_XENON_USB 0x00000400 44 | 45 | typedef uint32_t sec_t; 46 | 47 | typedef bool (* FN_MEDIUM_STARTUP)(void) ; 48 | typedef bool (* FN_MEDIUM_ISINSERTED)(void) ; 49 | typedef bool (* FN_MEDIUM_READSECTORS)(sec_t sector, sec_t numSectors, void* buffer) ; 50 | typedef bool (* FN_MEDIUM_WRITESECTORS)(sec_t sector, sec_t numSectors, const void* buffer) ; 51 | typedef bool (* FN_MEDIUM_CLEARSTATUS)(void) ; 52 | typedef bool (* FN_MEDIUM_SHUTDOWN)(void) ; 53 | typedef s32 (* FN_MEDIUM_DEVSECTORS)(void) ; 54 | 55 | struct DISC_INTERFACE_STRUCT { 56 | unsigned long ioType ; 57 | unsigned long features ; 58 | FN_MEDIUM_STARTUP startup ; 59 | FN_MEDIUM_ISINSERTED isInserted ; 60 | FN_MEDIUM_READSECTORS readSectors ; 61 | FN_MEDIUM_WRITESECTORS writeSectors ; 62 | FN_MEDIUM_CLEARSTATUS clearStatus ; 63 | FN_MEDIUM_SHUTDOWN shutdown ; 64 | FN_MEDIUM_DEVSECTORS sectors; 65 | } ; 66 | 67 | typedef struct DISC_INTERFACE_STRUCT DISC_INTERFACE ; 68 | 69 | void register_disc_interface(DISC_INTERFACE *disc_io); 70 | void unregister_disc_interface(DISC_INTERFACE *disc_io); 71 | 72 | #endif // define OGC_DISC_IO_INCLUDE 73 | -------------------------------------------------------------------------------- /libxenon/drivers/elf/elf.h: -------------------------------------------------------------------------------- 1 | #ifndef ELF_H 2 | #define ELF_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | char *argv_GetFilename(const char *argv); 9 | char *argv_GetFilepath(const char *argv); 10 | char *argv_GetDevice(const char *argv); 11 | void elf_setArgcArgv(int argc, char *argv[]); 12 | int elf_runFromMemory(void *addr, int size); 13 | int elf_runFromDisk(char *filename); 14 | int elf_runWithDeviceTree(void *elf_addr, int elf_size, void *dt_addr, 15 | int dt_size); 16 | int kernel_prepare_initrd(void *start, size_t size); 17 | void kernel_relocate_initrd(void *start, size_t size); 18 | void kernel_reset_initrd(void); 19 | void kernel_build_cmdline(const char *parameters, const char *root); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif /* ELF_H */ 26 | 27 | -------------------------------------------------------------------------------- /libxenon/drivers/elf/elf_run.S: -------------------------------------------------------------------------------- 1 | .section ".elfldr" 2 | 3 | #include 4 | 5 | // NOTE: All code in this file is relocated. In order to access any static data, 6 | // you must use the offset register r2. 7 | 8 | .globl elf_call_real 9 | elf_call_real: 10 | /* r3 = real address */ 11 | mtsrr0 %r3 12 | 13 | /* Clear IR/DR and set 32bit mode */ 14 | mfmsr %r11 15 | li %r12, 0x30 16 | andc %r11, %r11, %r12 17 | rldicl %r11, %r11, 0, 1 18 | mtsrr1 %r11 19 | 20 | /* real-mode-ize the stack pointer */ 21 | clrldi %r1, %r1, 35 22 | 23 | /* Now branch to our real-mode function. */ 24 | rfid 25 | 26 | .globl elf_hold_thread 27 | elf_hold_thread: 28 | // r2 = (ELF_CODE_RELOC_START - elfldr_start) (offset to reloc code) 29 | lis %r2, 0x87f8 // This must be ELF_CODE_RELOC_START@h 30 | lis %r3, elfldr_start@h 31 | ori %r3, %r3, elfldr_start@l 32 | sub %r2, %r2, %r3 33 | 34 | lis %r4, elf_secondary_count@h 35 | ori %r4, %r4, elf_secondary_count@l 36 | 37 | /* tell the loader we're here! */ 38 | 1: lwarx %r3, %r2, %r4 39 | addi %r3, %r3, 1 40 | stwcx. %r3, %r2, %r4 41 | bne- 1b 42 | 43 | lis %r3, elf_secondary_hold_addr@h 44 | ori %r3, %r3, elf_secondary_hold_addr@l 45 | add %r4,%r3,%r2 46 | 47 | 2: 48 | // or %r1, %r1, %r1 /* low priority */ 49 | lwz %r3, 0(%r4) 50 | cmpwi %r3, 0 51 | beq 2b 52 | 53 | /* Fall into elf_run. */ 54 | // or %r2, %r2, %r2 55 | li %r4,0 56 | 57 | .globl elf_run 58 | elf_run: 59 | /* Save arguments for b64 */ 60 | mr %r31,%r3 // entrypoint 61 | mr %r30,%r4 // device tree 62 | 63 | /* Load the relocated b64 routine and set it as the branch target */ 64 | lis %r4, 0x07F8 // This must be ELF_CODE_RELOC_START@h 65 | lis %r3, b64@h 66 | ori %r3, %r3, b64@l 67 | add %r4,%r4,%r3 68 | lis %r3, elfldr_start@h 69 | ori %r3, %r3, elfldr_start@l 70 | sub %r4,%r4,%r3 71 | mtsrr0 %r4 72 | 73 | /* Clear IR/DR and set 64bits mode */ 74 | mfmsr %r3 75 | li %r4, 0x30 76 | andc %r3, %r3, %r4 77 | lis %r4, 0x8000 78 | rldicr %r4, %r4, 32, 31 79 | or %r3, %r3, %r4 80 | mtsrr1 %r3 81 | 82 | /* Return from interrupt because we're swapping to real mode */ 83 | rfid 84 | 85 | b64: 86 | /* invalidate all SLBs */ 87 | isync 88 | slbia 89 | isync 90 | 91 | /* reset page sizes */ 92 | mfspr %r3, hid6 93 | li %r4, 0xF 94 | sldi %r4, %r4, 44 95 | andc %r3, %r3, %r4 96 | li %r4, 0x8 97 | sldi %r4, %r4, 44 98 | or %r3, %r3, %r4 99 | mtspr hid6, %r3 100 | sync 101 | isync 102 | 103 | /* reset TLB reload */ 104 | mfspr %r3, lpcr 105 | li %r4, 0x400 106 | andc %r3,%r3,%r4 107 | mtspr lpcr, %r3 108 | sync 109 | isync 110 | 111 | /* gogogo :) */ 112 | mfspr %r3, pir /* linux wants thread # in r3 for secondary threads */ 113 | cmplwi %r3,0 114 | bne 1f 115 | 116 | // We're the main thread! 117 | mr %r3,%r30 118 | 1: 119 | mr %r4,%r31 120 | li %r5,0 121 | 122 | // Kernel entry: 123 | // r3 = DT physical pointer 124 | // r4 = physical pointer to the kernel 125 | 126 | // Entrypoint (from elf_run) 127 | mtctr %r31 128 | bctr 129 | trap 130 | 131 | .globl elf_secondary_hold_addr 132 | elf_secondary_hold_addr: 133 | .long 0 134 | 135 | .globl elf_secondary_count 136 | elf_secondary_count: 137 | .long 0 138 | -------------------------------------------------------------------------------- /libxenon/drivers/input/input.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static struct controller_data_s ctrl[4]; 4 | static int valid[4]; 5 | 6 | int get_controller_data(struct controller_data_s *d, int port) 7 | { 8 | if (port >= 4) 9 | return 0; 10 | *d = ctrl[port]; 11 | int r = valid[port]; 12 | valid[port] = 0; 13 | return r; 14 | } 15 | 16 | void set_controller_data(int port, const struct controller_data_s *d) 17 | { 18 | if (port >= 4) 19 | return; 20 | ctrl[port] = *d; 21 | valid[port] = 1; 22 | } 23 | 24 | extern int usbctrl_set_rumble(int port, uint8_t l, uint8_t r); 25 | 26 | void set_controller_rumble(int port, uint8_t l, uint8_t r) 27 | { 28 | usbctrl_set_rumble(port, l, r); 29 | } 30 | -------------------------------------------------------------------------------- /libxenon/drivers/input/input.h: -------------------------------------------------------------------------------- 1 | #ifndef __input_h 2 | #define __input_h 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif /* __cplusplus */ 7 | 8 | #include 9 | 10 | struct controller_data_s 11 | { 12 | signed short s1_x, s1_y, s2_x, s2_y; 13 | int s1_z, s2_z, lb, rb, start, back, a, b, x, y, up, down, left, right; 14 | unsigned char lt, rt; 15 | int logo; 16 | }; 17 | 18 | int get_controller_data(struct controller_data_s *d, int port); 19 | 20 | void set_controller_data(int port, const struct controller_data_s *d); 21 | 22 | void set_controller_rumble(int port, uint8_t l, uint8_t r); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif /* __cplusplus */ 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libxenon/drivers/iso9660/iso9660.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * ISO9660 devoptab 3 | * 4 | * Copyright (C) 2008-2010 5 | * tipoloski, clava, shagkur, Tantric, joedj 6 | ****************************************************************************/ 7 | 8 | #ifndef __ISO9660_H__ 9 | #define __ISO9660_H__ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #define MAX_ISO_FILES 8 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | bool ISO9660_Mount(const char* name, const DISC_INTERFACE* disc_interface); 22 | bool ISO9660_Unmount(const char* name); 23 | const char *ISO9660_GetVolumeLabel(const char *name); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /libxenon/drivers/libfdt/fdt.h: -------------------------------------------------------------------------------- 1 | #ifndef _FDT_H 2 | #define _FDT_H 3 | 4 | #ifndef __ASSEMBLY__ 5 | 6 | struct fdt_header { 7 | uint32_t magic; /* magic word FDT_MAGIC */ 8 | uint32_t totalsize; /* total size of DT block */ 9 | uint32_t off_dt_struct; /* offset to structure */ 10 | uint32_t off_dt_strings; /* offset to strings */ 11 | uint32_t off_mem_rsvmap; /* offset to memory reserve map */ 12 | uint32_t version; /* format version */ 13 | uint32_t last_comp_version; /* last compatible version */ 14 | 15 | /* version 2 fields below */ 16 | uint32_t boot_cpuid_phys; /* Which physical CPU id we're 17 | booting on */ 18 | /* version 3 fields below */ 19 | uint32_t size_dt_strings; /* size of the strings block */ 20 | 21 | /* version 17 fields below */ 22 | uint32_t size_dt_struct; /* size of the structure block */ 23 | }; 24 | 25 | struct fdt_reserve_entry { 26 | uint64_t address; 27 | uint64_t size; 28 | }; 29 | 30 | struct fdt_node_header { 31 | uint32_t tag; 32 | char name[0]; 33 | }; 34 | 35 | struct fdt_property { 36 | uint32_t tag; 37 | uint32_t len; 38 | uint32_t nameoff; 39 | char data[0]; 40 | }; 41 | 42 | #endif /* !__ASSEMBLY */ 43 | 44 | #define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ 45 | #define FDT_TAGSIZE sizeof(uint32_t) 46 | 47 | #define FDT_BEGIN_NODE 0x1 /* Start node: full name */ 48 | #define FDT_END_NODE 0x2 /* End node */ 49 | #define FDT_PROP 0x3 /* Property: name off, 50 | size, content */ 51 | #define FDT_NOP 0x4 /* nop */ 52 | #define FDT_END 0x9 53 | 54 | #define FDT_V1_SIZE (7*sizeof(uint32_t)) 55 | #define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(uint32_t)) 56 | #define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(uint32_t)) 57 | #define FDT_V16_SIZE FDT_V3_SIZE 58 | #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(uint32_t)) 59 | 60 | #endif /* _FDT_H */ 61 | -------------------------------------------------------------------------------- /libxenon/drivers/libfdt/libfdt_env.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBFDT_ENV_H 2 | #define _LIBFDT_ENV_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "string.h" 8 | 9 | typedef u8 uint8_t; 10 | typedef u16 uint16_t; 11 | typedef u32 uint32_t; 12 | typedef u64 uint64_t; 13 | 14 | typedef s8 int8_t; 15 | typedef s16 int16_t; 16 | typedef s32 int32_t; 17 | typedef s64 int64_t; 18 | 19 | #define _B(n) ((unsigned long long)((uint8_t *)&x)[n]) 20 | static inline uint32_t fdt32_to_cpu(uint32_t x) 21 | { 22 | return (_B(0) << 24) | (_B(1) << 16) | (_B(2) << 8) | _B(3); 23 | } 24 | #define cpu_to_fdt32(x) fdt32_to_cpu(x) 25 | 26 | static inline uint64_t fdt64_to_cpu(uint64_t x) 27 | { 28 | return (_B(0) << 56) | (_B(1) << 48) | (_B(2) << 40) | (_B(3) << 32) 29 | | (_B(4) << 24) | (_B(5) << 16) | (_B(6) << 8) | _B(7); 30 | } 31 | #define cpu_to_fdt64(x) fdt64_to_cpu(x) 32 | #undef _B 33 | 34 | #endif /* _LIBFDT_ENV_H */ 35 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/CHANGELOG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Free60Project/libxenon/08811c2f36919d0a0cc5d2ec2a71fff267e331f3/libxenon/drivers/lwip/CHANGELOG -------------------------------------------------------------------------------- /libxenon/drivers/lwip/api/err.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Error Management module 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/err.h" 40 | 41 | #ifdef LWIP_DEBUG 42 | 43 | static const char *err_strerr[] = { 44 | "Ok.", /* ERR_OK 0 */ 45 | "Out of memory error.", /* ERR_MEM -1 */ 46 | "Buffer error.", /* ERR_BUF -2 */ 47 | "Timeout.", /* ERR_TIMEOUT -3 */ 48 | "Routing problem.", /* ERR_RTE -4 */ 49 | "Operation in progress.", /* ERR_INPROGRESS -5 */ 50 | "Illegal value.", /* ERR_VAL -6 */ 51 | "Operation would block.", /* ERR_WOULDBLOCK -7 */ 52 | "Address in use.", /* ERR_USE -8 */ 53 | "Already connected.", /* ERR_ISCONN -9 */ 54 | "Connection aborted.", /* ERR_ABRT -10 */ 55 | "Connection reset.", /* ERR_RST -11 */ 56 | "Connection closed.", /* ERR_CLSD -12 */ 57 | "Not connected.", /* ERR_CONN -13 */ 58 | "Illegal argument.", /* ERR_ARG -14 */ 59 | "Low-level netif error.", /* ERR_IF -15 */ 60 | }; 61 | 62 | /** 63 | * Convert an lwip internal error to a string representation. 64 | * 65 | * @param err an lwip internal err_t 66 | * @return a string representation for err 67 | */ 68 | const char * 69 | lwip_strerr(err_t err) 70 | { 71 | return err_strerr[-err]; 72 | 73 | } 74 | 75 | #endif /* LWIP_DEBUG */ 76 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/core/ipv4/inet.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Functions common to all TCP/IPv4 modules, such as the byte order functions. 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | 41 | #include "lwip/inet.h" 42 | 43 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/core/ipv6/README: -------------------------------------------------------------------------------- 1 | IPv6 support in lwIP is very experimental. 2 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/core/ipv6/ip6_addr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #include "lwip/opt.h" 34 | #include "lwip/ip_addr.h" 35 | #include "lwip/inet.h" 36 | 37 | u8_t 38 | ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, 39 | struct ip_addr *mask) 40 | { 41 | return((addr1->addr[0] & mask->addr[0]) == (addr2->addr[0] & mask->addr[0]) && 42 | (addr1->addr[1] & mask->addr[1]) == (addr2->addr[1] & mask->addr[1]) && 43 | (addr1->addr[2] & mask->addr[2]) == (addr2->addr[2] & mask->addr[2]) && 44 | (addr1->addr[3] & mask->addr[3]) == (addr2->addr[3] & mask->addr[3])); 45 | 46 | } 47 | 48 | u8_t 49 | ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2) 50 | { 51 | return(addr1->addr[0] == addr2->addr[0] && 52 | addr1->addr[1] == addr2->addr[1] && 53 | addr1->addr[2] == addr2->addr[2] && 54 | addr1->addr[3] == addr2->addr[3]); 55 | } 56 | 57 | void 58 | ip_addr_set(struct ip_addr *dest, struct ip_addr *src) 59 | { 60 | SMEMCPY(dest, src, sizeof(struct ip_addr)); 61 | /* dest->addr[0] = src->addr[0]; 62 | dest->addr[1] = src->addr[1]; 63 | dest->addr[2] = src->addr[2]; 64 | dest->addr[3] = src->addr[3];*/ 65 | } 66 | 67 | u8_t 68 | ip_addr_isany(struct ip_addr *addr) 69 | { 70 | if (addr == NULL) return 1; 71 | return((addr->addr[0] | addr->addr[1] | addr->addr[2] | addr->addr[3]) == 0); 72 | } 73 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/core/sys.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP Operating System abstraction 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | 41 | #include "lwip/sys.h" 42 | 43 | /* Most of the functions defined in sys.h must be implemented in the 44 | * architecture-dependent file sys_arch.c */ 45 | 46 | #if !NO_SYS 47 | 48 | #ifndef sys_msleep 49 | /** 50 | * Sleep for some ms. Timeouts are NOT processed while sleeping. 51 | * 52 | * @param ms number of milliseconds to sleep 53 | */ 54 | void 55 | sys_msleep(u32_t ms) 56 | { 57 | if (ms > 0) { 58 | sys_sem_t delaysem; 59 | err_t err = sys_sem_new(&delaysem, 0); 60 | if (err == ERR_OK) { 61 | sys_arch_sem_wait(&delaysem, ms); 62 | sys_sem_free(&delaysem); 63 | } 64 | } 65 | } 66 | #endif /* sys_msleep */ 67 | 68 | #endif /* !NO_SYS */ 69 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/include/ipv4/lwip/ip_frag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Jani Monoses 30 | * 31 | */ 32 | 33 | #ifndef __LWIP_IP_FRAG_H__ 34 | #define __LWIP_IP_FRAG_H__ 35 | 36 | #include "lwip/opt.h" 37 | #include "lwip/err.h" 38 | #include "lwip/pbuf.h" 39 | #include "lwip/netif.h" 40 | #include "lwip/ip_addr.h" 41 | #include "lwip/ip.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #if IP_REASSEMBLY 48 | /* The IP reassembly timer interval in milliseconds. */ 49 | #define IP_TMR_INTERVAL 1000 50 | 51 | /* IP reassembly helper struct. 52 | * This is exported because memp needs to know the size. 53 | */ 54 | struct ip_reassdata { 55 | struct ip_reassdata *next; 56 | struct pbuf *p; 57 | struct ip_hdr iphdr; 58 | u16_t datagram_len; 59 | u8_t flags; 60 | u8_t timer; 61 | }; 62 | 63 | void ip_reass_init(void); 64 | void ip_reass_tmr(void); 65 | struct pbuf * ip_reass(struct pbuf *p); 66 | #endif /* IP_REASSEMBLY */ 67 | 68 | #if IP_FRAG 69 | #if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF 70 | /** A custom pbuf that holds a reference to another pbuf, which is freed 71 | * when this custom pbuf is freed. This is used to create a custom PBUF_REF 72 | * that points into the original pbuf. */ 73 | struct pbuf_custom_ref { 74 | /** 'base class' */ 75 | struct pbuf_custom pc; 76 | /** pointer to the original pbuf that is referenced */ 77 | struct pbuf *original; 78 | }; 79 | #endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ 80 | 81 | err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest); 82 | #endif /* IP_FRAG */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* __LWIP_IP_FRAG_H__ */ 89 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/include/ipv6/lwip/icmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_ICMP_H__ 33 | #define __LWIP_ICMP_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ 38 | 39 | #include "lwip/pbuf.h" 40 | #include "lwip/netif.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define ICMP6_DUR 1 47 | #define ICMP6_TE 3 48 | #define ICMP6_ECHO 128 /* echo */ 49 | #define ICMP6_ER 129 /* echo reply */ 50 | 51 | 52 | enum icmp_dur_type { 53 | ICMP_DUR_NET = 0, /* net unreachable */ 54 | ICMP_DUR_HOST = 1, /* host unreachable */ 55 | ICMP_DUR_PROTO = 2, /* protocol unreachable */ 56 | ICMP_DUR_PORT = 3, /* port unreachable */ 57 | ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ 58 | ICMP_DUR_SR = 5 /* source route failed */ 59 | }; 60 | 61 | enum icmp_te_type { 62 | ICMP_TE_TTL = 0, /* time to live exceeded in transit */ 63 | ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ 64 | }; 65 | 66 | void icmp_input(struct pbuf *p, struct netif *inp); 67 | 68 | void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); 69 | void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); 70 | 71 | struct icmp_echo_hdr { 72 | u8_t type; 73 | u8_t icode; 74 | u16_t chksum; 75 | u16_t id; 76 | u16_t seqno; 77 | }; 78 | 79 | struct icmp_dur_hdr { 80 | u8_t type; 81 | u8_t icode; 82 | u16_t chksum; 83 | u32_t unused; 84 | }; 85 | 86 | struct icmp_te_hdr { 87 | u8_t type; 88 | u8_t icode; 89 | u16_t chksum; 90 | u32_t unused; 91 | }; 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* LWIP_ICMP */ 98 | 99 | #endif /* __LWIP_ICMP_H__ */ 100 | 101 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/include/ipv6/lwip/inet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_INET_H__ 33 | #define __LWIP_INET_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/pbuf.h" 37 | #include "lwip/ip_addr.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | u16_t inet_chksum(void *data, u16_t len); 44 | u16_t inet_chksum_pbuf(struct pbuf *p); 45 | u16_t inet_chksum_pseudo(struct pbuf *p, 46 | struct ip_addr *src, struct ip_addr *dest, 47 | u8_t proto, u32_t proto_len); 48 | 49 | u32_t inet_addr(const char *cp); 50 | s8_t inet_aton(const char *cp, struct in_addr *addr); 51 | 52 | #ifndef _MACHINE_ENDIAN_H_ 53 | #ifndef _NETINET_IN_H 54 | #ifndef _LINUX_BYTEORDER_GENERIC_H 55 | u16_t htons(u16_t n); 56 | u16_t ntohs(u16_t n); 57 | u32_t htonl(u32_t n); 58 | u32_t ntohl(u32_t n); 59 | #endif /* _LINUX_BYTEORDER_GENERIC_H */ 60 | #endif /* _NETINET_IN_H */ 61 | #endif /* _MACHINE_ENDIAN_H_ */ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* __LWIP_INET_H__ */ 68 | 69 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/include/lwip/err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_ERR_H__ 33 | #define __LWIP_ERR_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/arch.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** Define LWIP_ERR_T in cc.h if you want to use 43 | * a different type for your platform (must be signed). */ 44 | #ifdef LWIP_ERR_T 45 | typedef LWIP_ERR_T err_t; 46 | #else /* LWIP_ERR_T */ 47 | typedef s8_t err_t; 48 | #endif /* LWIP_ERR_T*/ 49 | 50 | /* Definitions for error constants. */ 51 | 52 | #define ERR_OK 0 /* No error, everything OK. */ 53 | #define ERR_MEM -1 /* Out of memory error. */ 54 | #define ERR_BUF -2 /* Buffer error. */ 55 | #define ERR_TIMEOUT -3 /* Timeout. */ 56 | #define ERR_RTE -4 /* Routing problem. */ 57 | #define ERR_INPROGRESS -5 /* Operation in progress */ 58 | #define ERR_VAL -6 /* Illegal value. */ 59 | #define ERR_WOULDBLOCK -7 /* Operation would block. */ 60 | #define ERR_USE -8 /* Address in use. */ 61 | #define ERR_ISCONN -9 /* Already connected. */ 62 | 63 | #define ERR_IS_FATAL(e) ((e) < ERR_ISCONN) 64 | 65 | #define ERR_ABRT -10 /* Connection aborted. */ 66 | #define ERR_RST -11 /* Connection reset. */ 67 | #define ERR_CLSD -12 /* Connection closed. */ 68 | #define ERR_CONN -13 /* Not connected. */ 69 | 70 | #define ERR_ARG -14 /* Illegal argument. */ 71 | 72 | #define ERR_IF -15 /* Low-level netif error */ 73 | 74 | 75 | #ifdef LWIP_DEBUG 76 | extern const char *lwip_strerr(err_t err); 77 | #else 78 | #define lwip_strerr(x) "" 79 | #endif /* LWIP_DEBUG */ 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* __LWIP_ERR_H__ */ 86 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/include/lwip/init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_INIT_H__ 33 | #define __LWIP_INIT_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /** X.x.x: Major version of the stack */ 42 | #define LWIP_VERSION_MAJOR 1U 43 | /** x.X.x: Minor version of the stack */ 44 | #define LWIP_VERSION_MINOR 4U 45 | /** x.x.X: Revision of the stack */ 46 | #define LWIP_VERSION_REVISION 1U 47 | /** For release candidates, this is set to 1..254 48 | * For official releases, this is set to 255 (LWIP_RC_RELEASE) 49 | * For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */ 50 | #define LWIP_VERSION_RC 255U 51 | 52 | /** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ 53 | #define LWIP_RC_RELEASE 255U 54 | /** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for CVS versions */ 55 | #define LWIP_RC_DEVELOPMENT 0U 56 | 57 | #define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) 58 | #define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) 59 | #define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) 60 | 61 | /** Provides the version of the stack */ 62 | #define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \ 63 | LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC) 64 | 65 | /* Modules initialization */ 66 | void lwip_init(void); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __LWIP_INIT_H__ */ 73 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/include/netif/loopif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __NETIF_LOOPIF_H__ 33 | #define __NETIF_LOOPIF_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/netif.h" 37 | #include "lwip/err.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #if !LWIP_NETIF_LOOPBACK_MULTITHREADING 44 | #define loopif_poll netif_poll 45 | #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ 46 | 47 | err_t loopif_init(struct netif *netif); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* __NETIF_LOOPIF_H__ */ 54 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/include/netif/slipif.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 | */ 34 | #ifndef __NETIF_SLIPIF_H__ 35 | #define __NETIF_SLIPIF_H__ 36 | 37 | #include "lwip/opt.h" 38 | #include "lwip/netif.h" 39 | 40 | /** Set this to 1 to start a thread that blocks reading on the serial line 41 | * (using sio_read()). 42 | */ 43 | #ifndef SLIP_USE_RX_THREAD 44 | #define SLIP_USE_RX_THREAD !NO_SYS 45 | #endif 46 | 47 | /** Set this to 1 to enable functions to pass in RX bytes from ISR context. 48 | * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled 49 | * packets on a queue, which is fed into lwIP from slipif_poll(). 50 | * If disabled, slipif_poll() polls the serila line (using sio_tryread()). 51 | */ 52 | #ifndef SLIP_RX_FROM_ISR 53 | #define SLIP_RX_FROM_ISR 0 54 | #endif 55 | 56 | /** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets 57 | * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. 58 | * If disabled, packets will be dropped if more than one packet is received. 59 | */ 60 | #ifndef SLIP_RX_QUEUE 61 | #define SLIP_RX_QUEUE SLIP_RX_FROM_ISR 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | err_t slipif_init(struct netif * netif); 69 | void slipif_poll(struct netif *netif); 70 | #if SLIP_RX_FROM_ISR 71 | void slipif_process_rxqueue(struct netif *netif); 72 | void slipif_received_byte(struct netif *netif, u8_t data); 73 | void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); 74 | #endif /* SLIP_RX_FROM_ISR */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/include/posix/netdb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/netdb.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/netdb.h" 34 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/include/posix/sys/socket.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/netif/FILES: -------------------------------------------------------------------------------- 1 | This directory contains generic network interface device drivers that 2 | do not contain any hardware or architecture specific code. The files 3 | are: 4 | 5 | etharp.c 6 | Implements the ARP (Address Resolution Protocol) over 7 | Ethernet. The code in this file should be used together with 8 | Ethernet device drivers. Note that this module has been 9 | largely made Ethernet independent so you should be able to 10 | adapt this for other link layers (such as Firewire). 11 | 12 | ethernetif.c 13 | An example of how an Ethernet device driver could look. This 14 | file can be used as a "skeleton" for developing new Ethernet 15 | network device drivers. It uses the etharp.c ARP code. 16 | 17 | loopif.c 18 | A "loopback" network interface driver. It requires configuration 19 | through the define LWIP_LOOPIF_MULTITHREADING (see opt.h). 20 | 21 | slipif.c 22 | A generic implementation of the SLIP (Serial Line IP) 23 | protocol. It requires a sio (serial I/O) module to work. 24 | 25 | ppp/ Point-to-Point Protocol stack 26 | The PPP stack has been ported from ucip (http://ucip.sourceforge.net). 27 | It matches quite well to pppd 2.3.1 (http://ppp.samba.org), although 28 | compared to that, it has some modifications for embedded systems and 29 | the source code has been reordered a bit. -------------------------------------------------------------------------------- /libxenon/drivers/lwip/netif/loopif.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Loop Interface 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | #include "lwip/opt.h" 39 | 40 | #if LWIP_HAVE_LOOPIF 41 | 42 | #include "netif/loopif.h" 43 | #include "lwip/snmp.h" 44 | 45 | /** 46 | * Initialize a lwip network interface structure for a loopback interface 47 | * 48 | * @param netif the lwip network interface structure for this loopif 49 | * @return ERR_OK if the loopif is initialized 50 | * ERR_MEM if private data couldn't be allocated 51 | */ 52 | err_t 53 | loopif_init(struct netif *netif) 54 | { 55 | /* initialize the snmp variables and counters inside the struct netif 56 | * ifSpeed: no assumption can be made! 57 | */ 58 | NETIF_INIT_SNMP(netif, snmp_ifType_softwareLoopback, 0); 59 | 60 | netif->name[0] = 'l'; 61 | netif->name[1] = 'o'; 62 | netif->output = netif_loop_output; 63 | return ERR_OK; 64 | } 65 | 66 | #endif /* LWIP_HAVE_LOOPIF */ 67 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/netif/ppp/chpms.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * chpms.h - Network Microsoft Challenge Handshake Protocol header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1998 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 98-01-30 Guy Lancaster , Global Election Systems Inc. 31 | * Original built from BSD network code. 32 | ******************************************************************************/ 33 | /* 34 | * chap.h - Challenge Handshake Authentication Protocol definitions. 35 | * 36 | * Copyright (c) 1995 Eric Rosenquist, Strata Software Limited. 37 | * http://www.strataware.com/ 38 | * 39 | * All rights reserved. 40 | * 41 | * Redistribution and use in source and binary forms are permitted 42 | * provided that the above copyright notice and this paragraph are 43 | * duplicated in all such forms and that any documentation, 44 | * advertising materials, and other materials related to such 45 | * distribution and use acknowledge that the software was developed 46 | * by Eric Rosenquist. The name of the author may not be used to 47 | * endorse or promote products derived from this software without 48 | * specific prior written permission. 49 | * 50 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 51 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 52 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 53 | * 54 | * $Id: chpms.h,v 1.5 2007/12/19 20:47:23 fbernon Exp $ 55 | */ 56 | 57 | #ifndef CHPMS_H 58 | #define CHPMS_H 59 | 60 | #define MAX_NT_PASSWORD 256 /* Maximum number of (Unicode) chars in an NT password */ 61 | 62 | void ChapMS (chap_state *, char *, int, char *, int); 63 | 64 | #endif /* CHPMS_H */ 65 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/netif/ppp/magic.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * magic.c - Network Random Number Generator program file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1997 by Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc. 31 | * Original based on BSD magic.c. 32 | *****************************************************************************/ 33 | /* 34 | * magic.c - PPP Magic Number routines. 35 | * 36 | * Copyright (c) 1989 Carnegie Mellon University. 37 | * All rights reserved. 38 | * 39 | * Redistribution and use in source and binary forms are permitted 40 | * provided that the above copyright notice and this paragraph are 41 | * duplicated in all such forms and that any documentation, 42 | * advertising materials, and other materials related to such 43 | * distribution and use acknowledge that the software was developed 44 | * by Carnegie Mellon University. The name of the 45 | * University may not be used to endorse or promote products derived 46 | * from this software without specific prior written permission. 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 50 | */ 51 | 52 | #include "lwip/opt.h" 53 | 54 | #if PPP_SUPPORT 55 | 56 | #include "ppp_impl.h" 57 | #include "randm.h" 58 | #include "magic.h" 59 | 60 | 61 | /* 62 | * magicInit - Initialize the magic number generator. 63 | * 64 | * Since we use another random number generator that has its own 65 | * initialization, we do nothing here. 66 | */ 67 | void magicInit() 68 | { 69 | return; 70 | } 71 | 72 | /* 73 | * magic - Returns the next magic number. 74 | */ 75 | u32_t magic() 76 | { 77 | return avRandom(); 78 | } 79 | 80 | #endif /* PPP_SUPPORT */ 81 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/netif/ppp/magic.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * magic.h - Network Random Number Generator header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1997 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc. 31 | * Original derived from BSD codes. 32 | *****************************************************************************/ 33 | /* 34 | * magic.h - PPP Magic Number definitions. 35 | * 36 | * Copyright (c) 1989 Carnegie Mellon University. 37 | * All rights reserved. 38 | * 39 | * Redistribution and use in source and binary forms are permitted 40 | * provided that the above copyright notice and this paragraph are 41 | * duplicated in all such forms and that any documentation, 42 | * advertising materials, and other materials related to such 43 | * distribution and use acknowledge that the software was developed 44 | * by Carnegie Mellon University. The name of the 45 | * University may not be used to endorse or promote products derived 46 | * from this software without specific prior written permission. 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 50 | * 51 | * $Id: magic.h,v 1.3 2010/01/18 20:49:43 goldsimon Exp $ 52 | */ 53 | 54 | #ifndef MAGIC_H 55 | #define MAGIC_H 56 | 57 | /* Initialize the magic number generator */ 58 | void magicInit(void); 59 | 60 | /* Returns the next magic number */ 61 | u32_t magic(void); 62 | 63 | #endif /* MAGIC_H */ 64 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/netif/ppp/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | *********************************************************************** 3 | ** md5.h -- header file for implementation of MD5 ** 4 | ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** 5 | ** Created: 2/17/90 RLR ** 6 | ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** 7 | ** Revised (for MD5): RLR 4/27/91 ** 8 | ** -- G modified to have y&~z instead of y&z ** 9 | ** -- FF, GG, HH modified to add in last register done ** 10 | ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** 11 | ** -- distinct additive constant for each step ** 12 | ** -- round 4 added, working mod 7 ** 13 | *********************************************************************** 14 | */ 15 | 16 | /* 17 | *********************************************************************** 18 | ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** 19 | ** ** 20 | ** License to copy and use this software is granted provided that ** 21 | ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** 22 | ** Digest Algorithm" in all material mentioning or referencing this ** 23 | ** software or this function. ** 24 | ** ** 25 | ** License is also granted to make and use derivative works ** 26 | ** provided that such works are identified as "derived from the RSA ** 27 | ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** 28 | ** material mentioning or referencing the derived work. ** 29 | ** ** 30 | ** RSA Data Security, Inc. makes no representations concerning ** 31 | ** either the merchantability of this software or the suitability ** 32 | ** of this software for any particular purpose. It is provided "as ** 33 | ** is" without express or implied warranty of any kind. ** 34 | ** ** 35 | ** These notices must be retained in any copies of any part of this ** 36 | ** documentation and/or software. ** 37 | *********************************************************************** 38 | */ 39 | 40 | #ifndef MD5_H 41 | #define MD5_H 42 | 43 | /* Data structure for MD5 (Message-Digest) computation */ 44 | typedef struct { 45 | u32_t i[2]; /* number of _bits_ handled mod 2^64 */ 46 | u32_t buf[4]; /* scratch buffer */ 47 | unsigned char in[64]; /* input buffer */ 48 | unsigned char digest[16]; /* actual digest after MD5Final call */ 49 | } MD5_CTX; 50 | 51 | void MD5Init ( MD5_CTX *mdContext); 52 | void MD5Update( MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen); 53 | void MD5Final ( unsigned char hash[], MD5_CTX *mdContext); 54 | 55 | #endif /* MD5_H */ 56 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/netif/ppp/pppdebug.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * pppdebug.h - System debugging utilities. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1998 Global Election Systems Inc. 6 | * portions Copyright (c) 2001 by Cognizant Pty Ltd. 7 | * 8 | * The authors hereby grant permission to use, copy, modify, distribute, 9 | * and license this software and its documentation for any purpose, provided 10 | * that existing copyright notices are retained in all copies and that this 11 | * notice and the following disclaimer are included verbatim in any 12 | * distributions. No written agreement, license, or royalty fee is required 13 | * for any of the authorized uses. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | ****************************************************************************** 27 | * REVISION HISTORY (please don't use tabs!) 28 | * 29 | * 03-01-01 Marc Boucher 30 | * Ported to lwIP. 31 | * 98-07-29 Guy Lancaster , Global Election Systems Inc. 32 | * Original. 33 | * 34 | ***************************************************************************** 35 | */ 36 | #ifndef PPPDEBUG_H 37 | #define PPPDEBUG_H 38 | 39 | /* Trace levels. */ 40 | #define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) 41 | #define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) 42 | #define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) 43 | #define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) 44 | #define LOG_INFO (PPP_DEBUG) 45 | #define LOG_DETAIL (PPP_DEBUG) 46 | #define LOG_DEBUG (PPP_DEBUG) 47 | 48 | 49 | #define TRACELCP PPP_DEBUG 50 | 51 | #if PPP_DEBUG 52 | 53 | #define AUTHDEBUG(a, b) LWIP_DEBUGF(a, b) 54 | #define IPCPDEBUG(a, b) LWIP_DEBUGF(a, b) 55 | #define UPAPDEBUG(a, b) LWIP_DEBUGF(a, b) 56 | #define LCPDEBUG(a, b) LWIP_DEBUGF(a, b) 57 | #define FSMDEBUG(a, b) LWIP_DEBUGF(a, b) 58 | #define CHAPDEBUG(a, b) LWIP_DEBUGF(a, b) 59 | #define PPPDEBUG(a, b) LWIP_DEBUGF(a, b) 60 | 61 | #else /* PPP_DEBUG */ 62 | 63 | #define AUTHDEBUG(a, b) 64 | #define IPCPDEBUG(a, b) 65 | #define UPAPDEBUG(a, b) 66 | #define LCPDEBUG(a, b) 67 | #define FSMDEBUG(a, b) 68 | #define CHAPDEBUG(a, b) 69 | #define PPPDEBUG(a, b) 70 | 71 | #endif /* PPP_DEBUG */ 72 | 73 | #endif /* PPPDEBUG_H */ 74 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/netif/ppp/randm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * randm.h - Random number generator header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * Copyright (c) 1998 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 98-05-29 Guy Lancaster , Global Election Systems Inc. 31 | * Extracted from avos. 32 | *****************************************************************************/ 33 | 34 | #ifndef RANDM_H 35 | #define RANDM_H 36 | 37 | /*********************** 38 | *** PUBLIC FUNCTIONS *** 39 | ***********************/ 40 | /* 41 | * Initialize the random number generator. 42 | */ 43 | void avRandomInit(void); 44 | 45 | /* 46 | * Churn the randomness pool on a random event. Call this early and often 47 | * on random and semi-random system events to build randomness in time for 48 | * usage. For randomly timed events, pass a null pointer and a zero length 49 | * and this will use the system timer and other sources to add randomness. 50 | * If new random data is available, pass a pointer to that and it will be 51 | * included. 52 | */ 53 | void avChurnRand(char *randData, u32_t randLen); 54 | 55 | /* 56 | * Randomize our random seed value. To be called for truely random events 57 | * such as user operations and network traffic. 58 | */ 59 | #if MD5_SUPPORT 60 | #define avRandomize() avChurnRand(NULL, 0) 61 | #else /* MD5_SUPPORT */ 62 | void avRandomize(void); 63 | #endif /* MD5_SUPPORT */ 64 | 65 | /* 66 | * Use the random pool to generate random data. This degrades to pseudo 67 | * random when used faster than randomness is supplied using churnRand(). 68 | * Thus it's important to make sure that the results of this are not 69 | * published directly because one could predict the next result to at 70 | * least some degree. Also, it's important to get a good seed before 71 | * the first use. 72 | */ 73 | void avGenRand(char *buf, u32_t bufLen); 74 | 75 | /* 76 | * Return a new random number. 77 | */ 78 | u32_t avRandom(void); 79 | 80 | 81 | #endif /* RANDM_H */ 82 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/netif/ppp/vjbsdhdr.h: -------------------------------------------------------------------------------- 1 | #ifndef VJBSDHDR_H 2 | #define VJBSDHDR_H 3 | 4 | #include "lwip/tcp.h" 5 | 6 | /* 7 | * Structure of an internet header, naked of options. 8 | * 9 | * We declare ip_len and ip_off to be short, rather than u_short 10 | * pragmatically since otherwise unsigned comparisons can result 11 | * against negative integers quite easily, and fail in subtle ways. 12 | */ 13 | PACK_STRUCT_BEGIN 14 | struct ip 15 | { 16 | #if defined(NO_CHAR_BITFIELDS) 17 | u_char ip_hl_v; /* bug in GCC for mips means the bitfield stuff will sometimes break - so we use a char for both and get round it with macro's instead... */ 18 | #else 19 | #if BYTE_ORDER == LITTLE_ENDIAN 20 | unsigned ip_hl:4, /* header length */ 21 | ip_v :4; /* version */ 22 | #elif BYTE_ORDER == BIG_ENDIAN 23 | unsigned ip_v :4, /* version */ 24 | ip_hl:4; /* header length */ 25 | #else 26 | COMPLAIN - NO BYTE ORDER SELECTED! 27 | #endif 28 | #endif 29 | u_char ip_tos; /* type of service */ 30 | u_short ip_len; /* total length */ 31 | u_short ip_id; /* identification */ 32 | u_short ip_off; /* fragment offset field */ 33 | #define IP_DF 0x4000 /* dont fragment flag */ 34 | #define IP_MF 0x2000 /* more fragments flag */ 35 | #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ 36 | u_char ip_ttl; /* time to live */ 37 | u_char ip_p; /* protocol */ 38 | u_short ip_sum; /* checksum */ 39 | struct in_addr ip_src,ip_dst; /* source and dest address */ 40 | }; 41 | PACK_STRUCT_END 42 | 43 | typedef u32_t tcp_seq; 44 | 45 | /* 46 | * TCP header. 47 | * Per RFC 793, September, 1981. 48 | */ 49 | PACK_STRUCT_BEGIN 50 | struct tcphdr 51 | { 52 | u_short th_sport; /* source port */ 53 | u_short th_dport; /* destination port */ 54 | tcp_seq th_seq; /* sequence number */ 55 | tcp_seq th_ack; /* acknowledgement number */ 56 | #if defined(NO_CHAR_BITFIELDS) 57 | u_char th_x2_off; 58 | #else 59 | #if BYTE_ORDER == LITTLE_ENDIAN 60 | unsigned th_x2 :4, /* (unused) */ 61 | th_off:4; /* data offset */ 62 | #endif 63 | #if BYTE_ORDER == BIG_ENDIAN 64 | unsigned th_off:4, /* data offset */ 65 | th_x2 :4; /* (unused) */ 66 | #endif 67 | #endif 68 | u_char th_flags; 69 | u_short th_win; /* window */ 70 | u_short th_sum; /* checksum */ 71 | u_short th_urp; /* urgent pointer */ 72 | }; 73 | PACK_STRUCT_END 74 | 75 | #endif /* VJBSDHDR_H */ 76 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/xenon/include/arch/cc.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: cc.h,v 1.1 2007/03/19 20:10:27 tmbinc Exp $ 34 | */ 35 | #ifndef __ARCH_CC_H__ 36 | #define __ARCH_CC_H__ 37 | 38 | typedef unsigned char u8_t; 39 | typedef signed char s8_t; 40 | typedef unsigned short u16_t; 41 | typedef signed short s16_t; 42 | typedef unsigned int u32_t; 43 | typedef signed int s32_t; 44 | typedef unsigned long u64_t; 45 | typedef signed long s64_t; 46 | 47 | typedef u64_t mem_ptr_t; 48 | 49 | #define U32_F "u" 50 | #define U16_F "hu" 51 | #define S32_F "d" 52 | #define S16_F "hd" 53 | #define X32_F "x" 54 | #define X16_F "hx" 55 | 56 | //#define PACK_STRUCT_FIELD(x) x __attribute__((packed)) 57 | #define PACK_STRUCT_FIELD(x) x 58 | #define PACK_STRUCT_STRUCT __attribute__((packed)) 59 | #define PACK_STRUCT_BEGIN 60 | #define PACK_STRUCT_END 61 | 62 | #ifdef LWIP_DEBUG 63 | 64 | /* LW: forward declaration */ 65 | int printf(const char *format, ...); 66 | 67 | /* Plaform specific diagnostic output */ 68 | 69 | #endif/* LWIP_DEBUG */ 70 | #define LWIP_PLATFORM_DIAG(x) { printf x; } 71 | #define LWIP_PLATFORM_ASSERT(x) { printf("\fline %d in %s\n", __LINE__, __FILE__); while(1); } 72 | 73 | #endif /* __ARCH_CC_H__ */ 74 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/xenon/include/arch/cpu.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: cpu.h,v 1.1 2007/03/19 20:10:27 tmbinc Exp $ 34 | */ 35 | #ifndef __CPU_H__ 36 | #define __CPU_H__ 37 | 38 | #define BYTE_ORDER BIG_ENDIAN 39 | 40 | #endif /* __CPU_H__ */ 41 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/xenon/include/arch/init.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: init.h,v 1.1 2007/03/19 20:10:28 tmbinc Exp $ 34 | */ 35 | #ifndef __ARCH_INIT_H__ 36 | #define __ARCH_INIT_H__ 37 | 38 | #define TCPIP_INIT_DONE(arg) tcpip_init_done(arg) 39 | 40 | void tcpip_init_done(void *); 41 | int wait_for_tcpip_init(void); 42 | 43 | #endif /* __ARCH_INIT_H__ */ 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/xenon/include/arch/lib.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: lib.h,v 1.1 2007/03/19 20:10:28 tmbinc Exp $ 34 | */ 35 | #ifndef __LIB_H__ 36 | #define __LIB_H__ 37 | 38 | #include 39 | 40 | #define bcopy(s, d, l) memcpy(d, s, l) 41 | #define bzero(d, l) memset(d, 0, l) 42 | 43 | #endif /* __LIB_H__ */ 44 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/xenon/include/arch/perf.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: perf.h,v 1.1 2007/03/19 20:10:29 tmbinc Exp $ 34 | */ 35 | #ifndef __PERF_H__ 36 | #define __PERF_H__ 37 | 38 | #define PERF_START /* null definition */ 39 | #define PERF_STOP(x) /* null definition */ 40 | 41 | #endif /* __PERF_H__ */ 42 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/xenon/include/arch/sys_arch.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: sys_arch.h,v 1.1 2007/03/19 20:10:29 tmbinc Exp $ 34 | */ 35 | #ifndef __SYS_C64_H__ 36 | #define __SYS_C64_H__ 37 | 38 | #define SYS_MBOX_NULL 0 39 | #define SYS_SEM_NULL 0 40 | 41 | typedef int sys_sem_t; 42 | typedef int sys_mbox_t; 43 | typedef int sys_thread_t; 44 | 45 | #endif /* __SYS_C64_H__ */ 46 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/xenon/src/lib.c: -------------------------------------------------------------------------------- 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: lib.c,v 1.1 2007/03/19 20:10:25 tmbinc Exp $ 34 | */ 35 | 36 | /* These are generic implementations of various library functions used 37 | * throughout the lwIP code. When porting, those should be optimized 38 | * for the particular processor architecture, preferably coded in 39 | * assembler. 40 | */ 41 | 42 | #include "lwip/arch.h" 43 | 44 | -------------------------------------------------------------------------------- /libxenon/drivers/lwip/xenon/src/perf.c: -------------------------------------------------------------------------------- 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: perf.c,v 1.1 2007/03/19 20:10:26 tmbinc Exp $ 34 | */ 35 | 36 | #include "arch/perf.h" 37 | 38 | void 39 | perf_init(char *fname) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /libxenon/drivers/network/network.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "lwipopts.h" 6 | #include "lwip/debug.h" 7 | 8 | #include "lwip/timers.h" 9 | #include "lwip/mem.h" 10 | #include "lwip/memp.h" 11 | #include "lwip/sys.h" 12 | #include "lwip/init.h" 13 | #include "lwip/dhcp.h" 14 | #include "lwip/stats.h" 15 | 16 | #include "lwip/ip.h" 17 | #include "lwip/udp.h" 18 | #include "lwip/tcp.h" 19 | #include "lwip/tcp_impl.h" 20 | 21 | struct netif netif; 22 | 23 | ip_addr_t ipaddr, netmask, gateway; 24 | static uint64_t now, last_tcp, last_dhcp_coarse, last_dhcp_fine, now2, dhcp_wait; 25 | 26 | #define NTOA(ip) (int)((ip.addr>>24)&0xff), (int)((ip.addr>>16)&0xff), (int)((ip.addr>>8)&0xff), (int)(ip.addr&0xff) 27 | 28 | extern void enet_poll(struct netif *netif); 29 | extern err_t enet_init(struct netif *netif); 30 | 31 | void network_poll(); 32 | 33 | 34 | void network_init() 35 | { 36 | 37 | #ifdef STATS 38 | stats_init(); 39 | #endif /* STATS */ 40 | printf(" * initializing lwip 1.4.1...\n"); 41 | 42 | last_tcp=mftb(); 43 | last_dhcp_fine=mftb(); 44 | last_dhcp_coarse=mftb(); 45 | 46 | //printf(" * configuring device for DHCP...\r\n"); 47 | /* Start Network with DHCP */ 48 | IP4_ADDR(&netmask, 255,255,255,255); 49 | IP4_ADDR(&gateway, 0,0,0,0); 50 | IP4_ADDR(&ipaddr, 0,0,0,0); 51 | 52 | lwip_init(); //lwip 1.4.1 53 | 54 | printf(" * initializing NIC\n"); 55 | if (!netif_add(&netif, &ipaddr, &netmask, &gateway, NULL, enet_init, ip_input)){ 56 | printf(" ! netif_add failed!\n"); 57 | return; 58 | } 59 | netif_set_default(&netif); 60 | 61 | printf(" * requesting dhcp..."); 62 | //dhcp_set_struct(&netif, &netif_dhcp); 63 | dhcp_start(&netif); 64 | 65 | dhcp_wait=mftb(); 66 | int i = 0; 67 | while (netif.ip_addr.addr==0 && i < 60) { 68 | network_poll(); 69 | now2=mftb(); 70 | if (tb_diff_msec(now2, dhcp_wait) >= 250){ 71 | dhcp_wait=mftb(); 72 | i++; 73 | if (i % 2) 74 | printf("."); 75 | } 76 | } 77 | 78 | if (netif.ip_addr.addr) { 79 | printf("success\n"); 80 | } else { 81 | printf("failed\n"); 82 | printf(" * now assigning a static ip\n"); 83 | 84 | IP4_ADDR(&ipaddr, 192, 168, 1, 99); 85 | IP4_ADDR(&gateway, 192, 168, 1, 1); 86 | IP4_ADDR(&netmask, 255, 255, 255, 0); 87 | netif_set_addr(&netif, &ipaddr, &netmask, &gateway); 88 | netif_set_up(&netif); 89 | } 90 | } 91 | 92 | void network_poll() 93 | { 94 | 95 | // sys_check_timeouts(); 96 | 97 | now=mftb(); 98 | enet_poll(&netif); 99 | 100 | if (tb_diff_msec(now, last_tcp) >= TCP_TMR_INTERVAL) 101 | { 102 | last_tcp=mftb(); 103 | tcp_tmr(); 104 | } 105 | 106 | if (tb_diff_msec(now, last_dhcp_fine) >= DHCP_FINE_TIMER_MSECS) 107 | { 108 | last_dhcp_fine=mftb(); 109 | dhcp_fine_tmr(); 110 | } 111 | 112 | if (tb_diff_sec(now, last_dhcp_coarse) >= DHCP_COARSE_TIMER_SECS) 113 | { 114 | last_dhcp_coarse=mftb(); 115 | dhcp_coarse_tmr(); 116 | } 117 | } 118 | 119 | void network_print_config() 120 | { 121 | printf(" * network config: %d.%d.%d.%d / %d.%d.%d.%d\n", 122 | NTOA(netif.ip_addr), NTOA(netif.netmask)); 123 | printf(" MAC: %02X%02X%02X%02X%02X%02X\n\n", 124 | netif.hwaddr[0], netif.hwaddr[1], netif.hwaddr[2], 125 | netif.hwaddr[3], netif.hwaddr[4], netif.hwaddr[5]); 126 | } 127 | 128 | 129 | -------------------------------------------------------------------------------- /libxenon/drivers/network/network.h: -------------------------------------------------------------------------------- 1 | #ifndef __include_network_h 2 | #define __include_network_h 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | void network_init(); 12 | void network_poll(); 13 | void network_print_config(); 14 | 15 | extern struct netif netif; 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #endif -------------------------------------------------------------------------------- /libxenon/drivers/nocfe/cfe.h: -------------------------------------------------------------------------------- 1 | #include "lib_types.h" 2 | #include "lib_queue.h" 3 | #include "lib_malloc.h" 4 | #include 5 | #include 6 | #include