├── .gitignore ├── Makefile ├── README ├── cache.S ├── cdrom.c ├── ctype.c ├── diskio.c ├── dtc.S ├── fat.c ├── flash.c ├── flash.h ├── font_8x16.c ├── httpd ├── fsdata.c ├── httpd.c ├── httpd.h ├── makefsdata ├── vfs.c └── vfs.h ├── include ├── cache.h ├── ctype.h ├── diskio.h ├── elf_abi.h ├── lwipopts.h ├── network.h ├── processor.h ├── string.h ├── tftp.h ├── time.h ├── types.h └── vsprintf.h ├── lwip ├── FILES ├── api │ ├── api_lib.c │ ├── api_msg.c │ ├── err.c │ ├── sockets.c │ └── tcpip.c ├── arch │ └── xenon │ │ ├── include │ │ └── arch │ │ │ ├── cc.h │ │ │ ├── cpu.h │ │ │ ├── init.h │ │ │ ├── lib.h │ │ │ ├── perf.h │ │ │ └── sys_arch.h │ │ ├── lib.c │ │ ├── netif │ │ └── enet.c │ │ ├── perf.c │ │ └── sys_arch.c ├── core │ ├── dhcp.c │ ├── inet.c │ ├── inet6.c │ ├── ipv4 │ │ ├── icmp.c │ │ ├── ip.c │ │ ├── ip_addr.c │ │ └── ip_frag.c │ ├── ipv6 │ │ ├── README │ │ ├── icmp6.c │ │ ├── ip6.c │ │ └── ip6_addr.c │ ├── mem.c │ ├── memp.c │ ├── netif.c │ ├── pbuf.c │ ├── raw.c │ ├── stats.c │ ├── sys.c │ ├── tcp.c │ ├── tcp_in.c │ ├── tcp_out.c │ └── udp.c ├── include │ ├── ipv4 │ │ └── lwip │ │ │ ├── icmp.h │ │ │ ├── inet.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 │ │ ├── err.h │ │ ├── mem.h │ │ ├── memp.h │ │ ├── netif.h │ │ ├── opt.h │ │ ├── pbuf.h │ │ ├── raw.h │ │ ├── sio.h │ │ ├── snmp.h │ │ ├── sockets.h │ │ ├── stats.h │ │ ├── sys.h │ │ ├── tcp.h │ │ ├── tcpip.h │ │ └── udp.h │ └── netif │ │ ├── etharp.h │ │ ├── loopif.h │ │ └── slipif.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 │ ├── pppdebug.h │ ├── randm.c │ ├── randm.h │ ├── vj.c │ ├── vj.h │ └── vjbsdhdr.h │ └── slipif.c ├── main.c ├── network.c ├── nocfe ├── addrspace.h ├── cfe.h ├── cfe_console.h ├── cfe_timer.h ├── cpu_config.h ├── lib_malloc.c ├── lib_malloc.h ├── lib_physio.c ├── lib_physio.h ├── lib_printf.h ├── lib_queue.c ├── lib_queue.h ├── lib_string.h └── lib_types.h ├── readcd ├── README └── readsector.S ├── startup2.S ├── string.c ├── tftp.c ├── time.c ├── usb ├── README ├── dev_usb_asix.c ├── dev_usb_catc.c ├── dev_usb_klsi.c ├── dev_usb_pegasus.c ├── dev_usb_rtek.c ├── klsi_fw.h ├── ohci.c ├── ohci.h ├── usbchap9.h ├── usbd.c ├── usbd.h ├── usbdebug.c ├── usbdevs.c ├── usbeth.c ├── usbeth.h ├── usbhack.c ├── usbhack.h ├── usbhid.c ├── usbhub.c ├── usbmain.c ├── usbmass.c └── usbserial.c ├── vsprintf.c ├── xell-1f.lds ├── xell-2f.lds ├── xell-readcd.lds ├── xell-serial.lds ├── xell-xell.lds ├── xenon.dts ├── xenon_gpio.h ├── xenon_smc.c ├── xenon_smc.h ├── xenos.c ├── xenos_init.c └── xenos_init.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.elf 3 | *.elf32 4 | *.bin 5 | version.h 6 | .cdtproject 7 | .cproject 8 | .project 9 | .settings/ 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CROSS=xenon- 2 | CC=$(CROSS)gcc 3 | OBJCOPY=$(CROSS)objcopy 4 | LD=$(CROSS)ld 5 | AS=$(CROSS)as 6 | STRIP=$(CROSS)strip 7 | 8 | RELEASE=0.3 9 | 10 | # Configuration 11 | CFLAGS = -Wall -O2 -I. -Ilwip/include \ 12 | -Iinclude -I./lwip/include/ipv4 -Ilwip/arch/xenon/include \ 13 | -m64 -mno-toc -DBYTE_ORDER=BIG_ENDIAN -mno-altivec \ 14 | -I nocfe -D_CFE_=1 -DENDIAN_BIG=1 15 | 16 | ifdef CYGNOS 17 | CFLAGS += -DCYGNOS 18 | endif 19 | 20 | AFLAGS = -Iinclude -m64 21 | LDFLAGS = -nostdlib -n 22 | 23 | #-DLWIP_DEBUG -O2 24 | #-Werror 25 | 26 | OBJS = crt0.o main_ardl_.o string_asm.o string.o ctype.o video.o console.o exi.o \ 27 | 28 | LWIP_OBJS = ./lwip/core/tcp_in.o \ 29 | ./lwip/core/inet.o ./lwip/core/mem.o ./lwip/core/memp.o \ 30 | ./lwip/core/netif.o ./lwip/core/pbuf.o ./lwip/core/stats.o ./lwip/core/sys.o \ 31 | ./lwip/core/tcp.o ./lwip/core/ipv4/ip_addr.o ./lwip/core/ipv4/icmp.o \ 32 | ./lwip/core/ipv4/ip.o ./lwip/core/ipv4/ip_frag.o \ 33 | ./lwip/core/tcp_out.o \ 34 | ./lwip/core/udp.o ./lwip/netif/etharp.o ./lwip/netif/loopif.o ./lwip/core/dhcp.o \ 35 | ./lwip/core/raw.o \ 36 | ./lwip/arch/xenon/lib.o ./lwip/arch/xenon/netif/enet.o 37 | 38 | USB_OBJS = \ 39 | usb/ohci.o usb/usbd.o usb/usbdebug.o usb/usbdevs.o usb/usbhid.o usb/usbhub.o usb/usbmain.o usb/usbmass.o \ 40 | nocfe/lib_malloc.o nocfe/lib_queue.o fat.o flash.o 41 | 42 | # usb/dev_usb_asix.o usb/dev_usb_catc.o usb/dev_usb_klsi.o usb/dev_usb_pegasus.o usb/dev_usb_rtek.o usb/ohci.o usb/usbd.o usb/usbdebug.o usb/usbdevs.o usb/usbeth.o usb/usbhack.o usb/usbhid.o usb/usbhub.o usb/usbmain.o usb/usbmass.o usb/usbserial.o 43 | 44 | OBJS = startup2.o main.o string.o vsprintf.o ctype.o time.o \ 45 | cache.o $(LWIP_OBJS) network.o tftp.o httpd/httpd.o httpd/vfs.o dtc.o \ 46 | cdrom.o xenos.o font_8x16.o xenos_init.o xenon_smc.o $(USB_OBJS) \ 47 | ./diskio.o 48 | 49 | BUILD = xell-serial xell-readcd xell-1f xell-2f xell-xell 50 | 51 | TARGETS = $(foreach name,$(BUILD),$(addprefix $(name).,bin elf elf32)) 52 | 53 | # Build rules 54 | all: $(TARGETS) 55 | 56 | .SECONDARY: $(OBJS) 57 | 58 | .PHONY: clean version.h 59 | 60 | clean: 61 | rm -rf $(OBJS) $(TARGETS) 62 | 63 | version.h: 64 | @echo 'Creating version.h' 65 | @echo '/* AUTO GENERATED BY make. DO NOT EDIT! */' > version.h 66 | @echo '' >> version.h 67 | @echo '#define RELEASE "$(RELEASE)"' >> version.h 68 | @echo '#define BLAME "'$(shell id -u -n)'@'$(shell uname -n -m)'"' >> version.h 69 | @date +'#define DATE "%F"' >> version.h 70 | @echo '#define GITREV "'$(shell git log --format="%h" HEAD^..HEAD)'"' >> version.h 71 | @echo '' >> version.h 72 | @echo '#define VERSION RELEASE "-git-" GITREV' >> version.h 73 | @echo '#define LONGVERSION VERSION " " DATE " (" BLAME ")"' >> version.h 74 | 75 | main.o: version.h 76 | xenos.o: version.h 77 | 78 | .c.o: 79 | $(CC) $(CFLAGS) -c -o $@ $*.c 80 | 81 | .S.o: 82 | $(CC) $(AFLAGS) -c -o $@ $*.S 83 | 84 | %.elf: %.lds $(OBJS) 85 | $(CC) -n -T $< -nostdlib -m64 -o $@ $(OBJS) 86 | 87 | %.elf32: %.elf 88 | $(OBJCOPY) -O elf32-powerpc $< $@ 89 | $(STRIP) -s $@ 90 | 91 | %.bin: %.elf 92 | $(OBJCOPY) -O binary $< $@ 93 | echo -n "xxxxxxxxxxxxxxxx" >> $@ 94 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This is XeLL. 2 | 3 | XeLL is the Xenon Linux Loader. It's a second-stage bootloader and is 4 | usually run by an exploit. The method of booting this is not a part of this 5 | project. 6 | 7 | XeLL catches CPU threads, sets them up (basically setting HRMOR to zero), 8 | loads an ELF file from either network (tftp) or CDROM, and launches it. 9 | 10 | It also contains a flat device tree for linux. 11 | 12 | cdrom.c includes a very simple ISO9660 parser, which tries to boot the file 13 | named ""vmlinux". 14 | 15 | lwIP (http://www.sics.se/~adam/lwip/) is used for networking. Network config 16 | is currently hardcoded in network.c (and main.c). 17 | 18 | XeLL also contains a HTTP server. It is not really used. 19 | 20 | XeLL is licensed under the GPL v2, and no other version. 21 | 22 | Xenon-specific stuff of XeLL was written by Felix Domke , 23 | other parts where taken from other free sourcecodes. No non-free hardware 24 | documentation was used for developing XeLL. 25 | 26 | XeLL is in a very early stage, but is (most of the time) fully working. 27 | -------------------------------------------------------------------------------- /cache.S: -------------------------------------------------------------------------------- 1 | #define CACHE_SIZE 0x80 2 | 3 | .globl dcache_flush 4 | dcache_flush: 5 | lis %r5, 0xFFFF 6 | ori %r5, %r5, 0xFFF1 7 | and %r5, %r5, %r3 8 | subf %r3, %r5, %r3 9 | add %r4, %r4, %r3 10 | 1: 11 | dcbst %r0, %r5 12 | addic %r5, %r5, CACHE_SIZE 13 | subic. %r4, %r4, CACHE_SIZE 14 | bge 1b 15 | isync 16 | blr 17 | 18 | .globl dcache_inv 19 | dcache_inv: 20 | lis %r5, 0xFFFF 21 | ori %r5, %r5, 0xFFF1 22 | and %r5, %r5, %r3 23 | subf %r3, %r5, %r3 24 | add %r4, %r4, %r3 25 | 1: 26 | dcbf %r0, %r5 27 | addic %r5, %r5, CACHE_SIZE 28 | subic. %r4, %r4, CACHE_SIZE 29 | bge 1b 30 | isync 31 | blr 32 | 33 | .globl flush_code 34 | flush_code: 35 | lis %r5, 0xFFFF 36 | ori %r5, %r5, 0xFFF1 37 | and %r5, %r5, %r3 38 | subf %r3, %r5, %r3 39 | add %r4, %r4, %r3 40 | 1: 41 | dcbst %r0, %r5 42 | sync 43 | icbi %r0, %r5 44 | addic %r5, %r5, CACHE_SIZE 45 | subic. %r4, %r4, CACHE_SIZE 46 | bge 1b 47 | sync 48 | isync 49 | blr 50 | -------------------------------------------------------------------------------- /ctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2000 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4 | * 5 | * See file CREDITS for list of people who contributed to this 6 | * project. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License as 10 | * published by the Free Software Foundation; either version 2 of 11 | * the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 | * MA 02111-1307 USA 22 | */ 23 | 24 | /* 25 | * lib/ctype.c 26 | * 27 | * Copyright (C) 1991, 1992 Linus Torvalds 28 | */ 29 | 30 | #include 31 | 32 | unsigned char _ctype[] = { 33 | _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ 34 | _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ 35 | _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ 36 | _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ 37 | _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ 38 | _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ 39 | _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ 40 | _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ 41 | _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ 42 | _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ 43 | _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ 44 | _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ 45 | _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ 46 | _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ 47 | _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ 48 | _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ 49 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ 50 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ 51 | _S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */ 52 | _P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */ 53 | _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */ 54 | _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ 55 | _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ 56 | _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ 57 | -------------------------------------------------------------------------------- /diskio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define MAX_DEVICES 16 6 | 7 | struct bdev devices[MAX_DEVICES]; 8 | 9 | struct bdev *register_bdev(void *ctx, struct bdev_ops *ops, const char *name) 10 | { 11 | int i; 12 | for (i = 0; i < MAX_DEVICES; ++i) 13 | { 14 | if (!devices[i].ops) 15 | break; 16 | } 17 | if (i == MAX_DEVICES) 18 | return 0; 19 | devices[i].ctx = ctx; 20 | strcpy(devices[i].name, name); /* strlen(name)>=16 and i'll kill you! */ 21 | devices[i].ops = ops; 22 | printf("registered new device: %s\n", name); 23 | return devices + i; 24 | } 25 | 26 | struct bdev *register_bdev_child(struct bdev *parent, lba_t offset, int index) 27 | { 28 | struct bdev *c = register_bdev(parent->ctx, parent->ops, ""); 29 | if (!c) 30 | return 0; 31 | sprintf(c->name, "%s%d", parent->name, index); 32 | c->offset = offset; 33 | return c; 34 | } 35 | 36 | void unregister_bdev(struct bdev *bdev) 37 | { 38 | bdev->disabled = 1; 39 | } 40 | 41 | struct bdev *bdev_open(const char *name) 42 | { 43 | int i; 44 | for (i = 0; i < MAX_DEVICES; ++i) 45 | if (!strcmp(devices[i].name, name)) 46 | return devices + i; 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /flash.c: -------------------------------------------------------------------------------- 1 | #include "include/types.h" 2 | #include 3 | 4 | #define STATUS (1) 5 | #define COMMAND (2) 6 | #define ADDRESS (3) 7 | #define DATA (4) 8 | 9 | static inline uint32_t bswap_32(uint32_t t) 10 | { 11 | return ((t & 0xFF) << 24) | ((t & 0xFF00) << 8) | ((t & 0xFF0000) >> 8) | ((t & 0xFF000000) >> 24); 12 | } 13 | 14 | void sfcx_writereg(int addr, unsigned long data) 15 | { 16 | *(volatile unsigned int*)(0x200ea00c000ULL|(addr*4)) = bswap_32(data); 17 | } 18 | 19 | unsigned long sfcx_readreg(int addr) 20 | { 21 | return bswap_32(*(volatile unsigned int*)(0x200ea00c000ULL|(addr*4))); 22 | } 23 | 24 | void readsector(unsigned char *data, int sector, int raw) 25 | { 26 | int status; 27 | sfcx_writereg(STATUS, sfcx_readreg(STATUS)); 28 | sfcx_writereg(ADDRESS, sector); 29 | sfcx_writereg(COMMAND, raw ? 3 : 2); 30 | 31 | while ((status = sfcx_readreg(STATUS))&1); 32 | 33 | if (status != 0x200) 34 | { 35 | if (status & 0x40) 36 | printf(" * Bad block found at %08x\n", sector); 37 | else if (status & 0x1c) 38 | printf(" * (corrected) ECC error %08x: %08x\n", sector, status); 39 | else if (!raw && (status & 0x800)) 40 | printf(" * illegal logical block %08x (status: %08x)\n", sector, status); 41 | else 42 | printf(" * Unknown error at %08x: %08x. Please worry.\n", sector, status); 43 | } 44 | 45 | sfcx_writereg(ADDRESS, 0); 46 | 47 | int i; 48 | for (i = 0; i < 0x210; i+=4) 49 | { 50 | sfcx_writereg(COMMAND, 0); 51 | *(int*)(data + i) = bswap_32(sfcx_readreg(DATA)); 52 | } 53 | } 54 | 55 | void flash_erase(int address) 56 | { 57 | sfcx_writereg(0, sfcx_readreg(0) | 8); 58 | sfcx_writereg(STATUS, 0xFF); 59 | sfcx_writereg(ADDRESS, address); 60 | while (sfcx_readreg(STATUS) & 1); 61 | sfcx_writereg(COMMAND, 0xAA); 62 | sfcx_writereg(COMMAND, 0x55); 63 | while (sfcx_readreg(STATUS) & 1); 64 | sfcx_writereg(COMMAND, 0x5); 65 | while (sfcx_readreg(STATUS) & 1); 66 | int status = sfcx_readreg(STATUS); 67 | if (status != 0x200) 68 | printf("[%08x]", status); 69 | sfcx_writereg(STATUS, 0xFF); 70 | sfcx_writereg(0, sfcx_readreg(0) & ~8); 71 | } 72 | 73 | void write_page(int address, unsigned char *data) 74 | { 75 | sfcx_writereg(STATUS, 0xFF); 76 | sfcx_writereg(0, sfcx_readreg(0) | 8); 77 | 78 | sfcx_writereg(ADDRESS, 0); 79 | 80 | int i; 81 | 82 | for (i = 0; i < 0x210; i+=4) 83 | { 84 | sfcx_writereg(DATA, bswap_32(*(int*)(data + i))); 85 | sfcx_writereg(COMMAND, 1); 86 | } 87 | 88 | sfcx_writereg(ADDRESS, address); 89 | sfcx_writereg(COMMAND, 0x55); 90 | while (sfcx_readreg(STATUS) & 1); 91 | sfcx_writereg(COMMAND, 0xAA); 92 | while (sfcx_readreg(STATUS) & 1); 93 | sfcx_writereg(COMMAND, 0x4); 94 | while (sfcx_readreg(STATUS) & 1); 95 | int status = sfcx_readreg(STATUS); 96 | if (status != 0x200) 97 | printf("[%08x]", status); 98 | sfcx_writereg(0, sfcx_readreg(0) & ~8); 99 | } 100 | 101 | 102 | void calcecc(unsigned int *data) 103 | { 104 | unsigned int i=0, val=0; 105 | unsigned char *edc = ((unsigned char*)data) + 0x200; 106 | 107 | unsigned int v; 108 | 109 | for (i = 0; i < 0x1066; i++) 110 | { 111 | if (!(i & 31)) 112 | v = ~bswap_32(*data++); 113 | val ^= v & 1; 114 | v>>=1; 115 | if (val & 1) 116 | val ^= 0x6954559; 117 | val >>= 1; 118 | } 119 | 120 | val = ~val; 121 | 122 | 123 | edc[0xC] |= (val << 6) & 0xC0; 124 | edc[0xD] = (val >> 2) & 0xFF; 125 | edc[0xE] = (val >> 10) & 0xFF; 126 | edc[0xF] = (val >> 18) & 0xFF; 127 | } 128 | -------------------------------------------------------------------------------- /flash.h: -------------------------------------------------------------------------------- 1 | #ifndef __flash_h 2 | #define __flash_h 3 | 4 | void sfcx_writereg(int addr, unsigned long data); 5 | unsigned long sfcx_readreg(int addr); 6 | void readsector(unsigned char *data, int sector, int raw); 7 | void flash_erase(int address); 8 | void write_page(int address, unsigned char *data); 9 | void calcecc(unsigned char *data); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /font_8x16.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Free60Project/xell/c1c421376916d1706b737bb8dcc49c6f92612c20/font_8x16.c -------------------------------------------------------------------------------- /httpd/fsdata.c: -------------------------------------------------------------------------------- 1 | static struct vfs_entry_s vfs_entries[]={ 2 | {0, 0, 0, 0} 3 | }; 4 | -------------------------------------------------------------------------------- /httpd/httpd.h: -------------------------------------------------------------------------------- 1 | #ifndef __httpd_h 2 | #define __httpd_h 3 | 4 | #define MAX_LINESIZE 256 5 | 6 | #define HTTPD_CLIENT_REQUEST 0 7 | #define HTTPD_CLIENT_HEADER 1 8 | #define HTTPD_CLIENT_DATA 2 9 | #define HTTPD_CLIENT_IDLE 3 10 | 11 | #define HTTPD_SERVER_IDLE 0 12 | #define HTTPD_SERVER_RESPONSE 1 13 | #define HTTPD_SERVER_HEADER 2 14 | #define HTTPD_SERVER_DATA 3 15 | #define HTTPD_SERVER_CLOSE 4 16 | 17 | #define SENDBUFFER_LEN 4096 18 | 19 | struct http_state; 20 | 21 | extern int httpd_available_sendbuffer(struct http_state *http); 22 | extern void httpd_put_sendbuffer(struct http_state *http, const void *data, int len); 23 | extern void httpd_put_sendbuffer_string(struct http_state *http, const char *data); 24 | extern int httpd_do_std_header(struct http_state *http); 25 | 26 | struct httpd_handler 27 | { 28 | int (*process_request)(struct http_state *http, const char *method, const char *url); 29 | void (*process_header)(struct http_state *http, const char *option, const char *val); 30 | void (*start_response)(struct http_state *http); 31 | int (*do_header)(struct http_state *http); 32 | int (*do_data)(struct http_state *http); 33 | int (*process_data)(struct http_state *http, const void *data, int len); /* return != len *ONLY* in case you changed the state! */ 34 | void (*finish)(struct http_state *http); 35 | }; 36 | 37 | extern struct httpd_handler http_handler[]; 38 | 39 | struct http_state 40 | { 41 | int state_server, state_client; 42 | 43 | int code; 44 | char *code_descr; 45 | 46 | char linebuffer[MAX_LINESIZE + 1]; 47 | int linebuffer_ptr; 48 | 49 | char sendbuffer[SENDBUFFER_LEN]; 50 | int sendbuffer_read, sendbuffer_write; 51 | int std_header_state; 52 | int retries; 53 | int isserial; 54 | 55 | struct httpd_handler *handler; 56 | void *response_priv; 57 | }; 58 | 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /httpd/makefsdata: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | open(OUTPUT, "> fsdata.c"); 4 | 5 | chdir("fs"); 6 | open(FILES, "find . -type f |"); 7 | 8 | while($file = ) { 9 | 10 | # Do not include files in CVS directories nor backup files. 11 | if($file =~ /(CVS|~)/) { 12 | next; 13 | } 14 | 15 | chop($file); 16 | $flag = "0"; 17 | 18 | if($file =~ /\.html$/) { 19 | $mime = "text/html; charset=utf-8"; 20 | } elsif($file =~ /\.dhtml$/) { 21 | $flag = "1"; 22 | $mime = "text/html; charset=utf-8"; 23 | } elsif($file =~ /\.gif$/) { 24 | $mime = "image/gif"; 25 | } elsif($file =~ /\.png$/) { 26 | $mime = "image/png"; 27 | } elsif($file =~ /\.jpg$/) { 28 | $mime = "image/jpeg"; 29 | } elsif($file =~ /\.class$/) { 30 | $mime = "application/octet-stream"; 31 | } elsif($file =~ /\.ram$/) { 32 | $mime = "audio/x-pn-realaudio"; 33 | } else { 34 | $mime = "text/plain"; 35 | } 36 | 37 | open(FILE, "$file"); 38 | 39 | $file =~ s/\.//; 40 | 41 | $fvar = $file; 42 | $fvar =~ s-/-_-g; 43 | $fvar =~ s-\.-_-g; 44 | print(OUTPUT "static const unsigned char data".$fvar."[] = {\n"); 45 | print(OUTPUT "\t/* $file */\n\t"); 46 | 47 | $i = 0; 48 | while(read(FILE, $data, 1)) { 49 | if($i == 0) { 50 | print(OUTPUT "\t"); 51 | } 52 | printf(OUTPUT "%#02x, ", unpack("C", $data)); 53 | $i++; 54 | if($i == 10) { 55 | print(OUTPUT "\n"); 56 | $i = 0; 57 | } 58 | } 59 | print(OUTPUT "};\n\n"); 60 | close(FILE); 61 | push(@fvars, $fvar); 62 | push(@files, $file); 63 | push(@flags, $flag); 64 | push(@mime, $mime); 65 | } 66 | 67 | print(OUTPUT "static struct vfs_entry_s vfs_entries[]={\n"); 68 | 69 | for($i = 0; $i < @fvars; $i++) { 70 | $file = $files[$i]; 71 | $fvar = $fvars[$i]; 72 | $mime = $mime[$i]; 73 | $flag = $flags[$i]; 74 | print(OUTPUT "\t{\"$file\", data$fvar, sizeof(data$fvar), \"$mime\", $flag}, \n"); 75 | } 76 | 77 | print(OUTPUT "\t{0, 0, 0, 0}\n};\n"); 78 | -------------------------------------------------------------------------------- /httpd/vfs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "vfs.h" 3 | 4 | #include "fsdata.c" 5 | 6 | struct vfs_entry_s *search_file(const char *filename) 7 | { 8 | struct vfs_entry_s *vfs = vfs_entries; 9 | while (vfs->filename) 10 | if (!strcmp(filename, vfs->filename)) 11 | return vfs; 12 | else 13 | ++vfs; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /httpd/vfs.h: -------------------------------------------------------------------------------- 1 | #ifndef __vfs_h 2 | #define __vfs_h 3 | 4 | struct vfs_entry_s 5 | { 6 | const char *filename; 7 | const char *data; 8 | int len; 9 | const char *mime_type; 10 | int flags; 11 | }; 12 | 13 | struct vfs_entry_s *search_file(const char *filename); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/cache.h: -------------------------------------------------------------------------------- 1 | #ifndef __CACHE_H 2 | #define __CACHE_H 3 | 4 | void flush_code(volatile void *, int len); 5 | void dcache_flush(volatile void *, int len); 6 | void dcache_inv(volatile void *, int len); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/ctype.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_CTYPE_H 2 | #define _LINUX_CTYPE_H 3 | 4 | /* 5 | * NOTE! This ctype does not handle EOF like the standard C 6 | * library is required to. 7 | */ 8 | 9 | #define _U 0x01 /* upper */ 10 | #define _L 0x02 /* lower */ 11 | #define _D 0x04 /* digit */ 12 | #define _C 0x08 /* cntrl */ 13 | #define _P 0x10 /* punct */ 14 | #define _S 0x20 /* white space (space/lf/tab) */ 15 | #define _X 0x40 /* hex digit */ 16 | #define _SP 0x80 /* hard space (0x20) */ 17 | 18 | extern unsigned char _ctype[]; 19 | 20 | #define __ismask(x) (_ctype[(int)(unsigned char)(x)]) 21 | 22 | #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0) 23 | #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0) 24 | #define iscntrl(c) ((__ismask(c)&(_C)) != 0) 25 | #define isdigit(c) ((__ismask(c)&(_D)) != 0) 26 | #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0) 27 | #define islower(c) ((__ismask(c)&(_L)) != 0) 28 | #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) 29 | #define ispunct(c) ((__ismask(c)&(_P)) != 0) 30 | #define isspace(c) ((__ismask(c)&(_S)) != 0) 31 | #define isupper(c) ((__ismask(c)&(_U)) != 0) 32 | #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) 33 | 34 | #define isascii(c) (((unsigned char)(c))<=0x7f) 35 | #define toascii(c) (((unsigned char)(c))&0x7f) 36 | 37 | static inline unsigned char __tolower(unsigned char c) 38 | { 39 | if (isupper(c)) 40 | c -= 'A'-'a'; 41 | return c; 42 | } 43 | 44 | static inline unsigned char __toupper(unsigned char c) 45 | { 46 | if (islower(c)) 47 | c -= 'a'-'A'; 48 | return c; 49 | } 50 | 51 | #define tolower(c) __tolower(c) 52 | #define toupper(c) __toupper(c) 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/diskio.h: -------------------------------------------------------------------------------- 1 | #ifndef __diskio_h 2 | #define __diskio_h 3 | 4 | typedef unsigned long long lba_t; 5 | 6 | struct bdev; 7 | 8 | struct bdev_ops 9 | { 10 | int (*read)(struct bdev *dev, void *data, lba_t lba, int num); 11 | }; 12 | 13 | struct bdev 14 | { 15 | void *ctx; 16 | char name[32]; 17 | lba_t offset; 18 | struct bdev_ops *ops; 19 | int disabled; /* used when USB device is unplugged */ 20 | }; 21 | 22 | struct bdev *register_bdev(void *ctx, struct bdev_ops *ops, const char *name); 23 | struct bdev *register_bdev_child(struct bdev *parent, lba_t offset, int index); 24 | 25 | void unregister_bdev(struct bdev *bdev); 26 | 27 | struct bdev *bdev_open(const char *name); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /include/network.h: -------------------------------------------------------------------------------- 1 | #ifndef __include_network_h 2 | #define __include_network_h 3 | 4 | void network_init(); 5 | void network_poll(); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /include/processor.h: -------------------------------------------------------------------------------- 1 | #ifndef __processor_h 2 | #define __processor_h 3 | 4 | typedef struct 5 | { 6 | unsigned long l, u; 7 | } tb_t; 8 | 9 | #define __stringify(rn) #rn 10 | 11 | #define mfdcr(rn) ({unsigned int rval; \ 12 | asm volatile("mfdcr %0," __stringify(rn) \ 13 | : "=r" (rval)); rval;}) 14 | #define mtdcr(rn, v) asm volatile("mtdcr " __stringify(rn) ",%0" : : "r" (v)) 15 | 16 | #define mfmsr() ({unsigned long rval; \ 17 | asm volatile("mfmsr %0" : "=r" (rval)); rval;}) 18 | #define mtmsr(v) asm volatile("mtmsr %0" : : "r" (v)) 19 | 20 | #define mfdec() ({unsigned long rval; \ 21 | asm volatile("mfdec %0" : "=r" (rval)); rval;}) 22 | #define mtdec(v) asm volatile("mtdec %0" : : "r" (v)) 23 | 24 | #define mfspr(rn) ({unsigned long rval; \ 25 | asm volatile("mfspr %0," __stringify(rn) \ 26 | : "=r" (rval)); rval;}) 27 | #define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v)) 28 | 29 | #define mftb(rval) ({unsigned long u; do { \ 30 | asm volatile ("mftbu %0" : "=r" (u)); \ 31 | asm volatile ("mftb %0" : "=r" ((rval)->l)); \ 32 | asm volatile ("mftbu %0" : "=r" ((rval)->u)); \ 33 | } while(u != ((rval)->u)); }) 34 | 35 | /* checkme */ 36 | #define TB_CLOCK 45000000 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /include/string.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_STRING_H_ 2 | #define _LINUX_STRING_H_ 3 | 4 | #include /* for size_t */ 5 | #include /* for NULL */ 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | extern char * ___strtok; 12 | extern char * strpbrk(const char *,const char *); 13 | extern char * strtok(char *,const char *); 14 | extern char * strsep(char **,const char *); 15 | extern __kernel_size_t strspn(const char *,const char *); 16 | 17 | 18 | /* 19 | * Include machine specific inline routines 20 | */ 21 | 22 | #ifndef __HAVE_ARCH_STRCPY 23 | extern char * strcpy(char *,const char *); 24 | #endif 25 | #ifndef __HAVE_ARCH_STRNCPY 26 | extern char * strncpy(char *,const char *, __kernel_size_t); 27 | #endif 28 | #ifndef __HAVE_ARCH_STRCAT 29 | extern char * strcat(char *, const char *); 30 | #endif 31 | #ifndef __HAVE_ARCH_STRNCAT 32 | extern char * strncat(char *, const char *, __kernel_size_t); 33 | #endif 34 | #ifndef __HAVE_ARCH_STRCMP 35 | extern int strcmp(const char *,const char *); 36 | #endif 37 | #ifndef __HAVE_ARCH_STRNCMP 38 | extern int strncmp(const char *,const char *,__kernel_size_t); 39 | #endif 40 | #ifndef __HAVE_ARCH_STRNICMP 41 | extern int strnicmp(const char *, const char *, __kernel_size_t); 42 | #endif 43 | #ifndef __HAVE_ARCH_STRCHR 44 | extern char * strchr(const char *,int); 45 | #endif 46 | #ifndef __HAVE_ARCH_STRRCHR 47 | extern char * strrchr(const char *,int); 48 | #endif 49 | #ifndef __HAVE_ARCH_STRSTR 50 | extern char * strstr(const char *,const char *); 51 | #endif 52 | #ifndef __HAVE_ARCH_STRLEN 53 | extern __kernel_size_t strlen(const char *); 54 | #endif 55 | #ifndef __HAVE_ARCH_STRNLEN 56 | extern __kernel_size_t strnlen(const char *,__kernel_size_t); 57 | #endif 58 | #ifndef __HAVE_ARCH_STRDUP 59 | extern char * strdup(const char *); 60 | #endif 61 | 62 | #ifndef __HAVE_ARCH_MEMSET 63 | extern void * memset(void *,int,__kernel_size_t); 64 | #endif 65 | #ifndef __HAVE_ARCH_MEMCPY 66 | extern void * memcpy(void *,const void *,__kernel_size_t); 67 | #endif 68 | #ifndef __HAVE_ARCH_MEMMOVE 69 | extern void * memmove(void *,const void *,__kernel_size_t); 70 | #endif 71 | #ifndef __HAVE_ARCH_MEMSCAN 72 | extern void * memscan(void *,int,__kernel_size_t); 73 | #endif 74 | #ifndef __HAVE_ARCH_MEMCMP 75 | extern int memcmp(const void *,const void *,__kernel_size_t); 76 | #endif 77 | #ifndef __HAVE_ARCH_MEMCHR 78 | extern void * memchr(const void *,int,__kernel_size_t); 79 | #endif 80 | 81 | #if ARCH==7020 82 | #define __HAVE_ARCH_STRCPY 83 | #define __HAVE_ARCH_STRNCPY 84 | #define __HAVE_ARCH_STRCAT 85 | #define __HAVE_ARCH_STRCMP 86 | #define __HAVE_ARCH_STRLEN 87 | #define __HAVE_ARCH_MEMSET 88 | #define __HAVE_ARCH_BCOPY 89 | #define __HAVE_ARCH_MEMMOVE 90 | #define __HAVE_ARCH_MEMCPY 91 | #define __HAVE_ARCH_BACKWARDS_MEMCPY 92 | #define __HAVE_ARCH_MEMCMP 93 | #define __HAVE_ARCH_MEMCHR 94 | #endif 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* _LINUX_STRING_H_ */ 101 | -------------------------------------------------------------------------------- /include/tftp.h: -------------------------------------------------------------------------------- 1 | #ifndef __tftp_h 2 | #define __tftp_h 3 | 4 | #include 5 | 6 | extern int do_tftp(struct ip_addr server, const char *file); 7 | extern int boot_tftp(const char *server_addr, const char *filename); 8 | extern int boot_tftp_url(const char *url); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /include/time.h: -------------------------------------------------------------------------------- 1 | #ifndef __time_h 2 | #define __time_h 3 | 4 | #include "processor.h" 5 | 6 | unsigned long tb_diff_sec(tb_t *end, tb_t *start); 7 | unsigned long tb_diff_msec(tb_t *end, tb_t *start); 8 | unsigned long tb_diff_usec(tb_t *end, tb_t *start); 9 | void udelay(unsigned int us); 10 | void mdelay(unsigned int ms); 11 | void delay(unsigned int s); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/types.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_TYPES_H 2 | #define _LINUX_TYPES_H 3 | 4 | typedef unsigned long size_t; 5 | typedef size_t __kernel_size_t; 6 | 7 | /* bsd */ 8 | typedef unsigned char u_char; 9 | typedef unsigned short u_short; 10 | typedef unsigned int u_int; 11 | typedef unsigned long u_long; 12 | 13 | /* sysv */ 14 | typedef unsigned char unchar; 15 | typedef unsigned short ushort; 16 | typedef unsigned int uint; 17 | typedef unsigned long ulong; 18 | 19 | typedef unsigned char __u8; 20 | typedef signed char __s8; 21 | typedef unsigned short __u16; 22 | typedef signed short __s16; 23 | typedef unsigned int __u32; 24 | typedef signed int __s32; 25 | typedef unsigned long __u64; 26 | typedef signed long __s64; 27 | 28 | typedef __u8 u_int8_t; 29 | typedef __s8 int8_t; 30 | typedef __u16 u_int16_t; 31 | typedef __s16 int16_t; 32 | typedef __u32 u_int32_t; 33 | typedef __s32 int32_t; 34 | 35 | typedef __u8 u8; 36 | typedef __s8 s8; 37 | typedef __u16 u16; 38 | typedef __s16 s16; 39 | typedef __u32 u32; 40 | typedef __s32 s32; 41 | typedef __u64 u64; 42 | typedef __s64 s64; 43 | 44 | typedef __u8 uint8_t; 45 | typedef __u16 uint16_t; 46 | typedef __u32 uint32_t; 47 | typedef __u64 uint64_t; 48 | typedef __u64 u_int64_t; 49 | typedef __s64 int64_t; 50 | 51 | #endif /* _LINUX_TYPES_H */ 52 | -------------------------------------------------------------------------------- /include/vsprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef __vsprintf_h 2 | #define __vsprintf_h 3 | 4 | int sprintf(char * buf, const char *fmt, ...); 5 | int printf( const char *fmt, ...); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /lwip/FILES: -------------------------------------------------------------------------------- 1 | api/ - The code for the high-level wrapper API. Not needed if 2 | you use the lowel-level call-back/raw API. 3 | 4 | core/ - The core of the TPC/IP stack; protocol implementations, 5 | memory and buffer management, and the low-level raw API. 6 | 7 | include/ - lwIP include files. 8 | 9 | netif/ - Generic network interface device drivers are kept here, 10 | as well as the ARP module. 11 | 12 | For more information on the various subdirectories, check the FILES 13 | file in each directory. 14 | -------------------------------------------------------------------------------- /lwip/api/err.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/err.h" 34 | 35 | #ifdef LWIP_DEBUG 36 | 37 | static char *err_strerr[] = {"Ok.", 38 | "Out of memory error.", 39 | "Buffer error.", 40 | "Connection aborted.", 41 | "Connection reset.", 42 | "Connection closed.", 43 | "Not connected.", 44 | "Illegal value.", 45 | "Illegal argument.", 46 | "Routing problem.", 47 | "Address in use." 48 | }; 49 | 50 | 51 | char * 52 | lwip_strerr(err_t err) 53 | { 54 | return err_strerr[-err]; 55 | 56 | } 57 | 58 | 59 | #endif /* LWIP_DEBUG */ 60 | -------------------------------------------------------------------------------- /lwip/arch/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_STRUCT __attribute__((packed)) 58 | #define PACK_STRUCT_BEGIN 59 | #define PACK_STRUCT_END 60 | 61 | #ifdef LWIP_DEBUG 62 | 63 | /* LW: forward declaration */ 64 | int printf(const char *format, ...); 65 | 66 | /* Plaform specific diagnostic output */ 67 | 68 | #endif/* LWIP_DEBUG */ 69 | #define LWIP_PLATFORM_DIAG(x) { printf x; } 70 | #define LWIP_PLATFORM_ASSERT(x) { printf("\fline %d in %s\n", __LINE__, __FILE__); while(1); } 71 | 72 | #endif /* __ARCH_CC_H__ */ 73 | -------------------------------------------------------------------------------- /lwip/arch/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 | -------------------------------------------------------------------------------- /lwip/arch/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 | -------------------------------------------------------------------------------- /lwip/arch/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 | -------------------------------------------------------------------------------- /lwip/arch/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 | -------------------------------------------------------------------------------- /lwip/arch/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 | -------------------------------------------------------------------------------- /lwip/arch/xenon/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 | -------------------------------------------------------------------------------- /lwip/arch/xenon/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 | -------------------------------------------------------------------------------- /lwip/arch/xenon/sys_arch.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: sys_arch.c,v 1.1 2007/03/19 20:10:27 tmbinc Exp $ 34 | */ 35 | 36 | #include "lwip/sys.h" 37 | #include "lwip/def.h" 38 | 39 | struct sys_timeouts timeouts; 40 | 41 | /*-----------------------------------------------------------------------------------*/ 42 | void 43 | sys_arch_block(u16_t time) 44 | { 45 | int i; 46 | for (i=0; i< time*1000; ++i) ; 47 | } 48 | /*-----------------------------------------------------------------------------------*/ 49 | sys_mbox_t 50 | sys_mbox_new(void) 51 | { 52 | return SYS_MBOX_NULL; 53 | } 54 | /*-----------------------------------------------------------------------------------*/ 55 | void 56 | sys_mbox_free(sys_mbox_t mbox) 57 | { 58 | return; 59 | } 60 | /*-----------------------------------------------------------------------------------*/ 61 | void 62 | sys_mbox_post(sys_mbox_t mbox, void *data) 63 | { 64 | return; 65 | } 66 | /*-----------------------------------------------------------------------------------*/ 67 | u16_t 68 | sys_arch_mbox_fetch(sys_mbox_t mbox, void **data, u16_t timeout) 69 | { 70 | sys_arch_block(timeout); 71 | return 0; 72 | } 73 | /*-----------------------------------------------------------------------------------*/ 74 | sys_sem_t 75 | sys_sem_new(u8_t count) 76 | { 77 | return 0; 78 | } 79 | /*-----------------------------------------------------------------------------------*/ 80 | u16_t 81 | sys_arch_sem_wait(sys_sem_t sem, u16_t timeout) 82 | { 83 | sys_arch_block(timeout); 84 | return 0; 85 | } 86 | /*-----------------------------------------------------------------------------------*/ 87 | void 88 | sys_sem_signal(sys_sem_t sem) 89 | { 90 | return; 91 | } 92 | /*-----------------------------------------------------------------------------------*/ 93 | void 94 | sys_sem_free(sys_sem_t sem) 95 | { 96 | return; 97 | } 98 | /*-----------------------------------------------------------------------------------*/ 99 | void 100 | sys_init(void) 101 | { 102 | timeouts.next = NULL; 103 | return; 104 | } 105 | /*-----------------------------------------------------------------------------------*/ 106 | struct sys_timeouts * 107 | sys_arch_timeouts(void) 108 | { 109 | return &timeouts; 110 | } 111 | /*-----------------------------------------------------------------------------------*/ 112 | void 113 | sys_thread_new(void (* function)(void *arg), void *arg) 114 | { 115 | } 116 | /*-----------------------------------------------------------------------------------*/ 117 | -------------------------------------------------------------------------------- /lwip/core/inet6.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 | 34 | /* inet6.c 35 | * 36 | * Functions common to all TCP/IP modules, such as the Internet checksum and the 37 | * byte order functions. 38 | * 39 | */ 40 | 41 | 42 | #include "lwip/opt.h" 43 | 44 | #include "lwip/def.h" 45 | #include "lwip/inet.h" 46 | 47 | 48 | 49 | /* chksum: 50 | * 51 | * Sums up all 16 bit words in a memory portion. Also includes any odd byte. 52 | * This function is used by the other checksum functions. 53 | * 54 | * For now, this is not optimized. Must be optimized for the particular processor 55 | * arcitecture on which it is to run. Preferebly coded in assembler. 56 | */ 57 | 58 | static u32_t 59 | chksum(void *dataptr, u16_t len) 60 | { 61 | u16_t *sdataptr = dataptr; 62 | u32_t acc; 63 | 64 | 65 | for(acc = 0; len > 1; len -= 2) { 66 | acc += *sdataptr++; 67 | } 68 | 69 | /* add up any odd byte */ 70 | if (len == 1) { 71 | acc += htons((u16_t)(*(u8_t *)dataptr) << 8); 72 | } 73 | 74 | return acc; 75 | 76 | } 77 | 78 | /* inet_chksum_pseudo: 79 | * 80 | * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. 81 | */ 82 | 83 | u16_t 84 | inet_chksum_pseudo(struct pbuf *p, 85 | struct ip_addr *src, struct ip_addr *dest, 86 | u8_t proto, u32_t proto_len) 87 | { 88 | u32_t acc; 89 | struct pbuf *q; 90 | u8_t swapped, i; 91 | 92 | acc = 0; 93 | swapped = 0; 94 | for(q = p; q != NULL; q = q->next) { 95 | acc += chksum(q->payload, q->len); 96 | while (acc >> 16) { 97 | acc = (acc & 0xffff) + (acc >> 16); 98 | } 99 | if (q->len % 2 != 0) { 100 | swapped = 1 - swapped; 101 | acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); 102 | } 103 | } 104 | 105 | if (swapped) { 106 | acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); 107 | } 108 | 109 | for(i = 0; i < 8; i++) { 110 | acc += ((u16_t *)src->addr)[i] & 0xffff; 111 | acc += ((u16_t *)dest->addr)[i] & 0xffff; 112 | while (acc >> 16) { 113 | acc = (acc & 0xffff) + (acc >> 16); 114 | } 115 | } 116 | acc += (u16_t)htons((u16_t)proto); 117 | acc += ((u16_t *)&proto_len)[0] & 0xffff; 118 | acc += ((u16_t *)&proto_len)[1] & 0xffff; 119 | 120 | while (acc >> 16) { 121 | acc = (acc & 0xffff) + (acc >> 16); 122 | } 123 | return ~(acc & 0xffff); 124 | } 125 | 126 | /* inet_chksum: 127 | * 128 | * Calculates the Internet checksum over a portion of memory. Used primarely for IP 129 | * and ICMP. 130 | */ 131 | 132 | u16_t 133 | inet_chksum(void *dataptr, u16_t len) 134 | { 135 | u32_t acc, sum; 136 | 137 | acc = chksum(dataptr, len); 138 | sum = (acc & 0xffff) + (acc >> 16); 139 | sum += (sum >> 16); 140 | return ~(sum & 0xffff); 141 | } 142 | 143 | u16_t 144 | inet_chksum_pbuf(struct pbuf *p) 145 | { 146 | u32_t acc; 147 | struct pbuf *q; 148 | u8_t swapped; 149 | 150 | acc = 0; 151 | swapped = 0; 152 | for(q = p; q != NULL; q = q->next) { 153 | acc += chksum(q->payload, q->len); 154 | while (acc >> 16) { 155 | acc = (acc & 0xffff) + (acc >> 16); 156 | } 157 | if (q->len % 2 != 0) { 158 | swapped = 1 - swapped; 159 | acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8); 160 | } 161 | } 162 | 163 | if (swapped) { 164 | acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); 165 | } 166 | return ~(acc & 0xffff); 167 | } 168 | 169 | -------------------------------------------------------------------------------- /lwip/core/ipv4/ip_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/ip_addr.h" 34 | #include "lwip/inet.h" 35 | #include "lwip/netif.h" 36 | 37 | /* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */ 38 | const struct ip_addr ip_addr_any = { 0x00000000UL }; 39 | const struct ip_addr ip_addr_broadcast = { 0xffffffffUL }; 40 | 41 | /* Determine if an address is a broadcast address on a network interface 42 | * 43 | * @param addr address to be checked 44 | * @param netif the network interface against which the address is checked 45 | * @return returns non-zero if the address is a broadcast address 46 | * 47 | */ 48 | 49 | u8_t ip_addr_isbroadcast(struct ip_addr *addr, struct netif *netif) 50 | { 51 | /* all ones (broadcast) or all zeroes (old skool broadcast) */ 52 | if ((addr->addr == ip_addr_broadcast.addr) || 53 | (addr->addr == ip_addr_any.addr)) 54 | return 1; 55 | /* no broadcast support on this network interface? */ 56 | else if ((netif->flags & NETIF_FLAG_BROADCAST) == 0) 57 | /* the given address cannot be a broadcast address 58 | * nor can we check against any broadcast addresses */ 59 | return 0; 60 | /* address matches network interface address exactly? => no broadcast */ 61 | else if (addr->addr == netif->ip_addr.addr) 62 | return 0; 63 | /* on the same (sub) network... */ 64 | else if (ip_addr_netcmp(addr, &(netif->ip_addr), &(netif->netmask)) 65 | /* ...and host identifier bits are all ones? =>... */ 66 | && ((addr->addr & ~netif->netmask.addr) == 67 | (ip_addr_broadcast.addr & ~netif->netmask.addr))) 68 | /* => network broadcast address */ 69 | return 1; 70 | else 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /lwip/core/ipv6/README: -------------------------------------------------------------------------------- 1 | IPv6 support in lwIP is very experimental. 2 | -------------------------------------------------------------------------------- /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/ip_addr.h" 34 | #include "lwip/inet.h" 35 | 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 | memcpy(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 | 74 | 75 | /*#if IP_DEBUG*/ 76 | void 77 | ip_addr_debug_print(struct ip_addr *addr) 78 | { 79 | printf("%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F", 80 | ntohl(addr->addr[0]) >> 16 & 0xffff, 81 | ntohl(addr->addr[0]) & 0xffff, 82 | ntohl(addr->addr[1]) >> 16 & 0xffff, 83 | ntohl(addr->addr[1]) & 0xffff, 84 | ntohl(addr->addr[2]) >> 16 & 0xffff, 85 | ntohl(addr->addr[2]) & 0xffff, 86 | ntohl(addr->addr[3]) >> 16 & 0xffff, 87 | ntohl(addr->addr[3]) & 0xffff); 88 | } 89 | /*#endif*/ /* IP_DEBUG */ 90 | 91 | -------------------------------------------------------------------------------- /lwip/core/stats.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 34 | 35 | #include "lwip/opt.h" 36 | 37 | #include "lwip/def.h" 38 | 39 | #include "lwip/stats.h" 40 | #include "lwip/mem.h" 41 | 42 | 43 | #if LWIP_STATS 44 | struct stats_ lwip_stats; 45 | 46 | void 47 | stats_init(void) 48 | { 49 | memset(&lwip_stats, 0, sizeof(struct stats_)); 50 | } 51 | #if LWIP_STATS_DISPLAY 52 | void 53 | stats_display_proto(struct stats_proto *proto, char *name) 54 | { 55 | LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); 56 | LWIP_PLATFORM_DIAG(("xmit: %"S16_F"\n\t", proto->xmit)); 57 | LWIP_PLATFORM_DIAG(("rexmit: %"S16_F"\n\t", proto->rexmit)); 58 | LWIP_PLATFORM_DIAG(("recv: %"S16_F"\n\t", proto->recv)); 59 | LWIP_PLATFORM_DIAG(("fw: %"S16_F"\n\t", proto->fw)); 60 | LWIP_PLATFORM_DIAG(("drop: %"S16_F"\n\t", proto->drop)); 61 | LWIP_PLATFORM_DIAG(("chkerr: %"S16_F"\n\t", proto->chkerr)); 62 | LWIP_PLATFORM_DIAG(("lenerr: %"S16_F"\n\t", proto->lenerr)); 63 | LWIP_PLATFORM_DIAG(("memerr: %"S16_F"\n\t", proto->memerr)); 64 | LWIP_PLATFORM_DIAG(("rterr: %"S16_F"\n\t", proto->rterr)); 65 | LWIP_PLATFORM_DIAG(("proterr: %"S16_F"\n\t", proto->proterr)); 66 | LWIP_PLATFORM_DIAG(("opterr: %"S16_F"\n\t", proto->opterr)); 67 | LWIP_PLATFORM_DIAG(("err: %"S16_F"\n\t", proto->err)); 68 | LWIP_PLATFORM_DIAG(("cachehit: %"S16_F"\n", proto->cachehit)); 69 | } 70 | 71 | void 72 | stats_display_pbuf(struct stats_pbuf *pbuf) 73 | { 74 | LWIP_PLATFORM_DIAG(("\nPBUF\n\t")); 75 | LWIP_PLATFORM_DIAG(("avail: %"S16_F"\n\t", pbuf->avail)); 76 | LWIP_PLATFORM_DIAG(("used: %"S16_F"\n\t", pbuf->used)); 77 | LWIP_PLATFORM_DIAG(("max: %"S16_F"\n\t", pbuf->max)); 78 | LWIP_PLATFORM_DIAG(("err: %"S16_F"\n\t", pbuf->err)); 79 | LWIP_PLATFORM_DIAG(("alloc_locked: %"S16_F"\n\t", pbuf->alloc_locked)); 80 | LWIP_PLATFORM_DIAG(("refresh_locked: %"S16_F"\n", pbuf->refresh_locked)); 81 | } 82 | 83 | void 84 | stats_display_mem(struct stats_mem *mem, char *name) 85 | { 86 | LWIP_PLATFORM_DIAG(("\n MEM %s\n\t", name)); 87 | LWIP_PLATFORM_DIAG(("avail: %"S16_F"\n\t", mem->avail)); 88 | LWIP_PLATFORM_DIAG(("used: %"S16_F"\n\t", mem->used)); 89 | LWIP_PLATFORM_DIAG(("max: %"S16_F"\n\t", mem->max)); 90 | LWIP_PLATFORM_DIAG(("err: %"S16_F"\n", mem->err)); 91 | 92 | } 93 | 94 | void 95 | stats_display(void) 96 | { 97 | s16_t i; 98 | char * memp_names[] = {"PBUF", "RAW_PCB", "UDP_PCB", "TCP_PCB", "TCP_PCB_LISTEN", 99 | "TCP_SEG", "NETBUF", "NETCONN", "API_MSG", "TCP_MSG", "TIMEOUT"}; 100 | stats_display_proto(&lwip_stats.link, "LINK"); 101 | stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG"); 102 | stats_display_proto(&lwip_stats.ip, "IP"); 103 | stats_display_proto(&lwip_stats.icmp, "ICMP"); 104 | stats_display_proto(&lwip_stats.udp, "UDP"); 105 | stats_display_proto(&lwip_stats.tcp, "TCP"); 106 | stats_display_pbuf(&lwip_stats.pbuf); 107 | stats_display_mem(&lwip_stats.mem, "HEAP"); 108 | for (i = 0; i < MEMP_MAX; i++) { 109 | stats_display_mem(&lwip_stats.memp[i], memp_names[i]); 110 | } 111 | 112 | } 113 | #endif /* LWIP_STATS_DISPLAY */ 114 | #endif /* LWIP_STATS */ 115 | 116 | -------------------------------------------------------------------------------- /lwip/include/ipv4/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/arch.h" 36 | 37 | #include "lwip/opt.h" 38 | #include "lwip/pbuf.h" 39 | 40 | #include "lwip/ip_addr.h" 41 | #include "lwip/netif.h" 42 | 43 | #define ICMP_ER 0 /* echo reply */ 44 | #define ICMP_DUR 3 /* destination unreachable */ 45 | #define ICMP_SQ 4 /* source quench */ 46 | #define ICMP_RD 5 /* redirect */ 47 | #define ICMP_ECHO 8 /* echo */ 48 | #define ICMP_TE 11 /* time exceeded */ 49 | #define ICMP_PP 12 /* parameter problem */ 50 | #define ICMP_TS 13 /* timestamp */ 51 | #define ICMP_TSR 14 /* timestamp reply */ 52 | #define ICMP_IRQ 15 /* information request */ 53 | #define ICMP_IR 16 /* information reply */ 54 | 55 | enum icmp_dur_type { 56 | ICMP_DUR_NET = 0, /* net unreachable */ 57 | ICMP_DUR_HOST = 1, /* host unreachable */ 58 | ICMP_DUR_PROTO = 2, /* protocol unreachable */ 59 | ICMP_DUR_PORT = 3, /* port unreachable */ 60 | ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ 61 | ICMP_DUR_SR = 5 /* source route failed */ 62 | }; 63 | 64 | enum icmp_te_type { 65 | ICMP_TE_TTL = 0, /* time to live exceeded in transit */ 66 | ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ 67 | }; 68 | 69 | void icmp_input(struct pbuf *p, struct netif *inp); 70 | 71 | void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); 72 | void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); 73 | 74 | #ifdef PACK_STRUCT_USE_INCLUDES 75 | # include "arch/bpstruct.h" 76 | #endif 77 | PACK_STRUCT_BEGIN 78 | struct icmp_echo_hdr { 79 | PACK_STRUCT_FIELD(u16_t _type_code); 80 | PACK_STRUCT_FIELD(u16_t chksum); 81 | PACK_STRUCT_FIELD(u16_t id); 82 | PACK_STRUCT_FIELD(u16_t seqno); 83 | } PACK_STRUCT_STRUCT; 84 | PACK_STRUCT_END 85 | 86 | PACK_STRUCT_BEGIN 87 | struct icmp_dur_hdr { 88 | PACK_STRUCT_FIELD(u16_t _type_code); 89 | PACK_STRUCT_FIELD(u16_t chksum); 90 | PACK_STRUCT_FIELD(u32_t unused); 91 | } PACK_STRUCT_STRUCT; 92 | PACK_STRUCT_END 93 | 94 | PACK_STRUCT_BEGIN 95 | struct icmp_te_hdr { 96 | PACK_STRUCT_FIELD(u16_t _type_code); 97 | PACK_STRUCT_FIELD(u16_t chksum); 98 | PACK_STRUCT_FIELD(u32_t unused); 99 | } PACK_STRUCT_STRUCT; 100 | PACK_STRUCT_END 101 | #ifdef PACK_STRUCT_USE_INCLUDES 102 | # include "arch/epstruct.h" 103 | #endif 104 | 105 | #define ICMPH_TYPE(hdr) (ntohs((hdr)->_type_code) >> 8) 106 | #define ICMPH_CODE(hdr) (ntohs((hdr)->_type_code) & 0xff) 107 | 108 | #define ICMPH_TYPE_SET(hdr, type) ((hdr)->_type_code = htons(ICMPH_CODE(hdr) | ((type) << 8))) 109 | #define ICMPH_CODE_SET(hdr, code) ((hdr)->_type_code = htons((code) | (ICMPH_TYPE(hdr) << 8))) 110 | 111 | #endif /* __LWIP_ICMP_H__ */ 112 | 113 | -------------------------------------------------------------------------------- /lwip/include/ipv4/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/arch.h" 36 | 37 | #include "lwip/opt.h" 38 | #include "lwip/pbuf.h" 39 | #include "lwip/ip_addr.h" 40 | 41 | u16_t inet_chksum(void *dataptr, u16_t len); 42 | #if 0 /* optimized routine */ 43 | u16_t inet_chksum4(u8_t *dataptr, u16_t len); 44 | #endif 45 | u16_t inet_chksum_pbuf(struct pbuf *p); 46 | u16_t inet_chksum_pseudo(struct pbuf *p, 47 | struct ip_addr *src, struct ip_addr *dest, 48 | u8_t proto, u16_t proto_len); 49 | 50 | u32_t inet_addr(const char *cp); 51 | s8_t inet_aton(const char *cp, struct in_addr *addr); 52 | char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */ 53 | 54 | #ifdef htons 55 | #undef htons 56 | #endif /* htons */ 57 | #ifdef htonl 58 | #undef htonl 59 | #endif /* htonl */ 60 | #ifdef ntohs 61 | #undef ntohs 62 | #endif /* ntohs */ 63 | #ifdef ntohl 64 | #undef ntohl 65 | #endif /* ntohl */ 66 | 67 | #if BYTE_ORDER == BIG_ENDIAN 68 | #define htons(x) (x) 69 | #define ntohs(x) (x) 70 | #define htonl(x) (x) 71 | #define ntohl(x) (x) 72 | #else 73 | #ifdef LWIP_PREFIX_BYTEORDER_FUNCS 74 | /* workaround for naming collisions on some platforms */ 75 | #define htons lwip_htons 76 | #define ntohs lwip_ntohs 77 | #define htonl lwip_htonl 78 | #define ntohl lwip_ntohl 79 | #endif 80 | u16_t htons(u16_t x); 81 | u16_t ntohs(u16_t x); 82 | u32_t htonl(u32_t x); 83 | u32_t ntohl(u32_t x); 84 | #endif 85 | 86 | #endif /* __LWIP_INET_H__ */ 87 | 88 | -------------------------------------------------------------------------------- /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/err.h" 37 | #include "lwip/pbuf.h" 38 | #include "lwip/netif.h" 39 | #include "lwip/ip_addr.h" 40 | 41 | void ip_reass_tmr(void); 42 | struct pbuf * ip_reass(struct pbuf *p); 43 | err_t ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest); 44 | 45 | #endif /* __LWIP_IP_FRAG_H__ */ 46 | 47 | 48 | -------------------------------------------------------------------------------- /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/arch.h" 36 | 37 | #include "lwip/opt.h" 38 | #include "lwip/pbuf.h" 39 | 40 | #include "lwip/netif.h" 41 | 42 | #define ICMP6_DUR 1 43 | #define ICMP6_TE 3 44 | #define ICMP6_ECHO 128 /* echo */ 45 | #define ICMP6_ER 129 /* echo reply */ 46 | 47 | 48 | enum icmp_dur_type { 49 | ICMP_DUR_NET = 0, /* net unreachable */ 50 | ICMP_DUR_HOST = 1, /* host unreachable */ 51 | ICMP_DUR_PROTO = 2, /* protocol unreachable */ 52 | ICMP_DUR_PORT = 3, /* port unreachable */ 53 | ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ 54 | ICMP_DUR_SR = 5 /* source route failed */ 55 | }; 56 | 57 | enum icmp_te_type { 58 | ICMP_TE_TTL = 0, /* time to live exceeded in transit */ 59 | ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ 60 | }; 61 | 62 | void icmp_input(struct pbuf *p, struct netif *inp); 63 | 64 | void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); 65 | void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); 66 | 67 | struct icmp_echo_hdr { 68 | u8_t type; 69 | u8_t icode; 70 | u16_t chksum; 71 | u16_t id; 72 | u16_t seqno; 73 | }; 74 | 75 | struct icmp_dur_hdr { 76 | u8_t type; 77 | u8_t icode; 78 | u16_t chksum; 79 | u32_t unused; 80 | }; 81 | 82 | struct icmp_te_hdr { 83 | u8_t type; 84 | u8_t icode; 85 | u16_t chksum; 86 | u32_t unused; 87 | }; 88 | 89 | #endif /* __LWIP_ICMP_H__ */ 90 | 91 | -------------------------------------------------------------------------------- /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/arch.h" 36 | 37 | #include "lwip/opt.h" 38 | #include "lwip/pbuf.h" 39 | #include "lwip/ip_addr.h" 40 | 41 | u16_t inet_chksum(void *data, u16_t len); 42 | u16_t inet_chksum_pbuf(struct pbuf *p); 43 | u16_t inet_chksum_pseudo(struct pbuf *p, 44 | struct ip_addr *src, struct ip_addr *dest, 45 | u8_t proto, u32_t proto_len); 46 | 47 | u32_t inet_addr(const char *cp); 48 | s8_t inet_aton(const char *cp, struct in_addr *addr); 49 | 50 | #ifndef _MACHINE_ENDIAN_H_ 51 | #ifndef _NETINET_IN_H 52 | #ifndef _LINUX_BYTEORDER_GENERIC_H 53 | u16_t htons(u16_t n); 54 | u16_t ntohs(u16_t n); 55 | u32_t htonl(u32_t n); 56 | u32_t ntohl(u32_t n); 57 | #endif /* _LINUX_BYTEORDER_GENERIC_H */ 58 | #endif /* _NETINET_IN_H */ 59 | #endif /* _MACHINE_ENDIAN_H_ */ 60 | 61 | #endif /* __LWIP_INET_H__ */ 62 | 63 | -------------------------------------------------------------------------------- /lwip/include/ipv6/lwip/ip.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_IP_H__ 33 | #define __LWIP_IP_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/def.h" 37 | #include "lwip/pbuf.h" 38 | #include "lwip/ip_addr.h" 39 | 40 | #include "lwip/err.h" 41 | 42 | #define IP_HLEN 40 43 | 44 | #define IP_PROTO_ICMP 58 45 | #define IP_PROTO_UDP 17 46 | #define IP_PROTO_UDPLITE 170 47 | #define IP_PROTO_TCP 6 48 | 49 | /* This is passed as the destination address to ip_output_if (not 50 | to ip_output), meaning that an IP header already is constructed 51 | in the pbuf. This is used when TCP retransmits. */ 52 | #ifdef IP_HDRINCL 53 | #undef IP_HDRINCL 54 | #endif /* IP_HDRINCL */ 55 | #define IP_HDRINCL NULL 56 | 57 | 58 | /* The IPv6 header. */ 59 | struct ip_hdr { 60 | #if BYTE_ORDER == LITTLE_ENDIAN 61 | u8_t tclass1:4, v:4; 62 | u8_t flow1:4, tclass2:4; 63 | #else 64 | u8_t v:4, tclass1:4; 65 | u8_t tclass2:8, flow1:4; 66 | #endif 67 | u16_t flow2; 68 | u16_t len; /* payload length */ 69 | u8_t nexthdr; /* next header */ 70 | u8_t hoplim; /* hop limit (TTL) */ 71 | struct ip_addr src, dest; /* source and destination IP addresses */ 72 | }; 73 | 74 | void ip_init(void); 75 | 76 | #include "lwip/netif.h" 77 | 78 | struct netif *ip_route(struct ip_addr *dest); 79 | 80 | void ip_input(struct pbuf *p, struct netif *inp); 81 | 82 | /* source and destination addresses in network byte order, please */ 83 | err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, 84 | u8_t ttl, u8_t proto); 85 | 86 | err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, 87 | u8_t ttl, u8_t proto, 88 | struct netif *netif); 89 | 90 | #if IP_DEBUG 91 | void ip_debug_print(struct pbuf *p); 92 | #endif /* IP_DEBUG */ 93 | 94 | #endif /* __LWIP_IP_H__ */ 95 | 96 | 97 | -------------------------------------------------------------------------------- /lwip/include/ipv6/lwip/ip_addr.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_IP_ADDR_H__ 33 | #define __LWIP_IP_ADDR_H__ 34 | 35 | #include "lwip/arch.h" 36 | 37 | #define IP_ADDR_ANY 0 38 | 39 | struct ip_addr { 40 | u32_t addr[4]; 41 | }; 42 | 43 | #define IP6_ADDR(ipaddr, a,b,c,d,e,f,g,h) do { (ipaddr)->addr[0] = htonl((u32_t)((a & 0xffff) << 16) | (b & 0xffff)); \ 44 | (ipaddr)->addr[1] = htonl(((c & 0xffff) << 16) | (d & 0xffff)); \ 45 | (ipaddr)->addr[2] = htonl(((e & 0xffff) << 16) | (f & 0xffff)); \ 46 | (ipaddr)->addr[3] = htonl(((g & 0xffff) << 16) | (h & 0xffff)); } while(0) 47 | 48 | u8_t ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, 49 | struct ip_addr *mask); 50 | u8_t ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2); 51 | void ip_addr_set(struct ip_addr *dest, struct ip_addr *src); 52 | u8_t ip_addr_isany(struct ip_addr *addr); 53 | 54 | 55 | #if IP_DEBUG 56 | void ip_addr_debug_print(struct ip_addr *addr); 57 | #endif /* IP_DEBUG */ 58 | 59 | #endif /* __LWIP_IP_ADDR_H__ */ 60 | -------------------------------------------------------------------------------- /lwip/include/lwip/api_msg.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_API_MSG_H__ 33 | #define __LWIP_API_MSG_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/pbuf.h" 37 | #include "lwip/sys.h" 38 | 39 | #include "lwip/ip.h" 40 | 41 | #include "lwip/udp.h" 42 | #include "lwip/tcp.h" 43 | 44 | #include "lwip/api.h" 45 | 46 | enum api_msg_type { 47 | API_MSG_NEWCONN, 48 | API_MSG_DELCONN, 49 | 50 | API_MSG_BIND, 51 | API_MSG_CONNECT, 52 | API_MSG_DISCONNECT, 53 | 54 | API_MSG_LISTEN, 55 | API_MSG_ACCEPT, 56 | 57 | API_MSG_SEND, 58 | API_MSG_RECV, 59 | API_MSG_WRITE, 60 | 61 | API_MSG_CLOSE, 62 | 63 | API_MSG_MAX 64 | }; 65 | 66 | struct api_msg_msg { 67 | struct netconn *conn; 68 | enum netconn_type conntype; 69 | union { 70 | struct pbuf *p; 71 | struct { 72 | struct ip_addr *ipaddr; 73 | u16_t port; 74 | } bc; 75 | struct { 76 | void *dataptr; 77 | u16_t len; 78 | u8_t copy; 79 | } w; 80 | sys_mbox_t mbox; 81 | u16_t len; 82 | } msg; 83 | }; 84 | 85 | struct api_msg { 86 | enum api_msg_type type; 87 | struct api_msg_msg msg; 88 | }; 89 | 90 | void api_msg_input(struct api_msg *msg); 91 | void api_msg_post(struct api_msg *msg); 92 | 93 | #endif /* __LWIP_API_MSG_H__ */ 94 | 95 | -------------------------------------------------------------------------------- /lwip/include/lwip/debug.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_DEBUG_H__ 33 | #define __LWIP_DEBUG_H__ 34 | 35 | #include "arch/cc.h" 36 | 37 | /** lower two bits indicate debug level 38 | * - 0 off 39 | * - 1 warning 40 | * - 2 serious 41 | * - 3 severe 42 | */ 43 | 44 | #define DBG_LEVEL_OFF 0 45 | #define DBG_LEVEL_WARNING 1 /* bad checksums, dropped packets, ... */ 46 | #define DBG_LEVEL_SERIOUS 2 /* memory allocation failures, ... */ 47 | #define DBG_LEVEL_SEVERE 3 /* */ 48 | #define DBG_MASK_LEVEL 3 49 | 50 | /** flag for LWIP_DEBUGF to enable that debug message */ 51 | #define DBG_ON 0x80U 52 | /** flag for LWIP_DEBUGF to disable that debug message */ 53 | #define DBG_OFF 0x00U 54 | 55 | /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ 56 | #define DBG_TRACE 0x40U 57 | /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ 58 | #define DBG_STATE 0x20U 59 | /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ 60 | #define DBG_FRESH 0x10U 61 | /** flag for LWIP_DEBUGF to halt after printing this debug message */ 62 | #define DBG_HALT 0x08U 63 | 64 | #ifndef LWIP_NOASSERT 65 | # define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0) 66 | #else 67 | # define LWIP_ASSERT(x,y) 68 | #endif 69 | 70 | #ifdef LWIP_DEBUG 71 | /** print debug message only if debug message type is enabled... 72 | * AND is of correct type AND is at least DBG_LEVEL 73 | */ 74 | # define LWIP_DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && ((s16_t)((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0) 75 | # define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0) 76 | #else /* LWIP_DEBUG */ 77 | # define LWIP_DEBUGF(debug,x) 78 | # define LWIP_ERROR(x) 79 | #endif /* LWIP_DEBUG */ 80 | 81 | #endif /* __LWIP_DEBUG_H__ */ 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /lwip/include/lwip/def.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_DEF_H__ 33 | #define __LWIP_DEF_H__ 34 | 35 | /* this might define NULL already */ 36 | #include "arch/cc.h" 37 | 38 | #define LWIP_MAX(x , y) (x) > (y) ? (x) : (y) 39 | #define LWIP_MIN(x , y) (x) < (y) ? (x) : (y) 40 | 41 | #ifndef NULL 42 | #define NULL ((void *)0) 43 | #endif 44 | 45 | 46 | #endif /* __LWIP_DEF_H__ */ 47 | 48 | -------------------------------------------------------------------------------- /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 | 37 | #include "arch/cc.h" 38 | 39 | typedef s8_t err_t; 40 | 41 | /* Definitions for error constants. */ 42 | 43 | #define ERR_OK 0 /* No error, everything OK. */ 44 | #define ERR_MEM -1 /* Out of memory error. */ 45 | #define ERR_BUF -2 /* Buffer error. */ 46 | 47 | 48 | #define ERR_ABRT -3 /* Connection aborted. */ 49 | #define ERR_RST -4 /* Connection reset. */ 50 | #define ERR_CLSD -5 /* Connection closed. */ 51 | #define ERR_CONN -6 /* Not connected. */ 52 | 53 | #define ERR_VAL -7 /* Illegal value. */ 54 | 55 | #define ERR_ARG -8 /* Illegal argument. */ 56 | 57 | #define ERR_RTE -9 /* Routing problem. */ 58 | 59 | #define ERR_USE -10 /* Address in use. */ 60 | 61 | #define ERR_IF -11 /* Low-level netif error */ 62 | #define ERR_ISCONN -12 /* Already connected. */ 63 | 64 | 65 | #ifdef LWIP_DEBUG 66 | extern char *lwip_strerr(err_t err); 67 | #else 68 | #define lwip_strerr(x) "" 69 | #endif /* LWIP_DEBUG */ 70 | #endif /* __LWIP_ERR_H__ */ 71 | -------------------------------------------------------------------------------- /lwip/include/lwip/mem.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_MEM_H__ 33 | #define __LWIP_MEM_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/arch.h" 37 | 38 | #if MEM_SIZE > 64000l 39 | typedef u32_t mem_size_t; 40 | #else 41 | typedef u16_t mem_size_t; 42 | #endif /* MEM_SIZE > 64000 */ 43 | 44 | 45 | void mem_init(void); 46 | 47 | void *mem_malloc(mem_size_t size); 48 | void mem_free(void *mem); 49 | void *mem_realloc(void *mem, mem_size_t size); 50 | void *mem_reallocm(void *mem, mem_size_t size); 51 | 52 | #ifndef MEM_ALIGN_SIZE 53 | #define MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)) 54 | #endif 55 | 56 | #ifndef MEM_ALIGN 57 | #define MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))) 58 | #endif 59 | 60 | #endif /* __LWIP_MEM_H__ */ 61 | 62 | -------------------------------------------------------------------------------- /lwip/include/lwip/memp.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 | 33 | #ifndef __LWIP_MEMP_H__ 34 | #define __LWIP_MEMP_H__ 35 | 36 | #include "lwip/opt.h" 37 | 38 | typedef enum { 39 | MEMP_PBUF, 40 | MEMP_RAW_PCB, 41 | MEMP_UDP_PCB, 42 | MEMP_TCP_PCB, 43 | MEMP_TCP_PCB_LISTEN, 44 | MEMP_TCP_SEG, 45 | 46 | MEMP_NETBUF, 47 | MEMP_NETCONN, 48 | MEMP_API_MSG, 49 | MEMP_TCPIP_MSG, 50 | 51 | MEMP_SYS_TIMEOUT, 52 | 53 | MEMP_MAX 54 | } memp_t; 55 | 56 | void memp_init(void); 57 | 58 | void *memp_malloc(memp_t type); 59 | void *memp_realloc(memp_t fromtype, memp_t totype, void *mem); 60 | void memp_free(memp_t type, void *mem); 61 | 62 | #endif /* __LWIP_MEMP_H__ */ 63 | 64 | -------------------------------------------------------------------------------- /lwip/include/lwip/pbuf.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 | 33 | #ifndef __LWIP_PBUF_H__ 34 | #define __LWIP_PBUF_H__ 35 | 36 | #include "arch/cc.h" 37 | 38 | 39 | #define PBUF_TRANSPORT_HLEN 20 40 | #define PBUF_IP_HLEN 20 41 | 42 | typedef enum { 43 | PBUF_TRANSPORT, 44 | PBUF_IP, 45 | PBUF_LINK, 46 | PBUF_RAW 47 | } pbuf_layer; 48 | 49 | typedef enum { 50 | PBUF_RAM, 51 | PBUF_ROM, 52 | PBUF_REF, 53 | PBUF_POOL 54 | } pbuf_flag; 55 | 56 | /* Definitions for the pbuf flag field. These are NOT the flags that 57 | * are passed to pbuf_alloc(). */ 58 | #define PBUF_FLAG_RAM 0x00U /* Flags that pbuf data is stored in RAM */ 59 | #define PBUF_FLAG_ROM 0x01U /* Flags that pbuf data is stored in ROM */ 60 | #define PBUF_FLAG_POOL 0x02U /* Flags that the pbuf comes from the pbuf pool */ 61 | #define PBUF_FLAG_REF 0x04U /* Flags thet the pbuf payload refers to RAM */ 62 | 63 | /** indicates this packet was broadcast on the link */ 64 | #define PBUF_FLAG_LINK_BROADCAST 0x80U 65 | 66 | struct pbuf { 67 | /** next pbuf in singly linked pbuf chain */ 68 | struct pbuf *next; 69 | 70 | /** pointer to the actual data in the buffer */ 71 | void *payload; 72 | 73 | /** 74 | * total length of this buffer and all next buffers in chain 75 | * belonging to the same packet. 76 | * 77 | * For non-queue packet chains this is the invariant: 78 | * p->tot_len == p->len + (p->next? p->next->tot_len: 0) 79 | */ 80 | u16_t tot_len; 81 | 82 | /** length of this buffer */ 83 | u16_t len; 84 | 85 | /** flags telling the type of pbuf, see PBUF_FLAG_ */ 86 | u16_t flags; 87 | 88 | /** 89 | * the reference count always equals the number of pointers 90 | * that refer to this pbuf. This can be pointers from an application, 91 | * the stack itself, or pbuf->next pointers from a chain. 92 | */ 93 | u16_t ref; 94 | 95 | }; 96 | 97 | void pbuf_init(void); 98 | 99 | struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_flag flag); 100 | void pbuf_realloc(struct pbuf *p, u16_t size); 101 | u8_t pbuf_header(struct pbuf *p, s16_t header_size); 102 | void pbuf_ref(struct pbuf *p); 103 | void pbuf_ref_chain(struct pbuf *p); 104 | u8_t pbuf_free(struct pbuf *p); 105 | u8_t pbuf_clen(struct pbuf *p); 106 | void pbuf_cat(struct pbuf *h, struct pbuf *t); 107 | void pbuf_chain(struct pbuf *h, struct pbuf *t); 108 | struct pbuf *pbuf_take(struct pbuf *f); 109 | struct pbuf *pbuf_dechain(struct pbuf *p); 110 | void pbuf_queue(struct pbuf *p, struct pbuf *n); 111 | struct pbuf * pbuf_dequeue(struct pbuf *p); 112 | 113 | #endif /* __LWIP_PBUF_H__ */ 114 | -------------------------------------------------------------------------------- /lwip/include/lwip/raw.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_RAW_H__ 33 | #define __LWIP_RAW_H__ 34 | 35 | #include "lwip/arch.h" 36 | 37 | #include "lwip/pbuf.h" 38 | #include "lwip/inet.h" 39 | #include "lwip/ip.h" 40 | 41 | struct raw_pcb { 42 | /* Common members of all PCB types */ 43 | IP_PCB; 44 | 45 | struct raw_pcb *next; 46 | 47 | u16_t protocol; 48 | 49 | u8_t (* recv)(void *arg, struct raw_pcb *pcb, struct pbuf *p, 50 | struct ip_addr *addr); 51 | void *recv_arg; 52 | }; 53 | 54 | /* The following functions is the application layer interface to the 55 | RAW code. */ 56 | struct raw_pcb * raw_new (u16_t proto); 57 | void raw_remove (struct raw_pcb *pcb); 58 | err_t raw_bind (struct raw_pcb *pcb, struct ip_addr *ipaddr); 59 | err_t raw_connect (struct raw_pcb *pcb, struct ip_addr *ipaddr); 60 | 61 | void raw_recv (struct raw_pcb *pcb, 62 | u8_t (* recv)(void *arg, struct raw_pcb *pcb, 63 | struct pbuf *p, 64 | struct ip_addr *addr), 65 | void *recv_arg); 66 | err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr); 67 | err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); 68 | 69 | /* The following functions are the lower layer interface to RAW. */ 70 | u8_t raw_input (struct pbuf *p, struct netif *inp); 71 | void raw_init (void); 72 | 73 | 74 | #endif /* __LWIP_RAW_H__ */ 75 | -------------------------------------------------------------------------------- /lwip/include/lwip/sio.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 | 30 | /* 31 | * This is the interface to the platform specific serial IO module 32 | * It needs to be implemented by those platforms which need SLIP or PPP 33 | */ 34 | 35 | #include "arch/cc.h" 36 | 37 | #ifndef __sio_fd_t_defined 38 | typedef void * sio_fd_t; 39 | #endif 40 | 41 | #ifndef sio_open 42 | sio_fd_t sio_open(u8_t); 43 | #endif 44 | 45 | #ifndef sio_send 46 | void sio_send(u8_t, sio_fd_t); 47 | #endif 48 | 49 | #ifndef sio_recv 50 | u8_t sio_recv(sio_fd_t); 51 | #endif 52 | 53 | #ifndef sio_read 54 | u32_t sio_read(sio_fd_t, u8_t *, u32_t); 55 | #endif 56 | 57 | #ifndef sio_write 58 | u32_t sio_write(sio_fd_t, u8_t *, u32_t); 59 | #endif 60 | 61 | #ifndef sio_read_abort 62 | void sio_read_abort(sio_fd_t); 63 | #endif 64 | -------------------------------------------------------------------------------- /lwip/include/lwip/stats.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_STATS_H__ 33 | #define __LWIP_STATS_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "arch/cc.h" 37 | 38 | #include "lwip/mem.h" 39 | #include "lwip/memp.h" 40 | 41 | #if LWIP_STATS 42 | 43 | struct stats_proto { 44 | u16_t xmit; /* Transmitted packets. */ 45 | u16_t rexmit; /* Retransmitted packets. */ 46 | u16_t recv; /* Received packets. */ 47 | u16_t fw; /* Forwarded packets. */ 48 | u16_t drop; /* Dropped packets. */ 49 | u16_t chkerr; /* Checksum error. */ 50 | u16_t lenerr; /* Invalid length error. */ 51 | u16_t memerr; /* Out of memory error. */ 52 | u16_t rterr; /* Routing error. */ 53 | u16_t proterr; /* Protocol error. */ 54 | u16_t opterr; /* Error in options. */ 55 | u16_t err; /* Misc error. */ 56 | u16_t cachehit; 57 | }; 58 | 59 | struct stats_mem { 60 | mem_size_t avail; 61 | mem_size_t used; 62 | mem_size_t max; 63 | mem_size_t err; 64 | }; 65 | 66 | struct stats_pbuf { 67 | u16_t avail; 68 | u16_t used; 69 | u16_t max; 70 | u16_t err; 71 | 72 | u16_t alloc_locked; 73 | u16_t refresh_locked; 74 | }; 75 | 76 | struct stats_syselem { 77 | u16_t used; 78 | u16_t max; 79 | u16_t err; 80 | }; 81 | 82 | struct stats_sys { 83 | struct stats_syselem sem; 84 | struct stats_syselem mbox; 85 | }; 86 | 87 | struct stats_ { 88 | struct stats_proto link; 89 | struct stats_proto ip_frag; 90 | struct stats_proto ip; 91 | struct stats_proto icmp; 92 | struct stats_proto udp; 93 | struct stats_proto tcp; 94 | struct stats_pbuf pbuf; 95 | struct stats_mem mem; 96 | struct stats_mem memp[MEMP_MAX]; 97 | struct stats_sys sys; 98 | }; 99 | 100 | extern struct stats_ lwip_stats; 101 | 102 | 103 | void stats_init(void); 104 | 105 | #define STATS_INC(x) ++lwip_stats.x 106 | #else 107 | #define stats_init() 108 | #define STATS_INC(x) 109 | #endif /* LWIP_STATS */ 110 | 111 | #if TCP_STATS 112 | #define TCP_STATS_INC(x) STATS_INC(x) 113 | #else 114 | #define TCP_STATS_INC(x) 115 | #endif 116 | 117 | #if UDP_STATS 118 | #define UDP_STATS_INC(x) STATS_INC(x) 119 | #else 120 | #define UDP_STATS_INC(x) 121 | #endif 122 | 123 | #if ICMP_STATS 124 | #define ICMP_STATS_INC(x) STATS_INC(x) 125 | #else 126 | #define ICMP_STATS_INC(x) 127 | #endif 128 | 129 | #if IP_STATS 130 | #define IP_STATS_INC(x) STATS_INC(x) 131 | #else 132 | #define IP_STATS_INC(x) 133 | #endif 134 | 135 | #if IPFRAG_STATS 136 | #define IPFRAG_STATS_INC(x) STATS_INC(x) 137 | #else 138 | #define IPFRAG_STATS_INC(x) 139 | #endif 140 | 141 | #if LINK_STATS 142 | #define LINK_STATS_INC(x) STATS_INC(x) 143 | #else 144 | #define LINK_STATS_INC(x) 145 | #endif 146 | 147 | /* Display of statistics */ 148 | #if LWIP_STATS_DISPLAY 149 | void stats_display(void); 150 | #else 151 | #define stats_display() 152 | #endif 153 | 154 | #endif /* __LWIP_STATS_H__ */ 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /lwip/include/lwip/tcpip.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_TCPIP_H__ 33 | #define __LWIP_TCPIP_H__ 34 | 35 | #include "lwip/api_msg.h" 36 | #include "lwip/pbuf.h" 37 | 38 | void tcpip_init(void (* tcpip_init_done)(void *), void *arg); 39 | void tcpip_apimsg(struct api_msg *apimsg); 40 | err_t tcpip_input(struct pbuf *p, struct netif *inp); 41 | err_t tcpip_callback(void (*f)(void *ctx), void *ctx); 42 | 43 | void tcpip_tcp_timer_needed(void); 44 | 45 | enum tcpip_msg_type { 46 | TCPIP_MSG_API, 47 | TCPIP_MSG_INPUT, 48 | TCPIP_MSG_CALLBACK 49 | }; 50 | 51 | struct tcpip_msg { 52 | enum tcpip_msg_type type; 53 | sys_sem_t *sem; 54 | union { 55 | struct api_msg *apimsg; 56 | struct { 57 | struct pbuf *p; 58 | struct netif *netif; 59 | } inp; 60 | struct { 61 | void (*f)(void *ctx); 62 | void *ctx; 63 | } cb; 64 | } msg; 65 | }; 66 | 67 | 68 | #endif /* __LWIP_TCPIP_H__ */ 69 | -------------------------------------------------------------------------------- /lwip/include/lwip/udp.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_UDP_H__ 33 | #define __LWIP_UDP_H__ 34 | 35 | #include "lwip/arch.h" 36 | 37 | #include "lwip/pbuf.h" 38 | #include "lwip/inet.h" 39 | #include "lwip/ip.h" 40 | 41 | #define UDP_HLEN 8 42 | 43 | struct udp_hdr { 44 | PACK_STRUCT_FIELD(u16_t src); 45 | PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ 46 | PACK_STRUCT_FIELD(u16_t len); 47 | PACK_STRUCT_FIELD(u16_t chksum); 48 | } PACK_STRUCT_STRUCT; 49 | 50 | #define UDP_FLAGS_NOCHKSUM 0x01U 51 | #define UDP_FLAGS_UDPLITE 0x02U 52 | #define UDP_FLAGS_CONNECTED 0x04U 53 | 54 | struct udp_pcb { 55 | /* Common members of all PCB types */ 56 | IP_PCB; 57 | 58 | /* Protocol specific PCB members */ 59 | 60 | struct udp_pcb *next; 61 | 62 | u8_t flags; 63 | u16_t local_port, remote_port; 64 | 65 | u16_t chksum_len; 66 | 67 | void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p, 68 | struct ip_addr *addr, u16_t port); 69 | void *recv_arg; 70 | }; 71 | 72 | /* The following functions is the application layer interface to the 73 | UDP code. */ 74 | struct udp_pcb * udp_new (void); 75 | void udp_remove (struct udp_pcb *pcb); 76 | err_t udp_bind (struct udp_pcb *pcb, struct ip_addr *ipaddr, 77 | u16_t port); 78 | err_t udp_connect (struct udp_pcb *pcb, struct ip_addr *ipaddr, 79 | u16_t port); 80 | void udp_disconnect (struct udp_pcb *pcb); 81 | void udp_recv (struct udp_pcb *pcb, 82 | void (* recv)(void *arg, struct udp_pcb *upcb, 83 | struct pbuf *p, 84 | struct ip_addr *addr, 85 | u16_t port), 86 | void *recv_arg); 87 | err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port); 88 | err_t udp_send (struct udp_pcb *pcb, struct pbuf *p); 89 | 90 | #define udp_flags(pcb) ((pcb)->flags) 91 | #define udp_setflags(pcb, f) ((pcb)->flags = (f)) 92 | 93 | /* The following functions are the lower layer interface to UDP. */ 94 | void udp_input (struct pbuf *p, struct netif *inp); 95 | void udp_init (void); 96 | 97 | #if UDP_DEBUG 98 | void udp_debug_print(struct udp_hdr *udphdr); 99 | #else 100 | #define udp_debug_print(udphdr) 101 | #endif 102 | #endif /* __LWIP_UDP_H__ */ 103 | 104 | 105 | -------------------------------------------------------------------------------- /lwip/include/netif/etharp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * Copyright (c) 2003-2004 Leon Woestenberg 4 | * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. 5 | * All rights reserved. 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 | * Author: Adam Dunkels 32 | * 33 | */ 34 | 35 | #ifndef __NETIF_ETHARP_H__ 36 | #define __NETIF_ETHARP_H__ 37 | 38 | #ifndef ETH_PAD_SIZE 39 | #define ETH_PAD_SIZE 0 40 | #endif 41 | 42 | #include "lwip/pbuf.h" 43 | #include "lwip/ip_addr.h" 44 | #include "lwip/netif.h" 45 | #include "lwip/ip.h" 46 | 47 | #ifdef PACK_STRUCT_USE_INCLUDES 48 | # include "arch/bpstruct.h" 49 | #endif 50 | PACK_STRUCT_BEGIN 51 | struct eth_addr { 52 | PACK_STRUCT_FIELD(u8_t addr[6]); 53 | } PACK_STRUCT_STRUCT; 54 | PACK_STRUCT_END 55 | #ifdef PACK_STRUCT_USE_INCLUDES 56 | # include "arch/epstruct.h" 57 | #endif 58 | 59 | #ifdef PACK_STRUCT_USE_INCLUDES 60 | # include "arch/bpstruct.h" 61 | #endif 62 | PACK_STRUCT_BEGIN 63 | struct eth_hdr { 64 | #if ETH_PAD_SIZE 65 | PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]); 66 | #endif 67 | PACK_STRUCT_FIELD(struct eth_addr dest); 68 | PACK_STRUCT_FIELD(struct eth_addr src); 69 | PACK_STRUCT_FIELD(u16_t type); 70 | } PACK_STRUCT_STRUCT; 71 | PACK_STRUCT_END 72 | #ifdef PACK_STRUCT_USE_INCLUDES 73 | # include "arch/epstruct.h" 74 | #endif 75 | 76 | #ifdef PACK_STRUCT_USE_INCLUDES 77 | # include "arch/bpstruct.h" 78 | #endif 79 | PACK_STRUCT_BEGIN 80 | /** the ARP message */ 81 | struct etharp_hdr { 82 | PACK_STRUCT_FIELD(struct eth_hdr ethhdr); 83 | PACK_STRUCT_FIELD(u16_t hwtype); 84 | PACK_STRUCT_FIELD(u16_t proto); 85 | PACK_STRUCT_FIELD(u16_t _hwlen_protolen); 86 | PACK_STRUCT_FIELD(u16_t opcode); 87 | PACK_STRUCT_FIELD(struct eth_addr shwaddr); 88 | PACK_STRUCT_FIELD(struct ip_addr2 sipaddr); 89 | PACK_STRUCT_FIELD(struct eth_addr dhwaddr); 90 | PACK_STRUCT_FIELD(struct ip_addr2 dipaddr); 91 | } PACK_STRUCT_STRUCT; 92 | PACK_STRUCT_END 93 | #ifdef PACK_STRUCT_USE_INCLUDES 94 | # include "arch/epstruct.h" 95 | #endif 96 | 97 | #ifdef PACK_STRUCT_USE_INCLUDES 98 | # include "arch/bpstruct.h" 99 | #endif 100 | PACK_STRUCT_BEGIN 101 | struct ethip_hdr { 102 | PACK_STRUCT_FIELD(struct eth_hdr eth); 103 | PACK_STRUCT_FIELD(struct ip_hdr ip); 104 | } PACK_STRUCT_STRUCT; 105 | PACK_STRUCT_END 106 | #ifdef PACK_STRUCT_USE_INCLUDES 107 | # include "arch/epstruct.h" 108 | #endif 109 | 110 | /** 5 seconds period */ 111 | #define ARP_TMR_INTERVAL 5000 112 | 113 | #define ETHTYPE_ARP 0x0806 114 | #define ETHTYPE_IP 0x0800 115 | 116 | void etharp_init(void); 117 | void etharp_tmr(void); 118 | void etharp_ip_input(struct netif *netif, struct pbuf *p); 119 | void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, 120 | struct pbuf *p); 121 | err_t etharp_output(struct netif *netif, struct ip_addr *ipaddr, 122 | struct pbuf *q); 123 | err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q); 124 | err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr); 125 | 126 | #endif /* __NETIF_ARP_H__ */ 127 | -------------------------------------------------------------------------------- /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/netif.h" 36 | 37 | err_t loopif_init(struct netif *netif); 38 | 39 | #endif /* __NETIF_LOOPIF_H__ */ 40 | -------------------------------------------------------------------------------- /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/netif.h" 38 | 39 | err_t slipif_init(struct netif * netif); 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /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 | An example network interface that shows how a "loopback" 19 | interface would work. This is not really intended for actual 20 | use, but as a very basic example of how initialization and 21 | output functions work. 22 | 23 | slipif.c 24 | A generic implementation of the SLIP (Serial Line IP) 25 | protocol. It requires a sio (serial I/O) module to work. 26 | 27 | ppp/ Point-to-Point Protocol stack 28 | -------------------------------------------------------------------------------- /lwip/netif/loopif.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 | #include "lwip/opt.h" 33 | 34 | #if LWIP_HAVE_LOOPIF 35 | 36 | #include "netif/loopif.h" 37 | #include "lwip/mem.h" 38 | 39 | #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) 40 | #include "netif/tcpdump.h" 41 | #endif /* LWIP_DEBUG && LWIP_TCPDUMP */ 42 | 43 | #include "lwip/tcp.h" 44 | #include "lwip/ip.h" 45 | 46 | static void 47 | loopif_input( void * arg ) 48 | { 49 | struct netif *netif = (struct netif *)( ((void **)arg)[ 0 ] ); 50 | struct pbuf *r = (struct pbuf *)( ((void **)arg)[ 1 ] ); 51 | 52 | mem_free( arg ); 53 | netif -> input( r, netif ); 54 | } 55 | 56 | static err_t 57 | loopif_output(struct netif *netif, struct pbuf *p, 58 | struct ip_addr *ipaddr) 59 | { 60 | struct pbuf *q, *r; 61 | u8_t *ptr; 62 | void **arg; 63 | 64 | #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) 65 | tcpdump(p); 66 | #endif /* LWIP_DEBUG && LWIP_TCPDUMP */ 67 | 68 | r = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); 69 | if (r != NULL) { 70 | ptr = r->payload; 71 | 72 | for(q = p; q != NULL; q = q->next) { 73 | memcpy(ptr, q->payload, q->len); 74 | ptr += q->len; 75 | } 76 | 77 | arg = mem_malloc( sizeof( void *[2])); 78 | if( NULL == arg ) { 79 | return ERR_MEM; 80 | } 81 | 82 | arg[0] = netif; 83 | arg[1] = r; 84 | /** 85 | * workaround (patch #1779) to try to prevent bug #2595: 86 | * When connecting to "localhost" with the loopif interface, 87 | * tcp_output doesn't get the opportunity to finnish sending the 88 | * segment before tcp_process gets it, resulting in tcp_process 89 | * referencing pcb->unacked-> which still is NULL. 90 | * 91 | * TODO: Is there still a race condition here? Leon 92 | */ 93 | sys_timeout( 1, loopif_input, arg ); 94 | 95 | return ERR_OK; 96 | } 97 | return ERR_MEM; 98 | } 99 | 100 | err_t 101 | loopif_init(struct netif *netif) 102 | { 103 | netif->name[0] = 'l'; 104 | netif->name[1] = 'o'; 105 | #if 0 /** TODO: I think this should be enabled, or not? Leon */ 106 | netif->input = loopif_input; 107 | #endif 108 | netif->output = loopif_output; 109 | return ERR_OK; 110 | } 111 | 112 | #endif /* LWIP_HAVE_LOOPIF */ 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /lwip/netif/ppp/auth.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * auth.h - PPP Authentication and phase control 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 | * 97-12-04 Guy Lancaster , Global Election Systems Inc. 31 | * Original derived from BSD pppd.h. 32 | *****************************************************************************/ 33 | /* 34 | * pppd.h - PPP daemon global declarations. 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 | 53 | #ifndef AUTH_H 54 | #define AUTH_H 55 | 56 | /*********************** 57 | *** PUBLIC FUNCTIONS *** 58 | ***********************/ 59 | void link_required (int); /* we are starting to use the link */ 60 | void link_terminated (int); /* we are finished with the link */ 61 | void link_down (int); /* the LCP layer has left the Opened state */ 62 | void link_established (int); /* the link is up; authenticate now */ 63 | void np_up (int, u16_t); /* a network protocol has come up */ 64 | void np_down (int, u16_t); /* a network protocol has gone down */ 65 | void np_finished (int, u16_t); /* a network protocol no longer needs link */ 66 | void auth_peer_fail (int, u16_t);/* peer failed to authenticate itself */ 67 | 68 | /* peer successfully authenticated itself */ 69 | void auth_peer_success (int, u16_t, char *, int); 70 | 71 | /* we failed to authenticate ourselves */ 72 | void auth_withpeer_fail (int, u16_t); 73 | 74 | /* we successfully authenticated ourselves */ 75 | void auth_withpeer_success (int, u16_t); 76 | 77 | /* check authentication options supplied */ 78 | void auth_check_options (void); 79 | void auth_reset (int); /* check what secrets we have */ 80 | 81 | /* Check peer-supplied username/password */ 82 | int check_passwd (int, char *, int, char *, int, char **, int *); 83 | 84 | /* get "secret" for chap */ 85 | int get_secret (int, char *, char *, char *, int *, int); 86 | 87 | /* check if IP address is authorized */ 88 | int auth_ip_addr (int, u32_t); 89 | 90 | /* check if IP address is unreasonable */ 91 | int bad_ip_adrs (u32_t); 92 | 93 | 94 | #endif /* AUTH_H */ 95 | -------------------------------------------------------------------------------- /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.1 2007/03/19 20:11:04 tmbinc 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 | -------------------------------------------------------------------------------- /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 "ppp.h" 53 | #include "randm.h" 54 | #include "magic.h" 55 | 56 | 57 | /***********************************/ 58 | /*** PUBLIC FUNCTION DEFINITIONS ***/ 59 | /***********************************/ 60 | /* 61 | * magicInit - Initialize the magic number generator. 62 | * 63 | * Since we use another random number generator that has its own 64 | * initialization, we do nothing here. 65 | */ 66 | void magicInit() 67 | { 68 | return; 69 | } 70 | 71 | /* 72 | * magic - Returns the next magic number. 73 | */ 74 | u32_t magic() 75 | { 76 | return avRandom(); 77 | } 78 | 79 | 80 | -------------------------------------------------------------------------------- /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.1 2007/03/19 20:11:06 tmbinc Exp $ 52 | */ 53 | 54 | #ifndef MAGIC_H 55 | #define MAGIC_H 56 | 57 | /***************************************************************************** 58 | ************************** PUBLIC FUNCTIONS ********************************** 59 | *****************************************************************************/ 60 | 61 | void magicInit(void); /* Initialize the magic number generator */ 62 | u32_t magic(void); /* Returns the next magic number */ 63 | 64 | #endif /* MAGIC_H */ 65 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | /************************ 40 | *** PUBLIC DATA TYPES *** 41 | ************************/ 42 | /* Trace levels. */ 43 | typedef enum { 44 | LOG_CRITICAL = 0, 45 | LOG_ERR = 1, 46 | LOG_NOTICE = 2, 47 | LOG_WARNING = 3, 48 | LOG_INFO = 5, 49 | LOG_DETAIL = 6, 50 | LOG_DEBUG = 7 51 | } LogCodes; 52 | 53 | 54 | /*********************** 55 | *** PUBLIC FUNCTIONS *** 56 | ***********************/ 57 | /* 58 | * ppp_trace - a form of printf to send tracing information to stderr 59 | */ 60 | void ppp_trace(int level, const char *format,...); 61 | 62 | #if PPP_DEBUG > 0 63 | 64 | #define AUTHDEBUG(a) ppp_trace a 65 | #define IPCPDEBUG(a) ppp_trace a 66 | #define UPAPDEBUG(a) ppp_trace a 67 | #define LCPDEBUG(a) ppp_trace a 68 | #define FSMDEBUG(a) ppp_trace a 69 | #define CHAPDEBUG(a) ppp_trace a 70 | #define PPPDEBUG(a) ppp_trace a 71 | 72 | #define TRACELCP 1 73 | 74 | #else 75 | 76 | #define AUTHDEBUG(a) 77 | #define IPCPDEBUG(a) 78 | #define UPAPDEBUG(a) 79 | #define LCPDEBUG(a) 80 | #define FSMDEBUG(a) 81 | #define CHAPDEBUG(a) 82 | 83 | #define PPPDEBUG(a) 84 | 85 | #define TRACELCP 0 86 | 87 | #endif 88 | 89 | #endif /* PPPDEBUG_H */ 90 | -------------------------------------------------------------------------------- /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 62 | void avRandomize(void); 63 | #endif 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 | -------------------------------------------------------------------------------- /lwip/netif/ppp/vjbsdhdr.h: -------------------------------------------------------------------------------- 1 | #ifndef VJBSDHDR_H 2 | #define VJBSDHDR_H 3 | 4 | #include "lwip/tcp.h" 5 | 6 | 7 | /* 8 | * Structure of an internet header, naked of options. 9 | * 10 | * We declare ip_len and ip_off to be short, rather than u_short 11 | * pragmatically since otherwise unsigned comparisons can result 12 | * against negative integers quite easily, and fail in subtle ways. 13 | */ 14 | PACK_STRUCT_BEGIN 15 | struct ip 16 | { 17 | #if defined(NO_CHAR_BITFIELDS) 18 | 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... */ 19 | #else 20 | #if BYTE_ORDER == LITTLE_ENDIAN 21 | unsigned ip_hl:4, /* header length */ 22 | ip_v:4; /* version */ 23 | #elif BYTE_ORDER == BIG_ENDIAN 24 | unsigned ip_v:4, /* version */ 25 | ip_hl:4; /* header length */ 26 | #else 27 | COMPLAIN - NO BYTE ORDER SELECTED! 28 | #endif 29 | #endif 30 | u_char ip_tos; /* type of service */ 31 | u_short ip_len; /* total length */ 32 | u_short ip_id; /* identification */ 33 | u_short ip_off; /* fragment offset field */ 34 | #define IP_DF 0x4000 /* dont fragment flag */ 35 | #define IP_MF 0x2000 /* more fragments flag */ 36 | #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ 37 | u_char ip_ttl; /* time to live */ 38 | u_char ip_p; /* protocol */ 39 | u_short ip_sum; /* checksum */ 40 | struct in_addr ip_src,ip_dst; /* source and dest address */ 41 | }; 42 | PACK_STRUCT_END 43 | 44 | typedef u32_t tcp_seq; 45 | 46 | /* 47 | * TCP header. 48 | * Per RFC 793, September, 1981. 49 | */ 50 | PACK_STRUCT_BEGIN 51 | struct tcphdr 52 | { 53 | u_short th_sport; /* source port */ 54 | u_short th_dport; /* destination port */ 55 | tcp_seq th_seq; /* sequence number */ 56 | tcp_seq th_ack; /* acknowledgement number */ 57 | #if defined(NO_CHAR_BITFIELDS) 58 | u_char th_x2_off; 59 | #else 60 | #if BYTE_ORDER == LITTLE_ENDIAN 61 | unsigned th_x2:4, /* (unused) */ 62 | th_off:4; /* data offset */ 63 | #endif 64 | #if BYTE_ORDER == BIG_ENDIAN 65 | unsigned th_off:4, /* data offset */ 66 | th_x2:4; /* (unused) */ 67 | #endif 68 | #endif 69 | u_char th_flags; 70 | u_short th_win; /* window */ 71 | u_short th_sum; /* checksum */ 72 | u_short th_urp; /* urgent pointer */ 73 | }; 74 | PACK_STRUCT_END 75 | 76 | #endif /* VJBSDHDR_H */ 77 | -------------------------------------------------------------------------------- /network.c: -------------------------------------------------------------------------------- 1 | #include "time.h" 2 | #include "lwipopts.h" 3 | #include "lwip/debug.h" 4 | 5 | #include "lwip/mem.h" 6 | #include "lwip/memp.h" 7 | #include "lwip/sys.h" 8 | 9 | #include "lwip/stats.h" 10 | 11 | #include "lwip/ip.h" 12 | #include "lwip/udp.h" 13 | #include "lwip/tcp.h" 14 | #include "netif/etharp.h" 15 | 16 | struct netif netif; 17 | static tb_t now, last_tcp, last_dhcp; 18 | 19 | extern void enet_poll(struct netif *netif); 20 | extern err_t enet_init(struct netif *netif); 21 | 22 | extern void httpd_start(void); 23 | 24 | void network_poll(); 25 | 26 | 27 | void network_init() 28 | { 29 | struct ip_addr ipaddr, netmask, gw; 30 | 31 | printf("trying to initialize network...\n"); 32 | 33 | #ifdef STATS 34 | stats_init(); 35 | #endif /* STATS */ 36 | 37 | mem_init(); 38 | memp_init(); 39 | pbuf_init(); 40 | netif_init(); 41 | ip_init(); 42 | udp_init(); 43 | tcp_init(); 44 | etharp_init(); 45 | printf("ok now the NIC\n"); 46 | 47 | if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, enet_init, ip_input)) 48 | { 49 | printf("netif_add failed!\n"); 50 | return; 51 | } 52 | 53 | netif_set_default(&netif); 54 | 55 | dhcp_start(&netif); 56 | 57 | mftb(&last_tcp); 58 | mftb(&last_dhcp); 59 | 60 | printf("\nWaiting for DHCP"); 61 | 62 | int i; 63 | for (i=0; i<10; i++) { 64 | mdelay(500); 65 | network_poll(); 66 | 67 | printf("."); 68 | 69 | if (netif.ip_addr.addr) 70 | break; 71 | } 72 | 73 | if (netif.ip_addr.addr) { 74 | printf("%u.%u.%u.%u\n", 75 | (netif.ip_addr.addr >> 24) & 0xFF, 76 | (netif.ip_addr.addr >> 16) & 0xFF, 77 | (netif.ip_addr.addr >> 8) & 0xFF, 78 | (netif.ip_addr.addr >> 0) & 0xFF); 79 | 80 | printf("\n"); 81 | } else { 82 | printf("failed.\n\n"); 83 | 84 | IP4_ADDR(&ipaddr, 10, 0, 120, 209); 85 | IP4_ADDR(&gw, 10, 0, 120, 1); 86 | IP4_ADDR(&netmask, 255, 255, 255, 0); 87 | netif_set_addr(&netif, &ipaddr, &netmask, &gw); 88 | netif_set_up(&netif); 89 | } 90 | 91 | 92 | printf("starting httpd server.."); 93 | httpd_start(); 94 | printf("ok!\n"); 95 | } 96 | 97 | void print_network_config() 98 | { 99 | #define NTOA(ip) (int)((ip.addr>>24)&0xff), (int)((ip.addr>>16)&0xff), (int)((ip.addr>>8)&0xff), (int)(ip.addr&0xff) 100 | printf(" * XeLL network config: %d.%d.%d.%d / %d.%d.%d.%d\n", 101 | NTOA(netif.ip_addr), NTOA(netif.netmask)); 102 | } 103 | 104 | void network_poll() 105 | { 106 | mftb(&now); 107 | enet_poll(&netif); 108 | 109 | if (tb_diff_msec(&now, &last_tcp) >= 100) 110 | { 111 | mftb(&last_tcp); 112 | tcp_tmr(); 113 | } 114 | 115 | if (tb_diff_msec(&now, &last_dhcp) >= DHCP_FINE_TIMER_MSECS) 116 | { 117 | mftb(&last_dhcp); 118 | dhcp_fine_tmr(); 119 | } 120 | } 121 | 122 | char *network_boot_server_name() 123 | { 124 | if (netif.dhcp && netif.dhcp->boot_server_name) 125 | return netif.dhcp->boot_server_name; 126 | 127 | return "10.0.120.78"; 128 | } 129 | 130 | char *network_boot_file_name() 131 | { 132 | if (netif.dhcp && netif.dhcp->boot_file_name) 133 | return netif.dhcp->boot_file_name; 134 | 135 | return "/tftpboot/xenon"; 136 | } 137 | -------------------------------------------------------------------------------- /nocfe/addrspace.h: -------------------------------------------------------------------------------- 1 | #define K0_TO_PHYS(x) (x) 2 | #define PHYS_TO_K1(x) (x) 3 | 4 | #define PHYSADDR(x) K0_TO_PHYS(x) 5 | #define KERNADDR(x) PHYS_TO_K0(x) 6 | #define UNCADDR(x) PHYS_TO_K1(x) 7 | -------------------------------------------------------------------------------- /nocfe/cfe.h: -------------------------------------------------------------------------------- 1 | #include "lib_types.h" 2 | #include "lib_queue.h" 3 | #include "lib_malloc.h" 4 | #include "cfe_console.h" 5 | #include "addrspace.h" 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | typedef void *hsaddr_t; 12 | #define HSADDR2PTR(x) x 13 | #define PTR2HSADDR(x) x 14 | 15 | #define CFE_HZ 1000 16 | 17 | #define cfe_sleep mdelay 18 | 19 | #define xprintf printf 20 | 21 | #define hs_memcpy_from_hs memcpy 22 | #define hs_memcpy_to_hs memcpy 23 | 24 | static inline void CACHE_DMA_SYNC(void *x, int l) { dcache_flush(x, l); } 25 | static inline void CACHE_DMA_INVAL(void *x, int l) { dcache_flush(x, l); } 26 | 27 | -------------------------------------------------------------------------------- /nocfe/cfe_console.h: -------------------------------------------------------------------------------- 1 | #define console_log(fmt, x...) printf(fmt "\n", x) 2 | -------------------------------------------------------------------------------- /nocfe/cfe_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __USB_CFE_TIMER_H 2 | #define __USB_CFE_TIMER_H 3 | 4 | #include 5 | 6 | #define CFE_HZ 1000 7 | static inline void cfe_sleep(int ticks) { mdelay(ticks); } 8 | static inline void cfe_usleep(int ticks) { udelay(ticks); } 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /nocfe/cpu_config.h: -------------------------------------------------------------------------------- 1 | #define CPUCFG_REGS32 1 2 | #define _MIPSREGS32_ 1 3 | -------------------------------------------------------------------------------- /nocfe/lib_malloc.h: -------------------------------------------------------------------------------- 1 | /* ********************************************************************* 2 | * Broadcom Common Firmware Environment (CFE) 3 | * 4 | * Local memory manager File: mempool.h 5 | * 6 | * This routine is used to manage memory allocated within the 7 | * firmware. You give it a chunk of memory to manage, and then 8 | * these routines manage suballocations from there. 9 | * 10 | * Author: Mitch Lichtenberg (mpl@broadcom.com) 11 | * 12 | ********************************************************************* 13 | * 14 | * Copyright 2000,2001 15 | * Broadcom Corporation. All rights reserved. 16 | * 17 | * This software is furnished under license and may be used and 18 | * copied only in accordance with the following terms and 19 | * conditions. Subject to these conditions, you may download, 20 | * copy, install, use, modify and distribute modified or unmodified 21 | * copies of this software in source and/or binary form. No title 22 | * or ownership is transferred hereby. 23 | * 24 | * 1) Any source code used, modified or distributed must reproduce 25 | * and retain this copyright notice and list of conditions as 26 | * they appear in the source file. 27 | * 28 | * 2) No right is granted to use any trade name, trademark, or 29 | * logo of Broadcom Corporation. Neither the "Broadcom 30 | * Corporation" name nor any trademark or logo of Broadcom 31 | * Corporation may be used to endorse or promote products 32 | * derived from this software without the prior written 33 | * permission of Broadcom Corporation. 34 | * 35 | * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 36 | * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 37 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 38 | * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 39 | * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 40 | * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 41 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 42 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 43 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 44 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 45 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 46 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 47 | * THE POSSIBILITY OF SUCH DAMAGE. 48 | ********************************************************************* */ 49 | 50 | #ifndef _LIB_MALLOC_H 51 | #define _LIB_MALLOC_H 52 | 53 | typedef struct memstats_s { 54 | int mem_totalbytes; 55 | int mem_allocbytes; 56 | int mem_freebytes; 57 | int mem_allocnodes; 58 | int mem_freenodes; 59 | int mem_largest; 60 | } memstats_t; 61 | 62 | typedef struct mempool_s mempool_t; 63 | void kmeminit(mempool_t *pool,unsigned char *buffer,int length); 64 | void kfree(mempool_t *pool,void *ptr); 65 | void *kmalloc(mempool_t *pool,unsigned int size,unsigned int align); 66 | int kmemchk(mempool_t *pool,int verbose); 67 | extern mempool_t kmempool; 68 | void *kmempoolbase(mempool_t *pool); 69 | int kmempoolsize(mempool_t *pool); 70 | int kmemstats(mempool_t *pool,memstats_t *stats); 71 | 72 | #define KMEMINIT(buffer,length) kmeminit(&kmempool,(buffer),(length)) 73 | #define KMEMPOOLBASE() kmempoolbase(&kmempool) 74 | #define KMEMPOOLSIZE() kmempoolsize(&kmempool) 75 | #define KMALLOC(size,align) kmalloc(&kmempool,(size),(align)) 76 | #define KFREE(ptr) kfree(&kmempool,(ptr)) 77 | #define KMEMSTATS(s) kmemstats(&kmempool,(s)) 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /nocfe/lib_physio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void phys_write8(physaddr_t a,uint8_t b) 6 | { 7 | } 8 | 9 | void phys_write16(physaddr_t a,uint16_t b) 10 | { 11 | } 12 | 13 | void phys_write32(physaddr_t a,uint32_t b) 14 | { 15 | } 16 | 17 | void phys_write64(physaddr_t a,uint64_t b) 18 | { 19 | } 20 | 21 | uint8_t phys_read8(physaddr_t a) 22 | { 23 | } 24 | 25 | uint16_t phys_read16(physaddr_t a) 26 | { 27 | } 28 | 29 | uint32_t phys_read32(physaddr_t a) 30 | { 31 | } 32 | 33 | uint64_t phys_read64(physaddr_t a) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /nocfe/lib_physio.h: -------------------------------------------------------------------------------- 1 | /* ********************************************************************* 2 | * Broadcom Common Firmware Environment (CFE) 3 | * 4 | * Physical memory peek/poke routines File: lib_physio.h 5 | * 6 | * Little stub routines to allow access to arbitrary physical 7 | * addresses. In most cases this should not be needed, as 8 | * many physical addresses are within kseg1, but this handles 9 | * the cases that are not automagically, so we don't need 10 | * to mess up the code with icky macros and such. 11 | * 12 | * Author: Mitch Lichtenberg (mpl@broadcom.com) 13 | * 14 | ********************************************************************* 15 | * 16 | * Copyright 2000,2001 17 | * Broadcom Corporation. All rights reserved. 18 | * 19 | * This software is furnished under license and may be used and 20 | * copied only in accordance with the following terms and 21 | * conditions. Subject to these conditions, you may download, 22 | * copy, install, use, modify and distribute modified or unmodified 23 | * copies of this software in source and/or binary form. No title 24 | * or ownership is transferred hereby. 25 | * 26 | * 1) Any source code used, modified or distributed must reproduce 27 | * and retain this copyright notice and list of conditions as 28 | * they appear in the source file. 29 | * 30 | * 2) No right is granted to use any trade name, trademark, or 31 | * logo of Broadcom Corporation. Neither the "Broadcom 32 | * Corporation" name nor any trademark or logo of Broadcom 33 | * Corporation may be used to endorse or promote products 34 | * derived from this software without the prior written 35 | * permission of Broadcom Corporation. 36 | * 37 | * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 38 | * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 39 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 40 | * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 41 | * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 42 | * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 43 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 44 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 45 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 46 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 47 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 48 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 49 | * THE POSSIBILITY OF SUCH DAMAGE. 50 | ********************************************************************* */ 51 | 52 | 53 | #ifndef _LIB_PHYSIO_H 54 | #define _LIB_PHYSIO_H 55 | 56 | typedef unsigned int physaddr_t; 57 | 58 | #define __UNCADDRX(x) (((unsigned long long)(x))|0x8000020000000000ULL) 59 | 60 | static inline uint32_t __pswap32(uint32_t x) 61 | { 62 | uint32_t y; 63 | 64 | y = ((x & 0xFF) << 24) | 65 | ((x & 0xFF00) << 8) | 66 | ((x & 0xFF0000) >> 8) | 67 | ((x & 0xFF000000) >> 24); 68 | 69 | return y; 70 | } 71 | 72 | 73 | //#define phys_write8(a,b) *((volatile uint8_t *) __UNCADDRX(a)) = (b) 74 | //#define phys_write16(a,b) *((volatile uint16_t *) __UNCADDRX(a)) = (b) 75 | #define phys_write32(a,b) *((volatile uint32_t *) __UNCADDRX(a)) = __pswap32(b) 76 | //#define phys_write64(a,b) *((volatile uint32_t *) __UNCADDRX(a)) = (b) 77 | //#define phys_read8(a) *((volatile uint8_t *) __UNCADDRX(a)) 78 | //#define phys_read16(a) *((volatile uint16_t *) __UNCADDRX(a)) 79 | #define _phys_read32(a) *((volatile uint32_t *) __UNCADDRX(a)) 80 | static inline uint32_t phys_read32(physaddr_t a) { uint32_t res = _phys_read32(a); return __pswap32(res); } 81 | //#define phys_read64(a) *((volatile uint64_t *) __UNCADDRX(a)) 82 | 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /nocfe/lib_printf.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /nocfe/lib_queue.h: -------------------------------------------------------------------------------- 1 | /* ********************************************************************* 2 | * Broadcom Common Firmware Environment (CFE) 3 | * 4 | * Queue management prototypes File: lib_queue.h 5 | * 6 | * Constants, structures, and function prototypes for the queue 7 | * manager. 8 | * 9 | * Author: Mitch Lichtenberg 10 | * 11 | ********************************************************************* 12 | * 13 | * Copyright 2000,2001,2002,2003 14 | * Broadcom Corporation. All rights reserved. 15 | * 16 | * This software is furnished under license and may be used and 17 | * copied only in accordance with the following terms and 18 | * conditions. Subject to these conditions, you may download, 19 | * copy, install, use, modify and distribute modified or unmodified 20 | * copies of this software in source and/or binary form. No title 21 | * or ownership is transferred hereby. 22 | * 23 | * 1) Any source code used, modified or distributed must reproduce 24 | * and retain this copyright notice and list of conditions 25 | * as they appear in the source file. 26 | * 27 | * 2) No right is granted to use any trade name, trademark, or 28 | * logo of Broadcom Corporation. The "Broadcom Corporation" 29 | * name may not be used to endorse or promote products derived 30 | * from this software without the prior written permission of 31 | * Broadcom Corporation. 32 | * 33 | * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 34 | * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 35 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 36 | * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 37 | * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 38 | * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 40 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 41 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 42 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 43 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 44 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 45 | * THE POSSIBILITY OF SUCH DAMAGE. 46 | ********************************************************************* */ 47 | 48 | 49 | #ifndef _LIB_QUEUE_H 50 | #define _LIB_QUEUE_H 51 | 52 | /* ********************************************************************* 53 | * Macros 54 | ********************************************************************* */ 55 | 56 | #define q_init(q) (q)->q_prev = (q), (q)->q_next = (q) 57 | #define q_isempty(q) ((q)->q_next == (q)) 58 | #define q_getfirst(q) ((q)->q_next) 59 | #define q_getlast(q) ((q)->q_prev) 60 | 61 | /* ********************************************************************* 62 | * Types 63 | ********************************************************************* */ 64 | 65 | 66 | typedef struct queue_s { 67 | struct queue_s *q_next; 68 | struct queue_s *q_prev; 69 | } queue_t; 70 | 71 | 72 | /* ********************************************************************* 73 | * Prototypes 74 | ********************************************************************* */ 75 | 76 | void q_enqueue(queue_t *,queue_t *); 77 | void q_dequeue(queue_t *); 78 | queue_t *q_deqnext(queue_t *); 79 | int q_map(queue_t *qb,int (*func)(queue_t *,unsigned int,unsigned int), 80 | unsigned int a,unsigned int b); 81 | int q_count(queue_t *); 82 | int q_find(queue_t *,queue_t *); 83 | 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /nocfe/lib_string.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /nocfe/lib_types.h: -------------------------------------------------------------------------------- 1 | /* ********************************************************************* 2 | * Broadcom Common Firmware Environment (CFE) 3 | * 4 | * Basic types File: lib_types.h 5 | * 6 | * This module defines the basic types used in CFE. Simple 7 | * types, such as uint64_t, are defined here. 8 | * 9 | * Author: Mitch Lichtenberg (mpl@broadcom.com) 10 | * 11 | ********************************************************************* 12 | * 13 | * Copyright 2000,2001 14 | * Broadcom Corporation. All rights reserved. 15 | * 16 | * This software is furnished under license and may be used and 17 | * copied only in accordance with the following terms and 18 | * conditions. Subject to these conditions, you may download, 19 | * copy, install, use, modify and distribute modified or unmodified 20 | * copies of this software in source and/or binary form. No title 21 | * or ownership is transferred hereby. 22 | * 23 | * 1) Any source code used, modified or distributed must reproduce 24 | * and retain this copyright notice and list of conditions as 25 | * they appear in the source file. 26 | * 27 | * 2) No right is granted to use any trade name, trademark, or 28 | * logo of Broadcom Corporation. Neither the "Broadcom 29 | * Corporation" name nor any trademark or logo of Broadcom 30 | * Corporation may be used to endorse or promote products 31 | * derived from this software without the prior written 32 | * permission of Broadcom Corporation. 33 | * 34 | * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 35 | * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 36 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 37 | * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 38 | * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 39 | * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 41 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 42 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 43 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 44 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 45 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 46 | * THE POSSIBILITY OF SUCH DAMAGE. 47 | ********************************************************************* */ 48 | 49 | 50 | #ifdef __mips 51 | #if ((defined(__MIPSEB)+defined(__MIPSEL)) != 1) 52 | #error "Either __MIPSEB or __MIPSEL must be defined!" 53 | #endif 54 | #endif 55 | 56 | 57 | #ifndef _LIB_TYPES_H 58 | #define _LIB_TYPES_H 59 | 60 | /* ********************************************************************* 61 | * Constants 62 | ********************************************************************* */ 63 | 64 | #ifndef NULL 65 | #define NULL 0 66 | #endif 67 | 68 | #ifndef TRUE 69 | #define TRUE 1 70 | #endif 71 | 72 | #ifndef FALSE 73 | #define FALSE 0 74 | #endif 75 | 76 | /* ********************************************************************* 77 | * Basic types 78 | ********************************************************************* */ 79 | 80 | #include 81 | 82 | #define unsigned signed /* Kludge to get unsigned size-shaped type. */ 83 | typedef __SIZE_TYPE__ intptr_t; 84 | #undef unsigned 85 | typedef __SIZE_TYPE__ uintptr_t; 86 | 87 | /* ********************************************************************* 88 | * Macros 89 | ********************************************************************* */ 90 | 91 | #ifndef offsetof 92 | #define offsetof(type,memb) ((size_t)&((type *)0)->memb) 93 | #endif 94 | 95 | /* ********************************************************************* 96 | * Structures 97 | ********************************************************************* */ 98 | 99 | typedef struct cons_s { 100 | char *str; 101 | int num; 102 | } cons_t; 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /readcd/README: -------------------------------------------------------------------------------- 1 | Not quite a part of XeLL, but might be useful: a "fixed sector reader". 2 | 3 | The code is a bit quick&dirty, but does the following: 4 | 5 | - load constants 6 | - open tray using SMC 7 | 8 | - delay a bit 9 | - issue READ(10)-command, 10 | - on error: request sense, loop 11 | - read ~128k starting at LBA 0x20 to 0x1310000 12 | - jump there 13 | 14 | So to actually use this for a live cd, you need the following: 15 | 16 | - prepare a CD with: 17 | - XeLL at LBA 0x20 (usually the first file on CD) 18 | - the kernel, named "vmlinux" in the root of the CD, 19 | - the kernel must contain an initramfs to load the rootfs, 20 | - the initramfs must mount the CD, and pivot_root (or whatever) in there. 21 | 22 | Then, launch the usual exploit code, but don't upload XeLL but instead this 23 | binary. It will eject the tray. Put in your linux CD. Close the tray, and 24 | it will launch XeLL. XeLL will launch vmlinux. from disc, and the kernel 25 | will run. 26 | 27 | The readsector.S is position independent code, so just link it wherever you 28 | want. Oh, and yes, this code is "small enough" for what you are all waiting 29 | for. 30 | 31 | Have fun ;) 32 | 33 | - tmbinc 34 | -------------------------------------------------------------------------------- /readcd/readsector.S: -------------------------------------------------------------------------------- 1 | // quick&dirty fixed sector reader (c) Felix Domke 2 | .globl .do_readsector 3 | .do_readsector: 4 | .globl _start 5 | _start: 6 | nop 7 | bl 1f 8 | .long 0x80000200 9 | .long 0xea000000 10 | 11 | .long 0x80000000 // code location: 12 | .long 0x01310000 // 0x1310000 13 | 14 | .long 0x28000000 // READ(10) 15 | .long 0x00200000 // LBA = 0x20 (first file, usually) 16 | .long 0x40000000 // 0x40 sectors == 128k 17 | 18 | 19 | 1: 20 | mflr %r3 // get address of constants 21 | ld %r4, 0(%r3) // base address for PCI 22 | ld %r7, 8(%r3) // target in memory 23 | lwz %r5, 0x10(%r3) // CDB 24 | lwz %r9, 0x14(%r3) // CDB 25 | lwz %r10, 0x18(%r3) // CDB 26 | li %r6, 0 27 | 28 | /* open tray using SMC command */ 29 | lis %r3, 0x4000 30 | stw %r3, 0x1084(%r4) /* start command */ 31 | lis %r3, 0x8b60 /* smc command 8b60 -> open tray */ 32 | stw %r3, 0x1080(%r4) 33 | stw %r6, 0x1080(%r4) 34 | stw %r6, 0x1080(%r4) 35 | stw %r6, 0x1080(%r4) 36 | stw %r6, 0x1084(%r4) /* end command */ 37 | 38 | retry: 39 | 40 | /* wait a bit */ 41 | lis %r3, 0x1000 42 | mtctr %r3 43 | 1: 44 | bdnz 1b 45 | 46 | /* try reading */ 47 | li %r3, 0x7fff 48 | mtctr %r3 49 | 50 | //li %r5, 2048 51 | //stb %r3, 0x1206(%r4) // drive select (A0) 52 | //bl waitready 53 | 54 | //stb %r5, 0x1204(%r4) // byte_cnt_l 55 | //stb %r6, 0x1205(%r4) // byte_cnt_h 56 | li %r3, 0xA0 57 | 58 | stb %r6, 0x1201(%r4) // atapi_features 59 | stb %r3, 0x1207(%r4) // atapi command 60 | bl waitready 61 | stw %r5, 0x1200(%r4) // write cdb 62 | stw %r9, 0x1200(%r4) 63 | stw %r10, 0x1200(%r4) 64 | bl waitready 65 | 66 | mr %r8, %r7 67 | 68 | 1: 69 | bl waitdrq 70 | lwz %r3, 0x1200(%r4) 71 | stw %r3, 0(%r8) 72 | dcbst %r0, %r8 73 | sync 74 | icbi %r0, %r8 75 | addi %r8, %r8, 4 76 | bdnz 1b 77 | 78 | lwz %r3, 0x1200(%r4) 79 | lwz %r3, 0x1200(%r4) 80 | 81 | 82 | li %r3, 'O' 83 | bl putc 84 | li %r3, 'K' 85 | bl putc 86 | li %r3, '\r' 87 | bl putc 88 | li %r3, '\n' 89 | bl putc 90 | 91 | li %r2, 0 92 | mtspr 313, %r2 // hrmor 93 | li %r3, 2 94 | mtspr 318, %r3 // lpcr 95 | 96 | 97 | mtctr %r7 98 | bctr 99 | 100 | waitdrq: 101 | lbz %r3, 0x1207(%r4) 102 | rlwinm. %r3, %r3, 0, 28,28 103 | beq waitdrq 104 | blr 105 | 106 | waitready: 107 | lbz %r3, 0x1207(%r4) 108 | rlwinm %r3, %r3, 0, 24, 25 109 | cmpwi %r3, 0x40 110 | bne waitready 111 | lbz %r3, 0x1207(%r4) 112 | rlwinm. %r3, %r3, 0, 31, 31 113 | bne request_sense 114 | blr 115 | 116 | putc: 117 | slwi %r3, %r3, 24 118 | stw %r3, 0x1014(%r4) 119 | 1: 120 | lwz %r3, 0x1018(%r4) 121 | rlwinm. %r3, %r3, 0, 6, 6 122 | beq 1b 123 | blr 124 | 125 | request_sense: 126 | 127 | li %r3, 'R' 128 | bl putc 129 | li %r3, 'S' 130 | bl putc 131 | li %r3, ':' 132 | bl putc 133 | 134 | // request sense 135 | li %r3, 0xA0 136 | stb %r6, 0x1201(%r4) // atapi_features 137 | stb %r3, 0x1207(%r4) // atapi command 138 | bl waitready 139 | lis %r3, 0x0300 140 | stw %r3, 0x1200(%r4) // write mode sense cdb 141 | stw %r6, 0x1200(%r4) 142 | stw %r6, 0x1200(%r4) 143 | bl waitready 144 | 145 | li %r3, '\r' 146 | bl putc 147 | li %r3, '\n' 148 | bl putc 149 | 150 | b retry 151 | -------------------------------------------------------------------------------- /startup2.S: -------------------------------------------------------------------------------- 1 | #define rmor 312 2 | #define hrmor 313 3 | #define hid1 1009 4 | #define hid4 1012 5 | #define hid6 1017 6 | #define lpcr 318 7 | #define pir 1023 8 | #define tsrr 897 9 | #define tscr 921 10 | #define ctrlb 152 11 | 12 | start_from_rom: 13 | or %r2, %r2, %r2 // normal priority 14 | 15 | // li %r2, 0 16 | // mtspr 313, %r2 // hrmor 17 | 18 | // disable interrupts (but enable vector available, gcc likes to use VMX 19 | // for memset) 20 | lis %r13, 0x200 21 | mtmsrd %r13, 1 22 | 23 | li %r3, 2 24 | isync 25 | mtspr lpcr, %r3 26 | isync 27 | li %r3, 0x3FF 28 | rldicr %r3, %r3, 32,31 29 | .long 0x7C201A24 30 | sync 31 | isync 32 | 33 | mfspr %r10, hid1 34 | li %r11, 3 35 | rldimi %r10, %r11, 58,4 // enable icache 36 | rldimi %r10, %r11, 38,25 // instr. prefetch 37 | sync 38 | mtspr hid1, %r10 39 | sync 40 | isync 41 | 42 | mfspr %r10, lpcr 43 | li %r11, 1 44 | rldimi %r10, %r11, 1,62 45 | isync 46 | mtspr lpcr, %r10 47 | isync 48 | 49 | // set stack 50 | li %sp, 0 51 | oris %sp, %sp, 0x8000 52 | rldicr %sp, %sp, 32,31 53 | oris %sp, %sp, 0x1e00 54 | 55 | mfspr %r3, pir 56 | slwi %r4, %r3, 16 // 64k stack 57 | sub %sp, %sp, %r4 58 | subi %sp, %sp, 0x80 59 | 60 | cmpwi %r3, 0 61 | bne hangon 62 | 63 | lis %r3, 0x8000 64 | rldicr %r3, %r3, 32,31 65 | oris %r3, %r3, start@h 66 | ori %r3, %r3, start@l 67 | ld %r2, 8(%r3) 68 | 69 | lis %r3, 0x8000 70 | sldi %r3, %r3, 32 71 | oris %r3, %r3, 1f@h 72 | ori %r3, %r3, 1f@l 73 | mtctr %r3 74 | bctr 75 | 1: 76 | 77 | 78 | mfspr %r3, pir 79 | mfpvr %r5 80 | mr %r4, %r15 81 | mr %r6, %r27 82 | bl start 83 | 84 | 1: 85 | b 1b 86 | 87 | putc: 88 | lis %r4, 0x8000 89 | ori %r4, %r4, 0x200 90 | rldicr %r4, %r4, 32,31 91 | oris %r4, %r4, 0xea00 92 | 93 | slwi %r3, %r3, 24 94 | stw %r3, 0x1014(%r4) 95 | 1: 96 | lwz %r3, 0x1018(%r4) 97 | rlwinm. %r3, %r3, 0, 6, 6 98 | beq 1b 99 | 100 | blr 101 | 102 | // r6 = addr, r7 = hrmor 103 | .globl jump 104 | jump: 105 | mtspr rmor, %r7 106 | mtspr hrmor, %r7 107 | isync 108 | sync 109 | mtsrr0 %r6 110 | 111 | /* switch into real mode */ 112 | mfmsr %r6 113 | li %r7, 0x30 114 | andc %r6, %r6, %r7 115 | mtsrr1 %r6 116 | rfid 117 | 118 | hangon: 119 | lis %r4, 0x8000 120 | rldicr %r4, %r4, 32,31 121 | oris %r4, %r4, processors_online@h 122 | ori %r4, %r4, processors_online@l 123 | slwi %r3, %r3, 2 124 | add %r4, %r4, %r3 125 | li %r5, 1 126 | stw %r5, 0(%r4) 127 | 128 | lis %r3, 0x8000 129 | rldicr %r3, %r3, 32,31 130 | oris %r3, %r3, secondary_hold_addr@h 131 | ori %r3, %r3, secondary_hold_addr@l 132 | 133 | .globl Idle 134 | Idle: 135 | 1: 136 | or %r1, %r1, %r1 /* low priority */ 137 | ld %r4, 0(%r3) 138 | cmpwi %r4, 0 139 | beq 1b 140 | 141 | li %r3, 0 142 | mtspr hrmor, %r3 143 | mtspr rmor, %r3 144 | 145 | mtctr %r4 146 | 147 | mfspr %r3, pir 148 | 149 | /* cmpwi %r3, 1 150 | beq stop 151 | cmpwi %r3, 3 152 | beq stop 153 | cmpwi %r3, 5 154 | beq stop */ 155 | 156 | bctr 157 | 158 | stop: 159 | li %r3, 0 160 | 1: 161 | mtspr ctrlb, %r3 162 | b 1b 163 | 164 | 165 | set_hrmor: 166 | mtspr rmor, %r3 167 | mtspr hrmor, %r3 168 | blr 169 | 170 | .globl _start 171 | .extern start 172 | .globl __start_other 173 | _start: 174 | b main 175 | 176 | 177 | . = _start + 0x60 178 | __start_other: 179 | b start_from_rom 180 | 181 | .globl fix_hrmor 182 | fix_hrmor: 183 | li %r3, 0 184 | mtspr hrmor, %r3 185 | blr 186 | -------------------------------------------------------------------------------- /time.c: -------------------------------------------------------------------------------- 1 | #include "processor.h" 2 | 3 | unsigned long tb_diff_sec(tb_t *end, tb_t *start) 4 | { 5 | unsigned long upper, lower; 6 | upper = end->u - start->u; 7 | if (start->l > end->l) 8 | upper--; 9 | lower = end->l - start->l; 10 | return ((upper*((unsigned long)0x80000000/(TB_CLOCK/2))) + (lower/ TB_CLOCK)); 11 | } 12 | 13 | unsigned long tb_diff_msec(tb_t *end, tb_t *start) 14 | { 15 | unsigned long upper, lower; 16 | upper = end->u - start->u; 17 | if (start->l > end->l) 18 | upper--; 19 | lower = end->l - start->l; 20 | return ((upper*((unsigned long)0x80000000/(TB_CLOCK/2000))) + (lower/(TB_CLOCK/1000))); 21 | } 22 | 23 | unsigned long tb_diff_usec(tb_t *end, tb_t *start) 24 | { 25 | unsigned long upper, lower; 26 | upper = end->u - start->u; 27 | if (start->l > end->l) 28 | upper--; 29 | lower = end->l - start->l; 30 | return ((upper*((unsigned long)0x80000000/(TB_CLOCK/2000000))) + (lower/(TB_CLOCK/1000000))); 31 | } 32 | 33 | void udelay(unsigned int us) 34 | { 35 | tb_t start, end; 36 | mftb(&start); 37 | while (1) 38 | { 39 | mftb(&end); 40 | if (tb_diff_usec(&end, &start) >= us) 41 | break; 42 | } 43 | } 44 | 45 | void mdelay(unsigned int ms) 46 | { 47 | tb_t start, end; 48 | mftb(&start); 49 | while (1) 50 | { 51 | mftb(&end); 52 | if (tb_diff_msec(&end, &start) >= ms) 53 | break; 54 | } 55 | } 56 | 57 | void delay(unsigned int s) 58 | { 59 | tb_t start, end; 60 | mftb(&start); 61 | while (1) 62 | { 63 | mftb(&end); 64 | if (tb_diff_sec(&end, &start) >= s) 65 | break; 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /usb/usbhack.h: -------------------------------------------------------------------------------- 1 | /* ********************************************************************* 2 | * Broadcom Common Firmware Environment (CFE) 3 | * 4 | * usb test harness definitions File: usbhack.h 5 | * 6 | * Anything special required by the test harness is defined 7 | * here. 8 | * 9 | * Author: Mitch Lichtenberg 10 | * 11 | ********************************************************************* 12 | * 13 | * Copyright 2000,2001,2002,2003 14 | * Broadcom Corporation. All rights reserved. 15 | * 16 | * This software is furnished under license and may be used and 17 | * copied only in accordance with the following terms and 18 | * conditions. Subject to these conditions, you may download, 19 | * copy, install, use, modify and distribute modified or unmodified 20 | * copies of this software in source and/or binary form. No title 21 | * or ownership is transferred hereby. 22 | * 23 | * 1) Any source code used, modified or distributed must reproduce 24 | * and retain this copyright notice and list of conditions 25 | * as they appear in the source file. 26 | * 27 | * 2) No right is granted to use any trade name, trademark, or 28 | * logo of Broadcom Corporation. The "Broadcom Corporation" 29 | * name may not be used to endorse or promote products derived 30 | * from this software without the prior written permission of 31 | * Broadcom Corporation. 32 | * 33 | * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 34 | * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 35 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 36 | * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 37 | * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 38 | * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 40 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 41 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 42 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 43 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 44 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 45 | * THE POSSIBILITY OF SUCH DAMAGE. 46 | ********************************************************************* */ 47 | 48 | /* ********************************************************************* 49 | * Constants 50 | ********************************************************************* */ 51 | 52 | 53 | #ifndef TRUE 54 | #define TRUE 1 55 | #endif 56 | 57 | #ifndef FALSE 58 | #define FALSE 0 59 | #endif 60 | 61 | /* ********************************************************************* 62 | * Prototypes 63 | ********************************************************************* */ 64 | 65 | void console_log(const char *tmplt,...); 66 | 67 | -------------------------------------------------------------------------------- /xell-1f.lds: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | SECTIONS 3 | { 4 | . = 0x800000001c000000; 5 | .text : { *(.text) } 6 | .data : { *(.data) } 7 | .sdata : { *(.sdata) } 8 | .rodata : { *(.rodata)} 9 | 10 | . = 0x800000001c080000; 11 | 12 | bss_start = .; 13 | .bss : { *(.bss) } 14 | .sbss : { *(.sbss) } 15 | bss_end = .; 16 | } 17 | -------------------------------------------------------------------------------- /xell-2f.lds: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | SECTIONS 3 | { 4 | . = 0x800000001c040000; 5 | .text : { *(.text) } 6 | .data : { *(.data) } 7 | .sdata : { *(.sdata) } 8 | .rodata : { *(.rodata)} 9 | 10 | . = 0x800000001c080000; 11 | 12 | bss_start = .; 13 | .bss : { *(.bss) } 14 | .sbss : { *(.sbss) } 15 | bss_end = .; 16 | } 17 | -------------------------------------------------------------------------------- /xell-readcd.lds: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | SECTIONS 3 | { 4 | . = 0x8000000001310000; 5 | .text : { *(.text) } 6 | .data : { *(.data) } 7 | .sdata : { *(.sdata) } 8 | .rodata : { *(.rodata)} 9 | 10 | . = 0x8000000001380000; 11 | 12 | bss_start = .; 13 | .bss : { *(.bss) } 14 | .sbss : { *(.sbss) } 15 | bss_end = .; 16 | } 17 | -------------------------------------------------------------------------------- /xell-serial.lds: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | SECTIONS 3 | { 4 | . = 0x8000000001300000; 5 | .text : { *(.text) } 6 | .data : { *(.data) } 7 | .sdata : { *(.sdata) } 8 | .rodata : { *(.rodata)} 9 | 10 | . = 0x8000000001380000; 11 | 12 | bss_start = .; 13 | .bss : { *(.bss) } 14 | .sbss : { *(.sbss) } 15 | bss_end = .; 16 | } 17 | -------------------------------------------------------------------------------- /xell-xell.lds: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | SECTIONS 3 | { 4 | . = 0x8000000002310000; 5 | .text : { *(.text) } 6 | .data : { *(.data) } 7 | .sdata : { *(.sdata) } 8 | .rodata : { *(.rodata)} 9 | 10 | . = 0x8000000001380000; 11 | 12 | bss_start = .; 13 | .bss : { *(.bss) } 14 | .sbss : { *(.sbss) } 15 | bss_end = .; 16 | } 17 | -------------------------------------------------------------------------------- /xenon.dts: -------------------------------------------------------------------------------- 1 | /* 2 | * xenon.dts - Xbox360 Game Console device tree. 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; version 2 of the License. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | */ 17 | 18 | 19 | / { 20 | model = "Xenon Game Console"; 21 | compatible = "XENON"; 22 | #address-cells = <2>; 23 | #size-cells = <1>; 24 | 25 | /* CHECKME: is this required? */ 26 | chosen { 27 | linux,platform = <00000801>; 28 | }; 29 | 30 | memory { 31 | device_type = "memory"; 32 | reg = <00000000 00000000 1e000000>; 33 | }; 34 | 35 | cpus { 36 | #cpus = <6>; 37 | #address-cells = <1>; 38 | #size-cells = <0>; 39 | 40 | Xenon,PPE@0 { 41 | device_type = "cpu"; 42 | linux,boot-cpu; 43 | reg = <0>; 44 | clock-frequency = ; // 3192 MHz 45 | timebase-frequency = <2F90838>; // 3192/64 MHz = 49.875 MHz 46 | i-cache-size = <8000>; 47 | i-cache-line-size = <80>; 48 | d-cache-size = <8000>; 49 | d-cache-line-size = <80>; 50 | 51 | /* this must be configured with regard to the HID6:LB value */ 52 | ibm,segment-page-sizes = < 53 | C 0 1 c 0 // 4k page 54 | 10 100 1 10 00 // 64k pages 55 | 18 110 1 18 01 // 16M pages 56 | >; 57 | }; 58 | Xenon,PPE@1 { 59 | device_type = "cpu"; 60 | reg = <1>; 61 | clock-frequency = ; 62 | timebase-frequency = <2F90838>; 63 | i-cache-size = <8000>; 64 | i-cache-line-size = <80>; 65 | d-cache-size = <8000>; 66 | d-cache-line-size = <80>; 67 | }; 68 | Xenon,PPE@2 { 69 | device_type = "cpu"; 70 | reg = <2>; 71 | clock-frequency = ; 72 | timebase-frequency = <2F90838>; 73 | i-cache-size = <8000>; 74 | i-cache-line-size = <80>; 75 | d-cache-size = <8000>; 76 | d-cache-line-size = <80>; 77 | }; 78 | Xenon,PPE@3 { 79 | device_type = "cpu"; 80 | reg = <3>; 81 | clock-frequency = ; 82 | timebase-frequency = <2F90838>; 83 | i-cache-size = <8000>; 84 | i-cache-line-size = <80>; 85 | d-cache-size = <8000>; 86 | d-cache-line-size = <80>; 87 | }; 88 | Xenon,PPE@4 { 89 | device_type = "cpu"; 90 | reg = <4>; 91 | clock-frequency = ; 92 | timebase-frequency = <2F90838>; 93 | i-cache-size = <8000>; 94 | i-cache-line-size = <80>; 95 | d-cache-size = <8000>; 96 | d-cache-line-size = <80>; 97 | }; 98 | Xenon,PPE@5 { 99 | device_type = "cpu"; 100 | reg = <5>; 101 | clock-frequency = ; 102 | timebase-frequency = <2F90838>; 103 | i-cache-size = <8000>; 104 | i-cache-line-size = <80>; 105 | d-cache-size = <8000>; 106 | d-cache-line-size = <80>; 107 | }; 108 | }; 109 | 110 | pci { 111 | compatible = "xenon"; 112 | device_type = "pci"; 113 | #address-cells = <3>; // phy up, mid, low 114 | #size-cells = <1>; 115 | #interrupt-cells = <1>; 116 | 117 | interrupt-parent = <40000>; 118 | // interrupts = <18 2>; 119 | interrupt-map-mask = ; // type, lower, upper, irq 120 | 121 | interrupt-map = < 122 | 0000 0 0 0 40000 44 // audio out (?) 123 | 0800 0 0 0 40000 24 // SATA cdrom 124 | 1000 0 0 0 40000 20 // SATA disk 125 | 2000 0 0 0 40000 2c // USB OHCI #1 126 | 2100 0 0 0 40000 30 // USB EHCI #1 127 | 2800 0 0 0 40000 34 // USB OHCI #2 128 | 2900 0 0 0 40000 38 // USB EHCI #2 129 | 3800 0 0 0 40000 4c // Enet 130 | 4000 0 0 0 40000 18 // Flash 131 | 4800 0 0 0 40000 40 // XMA (?) 132 | 5000 0 0 0 40000 14 // SMM, GPIO, ... 133 | >; 134 | 135 | bus-range = <0 0>; 136 | ranges = < 137 | 02000000 00000000 80000000 00000200 80000000 80000000 // PCI space at 80000000 is mapped to 200 80000000 138 | 02000000 00000000 00000000 00000000 00000000 20000000 // RAM is 1:1 mapped 139 | >; 140 | }; 141 | 142 | interrupt-controller { 143 | compatible = "xenon"; 144 | linux,phandle = <40000>; 145 | interrupt-controller; 146 | #address-cells = <0>; 147 | #interrupt-cells = <1>; 148 | built-in; 149 | reg = <00000200 00050000 6000>; 150 | interrupts = < 151 | 7c 78 74 70 6c 68 64 60 152 | 5c 58 54 50 4c 48 44 40 153 | 3c 38 34 30 2c 28 24 20 154 | 1c 18 14 10 0c 08 04 155 | >; 156 | }; 157 | }; 158 | -------------------------------------------------------------------------------- /xenon_gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef __xenon_smc_xenon_gpio_h 2 | #define __xenon_smc_xenon_gpio_h 3 | 4 | #include 5 | 6 | void xenon_gpio_set_oe(uint32_t clear, uint32_t set); 7 | void xenon_gpio_set(uint32_t clear, uint32_t set); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /xenon_smc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define SMC_BASE 0x80000200ea001000 5 | 6 | inline uint32_t bswap32(uint32_t t) 7 | { 8 | return ((t & 0xFF) << 24) | ((t & 0xFF00) << 8) | ((t & 0xFF0000) >> 8) | ((t & 0xFF000000) >> 24); 9 | } 10 | 11 | static inline uint32_t read32(long addr) 12 | { 13 | return bswap32(*(volatile uint32_t*)addr); 14 | } 15 | 16 | static inline uint32_t read32n(long addr) 17 | { 18 | return *(volatile uint32_t*)addr; 19 | } 20 | 21 | static inline void write32(long addr, uint32_t val) 22 | { 23 | *(volatile uint32_t*)addr = bswap32(val); 24 | } 25 | 26 | static inline void write32n(long addr, uint32_t val) 27 | { 28 | *(volatile uint32_t*)addr = val; 29 | } 30 | 31 | void xenon_smc_send_message(unsigned char *msg) 32 | { 33 | /* printf("SEND: "); 34 | int i; 35 | for (i = 0; i < 16; ++i) 36 | printf("%02x ", msg[i]); 37 | printf("\n"); 38 | */ 39 | while (!(read32(SMC_BASE + 0x84) & 4)); 40 | write32(SMC_BASE + 0x84, 4); 41 | write32n(SMC_BASE + 0x80, *(uint32_t*)(msg + 0)); 42 | write32n(SMC_BASE + 0x80, *(uint32_t*)(msg + 4)); 43 | write32n(SMC_BASE + 0x80, *(uint32_t*)(msg + 8)); 44 | write32n(SMC_BASE + 0x80, *(uint32_t*)(msg + 12)); 45 | write32(SMC_BASE + 0x84, 0); 46 | } 47 | 48 | int xenon_smc_receive_message(unsigned char *msg) 49 | { 50 | if (read32(SMC_BASE + 0x94) & 4) 51 | { 52 | uint32_t *msgl = (uint32_t*)msg; 53 | int i; 54 | write32(SMC_BASE + 0x94, 4); 55 | for (i = 0; i < 4; ++i) 56 | *msgl++ = read32n(SMC_BASE + 0x90); 57 | write32(SMC_BASE + 0x94, 0); 58 | return 0; 59 | } 60 | return -1; 61 | } 62 | 63 | void xenon_smc_handle_bulk(unsigned char *msg) 64 | { 65 | switch (msg[1]) 66 | { 67 | case 0x11: 68 | case 0x20: 69 | printf("SMC power message\n"); 70 | break; 71 | case 0x23: 72 | printf("IR RX [%02x %02x]\n", msg[2], msg[3]); 73 | break; 74 | case 0x60 ... 0x65: 75 | printf("DVD cover state: %02x\n", msg[1]); 76 | break; 77 | default: 78 | printf("unknown SMC bulk msg\n"); 79 | break; 80 | } 81 | } 82 | 83 | int xenon_smc_receive_response(unsigned char *msg) 84 | { 85 | while (1) 86 | { 87 | if (xenon_smc_receive_message(msg)) 88 | continue; 89 | 90 | /* printf("REC: "); 91 | int i; 92 | for (i = 0; i < 16; ++i) 93 | printf("%02x ", msg[i]); 94 | printf("\n"); 95 | */ 96 | if (msg[0] == 0x83) 97 | { 98 | xenon_smc_handle_bulk(msg); 99 | continue; 100 | } 101 | return 0; 102 | } 103 | } 104 | 105 | int xenon_smc_ana_write(uint8_t addr, uint32_t val) 106 | { 107 | uint8_t buf[16]; 108 | 109 | memset(buf, 0, 16); 110 | 111 | buf[0] = 0x11; 112 | buf[1] = 0x60; 113 | buf[3] = 0x80 | 0x70; 114 | 115 | buf[6] = addr; 116 | 117 | buf[8] = val; 118 | buf[9] = val >> 8; 119 | buf[10] = val >> 16; 120 | buf[11] = val >> 24; 121 | 122 | xenon_smc_send_message(buf); 123 | 124 | xenon_smc_receive_response(buf); 125 | if (buf[1] != 0) 126 | { 127 | printf("xenon_smc_ana_write failed, addr=%02x, err=%d\n", addr, buf[1]); 128 | return -1; 129 | } 130 | 131 | return 0; 132 | } 133 | int xenon_smc_ana_read(uint8_t addr, uint32_t *val) 134 | { 135 | uint8_t buf[16]; 136 | memset(buf, 0, 16); 137 | 138 | buf[0] = 0x11; 139 | buf[1] = 0x10; 140 | buf[2] = 5; 141 | buf[3] = 0x80 | 0x70; 142 | buf[5] = 0xF0; 143 | buf[6] = addr; 144 | 145 | xenon_smc_send_message(buf); 146 | xenon_smc_receive_response(buf); 147 | if (buf[1] != 0) 148 | { 149 | printf("xenon_smc_ana_read failed, addr=%02x, err=%d\n", addr, buf[1]); 150 | return -1; 151 | } 152 | *val = buf[4] | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24); 153 | return 0; 154 | } 155 | 156 | int xenon_smc_i2c_write(uint16_t addr, uint8_t val) 157 | { 158 | uint8_t buf[16]; 159 | memset(buf, 0, 16); 160 | 161 | int tmp=(addr>=0x200)?0x3d:0x39; 162 | 163 | buf[0] = 0x11; 164 | buf[1] = 0x20; 165 | buf[3] = tmp | 0x80; //3d 166 | 167 | buf[6] = addr & 0xff; //3a 168 | buf[7] = val; 169 | 170 | xenon_smc_send_message(buf); 171 | 172 | xenon_smc_receive_response(buf); 173 | if (buf[1] != 0) 174 | { 175 | printf("xenon_smc_i2c_write failed, addr=%04x, err=%d\n", addr, buf[1]); 176 | return -1; 177 | } 178 | 179 | return 0; 180 | } 181 | 182 | void xenon_smc_set_led(int override, int value) 183 | { 184 | uint8_t buf[16]; 185 | memset(buf, 0, 16); 186 | 187 | buf[0] = 0x99; 188 | buf[1] = override; 189 | buf[2] = value; 190 | 191 | xenon_smc_send_message(buf); 192 | } 193 | 194 | void xenon_smc_power_shutdown(void) 195 | { 196 | uint8_t buf[16] = {0x82, 0x11, 0x01}; 197 | xenon_smc_send_message(buf); 198 | } 199 | 200 | void xenon_smc_start_bootanim(void) 201 | { 202 | uint8_t buf[16] = {0x8c, 0x03, 0x01}; 203 | xenon_smc_send_message(buf); 204 | } 205 | 206 | 207 | void xenon_gpio_set_oe(uint32_t clear, uint32_t set) 208 | { 209 | write32(SMC_BASE + 0x20, (read32(SMC_BASE + 0x20) &~ clear) | set); 210 | } 211 | 212 | void xenon_gpio_set(uint32_t clear, uint32_t set) 213 | { 214 | write32(SMC_BASE + 0x34, (read32(SMC_BASE + 0x34) &~ clear) | set); 215 | } 216 | 217 | int xenon_smc_read_avpack(void) 218 | { 219 | uint8_t buf[16] = {0x0f}; 220 | xenon_smc_send_message(buf); 221 | xenon_smc_receive_response(buf); 222 | return buf[1]; 223 | } 224 | -------------------------------------------------------------------------------- /xenon_smc.h: -------------------------------------------------------------------------------- 1 | #ifndef __XENON_SMC 2 | #define __XENON_SMC 3 | 4 | #include 5 | 6 | void xenon_smc_send_message(const unsigned char *msg); 7 | int xenon_smc_receive_message(unsigned char *msg); 8 | 9 | int xenon_smc_ana_write(uint8_t addr, uint32_t val); 10 | int xenon_smc_ana_read(uint8_t addr, uint32_t *val); 11 | int xenon_smc_i2c_write(uint16_t addr, uint8_t val); 12 | 13 | void xenon_smc_set_led(int override, int value); 14 | void xenon_smc_power_shutdown(void); 15 | void xenon_smc_start_bootanim(void); 16 | 17 | 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /xenos_init.h: -------------------------------------------------------------------------------- 1 | #ifndef __xenos_init_h 2 | #define __xenos_init_h 3 | 4 | #include 5 | 6 | #define VIDEO_MODE_AUTO -1 7 | #define VIDEO_MODE_VGA_640x480 0 8 | #define VIDEO_MODE_VGA_1024x768 1 9 | #define VIDEO_MODE_PAL60 2 10 | #define VIDEO_MODE_480p 3 11 | #define VIDEO_MODE_PAL50 4 12 | #define VIDEO_MODE_VGA_1280x768 5 13 | #define VIDEO_MODE_VGA_1360x768 6 14 | #define VIDEO_MODE_VGA_1280x720 7 15 | #define VIDEO_MODE_VGA_1440x900 8 16 | #define VIDEO_MODE_VGA_1280x1024 9 17 | #define VIDEO_MODE_HDMI_720p 10 18 | 19 | #define EDRAM_CLK_CNTL 0x0244 20 | #define D1CRTC_UPDATE_LOCK 0x60e8 21 | #define DCP_LB_DATA_GAP_BETWEEN_CHUNK 0x6cbc 22 | #define D1CRTC_DOUBLE_BUFFER_CONTROL 0x60ec 23 | #define D1CRTC_V_TOTAL 0x6020 24 | #define D1CRTC_H_TOTAL 0x6000 25 | #define D1CRTC_H_SYNC_B 0x6010 26 | #define D1CRTC_H_BLANK_START_END 0x6004 27 | #define D1CRTC_H_SYNC_B_CNTL 0x6014 28 | #define D1CRTC_H_SYNC_A 0x6008 29 | #define D1CRTC_V_SYNC_B 0x6030 30 | #define D1CRTC_H_SYNC_A_CNTL 0x600c 31 | #define D1CRTC_MVP_INBAND_CNTL_CAP 0x604c 32 | #define D1CRTC_MVP_INBAND_CNTL_INSERT 0x6050 33 | #define D1CRTC_MVP_FIFO_STATUS 0x6044 34 | #define D1CRTC_MVP_SLAVE_STATUS 0x6048 35 | #define D1GRPH_UPDATE 0x6144 36 | #define D1GRPH_PITCH 0x6120 37 | #define D1GRPH_CONTROL 0x6104 38 | #define D1GRPH_LUT_SEL 0x6108 39 | #define D1GRPH_SURFACE_OFFSET_X 0x6124 40 | #define D1GRPH_SURFACE_OFFSET_Y 0x6128 41 | #define D1GRPH_X_START 0x612c 42 | #define D1GRPH_Y_START 0x6130 43 | #define D1GRPH_X_END 0x6134 44 | #define D1GRPH_Y_END 0x6138 45 | #define D1GRPH_PRIMARY_SURFACE_ADDRESS 0x6110 46 | #define D1GRPH_ENABLE 0x6100 47 | #define AVIVO_D1SCL_UPDATE 0x65cc 48 | #define AVIVO_D1SCL_SCALER_ENABLE 0x6590 49 | #define AVIVO_D1MODE_VIEWPORT_START 0x6580 50 | #define AVIVO_D1MODE_VIEWPORT_SIZE 0x6584 51 | #define AVIVO_D1MODE_DATA_FORMAT 0x6528 52 | #define D1GRPH_FLIP_CONTROL 0x6148 53 | #define AVIVO_D1SCL_SCALER_TAP_CONTROL 0x6594 54 | #define DC_LUTA_CONTROL 0x64C0 55 | #define DC_LUT_RW_INDEX 0x6488 56 | #define DC_LUT_RW_MODE 0x6484 57 | #define DC_LUT_WRITE_EN_MASK 0x649C 58 | #define DC_LUT_AUTOFILL 0x64a0 59 | #define D1CRTC_MVP_CONTROL1 0x6038 60 | #define D1CRTC_MVP_CONTROL2 0x603c 61 | #define D1CRTC_MVP_FIFO_CONTROL 0x6040 62 | #define AVIVO_D1CRTC_V_BLANK_START_END 0x6024 63 | #define D1CRTC_MVP_INBAND_CNTL_INSERT_TIMER 0x6054 64 | #define D1CRTC_MVP_BLACK_KEYER 0x6058 65 | #define D1CRTC_TRIGA_CNTL 0x6060 66 | #define D1CRTC_TRIGA_MANUAL_TRIG 0x6064 67 | #define D1CRTC_TRIGB_CNTL 0x6068 68 | #define AVIVO_D1MODE_DESKTOP_HEIGHT 0x652c 69 | #define D1GRPH_COLOR_MATRIX_TRANSFORMATION_CNTL 0x6380 70 | #define D1COLOR_MATRIX_COEF_1_1 0x6384 71 | #define D1COLOR_MATRIX_COEF_1_2 0x6388 72 | #define D1COLOR_MATRIX_COEF_1_3 0x638c 73 | #define D1COLOR_MATRIX_COEF_1_4 0x6390 74 | #define D1COLOR_MATRIX_COEF_2_1 0x6394 75 | #define D1COLOR_MATRIX_COEF_2_2 0x6398 76 | #define D1COLOR_MATRIX_COEF_2_3 0x639c 77 | #define D1COLOR_MATRIX_COEF_2_4 0x63a0 78 | #define D1COLOR_MATRIX_COEF_3_1 0x63a4 79 | #define D1COLOR_MATRIX_COEF_3_2 0x63a8 80 | #define D1COLOR_MATRIX_COEF_3_3 0x63ac 81 | #define D1COLOR_MATRIX_COEF_3_4 0x63b0 82 | 83 | #endif 84 | --------------------------------------------------------------------------------